]> git.karo-electronics.de Git - karo-tx-linux.git/commit
poll: add poll_requested_events() function
authorHans Verkuil <hverkuil@xs4all.nl>
Thu, 29 Sep 2011 07:30:21 +0000 (09:30 +0200)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 8 Nov 2011 19:26:43 +0000 (17:26 -0200)
commitd32afb1aea2c626b28ce950281e71a0fe7471686
treee495989ea3f149950686358d3b31eb5b3315e89b
parent1ea6b8f48918282bdca0b32a34095504ee65bab5
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