Re: [PATCH V5 2/2] iio: proximity: aw9610x: Add support for aw9610x proximity sensor
From: Krzysztof Kozlowski
Date: Sun Jul 28 2024 - 04:41:20 EST
On 27/07/2024 17:06, Jonathan Cameron wrote:
>
>> ...
>>
>>> +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, ®_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.
Sure
Best regards,
Krzysztof