Skip to content

Commit 4de4b8a

Browse files
pzalewski-thegoodpenguinBenjamin Tissoires
authored andcommitted
HID: hid-belkin: clean up usage of 'driver_data'
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@thegoodpenguin.co.uk> Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
1 parent e6f4f08 commit 4de4b8a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/hid/hid-belkin.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ static int belkin_input_mapping(struct hid_device *hdev, struct hid_input *hi,
2727
struct hid_field *field, struct hid_usage *usage,
2828
unsigned long **bit, int *max)
2929
{
30-
unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
30+
const struct hid_device_id *id = hid_get_drvdata(hdev);
31+
unsigned long quirks = id->driver_data;
3132

3233
if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER ||
3334
!(quirks & BELKIN_WKBD))
@@ -48,7 +49,7 @@ static int belkin_probe(struct hid_device *hdev, const struct hid_device_id *id)
4849
unsigned long quirks = id->driver_data;
4950
int ret;
5051

51-
hid_set_drvdata(hdev, (void *)quirks);
52+
hid_set_drvdata(hdev, (void *)id);
5253

5354
ret = hid_parse(hdev);
5455
if (ret) {

0 commit comments

Comments
 (0)