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: [PATCH v1 0/2] clk: Rework initialization of i2c_device_ids
Date: Fri, 15 May 2026 17:10:38 +0200 [thread overview]
Message-ID: <cover.1778857289.git.u.kleine-koenig@baylibre.com> (raw)
Hello,
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.)
My additional motivation for this effort is CHERI[1]. This is a hardware
extension that uses 128 bit pointers but unsigned long is still 64 bit.
So with CHERI you cannot store pointers in unsigned long variables.
The first patch drops unused assignments to .driver_data in one driver.
The second converts all clk drivers to use named initializers for
i2c_device_id.
Best regards
Uwe
Uwe Kleine-König (The Capable Hub) (2):
clk: si5341: Drop unused i2c driver_data
clk: Use named initializers for arrays of i2c_device_data
drivers/clk/clk-cdce706.c | 2 +-
drivers/clk/clk-cdce925.c | 8 ++++----
drivers/clk/clk-cs2000-cp.c | 4 ++--
drivers/clk/clk-renesas-pcie.c | 6 +++---
drivers/clk/clk-si514.c | 2 +-
drivers/clk/clk-si521xx.c | 6 +++---
drivers/clk/clk-si5341.c | 10 +++++-----
drivers/clk/clk-si5351.c | 8 ++++----
drivers/clk/clk-si544.c | 6 +++---
drivers/clk/clk-si570.c | 8 ++++----
drivers/clk/clk-versaclock5.c | 16 ++++++++--------
drivers/clk/clk-versaclock7.c | 4 ++--
12 files changed, 40 insertions(+), 40 deletions(-)
base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
--
2.47.3
next reply other threads:[~2026-05-15 15:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 15:10 Uwe Kleine-König (The Capable Hub) [this message]
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-15 15:10 ` [PATCH v1 2/2] clk: Use named initializers for arrays of i2c_device_data 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=cover.1778857289.git.u.kleine-koenig@baylibre.com \
--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