aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/usbhid/hid-core.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 0a1f2b52a12f..a34e0f098f63 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -512,7 +512,16 @@ static int hid_get_class_descriptor(struct usb_device *dev, int ifnum,
512 512
513int usbhid_open(struct hid_device *hid) 513int usbhid_open(struct hid_device *hid)
514{ 514{
515 ++hid->open; 515 struct usbhid_device *usbhid = hid->driver_data;
516 int res;
517
518 if (!hid->open++) {
519 res = usb_autopm_get_interface(usbhid->intf);
520 if (res < 0) {
521 hid->open--;
522 return -EIO;
523 }
524 }
516 if (hid_start_in(hid)) 525 if (hid_start_in(hid))
517 hid_io_error(hid); 526 hid_io_error(hid);
518 return 0; 527 return 0;
@@ -522,8 +531,10 @@ void usbhid_close(struct hid_device *hid)
522{ 531{
523 struct usbhid_device *usbhid = hid->driver_data; 532 struct usbhid_device *usbhid = hid->driver_data;
524 533
525 if (!--hid->open) 534 if (!--hid->open) {
526 usb_kill_urb(usbhid->urbin); 535 usb_kill_urb(usbhid->urbin);
536 usb_autopm_put_interface(usbhid->intf);
537 }
527} 538}
528 539
529/* 540/*
@@ -1048,6 +1059,7 @@ static struct usb_driver hid_driver = {
1048 .pre_reset = hid_pre_reset, 1059 .pre_reset = hid_pre_reset,
1049 .post_reset = hid_post_reset, 1060 .post_reset = hid_post_reset,
1050 .id_table = hid_usb_ids, 1061 .id_table = hid_usb_ids,
1062 .supports_autosuspend = 1,
1051}; 1063};
1052 1064
1053static int __init hid_init(void) 1065static int __init hid_init(void)