]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
HID: add remove function in nv hidraw
authorVinayak Pane <vpane@nvidia.com>
Wed, 14 May 2014 00:23:22 +0000 (17:23 -0700)
committerHarshada Kale <hkale@nvidia.com>
Thu, 29 May 2014 10:44:51 +0000 (03:44 -0700)
Adding remove function to remove sysfs attribute nodes
when blake is disconnected.

Bug 200003632

Change-Id: I5bf571176d2653b9f74f548775da904ef93007c8
Signed-off-by: Vinayak Pane <vpane@nvidia.com>
Reviewed-on: http://git-master/r/410596
(cherry picked from commit 9904c21f42b14f3675c27ef2646eae669440bd07)
Reviewed-on: http://git-master/r/409169
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Eric Chuang <echuang@nvidia.com>
GVS: Gerrit_Virtual_Submit

drivers/hid/hid-nvidia-blake.c

index 7e45449d07d2fd101c67263d7a4c097ac0c40c8a..e66f1f779c35eb08eb9e8098bcacb9b8df9282e5 100644 (file)
@@ -516,12 +516,16 @@ static int nvidia_probe(struct hid_device *hdev, const struct hid_device_id *id)
        loc->mode = MOUSE_MODE;
        hid_set_drvdata(hdev, loc);
 
-       ret = hid_open_report(hdev);
-       if (!ret)
-               ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+       /* Parse the HID report now */
+       ret = hid_parse(hdev);
+       if (ret) {
+               hid_err(hdev, "parse failed\n");
+               goto err_parse;
+       }
 
+       ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
        if (ret)
-               goto end;
+               goto err_parse;
 
        ret = device_create_file(&hdev->dev, &dev_attr_speed);
        if (ret)
@@ -529,15 +533,31 @@ static int nvidia_probe(struct hid_device *hdev, const struct hid_device_id *id)
        ret = device_create_file(&hdev->dev, &dev_attr_mode);
        if (ret)
                hid_warn(hdev, "cannot create sysfs for mode\n");
+       return 0;
 
 
        nvidia_init_ff(hdev, loc);
        nvidia_find_tp_len(hdev, loc);
 
-end:
+err_parse:
+       kfree(loc);
        return ret;
 }
 
+static void nvidia_remove(struct hid_device *hdev)
+{
+       struct nvidia_tp_loc *loc = hid_get_drvdata(hdev);
+
+       if (!loc)
+               return;
+
+       device_remove_file(&hdev->dev, &dev_attr_speed);
+       device_remove_file(&hdev->dev, &dev_attr_mode);
+
+       hid_hw_stop(hdev);
+       kfree(loc);
+}
+
 static int nvidia_input_mapped(struct hid_device *hdev, struct hid_input *hi,
                                  struct hid_field *field, struct hid_usage *usage,
                                  unsigned long **bit, int *max)
@@ -588,6 +608,7 @@ static struct hid_driver nvidia_driver = {
        .report_fixup = nv_report_fixup,
        .event = nvidia_event,
        .probe = nvidia_probe,
+       .remove = nvidia_remove,
 };
 module_hid_driver(nvidia_driver);