Re: [PATCH v7 5/7] iio: adc: mcp3911: Add support for spi-device-addr

Conor Dooley <[email protected]> Wed, 22 Jul 2026 17:43:30 +0100
Newsgroups org.kernel.vger.linux-spi,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-doc,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Message-ID <20260722-vintage-handwork-eaaa304ed0b4@spud>
On Wed, Jul 22, 2026 at 05:41:54PM +0100, Conor Dooley wrote:
> On Wed, Jul 22, 2026 at 09:54:17AM +0200, Janani Sunil wrote:
> > Read the generic spi-device-addr property when determining the hardware
> > device address. Fall back to the deprecated microchip,device-addr
> > property and then to the historical device-addr property to preserve
> > compatibility with existing devicetrees.
> > 
> > The device address remains 0 when none of the properties are present.
> > 
> > Signed-off-by: Janani Sunil <[email protected]>
> > ---
> >  drivers/iio/adc/mcp3911.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/iio/adc/mcp3911.c b/drivers/iio/adc/mcp3911.c
> > index ddc3721f3f68..3919a326b4db 100644
> > --- a/drivers/iio/adc/mcp3911.c
> > +++ b/drivers/iio/adc/mcp3911.c
> > @@ -740,10 +740,13 @@ static int mcp3911_probe(struct spi_device *spi)
> >  	}
> >  
> >  	/*
> > -	 * Fallback to "device-addr" due to historical mismatch between
> > -	 * dt-bindings and implementation.
> > +	 * Fall back to the vendor-specific property, then to "device-addr"
> > +	 * due to a historical mismatch between the binding and implementation.
> 
> Jaysus, bit of a mess here.
> Reviewed-by: Conor Dooley <[email protected]>
> 
> >  	 */
> > -	ret = device_property_read_u32(dev, "microchip,device-addr", &adc->dev_addr);
> > +	ret = device_property_read_u32(dev, "spi-device-addr", &adc->dev_addr);
> > +	if (ret)
> > +		ret = device_property_read_u32(dev, "microchip,device-addr",
> > +					       &adc->dev_addr);
> >  	if (ret)
> >  		device_property_read_u32(dev, "device-addr", &adc->dev_addr);

Actually, this should check the return value, right?

> >  	if (adc->dev_addr > 3) {
> > 
> > -- 
> > 2.43.0
> >
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCamDzMgAKCRB4tDGHoIJi
0rErAP9xzGMBe/PDCdRNBEqlrXN6qq5/O1LBKuRSGQ+tQODO4QEAlIfFedeapUhF
LnAS/LyqgovzW4LJZ0brnAlmGtWwNQc=
=D8op
-----END PGP SIGNATURE-----