summaryrefslogtreecommitdiff
path: root/fs/select.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-07-16 23:51:03 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-11-28 11:07:13 -0500
commitfb3679372bd7967f39ea48e701fcd1e8f55e75cd (patch)
tree371c4e45a7ef3cd7e280cb51712d9cda82b49a9d /fs/select.c
parent7594bf37ae9ffc434da425120c576909eb33b0bc (diff)
downloadlwn-fb3679372bd7967f39ea48e701fcd1e8f55e75cd.tar.gz
lwn-fb3679372bd7967f39ea48e701fcd1e8f55e75cd.zip
annotate poll(2) guts
struct pollfd contains two 16bit fields (mask and result) that encode the POLL... bitmaps. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/select.c')
-rw-r--r--fs/select.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/select.c b/fs/select.c
index 8d6d47912134..b2deeb215dbe 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -803,9 +803,9 @@ struct poll_list {
* pwait poll_table will be used by the fd-provided poll handler for waiting,
* if pwait->_qproc is non-NULL.
*/
-static inline unsigned int do_pollfd(struct pollfd *pollfd, poll_table *pwait,
+static inline __poll_t do_pollfd(struct pollfd *pollfd, poll_table *pwait,
bool *can_busy_poll,
- unsigned int busy_flag)
+ __poll_t busy_flag)
{
__poll_t mask;
int fd;
@@ -816,20 +816,24 @@ static inline unsigned int do_pollfd(struct pollfd *pollfd, poll_table *pwait,
struct fd f = fdget(fd);
mask = POLLNVAL;
if (f.file) {
+ /* userland u16 ->events contains POLL... bitmap */
+ __poll_t filter = (__force __poll_t)pollfd->events |
+ POLLERR | POLLHUP;
mask = DEFAULT_POLLMASK;
if (f.file->f_op->poll) {
- pwait->_key = pollfd->events|POLLERR|POLLHUP;
+ pwait->_key = filter;
pwait->_key |= busy_flag;
mask = f.file->f_op->poll(f.file, pwait);
if (mask & busy_flag)
*can_busy_poll = true;
}
/* Mask out unneeded events. */
- mask &= pollfd->events | POLLERR | POLLHUP;
+ mask &= filter;
fdput(f);
}
}
- pollfd->revents = mask;
+ /* ... and so does ->revents */
+ pollfd->revents = (__force u16)mask;
return mask;
}
@@ -841,7 +845,7 @@ static int do_poll(struct poll_list *list, struct poll_wqueues *wait,
ktime_t expire, *to = NULL;
int timed_out = 0, count = 0;
u64 slack = 0;
- unsigned int busy_flag = net_busy_loop_on() ? POLL_BUSY_LOOP : 0;
+ __poll_t busy_flag = net_busy_loop_on() ? POLL_BUSY_LOOP : 0;
unsigned long busy_start = 0;
/* Optimise the no-wait case */