diff options
author | Oliver Neukum | 2007-07-11 14:48:58 +0200 |
---|---|---|
committer | Jiri Kosina | 2007-10-14 13:40:00 +0200 |
commit | 933e3187d0042d9381d932757dc1f931d984e56d (patch) | |
tree | 69dc3f6505456672f577e9bfa01f2502c3964306 /drivers | |
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')
-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, int usbhid_open(struct hid_device *hid) { - ++hid->open; + struct usbhid_device *usbhid = hid->driver_data; + int res; + + if (!hid->open++) { + res = usb_autopm_get_interface(usbhid->intf); + if (res < 0) { + hid->open--; + return -EIO; + } + } if (hid_start_in(hid)) hid_io_error(hid); return 0; @@ -522,8 +531,10 @@ void usbhid_close(struct hid_device *hid) { struct usbhid_device *usbhid = hid->driver_data; - if (!--hid->open) + if (!--hid->open) { usb_kill_urb(usbhid->urbin); + usb_autopm_put_interface(usbhid->intf); + } } /* @@ -1048,6 +1059,7 @@ static struct usb_driver hid_driver = { .pre_reset = hid_pre_reset, .post_reset = hid_post_reset, .id_table = hid_usb_ids, + .supports_autosuspend = 1, }; static int __init hid_init(void) |