Devicetree
 help / color / mirror / Atom feed
From: Jorijn van der Graaf <jorijnvdgraaf@catcrafts.net>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Jorijn van der Graaf" <jorijnvdgraaf@catcrafts.net>,
	"Jonathan Cameron" <jic23@kernel.org>,
	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, 10 Aug 2026 23:51:57 +0200	[thread overview]
Message-ID: <20260810215157.154384-1-jorijnvdgraaf@catcrafts.net> (raw)
In-Reply-To: <anoZwgq6ZO_VY064@ashevche-desk.local>

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.

Thanks,
Jorijn

  reply	other threads:[~2026-08-10 21:52 UTC|newest]

Thread overview: 9+ 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 [this message]
2026-08-10 11:04 ` [PATCH 3/3] iio: light: stk3310: support the Sensortek STK36C61 Jorijn van der Graaf
2026-08-10 11:28   ` sashiko-bot
2026-08-10 18:37   ` Andy Shevchenko
2026-08-10 21:52     ` Jorijn van der Graaf

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=20260810215157.154384-1-jorijnvdgraaf@catcrafts.net \
    --to=jorijnvdgraaf@catcrafts.net \
    --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=jic23@kernel.org \
    --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