On Tue, 2 Jul 2019, Oliver Neukum wrote: > Am Montag, den 01.07.2019, 10:17 -0400 schrieb Alan Stern: > > On Mon, 1 Jul 2019, Oliver Neukum wrote: > > > > > Am Donnerstag, den 27.06.2019, 09:52 -0400 schrieb Alan Stern: > > > > > > > > > > > Or maybe the WAIT_FOR_RESUME ioctl returns because there was a remote > > > > wakeup. In this case also you would call FORBID_SUSPEND. > > > > > > > > In fact, you should call FORBID_SUSPEND _whenever_ WAIT_FOR_RESUME > > > > > > Well, this kind of indicates that the original syscall should bump > > > the counter. > > > > Perhaps it does, but... > > > > > > returns, unless your program has decided not to use the device any more > > > > (in which case you don't care whether the device is suspended or > > > > resumed). > > > > > > Then you should close the device. > > > > Exactly. Suppose WAIT_FOR_RESUME is interrupted and then the program > > closes the device. There's no need to force the device back to full > > power in this situation. > > But that is the error case. You return an error code. The point of that > is to report that a syscall did not have all requested effects. Okay, I can change the patch to work as you suggest. The WAIT_FOR_RESUME ioctl will do the equivalent of FORBID_SUSPEND whenever it returns with no error. Alan Stern