Re: [PATCH 4/9] Input: Block suspend while event queue is not empty.

Arve Hjønnevåg
2009-05-07T01:57:59Z

On Tue, May 5, 2009 at 1:02 PM, Pavel Machek <pavel@ucw.cz> wrote:
>
>> Add an ioctl, EVIOCSSUSPENDBLOCK, to enable a suspend_blocker that will block
>> suspend while the event queue is not empty. This allows userspace code to
>> process input events while the device appears to be asleep.
>>
>> Signed-off-by: Arve Hj??nnev??g <arve@android.com>
>
> Looks ok to  me, but I guess you should cc input maintainers.

OK.

>
>> @@ -582,6 +591,19 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
>>               else
>>                       return evdev_ungrab(evdev, client);
>>
>> +     case EVIOCGSUSPENDBLOCK:
>> +             return put_user(client->use_suspend_blocker, ip);
>> +
>> +     case EVIOCSSUSPENDBLOCK:
>> +             spin_lock_irq(&client->buffer_lock);
>> +             if (!client->use_suspend_blocker && p)
>> +                     suspend_blocker_init(&client->suspend_blocker, "evdev");
>> +             else if (client->use_suspend_blocker && !p)
>> +                     suspend_blocker_destroy(&client->suspend_blocker);
>> +             client->use_suspend_blocker = !!p;
>> +             spin_unlock_irq(&client->buffer_lock);
>> +             return 0;
>
> This returns 0 even when you destroy already destroyed blocker
> (etc). Is that ok?

Yes. If events did not block suspend before the call, they still do
not block suspend after the call, so the requested state was reached.

--
Arve Hjønnevåg