new version of usbhid autosuspend patch
Hi,
this version solves the "keyboard goes to sleep while keys are pressed" problem. Any testers? Comments?
Regards
Oliver
----
drivers/hid/hid-core.c +16 -0
@@ -990,5 +990,21 @@ int hid_input_report(struct hid_device * }EXPORT_SYMBOL_GPL (hid_input_report); +int hid_check_keys_pressed (struct hid_device *hid) +{ +struct hid_input *hidinput, *next; +int i; + +list_for_each_entry_safe (hidinput, next, &hid->inputs, list) { +for (i =0 ; i <NBITS (KEY_MAX ); i++) +if (hidinput->input->key[i]) +return 1 ; + } + +return 0 ; +} + +EXPORT_SYMBOL_GPL (hid_check_keys_pressed); +MODULE_LICENSE (DRIVER_LICENSE );
drivers/hid/usbhid/hid-core.c +309 -72
617 lines not on this page · raw message
drivers/hid/usbhid/hiddev.c +12 -4
@@ -248,10 +248,12 @@ static int hiddev_release(struct inode *spin_unlock_irqrestore (&list->hiddev->list_lock, flags);if (!--list->hiddev->open) { -if (list->hiddev->exist) +if (list->hiddev->exist) {usbhid_close (list->hiddev->hid); -else +usbhid_put_power (list->hiddev->hid); + }else {kfree (list->hiddev); + } }kfree (list);
@@ -266,6 +268,7 @@ static int hiddev_open(struct inode *ino {struct hiddev_list *list;unsigned long flags; +int res;int i =iminor (inode) -HIDDEV_MINOR_BASE ;
@@ -284,8 +287,13 @@ static int hiddev_open(struct inode *ino file->private_data = list;if (!list->hiddev->open++) -if (list->hiddev->exist) -usbhid_open (hiddev_table[i]->hid); +if (list->hiddev->exist) { +struct hid_device *hid = hiddev_table[i]->hid; + res =usbhid_get_power (hid); +if (res <0 ) +return -EIO ; +usbhid_open (hid); + }return 0 ;
drivers/hid/usbhid/usbhid.h +66 -34
113 lines not on this page · raw message
include/linux/hid.h +3 -0
@@ -410,6 +410,8 @@ struct hid_control_fifo {#define HID_RESET_PENDING 4#define HID_SUSPENDED 5#define HID_CLEAR_HALT 6 +#define HID_REPORTED_IDLE 7 +#define HID_KEYS_PRESSED 8struct hid_input {struct list_head list;
@@ -514,6 +516,7 @@ void hid_input_field(struct hid_device *void hid_output_report (struct hid_report *report,__u8 *data);void hid_free_device (struct hid_device *device);struct hid_device *hid_parse_report (__u8 *start,unsigned size); +int hid_check_keys_pressed (struct hid_device *hid);/* HID quirks API */ u32 usbhid_lookup_quirk (const u16 idVendor,const u16 idProduct);
Hi Oliver,
drivers/hid/hid-core.c int hid_input_report(struct hid_device * · line 1002
Quoted 10 lines · Oliver Neukum
drivers/hid/hid-core.c +10
-0+int hid_check_keys_pressed (struct hid_device *hid) +{ +struct hid_input *hidinput, *next; +int i; + +list_for_each_entry_safe (hidinput, next, &hid->inputs, list) { +for (i =0 ; i <NBITS (KEY_MAX ); i++) +if (hidinput->input->key[i]) +return 1 ; + }
Why are you using the list_for_each_entry_safe? You do not alter the list in your loop.
Signature · 1 line
Dmitry
Am Donnerstag 27 September 2007 schrieb Dmitry Torokhov:
Quoted 16 lines
Hi Oliver,
drivers/hid/hid-core.c int hid_input_report(struct hid_device * · line 1002
Quoted 10 lines · Oliver Neukum
drivers/hid/hid-core.c +10
-0+int hid_check_keys_pressed (struct hid_device *hid) +{ +struct hid_input *hidinput, *next; +int i; + +list_for_each_entry_safe (hidinput, next, &hid->inputs, list) { +for (i =0 ; i <NBITS (KEY_MAX ); i++) +if (hidinput->input->key[i]) +return 1 ; + }Why are you using the
list_for_each_entry_safe? You do not alter the list in your loop.
Relict from an older version. I am preparing a new patch.
Thanks
Oliver