Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: do not call hid_set_drvdata(hdev, NULL) in drivers

This is a common pattern in the HID drivers to reset the drvdata. Some
do it properly, some do it only in case of failure.

But, this is actually already handled by driver core, so there is no need
to do it manually.

[for hid-sensor-hub.c]
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[For hid-picolcd_core.c]
Acked-by: Bruno Prémont <bonbons@linux-vserver.org>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

+3 -20
+2 -4
drivers/hid/hid-cougar.c
··· 207 207 error = hid_parse(hdev); 208 208 if (error) { 209 209 hid_err(hdev, "parse failed\n"); 210 - goto fail; 210 + return error; 211 211 } 212 212 213 213 if (hdev->collection->usage == COUGAR_VENDOR_USAGE) { ··· 219 219 error = hid_hw_start(hdev, connect_mask); 220 220 if (error) { 221 221 hid_err(hdev, "hw start failed\n"); 222 - goto fail; 222 + return error; 223 223 } 224 224 225 225 error = cougar_bind_shared_data(hdev, cougar); ··· 249 249 250 250 fail_stop_and_cleanup: 251 251 hid_hw_stop(hdev); 252 - fail: 253 - hid_set_drvdata(hdev, NULL); 254 252 return error; 255 253 } 256 254
-7
drivers/hid/hid-gfrm.c
··· 123 123 return ret; 124 124 } 125 125 126 - static void gfrm_remove(struct hid_device *hdev) 127 - { 128 - hid_hw_stop(hdev); 129 - hid_set_drvdata(hdev, NULL); 130 - } 131 - 132 126 static const struct hid_device_id gfrm_devices[] = { 133 127 { HID_BLUETOOTH_DEVICE(0x58, 0x2000), 134 128 .driver_data = GFRM100 }, ··· 136 142 .name = "gfrm", 137 143 .id_table = gfrm_devices, 138 144 .probe = gfrm_probe, 139 - .remove = gfrm_remove, 140 145 .input_mapping = gfrm_input_mapping, 141 146 .raw_event = gfrm_raw_event, 142 147 .input_configured = gfrm_input_configured,
-2
drivers/hid/hid-lenovo.c
··· 866 866 867 867 led_classdev_unregister(&data_pointer->led_micmute); 868 868 led_classdev_unregister(&data_pointer->led_mute); 869 - 870 - hid_set_drvdata(hdev, NULL); 871 869 } 872 870 873 871 static void lenovo_remove_cptkbd(struct hid_device *hdev)
+1 -6
drivers/hid/hid-picolcd_core.c
··· 534 534 data = kzalloc(sizeof(struct picolcd_data), GFP_KERNEL); 535 535 if (data == NULL) { 536 536 hid_err(hdev, "can't allocate space for Minibox PicoLCD device data\n"); 537 - error = -ENOMEM; 538 - goto err_no_cleanup; 537 + return -ENOMEM; 539 538 } 540 539 541 540 spin_lock_init(&data->lock); ··· 596 597 hid_hw_stop(hdev); 597 598 err_cleanup_data: 598 599 kfree(data); 599 - err_no_cleanup: 600 - hid_set_drvdata(hdev, NULL); 601 - 602 600 return error; 603 601 } 604 602 ··· 631 635 picolcd_exit_cir(data); 632 636 picolcd_exit_keys(data); 633 637 634 - hid_set_drvdata(hdev, NULL); 635 638 mutex_destroy(&data->mutex); 636 639 /* Finally, clean up the picolcd data itself */ 637 640 kfree(data);
-1
drivers/hid/hid-sensor-hub.c
··· 742 742 } 743 743 spin_unlock_irqrestore(&data->lock, flags); 744 744 mfd_remove_devices(&hdev->dev); 745 - hid_set_drvdata(hdev, NULL); 746 745 mutex_destroy(&data->mutex); 747 746 } 748 747