Hi, this patch makes hid devices do simple open/close powersave. This is helpful only in a minority of cases, but it works. Powersave with timeouts will need this as a foundation. Alan, I've made use of your suggestion and put the macros into usb.h so they can be commonly used.
Regards Oliver Signed-off-by: Oliver Neukum <[EMAIL PROTECTED]> diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 0549ec9..7f840d2 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -1402,7 +1402,10 @@ static int hid_get_class_descriptor(stru int hid_open(struct hid_device *hid) { - ++hid->open; + if (!hid->open++) { + usb_autopm_disable(hid->intf); + } + if (hid_start_in(hid)) hid_io_error(hid); return 0; @@ -1410,8 +1413,10 @@ int hid_open(struct hid_device *hid) void hid_close(struct hid_device *hid) { - if (!--hid->open) + if (!--hid->open) { usb_kill_urb(hid->urbin); + usb_autopm_enable(hid->intf); + } } #define USB_VENDOR_ID_PANJIT 0x134c @@ -2221,6 +2226,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) diff --git a/include/linux/usb.h b/include/linux/usb.h index 6b902a3..9871651 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -744,6 +744,18 @@ extern void usb_deregister_dev(struct us extern int usb_disabled(void); +/* + * autopm helpers + */ + +#define usb_autopm_enable(intf) do { \ + (intf)->pm_usage_cnt = 0; \ + usb_autopm_set_interface(intf); } while (0) + +#define usb_autopm_disable(intf) do { \ + (intf)->pm_usage_cnt = 1; \ + usb_autopm_set_interface(intf); } while (0) + /* ----------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel