* [PATCH v2 0/3] crypto - Rework i2c_device_id initialisation
@ 2026-05-20 7:01 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)
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-20 7:01 UTC (permalink / raw)
To: Thorsten Blum, Herbert Xu, David S. Miller, Nicolas Ferre,
Alexandre Belloni, Claudiu Beznea
Cc: Ard Biesheuvel, linux-crypto, linux-arm-kernel, linux-kernel
Hello,
this is v2 of the patch available at
https://lore.kernel.org/linux-crypto/20260519141033.1586036-2-u.kleine-koenig@baylibre.com.
Changes since v1 are:
- Rebase to next-20260519 to account for changes since v7.1-rc1 (= the
previous base)
- Patch #1 is new
- The adaption to atmel-sha204a is a bit less trivial, so split into a
separate patch (#2)
Best regards
Uwe
Uwe Kleine-König (The Capable Hub) (3):
crypto: atmel-sha204a - Drop of_device_id data
crypto: atmel-sha204a - Use named initializers for struct
i2c_device_id
crypto: atmel-ecc - Use named initializers for struct i2c_device_id
drivers/crypto/atmel-ecc.c | 4 ++--
drivers/crypto/atmel-sha204a.c | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
base-commit: 6a50ba100ace43f43c87384367eb2d2605fcc16c
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/3] crypto: atmel-sha204a - Drop of_device_id data
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 ` Uwe Kleine-König (The Capable Hub)
2026-05-20 7:49 ` Ard Biesheuvel
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)
2 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-20 7:01 UTC (permalink / raw)
To: Thorsten Blum, Herbert Xu, David S. Miller, Nicolas Ferre,
Alexandre Belloni, Claudiu Beznea
Cc: Ard Biesheuvel, linux-crypto, linux-arm-kernel, linux-kernel
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);
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/3] crypto: atmel-sha204a - Use named initializers for struct i2c_device_id
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:01 ` 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)
2 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-20 7:01 UTC (permalink / raw)
To: Thorsten Blum, Herbert Xu, David S. Miller, Nicolas Ferre,
Alexandre Belloni, Claudiu Beznea
Cc: Ard Biesheuvel, linux-crypto, linux-arm-kernel, linux-kernel
While being less compact, using named initializers allows to more easily
see which members of the structs are assigned which value without having
to lookup the declaration of the struct. And it's also more robust
against changes to the struct definition.
This patch doesn't modify the compiled array, only its representation in
source form benefits. The former was confirmed with x86 and arm64
builds.
For consistency also assign .driver_data for the array item that the
driver relies on i2c_get_match_data() returning NULL for.
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 f17e1f6af1a3..f3bbe836778d 100644
--- a/drivers/crypto/atmel-sha204a.c
+++ b/drivers/crypto/atmel-sha204a.c
@@ -215,8 +215,8 @@ static const struct of_device_id atmel_sha204a_dt_ids[] = {
MODULE_DEVICE_TABLE(of, atmel_sha204a_dt_ids);
static const struct i2c_device_id atmel_sha204a_id[] = {
- { "atsha204", (kernel_ulong_t)&atsha204_quality },
- { "atsha204a" },
+ { .name = "atsha204", .driver_data = (kernel_ulong_t)&atsha204_quality },
+ { .name = "atsha204a", .driver_data = (kernel_ulong_t)NULL },
{ }
};
MODULE_DEVICE_TABLE(i2c, atmel_sha204a_id);
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 3/3] crypto: atmel-ecc - Use named initializers for struct i2c_device_id
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: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 ` Uwe Kleine-König (The Capable Hub)
2 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-20 7:01 UTC (permalink / raw)
To: Thorsten Blum, Herbert Xu, David S. Miller, Nicolas Ferre,
Alexandre Belloni, Claudiu Beznea
Cc: Ard Biesheuvel, linux-crypto, linux-arm-kernel, linux-kernel
While being less compact, using named initializers allows to more easily
see which members of the structs are assigned which value without having
to lookup the declaration of the struct. And it's also more robust
against changes to the struct definition.
This patch doesn't modify the compiled array, only its representation in
source form benefits. The former was confirmed with x86 and arm64
builds.
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
drivers/crypto/atmel-ecc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
index 9660f6426a84..0ca02995a1de 100644
--- a/drivers/crypto/atmel-ecc.c
+++ b/drivers/crypto/atmel-ecc.c
@@ -376,8 +376,8 @@ static const struct of_device_id atmel_ecc_dt_ids[] = {
MODULE_DEVICE_TABLE(of, atmel_ecc_dt_ids);
static const struct i2c_device_id atmel_ecc_id[] = {
- { "atecc508a" },
- { "atecc608b" },
+ { .name = "atecc508a" },
+ { .name = "atecc608b" },
{ }
};
MODULE_DEVICE_TABLE(i2c, atmel_ecc_id);
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/3] crypto: atmel-sha204a - Drop of_device_id data
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)
0 siblings, 1 reply; 6+ messages in thread
From: Ard Biesheuvel @ 2026-05-20 7:49 UTC (permalink / raw)
To: Uwe Kleine-König (The Capable Hub), Thorsten Blum,
Herbert Xu, David S. Miller, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea
Cc: linux-crypto, linux-arm-kernel, linux-kernel
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/3] crypto: atmel-sha204a - Drop of_device_id data
2026-05-20 7:49 ` Ard Biesheuvel
@ 2026-05-20 15:25 ` Uwe Kleine-König (The Capable Hub)
0 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-20 15:25 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Thorsten Blum, Herbert Xu, David S. Miller, Nicolas Ferre,
Alexandre Belloni, Claudiu Beznea, linux-crypto, linux-arm-kernel,
linux-kernel
[-- 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 --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-05-20 15:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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)
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)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox