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

Pavel Machek
2009-05-05T20:02:30Z

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

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

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html