/* Fish for pollable events on the pollfd->fd file descriptor. We're only interested in events matching the pollfd->events mask, and the result matching that mask is both recorded in pollfd->revents and returned. The pwait poll_table will be used by the fd-provided poll handler for waiting, if non-NULL.  */
static unsigned int do_pollfd(struct pollfd *pollfd, poll_table *pwait)
/* Fish for pollable events on the pollfd->fd file descriptor. We're only interested in events matching the pollfd->events mask, and the result matching that mask is both recorded in pollfd->revents and returned. The pwait poll_table will be used by the fd-provided poll handler for waiting, if non-NULL.  */
static unsigned int do_pollfd(struct pollfd *pollfd, poll_table *pwait)
{
	unsigned int mask;
	int fd;
	mask = 0;
	fd = pollfd->fd;
	if (fd >= 0) {
		int fput_needed;
		struct file * file;
		file = fget_light(fd, &fput_needed);
		mask = POLLNVAL;
		if (file != NULL) {
			mask = DEFAULT_POLLMASK;
			if (file->f_op && file->f_op->poll) {
				if (pwait)
					pwait->key = pollfd->events |
							POLLERR | POLLHUP;
				mask = file->f_op->poll(file, pwait);
			}
			mask &= pollfd->events | POLLERR | POLLHUP;
			fput_light(file, fput_needed);
		}
	}
	pollfd->revents = mask;
	return mask;
}