Re: [PATCH V5 2/2] iio: proximity: aw9610x: Add support for aw9610x proximity sensor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> ...
> 
> > +static int aw9610x_read_chipid(struct aw9610x *aw9610x)
> > +{
> > +	unsigned char cnt = 0;
> > +	u32 reg_val;
> > +	int ret;
> > +
> > +	while (cnt < AW_READ_CHIPID_RETRIES) {
Why retries? 
> > +		ret = aw9610x_i2c_read(aw9610x, REG_CHIPID, &reg_val);
> > +		if (ret < 0) {
> > +			cnt++;
> > +			usleep_range(2000, 3000);
> > +		} else {
> > +			reg_val = FIELD_GET(AW9610X_CHIPID_MASK, reg_val);
> > +			break;
> > +		}
> > +	}
> > +
> > +	if (reg_val == AW9610X_CHIP_ID)
> > +		return 0;  
> 
> So devices are detectable? Encode this in the bindings (oneOf and a
> fallback compatible) and drop unneeded entry from ID tables.

Hi Krzysztof,

I think this is not a good idea.

Even though these two are detectable, this breaks if along comes a 3rd device
in the future which is truly compatible with one of these two parts but that
we don't yet know about (so can't discover). For that part we will want to
provide a meaningful fallback compatible.

It needs to fallback to either the 3 channel or the 5 channel chip and handle
it as appropriate. (Note that this difference is non obvious as right now the
code pretends there are always 5 channels and that needs fixing).

If the chips provided a register that told all the chip specific data like
how many channels, then sure making one fallback to the other would be fine
as future devices could use those standard registers.

With just an Id register, we can't discover enough.  Hence these two
parts should not be listed as compatible with each other.

Jonathan

> 
> Best regards,
> Krzysztof
> 





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux