* [PATCH v1 0/9] HID: Make driver_data in hid_device_id a union
@ 2026-11-25 7:21 Uwe Kleine-König
2026-11-25 7:21 ` [PATCH v1 9/9] hwmon: (asus_rog_ryujin) Benefit from pointer typed driver_data in hid_device_id Uwe Kleine-König
2026-11-25 7:34 ` [PATCH v1 0/9] HID: Make driver_data in hid_device_id a union sashiko-bot
0 siblings, 2 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2026-11-25 7:21 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires, Guenter Roeck
Cc: linux-input, Danilo Krummrich, Bjorn Helgaas, Takashi Sakamoto,
Geert Uytterhoeven, Aleksa Savic, linux-kernel, Ping Cheng,
Jason Gerecke, linux-hwmon, Pawel Zalewski, Christian A. Ehrhardt
Hello,
the 5th patch of this series replaces .driver_data of struct
hid_device_id by an anonymous union. Drivers that store pointers in
.driver_data can benefit from that by less casting and still more
implicit type safety as something like:
struct sometype *driver_data = id->driver_data_ptr;
is catched by the compiler to lack a `const`.
The (IMHO tiny) downside is that with that union initialisations must be
done using designated (i.e. named) initializers. The first four patches
implement that for the few drivers that don't do that yet, which IMHO
could stand as improvements on its own. Patches #6 and later convert
drivers that store pointers in .driver_data to the new .driver_data_ptr.
All patches intend to have no effect on the build result, so this is
only about easier source code and tighter compiler checks.
My original motivation to work on this is that the result also works on
machines with CHERI support that have sizeof(unsigned long) <
sizeof(void *). It's still a long way to get these running mainline
Linux but the nice thing about this series is that it works towards such
a future and improves the code for non-CHERI architectures, too.
Some of the existing initializers use an unusual coding style. In the
first patch I converted that to a more common indentation while updating
to designated initializers, in the quirks patch I mostly kept the
existing style. If you have a strong opinion there or think the
opportunity should be taken to convert all such arrays, I can do that.
This conversion is also the main reason that this series doesn't have a
diffstat with nearly an equal number of insertions and deletions.
The dependencies are as follows:
- patch #5 (HID: core: Make driver_data in hid_device_id a union)
depends on patches #1 - #4
- patches #6 and later (...: Benefit from pointer typed driver_data in
hid_device_id) depend on patch #5.
I would expect that all but maybe the last patch go in via the HID tree.
I can resend patch #9 to hwmon when its dependencies landed in the
mainline.
I build tested this series on top of next-20261123 using allmodconfig on
arc, sh, alpha, arm64, x86_64, s390, riscv, mips, powerpc, loongarch,
sparc, m68k and parisc and there were no build regressions.
Best regards
Uwe
Uwe Kleine-König (9):
HID: asus: Use designated initializer for hid_device_id
HID: i2c-hid: Use designated initializer for hid_device_id
HID: input: Use designated initializer for hid_device_id
HID: quirks: Use designated initializer for hid_device_id
HID: core: Make driver_data in hid_device_id a union
HID: steelseries: Benefit from pointer typed driver_data in
hid_device_id
HID: tmff: Benefit from pointer typed driver_data in hid_device_id
HID: wacom: Benefit from pointer typed driver_data in hid_device_id
hwmon: (asus_rog_ryujin) Benefit from pointer typed driver_data in
hid_device_id
drivers/hid/hid-asus.c | 199 ++++++-----
drivers/hid/hid-input.c | 114 ++++---
drivers/hid/hid-quirks.c | 400 +++++++++++------------
drivers/hid/hid-steelseries-arctis.c | 39 ++-
drivers/hid/hid-tmff.c | 22 +-
drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c | 2 +-
drivers/hid/wacom_sys.c | 8 +-
drivers/hid/wacom_wac.c | 10 +-
drivers/hwmon/asus_rog_ryujin.c | 14 +-
include/linux/device-id/hid.h | 5 +-
10 files changed, 438 insertions(+), 375 deletions(-)
base-commit: 3191063649dbf7c0d0b768e1f3655e4c5fc6edb5
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH v1 9/9] hwmon: (asus_rog_ryujin) Benefit from pointer typed driver_data in hid_device_id
2026-11-25 7:21 [PATCH v1 0/9] HID: Make driver_data in hid_device_id a union Uwe Kleine-König
@ 2026-11-25 7:21 ` Uwe Kleine-König
2026-11-25 7:34 ` [PATCH v1 0/9] HID: Make driver_data in hid_device_id a union sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2026-11-25 7:21 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires, Guenter Roeck
Cc: Aleksa Savic, linux-hwmon, linux-input, Pawel Zalewski,
Christian A. Ehrhardt
With using .driver_data_ptr instead of .driver_data several explicit
casts can be dropped. Do that. Note that with
priv->info = id->driver_data_ptr;
instead of
priv->info = (const struct rog_ryujin_device_info *)id->driver_data;
the constness of .driver_data_ptr is checked by the compiler without the
explicit cast.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
drivers/hwmon/asus_rog_ryujin.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/hwmon/asus_rog_ryujin.c b/drivers/hwmon/asus_rog_ryujin.c
index e9722c2dec63..ae53e7583001 100644
--- a/drivers/hwmon/asus_rog_ryujin.c
+++ b/drivers/hwmon/asus_rog_ryujin.c
@@ -696,7 +696,7 @@ static int rog_ryujin_probe(struct hid_device *hdev, const struct hid_device_id
struct rog_ryujin_data *priv;
int ret;
- if (!id->driver_data)
+ if (!id->driver_data_ptr)
return -EINVAL;
priv = devm_kzalloc_obj(&hdev->dev, *priv);
@@ -704,7 +704,7 @@ static int rog_ryujin_probe(struct hid_device *hdev, const struct hid_device_id
return -ENOMEM;
priv->hdev = hdev;
- priv->info = (const struct rog_ryujin_device_info *)id->driver_data;
+ priv->info = id->driver_data_ptr;
hid_set_drvdata(hdev, priv);
/*
@@ -789,15 +789,15 @@ static void rog_ryujin_remove(struct hid_device *hdev)
static const struct hid_device_id rog_ryujin_table[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_AIO),
- .driver_data = (kernel_ulong_t)&rog_ryujin_ii_360_info },
+ .driver_data_ptr = &rog_ryujin_ii_360_info },
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_III_EXTREME),
- .driver_data = (kernel_ulong_t)&rog_ryujin_iii_info },
+ .driver_data_ptr = &rog_ryujin_iii_info },
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_III_EVA),
- .driver_data = (kernel_ulong_t)&rog_ryujin_iii_info },
+ .driver_data_ptr = &rog_ryujin_iii_info },
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_III_WHITE),
- .driver_data = (kernel_ulong_t)&rog_ryujin_iii_info },
+ .driver_data_ptr = &rog_ryujin_iii_info },
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_III),
- .driver_data = (kernel_ulong_t)&rog_ryujin_iii_info },
+ .driver_data_ptr = &rog_ryujin_iii_info },
{ }
};
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v1 0/9] HID: Make driver_data in hid_device_id a union
2026-11-25 7:21 [PATCH v1 0/9] HID: Make driver_data in hid_device_id a union Uwe Kleine-König
2026-11-25 7:21 ` [PATCH v1 9/9] hwmon: (asus_rog_ryujin) Benefit from pointer typed driver_data in hid_device_id Uwe Kleine-König
@ 2026-11-25 7:34 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-25 7:34 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: linux-hwmon
Sashiko has finished reviewing this 9-patch series:
- Patches 1-7 and 9: no issues found.
- Patch 8 ("HID: wacom: Benefit from pointer typed driver_data i..."): 1
potential issue (1 Low) and 1 related pre-existing bug
A detailed review has been sent as a separate reply to patch 8.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795589119.git.u.kleine-koenig@baylibre.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-25 7:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 7:21 [PATCH v1 0/9] HID: Make driver_data in hid_device_id a union Uwe Kleine-König
2026-11-25 7:21 ` [PATCH v1 9/9] hwmon: (asus_rog_ryujin) Benefit from pointer typed driver_data in hid_device_id Uwe Kleine-König
2026-11-25 7:34 ` [PATCH v1 0/9] HID: Make driver_data in hid_device_id a union sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox