Skip to content

Commit

Permalink
HID: do not call hid_set_drvdata(hdev, NULL) in drivers
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bentiss committed Aug 22, 2019
1 parent 15d90b2 commit 87fcb6a
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 20 deletions.
6 changes: 2 additions & 4 deletions drivers/hid/hid-cougar.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static int cougar_probe(struct hid_device *hdev,
error = hid_parse(hdev);
if (error) {
hid_err(hdev, "parse failed\n");
goto fail;
return error;
}

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

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

fail_stop_and_cleanup:
hid_hw_stop(hdev);
fail:
hid_set_drvdata(hdev, NULL);
return error;
}

Expand Down
7 changes: 0 additions & 7 deletions drivers/hid/hid-gfrm.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,6 @@ static int gfrm_probe(struct hid_device *hdev, const struct hid_device_id *id)
return ret;
}

static void gfrm_remove(struct hid_device *hdev)
{
hid_hw_stop(hdev);
hid_set_drvdata(hdev, NULL);
}

static const struct hid_device_id gfrm_devices[] = {
{ HID_BLUETOOTH_DEVICE(0x58, 0x2000),
.driver_data = GFRM100 },
Expand All @@ -142,7 +136,6 @@ static struct hid_driver gfrm_driver = {
.name = "gfrm",
.id_table = gfrm_devices,
.probe = gfrm_probe,
.remove = gfrm_remove,
.input_mapping = gfrm_input_mapping,
.raw_event = gfrm_raw_event,
.input_configured = gfrm_input_configured,
Expand Down
2 changes: 0 additions & 2 deletions drivers/hid/hid-lenovo.c
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,6 @@ static void lenovo_remove_tpkbd(struct hid_device *hdev)

led_classdev_unregister(&data_pointer->led_micmute);
led_classdev_unregister(&data_pointer->led_mute);

hid_set_drvdata(hdev, NULL);
}

static void lenovo_remove_cptkbd(struct hid_device *hdev)
Expand Down
7 changes: 1 addition & 6 deletions drivers/hid/hid-picolcd_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,7 @@ static int picolcd_probe(struct hid_device *hdev,
data = kzalloc(sizeof(struct picolcd_data), GFP_KERNEL);
if (data == NULL) {
hid_err(hdev, "can't allocate space for Minibox PicoLCD device data\n");
error = -ENOMEM;
goto err_no_cleanup;
return -ENOMEM;
}

spin_lock_init(&data->lock);
Expand Down Expand Up @@ -597,9 +596,6 @@ static int picolcd_probe(struct hid_device *hdev,
hid_hw_stop(hdev);
err_cleanup_data:
kfree(data);
err_no_cleanup:
hid_set_drvdata(hdev, NULL);

return error;
}

Expand Down Expand Up @@ -635,7 +631,6 @@ static void picolcd_remove(struct hid_device *hdev)
picolcd_exit_cir(data);
picolcd_exit_keys(data);

hid_set_drvdata(hdev, NULL);
mutex_destroy(&data->mutex);
/* Finally, clean up the picolcd data itself */
kfree(data);
Expand Down
1 change: 0 additions & 1 deletion drivers/hid/hid-sensor-hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,6 @@ static void sensor_hub_remove(struct hid_device *hdev)
}
spin_unlock_irqrestore(&data->lock, flags);
mfd_remove_devices(&hdev->dev);
hid_set_drvdata(hdev, NULL);
mutex_destroy(&data->mutex);
}

Expand Down

0 comments on commit 87fcb6a

Please sign in to comment.