]> git.karo-electronics.de Git - karo-tx-linux.git/commit
[media] poll: add poll_requested_events() function
authorHans Verkuil <hverkuil@xs4all.nl>
Thu, 29 Sep 2011 07:30:21 +0000 (04:30 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sat, 26 Nov 2011 15:38:45 +0000 (13:38 -0200)
commitb8f84eccbc267884b4368c6bf0e4bf69d0933458
tree64961c84fe7d6338deb84c89f2cf26b6627ee6da
parent87d466e503ab1e071eac4bd89c46eb3cb53246a1
[media] poll: add poll_requested_events() function

In some cases the poll() implementation in a driver has to do different
things depending on the events the caller wants to poll for. An example is
when a driver needs to start a DMA engine if the caller polls for POLLIN,
but doesn't want to do that if POLLIN is not requested but instead only
POLLOUT or POLLPRI is requested. This is something that can happen in the
video4linux subsystem.

Unfortunately, the current epoll/poll/select implementation doesn't provide
that information reliably. The poll_table_struct does have it: it has a key
field with the event mask. But once a poll() call matches one or more bits
of that mask any following poll() calls are passed a NULL poll_table_struct
pointer.

The solution is to set the qproc field to NULL in poll_table_struct once
poll() matches the events, not the poll_table_struct pointer itself. That
way drivers can obtain the mask through a new poll_requested_events inline.

The poll_table_struct can still be NULL since some kernel code calls it
internally (netfs_state_poll() in ./drivers/staging/pohmelfs/netfs.h). In
that case poll_requested_events() returns ~0 (i.e. all events).

Since eventpoll always leaves the key field at ~0 instead of using the
requested events mask, that source was changed as well to properly fill in
the key field.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Jonathan Corbet <corbet@lwn.net>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Davide Libenzi <davidel@xmailserver.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
fs/eventpoll.c
fs/select.c
include/linux/poll.h