[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <27fb423a-e8f4-44c2-be1a-38d2a42a11b6@kernel.org>
Date: Sun, 28 Jul 2024 10:41:05 +0200
From: Krzysztof Kozlowski <krzk@...nel.org>
To: Jonathan Cameron <jic23@...nel.org>
Cc: wangshuaijie@...nic.com, lars@...afoo.de, robh@...nel.org,
krzk+dt@...nel.org, conor+dt@...nel.org, waqar.hameed@...s.com,
linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, liweilei@...nic.com, kangjiajun@...nic.com
Subject: Re: [PATCH V5 2/2] iio: proximity: aw9610x: Add support for aw9610x
proximity sensor
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
Powered by blists - more mailing lists