Skip to content

Commit d36b7d4

Browse files
dtorJiri Kosina
authored andcommitted
HID: hiddev: use hid_hw_open/close instead of usbhid_open/close
Instead of calling into usbhid code directly, let's use the standard accessors for the transport HID drivers, and stop clobbering their errors with -EIO. This also allows us make usbhid_open and close static. Signed-off-by: Dmitry Torokhov <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 6df62e7 commit d36b7d4

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

drivers/hid/usbhid/hid-core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ static int hid_get_class_descriptor(struct usb_device *dev, int ifnum,
677677
return result;
678678
}
679679

680-
int usbhid_open(struct hid_device *hid)
680+
static int usbhid_open(struct hid_device *hid)
681681
{
682682
struct usbhid_device *usbhid = hid->driver_data;
683683
int res = 0;
@@ -722,7 +722,7 @@ int usbhid_open(struct hid_device *hid)
722722
return res;
723723
}
724724

725-
void usbhid_close(struct hid_device *hid)
725+
static void usbhid_close(struct hid_device *hid)
726726
{
727727
struct usbhid_device *usbhid = hid->driver_data;
728728

drivers/hid/usbhid/hiddev.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ static int hiddev_release(struct inode * inode, struct file * file)
237237
mutex_lock(&list->hiddev->existancelock);
238238
if (!--list->hiddev->open) {
239239
if (list->hiddev->exist) {
240-
usbhid_close(list->hiddev->hid);
240+
hid_hw_close(list->hiddev->hid);
241241
usbhid_put_power(list->hiddev->hid);
242242
} else {
243243
mutex_unlock(&list->hiddev->existancelock);
@@ -282,11 +282,9 @@ static int hiddev_open(struct inode *inode, struct file *file)
282282
*/
283283
if (list->hiddev->exist) {
284284
if (!list->hiddev->open++) {
285-
res = usbhid_open(hiddev->hid);
286-
if (res < 0) {
287-
res = -EIO;
285+
res = hid_hw_open(hiddev->hid);
286+
if (res < 0)
288287
goto bail;
289-
}
290288
}
291289
} else {
292290
res = -ENODEV;
@@ -306,10 +304,14 @@ static int hiddev_open(struct inode *inode, struct file *file)
306304
res = -EIO;
307305
goto bail_unlock;
308306
}
309-
usbhid_open(hid);
307+
res = hid_hw_open(hid);
308+
if (res < 0)
309+
goto bail_put_power;
310310
}
311311
mutex_unlock(&hiddev->existancelock);
312312
return 0;
313+
bail_put_power:
314+
usbhid_put_power(hid);
313315
bail_unlock:
314316
mutex_unlock(&hiddev->existancelock);
315317
bail:
@@ -935,7 +937,7 @@ void hiddev_disconnect(struct hid_device *hid)
935937

936938
if (hiddev->open) {
937939
mutex_unlock(&hiddev->existancelock);
938-
usbhid_close(hiddev->hid);
940+
hid_hw_close(hiddev->hid);
939941
wake_up_interruptible(&hiddev->wait);
940942
} else {
941943
mutex_unlock(&hiddev->existancelock);

drivers/hid/usbhid/usbhid.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
#include <linux/input.h>
3535

3636
/* API provided by hid-core.c for USB HID drivers */
37-
void usbhid_close(struct hid_device *hid);
38-
int usbhid_open(struct hid_device *hid);
3937
void usbhid_init_reports(struct hid_device *hid);
4038
int usbhid_get_power(struct hid_device *hid);
4139
void usbhid_put_power(struct hid_device *hid);

0 commit comments

Comments
 (0)