Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@baylibre.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
	 Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	 Nicolas Ferre <nicolas.ferre@microchip.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	 Claudiu Beznea <claudiu.beznea@tuxon.dev>,
	linux-crypto@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/3] crypto: atmel-sha204a - Drop of_device_id data
Date: Wed, 20 May 2026 17:25:35 +0200	[thread overview]
Message-ID: <ag3RTQEC_HyUM3K4@monoceros> (raw)
In-Reply-To: <46130020-eaa5-44ad-9c6d-62ccb30c19d9@app.fastmail.com>

[-- Attachment #1: Type: text/plain, Size: 2397 bytes --]

Hello Ard,

On Wed, May 20, 2026 at 09:49:49AM +0200, Ard Biesheuvel wrote:
> On Wed, 20 May 2026, at 09:01, Uwe Kleine-König (The Capable Hub) wrote:
> > The driver binds to i2c devices only and thus in the absence of an
> > assignment for .data in the of_device_id array i2c_get_match_data()
> > falls back to .driver_data from the i2c_device_id array. So only provide
> > &atsha204_quality once to reduce duplication.
> >
> > Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
> > ---
> >  drivers/crypto/atmel-sha204a.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/crypto/atmel-sha204a.c b/drivers/crypto/atmel-sha204a.c
> > index 6e6ac4770416..f17e1f6af1a3 100644
> > --- a/drivers/crypto/atmel-sha204a.c
> > +++ b/drivers/crypto/atmel-sha204a.c
> > @@ -208,8 +208,8 @@ static void atmel_sha204a_remove(struct i2c_client *client)
> >  }
> > 
> >  static const struct of_device_id atmel_sha204a_dt_ids[] = {
> > -	{ .compatible = "atmel,atsha204", .data = &atsha204_quality },
> > -	{ .compatible = "atmel,atsha204a", },
> > +	{ .compatible = "atmel,atsha204" },
> > +	{ .compatible = "atmel,atsha204a" },
> >  	{ }
> >  };
> >  MODULE_DEVICE_TABLE(of, atmel_sha204a_dt_ids);
> 
> Just trying to figure out how this is supposed to work:
> 
> i2c_get_match_data()
>   data = device_get_match_data(&client->dev);
>   ... returns NULL ...
>   if (!data) {
>     match = i2c_match_id(driver->id_table, client);
>     ... compares client->name with { "atsha204", "atsha204a" }
> 
> So we will be relying on client->name having been set to either 
> "atsha204" or "atsha204a" on the DT probe path before
> i2c_match_data() is called, but I am struggling to see where
> that might happen.

That happens when the client is created. Relevant are:

int of_i2c_get_board_info(struct device *dev, struct device_node *node,
	...
{
	...
	if (of_alias_from_compatible(node, info->type, sizeof(info->type)) < 0) {
		...
}

which sets info->type from .compatible with the vendor part skipped.
Then

static struct i2c_client *of_i2c_register_device(...)
{
	...
	ret = of_i2c_get_board_info(&adap->dev, node, &info);
	...
	client = i2c_new_client_device(adap, &info);
	...
}

where i2c_new_client_device() uses info->type to populate client->name.

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2026-05-20 15:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20  7:01 [PATCH v2 0/3] crypto - Rework i2c_device_id initialisation Uwe Kleine-König (The Capable Hub)
2026-05-20  7:01 ` [PATCH v2 1/3] crypto: atmel-sha204a - Drop of_device_id data Uwe Kleine-König (The Capable Hub)
2026-05-20  7:49   ` Ard Biesheuvel
2026-05-20 15:25     ` Uwe Kleine-König (The Capable Hub) [this message]
2026-05-20  7:01 ` [PATCH v2 2/3] crypto: atmel-sha204a - Use named initializers for struct i2c_device_id Uwe Kleine-König (The Capable Hub)
2026-05-20  7:01 ` [PATCH v2 3/3] crypto: atmel-ecc " Uwe Kleine-König (The Capable Hub)

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=ag3RTQEC_HyUM3K4@monoceros \
    --to=u.kleine-koenig@baylibre.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=ardb@kernel.org \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=thorsten.blum@linux.dev \
    /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