devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Jonathan Cameron <jic23@kernel.org>
Cc: wangshuaijie@awinic.com, lars@metafoo.de, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org, waqar.hameed@axis.com,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, liweilei@awinic.com,
	kangjiajun@awinic.com
Subject: Re: [PATCH V5 2/2] iio: proximity: aw9610x: Add support for aw9610x proximity sensor
Date: Sun, 28 Jul 2024 10:41:05 +0200	[thread overview]
Message-ID: <27fb423a-e8f4-44c2-be1a-38d2a42a11b6@kernel.org> (raw)
In-Reply-To: <20240727160628.115e295e@jic23-huawei>

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, &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.

Sure

Best regards,
Krzysztof


  reply	other threads:[~2024-07-28  8:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-26  6:13 [PATCH V5 0/2] Add support for aw9610x proximity sensor wangshuaijie
2024-07-26  6:13 ` [PATCH V5 1/2] dt-bindings: iio: aw9610x: Add bindings for aw9610x sensor wangshuaijie
2024-07-27  9:46   ` Krzysztof Kozlowski
2024-07-27 14:12   ` Jonathan Cameron
2024-07-26  6:13 ` [PATCH V5 2/2] iio: proximity: aw9610x: Add support for aw9610x proximity sensor wangshuaijie
2024-07-27  9:51   ` Krzysztof Kozlowski
2024-07-27 15:06     ` Jonathan Cameron
2024-07-28  8:41       ` Krzysztof Kozlowski [this message]
2024-07-27 15:02   ` Jonathan Cameron
2024-08-08 10:27     ` wangshuaijie
2024-08-10 10:16       ` Jonathan Cameron
2024-07-29 15:28   ` Dan Carpenter
2024-08-02 17:16   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=27fb423a-e8f4-44c2-be1a-38d2a42a11b6@kernel.org \
    --to=krzk@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=kangjiajun@awinic.com \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liweilei@awinic.com \
    --cc=robh@kernel.org \
    --cc=wangshuaijie@awinic.com \
    --cc=waqar.hameed@axis.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).