[PATCH 07/11] HID: hid-gfrm: clean up usage of 'driver_data'
From: Pawel Zalewski (The Capable Hub)
Date: Mon May 18 2026 - 12:12:22 EST
The module is storing an integer inside the drvdata pointer, which is
confusing, lets fix this and set the whole of 'hid_device_id' struct
as the drvdata and then simply use its integer 'driver_data' field for
quirks, which shall make the code cleaner, type-safe, consistent and
more readable.
This makes the cast to (void *) during storage a bit safer (just to
suppress the const qualifier warning) and the cast to (unsigned long)
during retrieval is removed.
Signed-off-by: Pawel Zalewski (The Capable Hub) <pzalewski@xxxxxxxxxxxxxxxxxxxx>
---
drivers/hid/hid-gfrm.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-gfrm.c b/drivers/hid/hid-gfrm.c
index 699186ff2349..0be49a93d28b 100644
--- a/drivers/hid/hid-gfrm.c
+++ b/drivers/hid/hid-gfrm.c
@@ -28,7 +28,8 @@ static int gfrm_input_mapping(struct hid_device *hdev, struct hid_input *hi,
struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max)
{
- unsigned long hdev_type = (unsigned long) hid_get_drvdata(hdev);
+ const struct hid_device_id *id = hid_get_drvdata(hdev);
+ unsigned long hdev_type = id->driver_data;
if (hdev_type == GFRM100) {
if (usage->hid == (HID_UP_CONSUMER | 0x4)) {
@@ -50,7 +51,8 @@ static int gfrm_input_mapping(struct hid_device *hdev, struct hid_input *hi,
static int gfrm_raw_event(struct hid_device *hdev, struct hid_report *report,
u8 *data, int size)
{
- unsigned long hdev_type = (unsigned long) hid_get_drvdata(hdev);
+ const struct hid_device_id *id = hid_get_drvdata(hdev);
+ unsigned long hdev_type = id->driver_data;
int ret = 0;
if (hdev_type != GFRM100)
@@ -99,7 +101,7 @@ static int gfrm_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
int ret;
- hid_set_drvdata(hdev, (void *) id->driver_data);
+ hid_set_drvdata(hdev, (void *)id);
ret = hid_parse(hdev);
if (ret)
--
2.43.0