On Tue, 6 Feb 2007, Oliver Neukum wrote:

> Hi,
> 
> this fixes the issue with output in the hid driver. I can now get keyboards
> to sleep. It is still not perfect, but an important step. Comments?
> 
>       Regards
>               Oliver
> 
> PS: against vanilla 2.6.20

I'd really prefer to see something like the patch below added instead of 
your idle timer.  (Note: not even compile-tested!)

With this infrastructure in place, all you have to do is

        set_bit(USB_DF_DEVICE_BUSY, &hid_to_usb_dev(hid)->dflags);

whenever an event occurs.  No messing around with extra timers.

Alan Stern



Index: usb-2.6/drivers/usb/core/usb.c
===================================================================
--- usb-2.6.orig/drivers/usb/core/usb.c
+++ usb-2.6/drivers/usb/core/usb.c
@@ -209,8 +209,13 @@ static void usb_autosuspend_work(struct 
                container_of(work, struct usb_device, autosuspend.work);
 
        usb_pm_lock(udev);
-       udev->auto_pm = 1;
-       usb_suspend_both(udev, PMSG_SUSPEND);
+       if (test_and_clear_bit(USB_DF_DEVICE_BUSY, &udev->dflags))
+               queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
+                               USB_AUTOSUSPEND_DELAY);
+       else {
+               udev->auto_pm = 1;
+               usb_suspend_both(udev, PMSG_SUSPEND);
+       }
        usb_pm_unlock(udev);
 }
 
Index: usb-2.6/include/linux/usb.h
===================================================================
--- usb-2.6.orig/include/linux/usb.h
+++ usb-2.6/include/linux/usb.h
@@ -389,6 +389,9 @@ struct usb_device {
 
        int pm_usage_cnt;               /* usage counter for autosuspend */
        u32 quirks;                     /* quirks of the whole device */
+       unsigned long dflags;           /* device-wide atomic bitflags */
+#define USB_DF_DEVICE_BUSY     0
+
 #ifdef CONFIG_PM
        struct delayed_work autosuspend; /* for delayed autosuspends */
        struct mutex pm_mutex;          /* protects PM operations */


-------------------------------------------------------------------------
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

Reply via email to