Commit a0f8dcfc authored by Christoph Hellwig's avatar Christoph Hellwig

fs: cleanup do_pollfd

Use straightline code with failure handling gotos instead of a lot
of nested conditionals.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 8f546ae1
...@@ -812,34 +812,32 @@ static inline __poll_t do_pollfd(struct pollfd *pollfd, poll_table *pwait, ...@@ -812,34 +812,32 @@ static inline __poll_t do_pollfd(struct pollfd *pollfd, poll_table *pwait,
bool *can_busy_poll, bool *can_busy_poll,
__poll_t busy_flag) __poll_t busy_flag)
{ {
__poll_t mask; int fd = pollfd->fd;
int fd; __poll_t mask = 0, filter;
struct fd f;
mask = 0;
fd = pollfd->fd; if (fd < 0)
if (fd >= 0) { goto out;
struct fd f = fdget(fd); mask = EPOLLNVAL;
mask = EPOLLNVAL; f = fdget(fd);
if (f.file) { if (!f.file)
/* userland u16 ->events contains POLL... bitmap */ goto out;
__poll_t filter = demangle_poll(pollfd->events) |
EPOLLERR | EPOLLHUP; /* userland u16 ->events contains POLL... bitmap */
mask = DEFAULT_POLLMASK; filter = demangle_poll(pollfd->events) | EPOLLERR | EPOLLHUP;
if (f.file->f_op->poll) { mask = DEFAULT_POLLMASK;
pwait->_key = filter; if (f.file->f_op->poll) {
pwait->_key |= busy_flag; pwait->_key = filter | busy_flag;
mask = f.file->f_op->poll(f.file, pwait); mask = f.file->f_op->poll(f.file, pwait);
if (mask & busy_flag) if (mask & busy_flag)
*can_busy_poll = true; *can_busy_poll = true;
}
/* Mask out unneeded events. */
mask &= filter;
fdput(f);
}
} }
mask &= filter; /* Mask out unneeded events. */
fdput(f);
out:
/* ... and so does ->revents */ /* ... and so does ->revents */
pollfd->revents = mangle_poll(mask); pollfd->revents = mangle_poll(mask);
return mask; return mask;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment