HID: do not call hid_set_drvdata(hdev, NULL) in drivers
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Mon, 12 Aug 2019 16:27:39 +0000 (18:27 +0200)
committerBenjamin Tissoires <benjamin.tissoires@redhat.com>
Thu, 22 Aug 2019 15:11:58 +0000 (17:11 +0200)
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>
drivers/hid/hid-cougar.c
drivers/hid/hid-gfrm.c
drivers/hid/hid-lenovo.c
drivers/hid/hid-picolcd_core.c
drivers/hid/hid-sensor-hub.c

index e0bb7b34f3a4de8a1f4b51a9f3bc8406b21cd621..4ff3bc1d25e23fe91b4d8460e4ab13d934ea14c2 100644 (file)
@@ -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) {
@@ -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);
@@ -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;
 }
 
index 86c317320bf20d3c7a91dfc05dfed48d74be6a9e..699186ff2349e92a6ee70ef23b93e1f6af6f4e88 100644 (file)
@@ -123,12 +123,6 @@ done:
        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 },
@@ -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,
index 364bc7f11d9d9d757a9efbc3142f922798c48aff..96fa2a2c2cd3a65f91a2031be36aac59c53452c6 100644 (file)
@@ -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)
index 5f7a39a5d4afab5906497aa99640ffb1e9757249..1b5c63241af0585d21fac6d24512c5742aae0b97 100644 (file)
@@ -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);
@@ -597,9 +596,6 @@ err_cleanup_hid_hw:
        hid_hw_stop(hdev);
 err_cleanup_data:
        kfree(data);
-err_no_cleanup:
-       hid_set_drvdata(hdev, NULL);
-
        return error;
 }
 
@@ -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);
index be92a6f79687094d917d4ba1cfdaa1494d88f481..94c7398b5c279f21775f5b1b5e550e0d848818c6 100644 (file)
@@ -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);
 }