summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinayak Pane <vpane@nvidia.com>2014-05-13 17:23:22 -0700
committerPeter Kim <pekim@nvidia.com>2014-06-12 21:56:42 -0700
commit7ccccf232f78411846dfd617121f12d212c57c81 (patch)
tree34cdaa5ce7932a9e7ff9c4a24ce1506a32ff3c93
parentfd35fa2f2145ddc0a0cde5bc09c7483841f68613 (diff)
HID: add remove function in nv hidraw
Adding remove function to remove sysfs attribute nodes when blake is disconnected. Bug 200003632 Bug 1466757 Change-Id: I5bf571176d2653b9f74f548775da904ef93007c8 Signed-off-by: Vinayak Pane <vpane@nvidia.com> Reviewed-on: http://git-master/r/410596 (cherry picked from commit 9904c21f42b14f3675c27ef2646eae669440bd07) Signed-off-by: Kenneth Kwak <kkwak@nvidia.com> Reviewed-on: http://git-master/r/411356 Signed-off-by: Kenneth Kwak <kkwak@nvidia.com> Reviewed-on: http://git-master/r/417526 Reviewed-by: Peter Kim <pekim@nvidia.com> Tested-by: Peter Kim <pekim@nvidia.com>
-rw-r--r--drivers/hid/hid-nvidia-blake.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/drivers/hid/hid-nvidia-blake.c b/drivers/hid/hid-nvidia-blake.c
index 6d64af86fda4..2d75fa21e2ec 100644
--- a/drivers/hid/hid-nvidia-blake.c
+++ b/drivers/hid/hid-nvidia-blake.c
@@ -355,12 +355,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)
@@ -368,11 +372,27 @@ 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;
-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)
@@ -422,6 +442,7 @@ static struct hid_driver nvidia_driver = {
.raw_event = nvidia_raw_event,
.event = nvidia_event,
.probe = nvidia_probe,
+ .remove = nvidia_remove,
};
static int __init hid_nvidia_blake_init(void)