Am Mittwoch, 31. Januar 2007 20:25 schrieb Alan Stern: > > How do I find out whether the device is idle? > > The mouse is not idle if it has been moved (or buttons clicked) > > To find out whether it has been moved the device must not be suspended. > > At which point in time then should I check? Are you saying that the > > timer should be started and suspend() should fail if the devices hasn't > > been idle? > > Logically speaking, the computer doesn't and can't know if the device is > currently idle. After all, it takes several milliseconds for the HID > reports indicating any activity to be transferred from the device to the > computer, so the computer's knowledge is always at least a little bit out > of date.
Yes, this race condition is unavoidable. > So you shouldn't base any decisions on whether the device is currently > idle. Instead, you have to check whether the device has been idle for a > sufficiently long time. That's what the timer is for: You restart the Yes, that's the way I currently do it. > timer whenever there is any activity, and when the timer expires you know > the device has been idle long enough that you should suspend it. That's > exactly how the autosuspend infrastructure works. This would call mod_timer() for every completed in-URB. Are you sure this is better than an approach maintaining a periodical timer and check for IO in the meantime? Regards Oliver ------------------------------------------------------------------------- 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