From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Jorijn van der Graaf" <jorijnvdgraaf@catcrafts.net>,
linux-iio@vger.kernel.org,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
devicetree@vger.kernel.org, "Kees Cook" <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
"Luca Weiss" <luca.weiss@fairphone.com>
Subject: Re: [PATCH 2/3] iio: light: stk3310: add per-chip match data
Date: Mon, 17 Aug 2026 03:05:12 +0100 [thread overview]
Message-ID: <20260817030512.67ffeb50@jic23-huawei> (raw)
In-Reply-To: <anr5BeHK-dboSBl3@ashevche-desk.local>
On Tue, 11 Aug 2026 13:27:17 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Mon, Aug 10, 2026 at 11:51:57PM +0200, Jorijn van der Graaf wrote:
> > On Mon, Aug 10, 2026 at 09:34:42PM +0300, Andy Shevchenko wrote:
> > > > + chip_info = i2c_get_match_data(client);
> > > > + if (!chip_info) {
> > > > + /*
> > > > + * Clients instantiated through the sysfs new_device
> > > > + * interface under the lowercase compatible-derived name
> > > > + * have no firmware node and do not match the uppercase
> > > > + * id table entries.
> > > > + */
> > > > + chip_info = &stk3310_chip_info;
> > >
> > > This is an interesting comment and approach.
> > >
> > > > + }
> > >
> > > - Where does this lowercase come from? Is it Linux forced conversion?
> >
> > No conversion - the client name is whatever is echoed into the sysfs
> > new_device file, and the lowercase spelling is the one that binds via
> > the OF table: for a client with no firmware node,
> > i2c_of_match_device() falls through to i2c_of_match_device_sysfs(),
> > which matches the client name against each compatible and its part
> > after the vendor prefix, so "stk3310" binds through
> > "sensortek,stk3310" - the same lowercase name a DT client gets from
> > of_alias_from_compatible(). The id table lookup stays case-sensitive,
> > which is why i2c_get_match_data() comes back NULL for such a client:
> > device_get_match_data() needs the firmware node it does not have, and
> > i2c_match_id() only knows the historic uppercase names.
> >
> > > - What's wrong with simply failing the probe?
> >
> > It would break a path that works before this patch: probe consumed no
> > match data, so "echo stk3310 0x48 > new_device" bound and probed fine
> > (we used exactly that during bring-up, before the DT node existed).
> > Failing it would be a userspace-visible regression in a patch that
> > claims no functional change.
> >
> > > As far as I understand the problem is preexisted. Or was there any default
> > > taken? How do we know that the chosen default is a good one?
> >
> > The path preexists; only this patch makes probe care about match
> > data. Before it the driver had no per-chip data at all - every client
> > got the same two channels and the hardcoded "stk3310" name however it
> > matched. The fallback selects stk3310_chip_info, which is exactly
> > that, so a client that probed before this patch behaves identically
> > after it. What the default cannot give is the new part's extra
> > channels: an STK36C61 instantiated under the lowercase name gets the
> > reduced legacy profile, and the id table spelling "STK36C61" selects
> > the full one.
>
> The problem preexists. I just looked into the Git history of this rather broken
> table IDs and what I have to say and state is the following:
>
> - the driver initially was written for ACPI and the author blindly (cargo cult?)
> used the same IDs as for ACPI _HID, while they have different rules
>
> - there is no existing in kernel driver that supports enumeration based
> on I2C ID table
>
> With that being said, I think we may just lower the case for the I²C ID
> table and fail enumeration when there is no chip_info provided.
> Yes, it will break very weird use case with capital letters via sysfs,
> but TBH it's a niche and people should know that most of the devices
> are enumerated as part number of OF compatible in that case.
>
> Also note that the DT users should also not use sysfs, and instead call
> DT overlay.
>
> I can take all the blame on very unlikely event of a breakage of somebody's
> setup in the future. TL;DR: just add a first patch to lower case the IDs
> with Suggested-by my name and I will give a Rb tag with full conscience and
> responsibility.
>
Hmm. I agree with fixing the capitals. However we have more options than
usual because we have a single part with which all supported are backwards
compatible.
For most / maybe all of the other drivers where similar has come up,
there is no right answer to what data to use (so we break this path).
They have two or more parts supported but they are mutually incompatible.
Here we could at least have provided the subset for now. I would
be careful though as a future part addition might mean we had to drop
that default as it wasn't backwards compatible with it.
Hence it would be a bit of a gamble on whether failing probe on lower
case inputs is enough of a problem to paper over now, given we may
have to break it in the future anyway.
Jonathan
next prev parent reply other threads:[~2026-08-17 2:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 11:04 [PATCH 0/3] iio: light: stk3310: per-chip match data and STK36C61 support Jorijn van der Graaf
2026-08-10 11:04 ` [PATCH 1/3] dt-bindings: iio: light: stk33xx: document the Sensortek STK36C61 Jorijn van der Graaf
2026-08-10 11:04 ` [PATCH 2/3] iio: light: stk3310: add per-chip match data Jorijn van der Graaf
2026-08-10 18:34 ` Andy Shevchenko
2026-08-10 21:51 ` Jorijn van der Graaf
2026-08-11 10:27 ` Andy Shevchenko
2026-08-17 2:05 ` Jonathan Cameron [this message]
2026-08-17 2:09 ` Jonathan Cameron
2026-08-10 11:04 ` [PATCH 3/3] iio: light: stk3310: support the Sensortek STK36C61 Jorijn van der Graaf
2026-08-10 18:37 ` Andy Shevchenko
2026-08-10 21:52 ` Jorijn van der Graaf
2026-08-17 2:15 ` Jonathan Cameron
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=20260817030512.67ffeb50@jic23-huawei \
--to=jic23@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=gustavoars@kernel.org \
--cc=jorijnvdgraaf@catcrafts.net \
--cc=kees@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.weiss@fairphone.com \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/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