aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-a4tech.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/hid-a4tech.c')
-rw-r--r--drivers/hid/hid-a4tech.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/drivers/hid/hid-a4tech.c b/drivers/hid/hid-a4tech.c
index 7c5507e94820..9428ea7cdf8a 100644
--- a/drivers/hid/hid-a4tech.c
+++ b/drivers/hid/hid-a4tech.c
@@ -90,11 +90,10 @@ static int a4_probe(struct hid_device *hdev, const struct hid_device_id *id)
90 struct a4tech_sc *a4; 90 struct a4tech_sc *a4;
91 int ret; 91 int ret;
92 92
93 a4 = kzalloc(sizeof(*a4), GFP_KERNEL); 93 a4 = devm_kzalloc(&hdev->dev, sizeof(*a4), GFP_KERNEL);
94 if (a4 == NULL) { 94 if (a4 == NULL) {
95 hid_err(hdev, "can't alloc device descriptor\n"); 95 hid_err(hdev, "can't alloc device descriptor\n");
96 ret = -ENOMEM; 96 return -ENOMEM;
97 goto err_free;
98 } 97 }
99 98
100 a4->quirks = id->driver_data; 99 a4->quirks = id->driver_data;
@@ -104,27 +103,16 @@ static int a4_probe(struct hid_device *hdev, const struct hid_device_id *id)
104 ret = hid_parse(hdev); 103 ret = hid_parse(hdev);
105 if (ret) { 104 if (ret) {
106 hid_err(hdev, "parse failed\n"); 105 hid_err(hdev, "parse failed\n");
107 goto err_free; 106 return ret;
108 } 107 }
109 108
110 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 109 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
111 if (ret) { 110 if (ret) {
112 hid_err(hdev, "hw start failed\n"); 111 hid_err(hdev, "hw start failed\n");
113 goto err_free; 112 return ret;
114 } 113 }
115 114
116 return 0; 115 return 0;
117err_free:
118 kfree(a4);
119 return ret;
120}
121
122static void a4_remove(struct hid_device *hdev)
123{
124 struct a4tech_sc *a4 = hid_get_drvdata(hdev);
125
126 hid_hw_stop(hdev);
127 kfree(a4);
128} 116}
129 117
130static const struct hid_device_id a4_devices[] = { 118static const struct hid_device_id a4_devices[] = {
@@ -144,7 +132,6 @@ static struct hid_driver a4_driver = {
144 .input_mapped = a4_input_mapped, 132 .input_mapped = a4_input_mapped,
145 .event = a4_event, 133 .event = a4_event,
146 .probe = a4_probe, 134 .probe = a4_probe,
147 .remove = a4_remove,
148}; 135};
149module_hid_driver(a4_driver); 136module_hid_driver(a4_driver);
150 137