[PATCH v1 5/9] HID: core: Make driver_data in hid_device_id a union
From: Uwe Kleine-König
Date: Wed Nov 25 2026 - 02:22:26 EST
With that anonymous union usage of struct hid_device_id is nearly
identical; only initialisation using a list initializer doesn't work
(and there are none of these in the tree).
The upside is that drivers storing a pointer in driver_data can do so
with more type-safety. So usually a missing const is catched by the
compiler. Also less explicit casting is needed.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx>
---
include/linux/device-id/hid.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/linux/device-id/hid.h b/include/linux/device-id/hid.h
index e865fc64bf94..e05a8974de4b 100644
--- a/include/linux/device-id/hid.h
+++ b/include/linux/device-id/hid.h
@@ -16,7 +16,10 @@ struct hid_device_id {
__u16 group;
__u32 vendor;
__u32 product;
- kernel_ulong_t driver_data;
+ union {
+ kernel_ulong_t driver_data;
+ const void *driver_data_ptr;
+ };
};
#endif /* ifndef LINUX_DEVICE_ID_HID_H */
--
2.47.3