From: Chanwoo Choi <cwchoi00@gmail.com>
To: "Uwe Kleine-König (The Capable Hub)"
<u.kleine-koenig@baylibre.com>,
"MyungJoo Ham" <myungjoo.ham@samsung.com>,
"Chanwoo Choi" <cw00.choi@samsung.com>
Cc: linux-kernel@vger.kernel.org, Krzysztof Kozlowski <krzk@kernel.org>
Subject: Re: [PATCH v1 0/2] extcon: Rework initialization of i2c_device_id
Date: Sat, 28 Nov 2026 07:50:17 +0900 [thread overview]
Message-ID: <95dba453-1ff4-4801-b800-337dac67704f@gmail.com> (raw)
In-Reply-To: <cover.1779100597.git.u.kleine-koenig@baylibre.com>
On 5/18/2026 7:41 PM, Uwe Kleine-König (The Capable Hub) wrote:
> Hello,
>
> I plan to do the following to the definition of i2c_device_id:
>
> 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 */
>
> . 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..dfb0b07500a7 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;
>
> 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 extcon driver that benefits, so
> this is "only" a regulator driver example.)
>
> 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 simplifies one extcon driver to not use .driver_data,
> the second converts all extcon drivers to initialize i2c_device_ids
> using named initializers.
>
> Best regards
> Uwe
>
> [1] https://cheri-alliance.org/discover-cheri/
> https://lwn.net/Articles/1037974/
>
> Uwe Kleine-König (The Capable Hub) (2):
> extcon: rt8973: Drop unused driver data
> extcon: Use named initializers for arrays of i2c_device_data
>
> drivers/extcon/extcon-fsa9480.c | 4 ++--
> drivers/extcon/extcon-lc824206xa.c | 2 +-
> drivers/extcon/extcon-max14526.c | 2 +-
> drivers/extcon/extcon-ptn5150.c | 2 +-
> drivers/extcon/extcon-rt8973a.c | 2 +-
> drivers/extcon/extcon-rt8973a.h | 4 ----
> drivers/extcon/extcon-sm5502.c | 6 +++---
> 7 files changed, 9 insertions(+), 13 deletions(-)
>
>
> base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
Applied them. Thanks.
Sorry for long late review.
--
Best Regards,
Chanwoo Choi
Principal Engineer, Samsung Electronics
prev parent reply other threads:[~2026-11-27 22:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 10:41 Uwe Kleine-König (The Capable Hub)
2026-05-18 10:41 ` [PATCH v1 1/2] extcon: rt8973: Drop unused driver data Uwe Kleine-König (The Capable Hub)
2026-05-18 10:41 ` [PATCH v1 2/2] extcon: Use named initializers for arrays of i2c_device_data Uwe Kleine-König (The Capable Hub)
2026-06-10 17:10 ` [PATCH v1 0/2] extcon: Rework initialization of i2c_device_id Uwe Kleine-König (The Capable Hub)
2026-07-17 10:31 ` Uwe Kleine-König (The Capable Hub)
2026-11-17 14:53 ` Uwe Kleine-König (The Capable Hub)
2026-11-27 9:50 ` extcon still alive? [Was: Re: [PATCH v1 0/2] extcon: Rework initialization of i2c_device_id] Uwe Kleine-König (The Capable Hub)
2026-11-27 11:08 ` Greg Kroah-Hartman
2026-11-27 22:35 ` Chanwoo Choi
2026-11-27 22:50 ` Chanwoo Choi [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=95dba453-1ff4-4801-b800-337dac67704f@gmail.com \
--to=cwchoi00@gmail.com \
--cc=chanwoo@kernel.org \
--cc=cw00.choi@samsung.com \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=u.kleine-koenig@baylibre.com \
/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
all inboxes | Powered by JetHome®