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

<[email protected]> Wed, 22 Jul 2026 17:18:03 +0000
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 <[email protected]>
On Wed, 2026-07-22 at 17:43 +0100, Conor Dooley wrote:
> 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?

Default hardware address is 0x00, unless a special order with custom
hardware address is made. I think is safe to try to communicate with
the default HW address, regardless of the return value.

> 
> > >  	if (adc->dev_addr > 3) {
> > > 
> > > -- 
> > > 2.43.0
> > > 
>