From: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@baylibre.com>
To: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
Max Filippov <jcmvbkbc@gmail.com>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Alex Helms <alexander.helms.jy@renesas.com>
Subject: Re: [PATCH v1 0/2] clk: Rework initialization of i2c_device_ids
Date: Thu, 11 Jun 2026 17:38:26 +0200 [thread overview]
Message-ID: <airWClCSYG0EY0VS@monoceros> (raw)
In-Reply-To: <cover.1778857289.git.u.kleine-koenig@baylibre.com>
[-- Attachment #1: Type: text/plain, Size: 2622 bytes --]
Hello,
On Fri, May 15, 2026 at 05:10:38PM +0200, Uwe Kleine-König (The Capable Hub) wrote:
> this series is a preparation for
>
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index 23ff24080dfd..aebd3a5e90af 100644
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -477,7 +477,11 @@ struct rpmsg_device_id {
>
> struct i2c_device_id {
> char name[I2C_NAME_SIZE];
> - kernel_ulong_t driver_data; /* Data private to the driver */
> + union {
> + /* Data private to the driver */
> + kernel_ulong_t driver_data;
> + const void *driver_data_ptr;
> + };
> };
>
> /* pci_epf */
>
> and this requires that .driver_data is assigned via a named initializer
> for static data. This requirement isn't a bad one because named
> initializers are also much better readable than list initializers.
>
> The union added to struct i2c_device_id enables further cleanups like:
>
> diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c
> index 0123ca8157a8..84272ba65d08 100644
> --- a/drivers/regulator/ad5398.c
> +++ b/drivers/regulator/ad5398.c
> @@ -207,8 +207,8 @@ struct ad5398_current_data_format {
> static const struct ad5398_current_data_format df_10_4_120 = {10, 4, 0, 120000};
>
> static const struct i2c_device_id ad5398_id[] = {
> - { .name = "ad5398", .driver_data = (kernel_ulong_t)&df_10_4_120 },
> - { .name = "ad5821", .driver_data = (kernel_ulong_t)&df_10_4_120 },
> + { .name = "ad5398", .driver_data_ptr = &df_10_4_120 },
> + { .name = "ad5821", .driver_data_ptr = &df_10_4_120 },
> { }
> };
> MODULE_DEVICE_TABLE(i2c, ad5398_id);
> @@ -219,8 +219,7 @@ static int ad5398_probe(struct i2c_client *client)
> struct regulator_init_data *init_data = dev_get_platdata(&client->dev);
> struct regulator_config config = { };
> struct ad5398_chip_info *chip;
> - const struct ad5398_current_data_format *df =
> - (struct ad5398_current_data_format *)id->driver_data;
> + const struct ad5398_current_data_format *df = id->driver_data_ptr;
>
> chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
> if (!chip)
>
> that are an improvement for readability (again!) and it keeps some
> properties of the pointers (here: being const) without having to pay
> attention for that. (I didn't find a good example in drivers/clk, so an
> regulator driver was used to demonstrate the gain.)
I wonder if you still have this series on your radar, it would be great
to get it into 7.2-rc1.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2026-06-11 15:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 15:10 [PATCH v1 0/2] clk: Rework initialization of i2c_device_ids Uwe Kleine-König (The Capable Hub)
2026-05-15 15:10 ` [PATCH v1 1/2] clk: si5341: Drop unused i2c driver_data Uwe Kleine-König (The Capable Hub)
2026-05-18 15:50 ` Brian Masney
2026-05-15 15:10 ` [PATCH v1 2/2] clk: Use named initializers for arrays of i2c_device_data Uwe Kleine-König (The Capable Hub)
2026-05-18 15:52 ` Brian Masney
2026-05-18 16:58 ` Luca Ceresoli
2026-06-11 15:38 ` Uwe Kleine-König (The Capable Hub) [this message]
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=airWClCSYG0EY0VS@monoceros \
--to=u.kleine-koenig@baylibre.com \
--cc=alexander.helms.jy@renesas.com \
--cc=jcmvbkbc@gmail.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=mturquette@baylibre.com \
--cc=sboyd@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