aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hidraw.c
diff options
context:
space:
mode:
authorOliver Neukum <oliver@neukum.org>2008-12-17 09:38:03 -0500
committerJiri Kosina <jkosina@suse.cz>2009-03-25 12:57:57 -0400
commit0361a28d3f9a4315a100c7b37ba0b55cfe15fe07 (patch)
tree2aa33c5325118e68ce8691a009c5fb30ffdea68c /drivers/hid/hidraw.c
parent8e0ee43bc2c3e19db56a4adaa9a9b04ce885cd84 (diff)
HID: autosuspend support for USB HID
This uses the USB busy mechanism for aggessive autosuspend of USB HID devices. It autosuspends all opened devices supporting remote wakeup after a timeout unless - output is being done to the device - a key is being held down (remote wakeup isn't triggered upon key release) - LED(s) are lit - hiddev is opened As in the current driver closed devices will be autosuspended even if they don't support remote wakeup. The patch is quite large because output to devices is done in hard interrupt context meaning a lot a queuing and locking had to be touched. The LED stuff has been solved by means of a simple counter. Additions to the generic HID code could be avoided. In addition it now covers hidraw. It contains an embryonic version of an API to let the generic HID code tell the lower levels which capabilities with respect to power management are needed. Signed-off-by: Oliver Neukum <oneukum@suse.de> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hidraw.c')
-rw-r--r--drivers/hid/hidraw.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 02b19db5442e..e263d4731179 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -181,9 +181,17 @@ static int hidraw_open(struct inode *inode, struct file *file)
181 181
182 dev = hidraw_table[minor]; 182 dev = hidraw_table[minor];
183 if (!dev->open++) { 183 if (!dev->open++) {
184 if (dev->hid->ll_driver->power) {
185 err = dev->hid->ll_driver->power(dev->hid, PM_HINT_FULLON);
186 if (err < 0)
187 goto out_unlock;
188 }
184 err = dev->hid->ll_driver->open(dev->hid); 189 err = dev->hid->ll_driver->open(dev->hid);
185 if (err < 0) 190 if (err < 0) {
191 if (dev->hid->ll_driver->power)
192 dev->hid->ll_driver->power(dev->hid, PM_HINT_NORMAL);
186 dev->open--; 193 dev->open--;
194 }
187 } 195 }
188 196
189out_unlock: 197out_unlock:
@@ -209,10 +217,13 @@ static int hidraw_release(struct inode * inode, struct file * file)
209 list_del(&list->node); 217 list_del(&list->node);
210 dev = hidraw_table[minor]; 218 dev = hidraw_table[minor];
211 if (!--dev->open) { 219 if (!--dev->open) {
212 if (list->hidraw->exist) 220 if (list->hidraw->exist) {
221 if (dev->hid->ll_driver->power)
222 dev->hid->ll_driver->power(dev->hid, PM_HINT_NORMAL);
213 dev->hid->ll_driver->close(dev->hid); 223 dev->hid->ll_driver->close(dev->hid);
214 else 224 } else {
215 kfree(list->hidraw); 225 kfree(list->hidraw);
226 }
216 } 227 }
217 228
218 kfree(list); 229 kfree(list);