diff options
author | Oliver Neukum <oliver@neukum.org> | 2007-07-11 08:48:58 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2007-10-14 07:40:00 -0400 |
commit | 933e3187d0042d9381d932757dc1f931d984e56d (patch) | |
tree | 69dc3f6505456672f577e9bfa01f2502c3964306 /drivers/hid | |
parent | 1fe8736da695c2b14961438c73d5600538bd92d9 (diff) |
HID: minimal autosuspend support for USB HID devices
Autosuspend for USB HID devices remains problematic as far as mice
and keyboards are concerned. While I am working on a grand solution,
here's a minimalist patch that works for those devices not continously
in use.
Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/usbhid/hid-core.c | 16 |
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 | ||
513 | int usbhid_open(struct hid_device *hid) | 513 | int 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 | ||
1053 | static int __init hid_init(void) | 1065 | static int __init hid_init(void) |