Skip to content

Commit 87fcb6a

Browse files
committed
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 <[email protected]> [For hid-picolcd_core.c] Acked-by: Bruno Prémont <[email protected]> Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent 15d90b2 commit 87fcb6a

File tree

5 files changed

+3
-20
lines changed

5 files changed

+3
-20
lines changed

drivers/hid/hid-cougar.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static int cougar_probe(struct hid_device *hdev,
207207
error = hid_parse(hdev);
208208
if (error) {
209209
hid_err(hdev, "parse failed\n");
210-
goto fail;
210+
return error;
211211
}
212212

213213
if (hdev->collection->usage == COUGAR_VENDOR_USAGE) {
@@ -219,7 +219,7 @@ static int cougar_probe(struct hid_device *hdev,
219219
error = hid_hw_start(hdev, connect_mask);
220220
if (error) {
221221
hid_err(hdev, "hw start failed\n");
222-
goto fail;
222+
return error;
223223
}
224224

225225
error = cougar_bind_shared_data(hdev, cougar);
@@ -249,8 +249,6 @@ static int cougar_probe(struct hid_device *hdev,
249249

250250
fail_stop_and_cleanup:
251251
hid_hw_stop(hdev);
252-
fail:
253-
hid_set_drvdata(hdev, NULL);
254252
return error;
255253
}
256254

drivers/hid/hid-gfrm.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,6 @@ static int gfrm_probe(struct hid_device *hdev, const struct hid_device_id *id)
123123
return ret;
124124
}
125125

126-
static void gfrm_remove(struct hid_device *hdev)
127-
{
128-
hid_hw_stop(hdev);
129-
hid_set_drvdata(hdev, NULL);
130-
}
131-
132126
static const struct hid_device_id gfrm_devices[] = {
133127
{ HID_BLUETOOTH_DEVICE(0x58, 0x2000),
134128
.driver_data = GFRM100 },
@@ -142,7 +136,6 @@ static struct hid_driver gfrm_driver = {
142136
.name = "gfrm",
143137
.id_table = gfrm_devices,
144138
.probe = gfrm_probe,
145-
.remove = gfrm_remove,
146139
.input_mapping = gfrm_input_mapping,
147140
.raw_event = gfrm_raw_event,
148141
.input_configured = gfrm_input_configured,

drivers/hid/hid-lenovo.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,8 +866,6 @@ static void lenovo_remove_tpkbd(struct hid_device *hdev)
866866

867867
led_classdev_unregister(&data_pointer->led_micmute);
868868
led_classdev_unregister(&data_pointer->led_mute);
869-
870-
hid_set_drvdata(hdev, NULL);
871869
}
872870

873871
static void lenovo_remove_cptkbd(struct hid_device *hdev)

drivers/hid/hid-picolcd_core.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,7 @@ static int picolcd_probe(struct hid_device *hdev,
534534
data = kzalloc(sizeof(struct picolcd_data), GFP_KERNEL);
535535
if (data == NULL) {
536536
hid_err(hdev, "can't allocate space for Minibox PicoLCD device data\n");
537-
error = -ENOMEM;
538-
goto err_no_cleanup;
537+
return -ENOMEM;
539538
}
540539

541540
spin_lock_init(&data->lock);
@@ -597,9 +596,6 @@ static int picolcd_probe(struct hid_device *hdev,
597596
hid_hw_stop(hdev);
598597
err_cleanup_data:
599598
kfree(data);
600-
err_no_cleanup:
601-
hid_set_drvdata(hdev, NULL);
602-
603599
return error;
604600
}
605601

@@ -635,7 +631,6 @@ static void picolcd_remove(struct hid_device *hdev)
635631
picolcd_exit_cir(data);
636632
picolcd_exit_keys(data);
637633

638-
hid_set_drvdata(hdev, NULL);
639634
mutex_destroy(&data->mutex);
640635
/* Finally, clean up the picolcd data itself */
641636
kfree(data);

drivers/hid/hid-sensor-hub.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,6 @@ static void sensor_hub_remove(struct hid_device *hdev)
742742
}
743743
spin_unlock_irqrestore(&data->lock, flags);
744744
mfd_remove_devices(&hdev->dev);
745-
hid_set_drvdata(hdev, NULL);
746745
mutex_destroy(&data->mutex);
747746
}
748747

0 commit comments

Comments
 (0)