From e410c60360e210671ad604d46b57e1f6f90f9078 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 3 Jul 2017 01:00:54 -0400 Subject: orangefs: fix a braino in ->poll() It's POLLIN, not POLL_IN... Signed-off-by: Al Viro --- fs/orangefs/devorangefs-req.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs') diff --git a/fs/orangefs/devorangefs-req.c b/fs/orangefs/devorangefs-req.c index ded456f17de6..a324dc584bf7 100644 --- a/fs/orangefs/devorangefs-req.c +++ b/fs/orangefs/devorangefs-req.c @@ -822,7 +822,7 @@ static unsigned int orangefs_devreq_poll(struct file *file, poll_wait(file, &orangefs_request_list_waitq, poll_table); if (!list_empty(&orangefs_request_list)) - poll_revent_mask |= POLL_IN; + poll_revent_mask |= POLLIN; return poll_revent_mask; } -- cgit v1.2.3 From a3f8683bf7d5e6254fe68f5c5d3585e27eea8ed0 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 2 Jul 2017 22:22:01 -0400 Subject: ->poll() methods should return __poll_t The most common place to find POLL... bitmaps: return values of ->poll() and its subsystem counterparts. Signed-off-by: Al Viro --- fs/proc/inode.c | 2 +- include/linux/fs.h | 2 +- include/linux/net.h | 2 +- include/linux/posix-clock.h | 2 +- include/linux/tty_ldisc.h | 2 +- include/media/media-devnode.h | 2 +- include/media/soc_camera.h | 2 +- include/media/v4l2-dev.h | 2 +- include/sound/hwdep.h | 2 +- include/sound/info.h | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) (limited to 'fs') diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 225f541f7078..44e37f38493b 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -238,7 +238,7 @@ static unsigned int proc_reg_poll(struct file *file, struct poll_table_struct *p { struct proc_dir_entry *pde = PDE(file_inode(file)); unsigned int rv = DEFAULT_POLLMASK; - unsigned int (*poll)(struct file *, struct poll_table_struct *); + __poll_t (*poll)(struct file *, struct poll_table_struct *); if (use_pde(pde)) { poll = pde->proc_fops->poll; if (poll) diff --git a/include/linux/fs.h b/include/linux/fs.h index 2995a271ec46..64695eb07992 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1698,7 +1698,7 @@ struct file_operations { ssize_t (*write_iter) (struct kiocb *, struct iov_iter *); int (*iterate) (struct file *, struct dir_context *); int (*iterate_shared) (struct file *, struct dir_context *); - unsigned int (*poll) (struct file *, struct poll_table_struct *); + __poll_t (*poll) (struct file *, struct poll_table_struct *); long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); long (*compat_ioctl) (struct file *, unsigned int, unsigned long); int (*mmap) (struct file *, struct vm_area_struct *); diff --git a/include/linux/net.h b/include/linux/net.h index caeb159abda5..c2d468cb9821 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -147,7 +147,7 @@ struct proto_ops { int (*getname) (struct socket *sock, struct sockaddr *addr, int *sockaddr_len, int peer); - unsigned int (*poll) (struct file *file, struct socket *sock, + __poll_t (*poll) (struct file *file, struct socket *sock, struct poll_table_struct *wait); int (*ioctl) (struct socket *sock, unsigned int cmd, unsigned long arg); diff --git a/include/linux/posix-clock.h b/include/linux/posix-clock.h index 38d8225510f1..3a3bc71017d5 100644 --- a/include/linux/posix-clock.h +++ b/include/linux/posix-clock.h @@ -68,7 +68,7 @@ struct posix_clock_operations { int (*open) (struct posix_clock *pc, fmode_t f_mode); - uint (*poll) (struct posix_clock *pc, + __poll_t (*poll) (struct posix_clock *pc, struct file *file, poll_table *wait); int (*release) (struct posix_clock *pc); diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h index 3bc5144b1c7e..1ef64d4ad887 100644 --- a/include/linux/tty_ldisc.h +++ b/include/linux/tty_ldisc.h @@ -187,7 +187,7 @@ struct tty_ldisc_ops { long (*compat_ioctl)(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); void (*set_termios)(struct tty_struct *tty, struct ktermios *old); - unsigned int (*poll)(struct tty_struct *, struct file *, + __poll_t (*poll)(struct tty_struct *, struct file *, struct poll_table_struct *); int (*hangup)(struct tty_struct *tty); diff --git a/include/media/media-devnode.h b/include/media/media-devnode.h index 511615d3bf6f..dc2f64e1b08f 100644 --- a/include/media/media-devnode.h +++ b/include/media/media-devnode.h @@ -56,7 +56,7 @@ struct media_file_operations { struct module *owner; ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); - unsigned int (*poll) (struct file *, struct poll_table_struct *); + __poll_t (*poll) (struct file *, struct poll_table_struct *); long (*ioctl) (struct file *, unsigned int, unsigned long); long (*compat_ioctl) (struct file *, unsigned int, unsigned long); int (*open) (struct file *); diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index 4d8cb0796bc6..b7e42a1b0910 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -117,7 +117,7 @@ struct soc_camera_host_ops { int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); int (*enum_framesizes)(struct soc_camera_device *, struct v4l2_frmsizeenum *); - unsigned int (*poll)(struct file *, poll_table *); + __poll_t (*poll)(struct file *, poll_table *); }; #define SOCAM_SENSOR_INVERT_PCLK (1 << 0) diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index 28a686eb7d09..fa99f6f66712 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h @@ -152,7 +152,7 @@ struct v4l2_file_operations { struct module *owner; ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); - unsigned int (*poll) (struct file *, struct poll_table_struct *); + __poll_t (*poll) (struct file *, struct poll_table_struct *); long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); #ifdef CONFIG_COMPAT long (*compat_ioctl32) (struct file *, unsigned int, unsigned long); diff --git a/include/sound/hwdep.h b/include/sound/hwdep.h index ab9fcb2f97f0..afeca593188a 100644 --- a/include/sound/hwdep.h +++ b/include/sound/hwdep.h @@ -37,7 +37,7 @@ struct snd_hwdep_ops { long count, loff_t *offset); int (*open)(struct snd_hwdep *hw, struct file * file); int (*release)(struct snd_hwdep *hw, struct file * file); - unsigned int (*poll)(struct snd_hwdep *hw, struct file *file, + __poll_t (*poll)(struct snd_hwdep *hw, struct file *file, poll_table *wait); int (*ioctl)(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg); diff --git a/include/sound/info.h b/include/sound/info.h index 67390ee846aa..becdf66d2825 100644 --- a/include/sound/info.h +++ b/include/sound/info.h @@ -62,7 +62,7 @@ struct snd_info_entry_ops { loff_t (*llseek)(struct snd_info_entry *entry, void *file_private_data, struct file *file, loff_t offset, int orig); - unsigned int (*poll)(struct snd_info_entry *entry, + __poll_t (*poll)(struct snd_info_entry *entry, void *file_private_data, struct file *file, poll_table *wait); int (*ioctl)(struct snd_info_entry *entry, void *file_private_data, -- cgit v1.2.3 From e6c8adca20ba459dd88057ca74232bf9f1045075 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 3 Jul 2017 22:25:56 -0400 Subject: anntotate the places where ->poll() return values go Signed-off-by: Al Viro --- drivers/media/platform/soc_camera/soc_camera.c | 2 +- drivers/media/v4l2-core/v4l2-dev.c | 2 +- drivers/staging/comedi/drivers/serial2002.c | 2 +- drivers/tty/tty_io.c | 2 +- drivers/vfio/virqfd.c | 2 +- drivers/vhost/vhost.c | 4 ++-- fs/debugfs/file.c | 2 +- fs/proc/inode.c | 2 +- fs/select.c | 5 +++-- net/smc/af_smc.c | 2 +- net/socket.c | 2 +- virt/kvm/eventfd.c | 2 +- 12 files changed, 15 insertions(+), 14 deletions(-) (limited to 'fs') diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index 916ff68b73d4..f805f45716a3 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -809,7 +809,7 @@ static unsigned int soc_camera_poll(struct file *file, poll_table *pt) { struct soc_camera_device *icd = file->private_data; struct soc_camera_host *ici = to_soc_camera_host(icd->parent); - unsigned res = POLLERR; + __poll_t res = POLLERR; if (icd->streamer != file) return POLLERR; diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index c647ba648805..ef178edc634b 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -334,7 +334,7 @@ static ssize_t v4l2_write(struct file *filp, const char __user *buf, static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll) { struct video_device *vdev = video_devdata(filp); - unsigned int res = POLLERR | POLLHUP; + __poll_t res = POLLERR | POLLHUP; if (!vdev->fops->poll) return DEFAULT_POLLMASK; diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index cc18e25103ca..a557be8a5076 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -119,7 +119,7 @@ static void serial2002_tty_read_poll_wait(struct file *f, int timeout) poll_initwait(&table); while (1) { long elapsed; - int mask; + __poll_t mask; mask = f->f_op->poll(f, &table.pt); if (mask & (POLLRDNORM | POLLRDBAND | POLLIN | diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index dc60aeea87d8..287f9a4eef6d 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -2059,7 +2059,7 @@ static unsigned int tty_poll(struct file *filp, poll_table *wait) { struct tty_struct *tty = file_tty(filp); struct tty_ldisc *ld; - int ret = 0; + __poll_t ret = 0; if (tty_paranoia_check(tty, file_inode(filp), "tty_poll")) return 0; diff --git a/drivers/vfio/virqfd.c b/drivers/vfio/virqfd.c index 4797217e5e72..d18b10ff119e 100644 --- a/drivers/vfio/virqfd.c +++ b/drivers/vfio/virqfd.c @@ -113,7 +113,7 @@ int vfio_virqfd_enable(void *opaque, struct eventfd_ctx *ctx; struct virqfd *virqfd; int ret = 0; - unsigned int events; + __poll_t events; virqfd = kzalloc(sizeof(*virqfd), GFP_KERNEL); if (!virqfd) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 33ac2b186b85..c18e70bd0466 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -203,7 +203,7 @@ EXPORT_SYMBOL_GPL(vhost_poll_init); * keep a reference to a file until after vhost_poll_stop is called. */ int vhost_poll_start(struct vhost_poll *poll, struct file *file) { - unsigned long mask; + __poll_t mask; int ret = 0; if (poll->wqh) @@ -211,7 +211,7 @@ int vhost_poll_start(struct vhost_poll *poll, struct file *file) mask = file->f_op->poll(file, &poll->table); if (mask) - vhost_poll_wakeup(&poll->wait, 0, 0, (void *)mask); + vhost_poll_wakeup(&poll->wait, 0, 0, (void *)(uintptr_t)mask); if (mask & POLLERR) { if (poll->wqh) remove_wait_queue(poll->wqh, &poll->wait); diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index cd12e6576b48..2571404a072b 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -210,7 +210,7 @@ static unsigned int full_proxy_poll(struct file *filp, struct poll_table_struct *wait) { struct dentry *dentry = F_DENTRY(filp); - unsigned int r = 0; + __poll_t r = 0; const struct file_operations *real_fops; if (debugfs_file_get(dentry)) diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 44e37f38493b..149fd4d75db6 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -237,7 +237,7 @@ static ssize_t proc_reg_write(struct file *file, const char __user *buf, size_t static unsigned int proc_reg_poll(struct file *file, struct poll_table_struct *pts) { struct proc_dir_entry *pde = PDE(file_inode(file)); - unsigned int rv = DEFAULT_POLLMASK; + __poll_t rv = DEFAULT_POLLMASK; __poll_t (*poll)(struct file *, struct poll_table_struct *); if (use_pde(pde)) { poll = pde->proc_fops->poll; diff --git a/fs/select.c b/fs/select.c index 6de493bb42a4..b2bf84be5056 100644 --- a/fs/select.c +++ b/fs/select.c @@ -484,8 +484,9 @@ static int do_select(int n, fd_set_bits *fds, struct timespec64 *end_time) rinp = fds->res_in; routp = fds->res_out; rexp = fds->res_ex; for (i = 0; i < n; ++rinp, ++routp, ++rexp) { - unsigned long in, out, ex, all_bits, bit = 1, mask, j; + unsigned long in, out, ex, all_bits, bit = 1, j; unsigned long res_in = 0, res_out = 0, res_ex = 0; + __poll_t mask; in = *inp++; out = *outp++; ex = *exp++; all_bits = in | out | ex; @@ -806,7 +807,7 @@ static inline unsigned int do_pollfd(struct pollfd *pollfd, poll_table *pwait, bool *can_busy_poll, unsigned int busy_flag) { - unsigned int mask; + __poll_t mask; int fd; mask = 0; diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 6451c5013e06..ae59826230be 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -1130,7 +1130,7 @@ static unsigned int smc_poll(struct file *file, struct socket *sock, poll_table *wait) { struct sock *sk = sock->sk; - unsigned int mask = 0; + __poll_t mask = 0; struct smc_sock *smc; int rc; diff --git a/net/socket.c b/net/socket.c index 42d8e9c9ccd5..dceab22a41fd 100644 --- a/net/socket.c +++ b/net/socket.c @@ -1093,7 +1093,7 @@ EXPORT_SYMBOL(sock_create_lite); /* No kernel lock held - perfect */ static unsigned int sock_poll(struct file *file, poll_table *wait) { - unsigned int busy_flag = 0; + __poll_t busy_flag = 0; struct socket *sock; /* diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index f2ac53ab8243..a1f68ed999d8 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -287,7 +287,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args) struct fd f; struct eventfd_ctx *eventfd = NULL, *resamplefd = NULL; int ret; - unsigned int events; + __poll_t events; int idx; if (!kvm_arch_intc_initialized(kvm)) -- cgit v1.2.3 From 3ad6f93e98d6df25d0667d847d3ab9cbdccb3eae Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 3 Jul 2017 20:14:56 -0400 Subject: annotate poll-related wait keys __poll_t is also used as wait key in some waitqueues. Verify that wait_..._poll() gets __poll_t as key and provide a helper for wakeup functions to get back to that __poll_t value. Signed-off-by: Al Viro --- drivers/vfio/virqfd.c | 2 +- drivers/vhost/vhost.c | 4 ++-- fs/eventpoll.c | 9 +++++---- fs/select.c | 2 +- include/linux/wait.h | 10 ++++++---- mm/memcontrol.c | 2 +- net/core/datagram.c | 4 +--- net/unix/af_unix.c | 2 +- virt/kvm/eventfd.c | 2 +- 9 files changed, 19 insertions(+), 18 deletions(-) (limited to 'fs') diff --git a/drivers/vfio/virqfd.c b/drivers/vfio/virqfd.c index d18b10ff119e..8cc4b48ff127 100644 --- a/drivers/vfio/virqfd.c +++ b/drivers/vfio/virqfd.c @@ -46,7 +46,7 @@ static void virqfd_deactivate(struct virqfd *virqfd) static int virqfd_wakeup(wait_queue_entry_t *wait, unsigned mode, int sync, void *key) { struct virqfd *virqfd = container_of(wait, struct virqfd, wait); - unsigned long flags = (unsigned long)key; + __poll_t flags = key_to_poll(key); if (flags & POLLIN) { /* An event has been signaled, call function */ diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index c18e70bd0466..7aad77be0b46 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -170,7 +170,7 @@ static int vhost_poll_wakeup(wait_queue_entry_t *wait, unsigned mode, int sync, { struct vhost_poll *poll = container_of(wait, struct vhost_poll, wait); - if (!((unsigned long)key & poll->mask)) + if (!(key_to_poll(key) & poll->mask)) return 0; vhost_poll_queue(poll); @@ -211,7 +211,7 @@ int vhost_poll_start(struct vhost_poll *poll, struct file *file) mask = file->f_op->poll(file, &poll->table); if (mask) - vhost_poll_wakeup(&poll->wait, 0, 0, (void *)(uintptr_t)mask); + vhost_poll_wakeup(&poll->wait, 0, 0, poll_to_key(mask)); if (mask & POLLERR) { if (poll->wqh) remove_wait_queue(poll->wqh, &poll->wait); diff --git a/fs/eventpoll.c b/fs/eventpoll.c index afd548ebc328..21e6fee00e8b 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1117,6 +1117,7 @@ static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v unsigned long flags; struct epitem *epi = ep_item_from_wait(wait); struct eventpoll *ep = epi->ep; + __poll_t pollflags = key_to_poll(key); int ewake = 0; spin_lock_irqsave(&ep->lock, flags); @@ -1138,7 +1139,7 @@ static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v * callback. We need to be able to handle both cases here, hence the * test for "key" != NULL before the event match test. */ - if (key && !((unsigned long) key & epi->event.events)) + if (pollflags && !(pollflags & epi->event.events)) goto out_unlock; /* @@ -1175,8 +1176,8 @@ static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v */ if (waitqueue_active(&ep->wq)) { if ((epi->event.events & EPOLLEXCLUSIVE) && - !((unsigned long)key & POLLFREE)) { - switch ((unsigned long)key & EPOLLINOUT_BITS) { + !(pollflags & POLLFREE)) { + switch (pollflags & EPOLLINOUT_BITS) { case POLLIN: if (epi->event.events & POLLIN) ewake = 1; @@ -1205,7 +1206,7 @@ out_unlock: if (!(epi->event.events & EPOLLEXCLUSIVE)) ewake = 1; - if ((unsigned long)key & POLLFREE) { + if (pollflags & POLLFREE) { /* * If we race with ep_remove_wait_queue() it can miss * ->whead = NULL and do another remove_wait_queue() after diff --git a/fs/select.c b/fs/select.c index b2bf84be5056..ffc16fd3673e 100644 --- a/fs/select.c +++ b/fs/select.c @@ -212,7 +212,7 @@ static int pollwake(wait_queue_entry_t *wait, unsigned mode, int sync, void *key struct poll_table_entry *entry; entry = container_of(wait, struct poll_table_entry, wait); - if (key && !((unsigned long)key & entry->key)) + if (key && !(key_to_poll(key) & entry->key)) return 0; return __pollwake(wait, mode, sync, key); } diff --git a/include/linux/wait.h b/include/linux/wait.h index 158715445ffb..55a611486bac 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -206,14 +206,16 @@ void __wake_up_sync(struct wait_queue_head *wq_head, unsigned int mode, int nr); /* * Wakeup macros to be used to report events to the targets. */ +#define poll_to_key(m) ((void *)(__force uintptr_t)(__poll_t)(m)) +#define key_to_poll(m) ((__force __poll_t)(uintptr_t)(void *)(m)) #define wake_up_poll(x, m) \ - __wake_up(x, TASK_NORMAL, 1, (void *) (m)) + __wake_up(x, TASK_NORMAL, 1, poll_to_key(m)) #define wake_up_locked_poll(x, m) \ - __wake_up_locked_key((x), TASK_NORMAL, (void *) (m)) + __wake_up_locked_key((x), TASK_NORMAL, poll_to_key(m)) #define wake_up_interruptible_poll(x, m) \ - __wake_up(x, TASK_INTERRUPTIBLE, 1, (void *) (m)) + __wake_up(x, TASK_INTERRUPTIBLE, 1, poll_to_key(m)) #define wake_up_interruptible_sync_poll(x, m) \ - __wake_up_sync_key((x), TASK_INTERRUPTIBLE, 1, (void *) (m)) + __wake_up_sync_key((x), TASK_INTERRUPTIBLE, 1, poll_to_key(m)) #define ___wait_cond_timeout(condition) \ ({ \ diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 50e6906314f8..006aa27f4fb4 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3777,7 +3777,7 @@ static int memcg_event_wake(wait_queue_entry_t *wait, unsigned mode, struct mem_cgroup_event *event = container_of(wait, struct mem_cgroup_event, wait); struct mem_cgroup *memcg = event->memcg; - unsigned long flags = (unsigned long)key; + __poll_t flags = key_to_poll(key); if (flags & POLLHUP) { /* diff --git a/net/core/datagram.c b/net/core/datagram.c index 522873ed120b..000da13c01f2 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c @@ -72,12 +72,10 @@ static inline int connection_based(struct sock *sk) static int receiver_wake_function(wait_queue_entry_t *wait, unsigned int mode, int sync, void *key) { - unsigned long bits = (unsigned long)key; - /* * Avoid a wakeup if event not interesting for us */ - if (bits && !(bits & (POLLIN | POLLERR))) + if (key && !(key_to_poll(key) & (POLLIN | POLLERR))) return 0; return autoremove_wake_function(wait, mode, sync, key); } diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index a9ee634f3c42..72957961ac22 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -367,7 +367,7 @@ static int unix_dgram_peer_wake_relay(wait_queue_entry_t *q, unsigned mode, int /* relaying can only happen while the wq still exists */ u_sleep = sk_sleep(&u->sk); if (u_sleep) - wake_up_interruptible_poll(u_sleep, key); + wake_up_interruptible_poll(u_sleep, key_to_poll(key)); return 0; } diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index a1f68ed999d8..a334399fafec 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -188,7 +188,7 @@ irqfd_wakeup(wait_queue_entry_t *wait, unsigned mode, int sync, void *key) { struct kvm_kernel_irqfd *irqfd = container_of(wait, struct kvm_kernel_irqfd, wait); - unsigned long flags = (unsigned long)key; + __poll_t flags = key_to_poll(key); struct kvm_kernel_irq_routing_entry irq; struct kvm *kvm = irqfd->kvm; unsigned seq; -- cgit v1.2.3 From 01699437758328090813212ecefe3ab6f0d5b9cc Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 3 Jul 2017 03:14:15 -0400 Subject: annotate poll_table_struct ->_key Only POLL... bitmaps ever end up there and their only use is checking for POLL... bits in them. Signed-off-by: Al Viro --- drivers/dma-buf/dma-buf.c | 2 +- drivers/media/pci/bt8xx/bttv-driver.c | 4 ++-- drivers/media/pci/cx18/cx18-fileops.c | 2 +- drivers/media/pci/ivtv/ivtv-fileops.c | 2 +- drivers/media/pci/saa7164/saa7164-encoder.c | 2 +- drivers/media/platform/fsl-viu.c | 2 +- drivers/media/radio/radio-cadet.c | 2 +- drivers/media/radio/radio-si476x.c | 2 +- drivers/media/radio/si470x/radio-si470x-common.c | 2 +- drivers/media/usb/cx231xx/cx231xx-417.c | 2 +- drivers/media/usb/cx231xx/cx231xx-video.c | 2 +- drivers/media/usb/gspca/gspca.c | 2 +- drivers/media/usb/hdpvr/hdpvr-video.c | 2 +- drivers/media/usb/tm6000/tm6000-video.c | 2 +- drivers/media/v4l2-core/v4l2-mem2mem.c | 2 +- drivers/media/v4l2-core/videobuf-core.c | 2 +- drivers/media/v4l2-core/videobuf2-core.c | 2 +- drivers/media/v4l2-core/videobuf2-v4l2.c | 2 +- drivers/misc/mei/main.c | 2 +- fs/select.c | 4 ++-- include/linux/poll.h | 8 ++++---- 21 files changed, 26 insertions(+), 26 deletions(-) (limited to 'fs') diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index bc1cb284111c..4f313593caf5 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -163,7 +163,7 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll) struct reservation_object *resv; struct reservation_object_list *fobj; struct dma_fence *fence_excl; - unsigned long events; + __poll_t events; unsigned shared_count, seq; dmabuf = file->private_data; diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c index b366a7e1d976..721f586c0394 100644 --- a/drivers/media/pci/bt8xx/bttv-driver.c +++ b/drivers/media/pci/bt8xx/bttv-driver.c @@ -2961,7 +2961,7 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait) struct bttv_buffer *buf; enum v4l2_field field; unsigned int rc = 0; - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); if (v4l2_event_pending(&fh->fh)) rc = POLLPRI; @@ -3333,7 +3333,7 @@ static unsigned int radio_poll(struct file *file, poll_table *wait) { struct bttv_fh *fh = file->private_data; struct bttv *btv = fh->btv; - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); struct saa6588_command cmd; unsigned int res = 0; diff --git a/drivers/media/pci/cx18/cx18-fileops.c b/drivers/media/pci/cx18/cx18-fileops.c index 4f9c2395941b..55130d5abffd 100644 --- a/drivers/media/pci/cx18/cx18-fileops.c +++ b/drivers/media/pci/cx18/cx18-fileops.c @@ -604,7 +604,7 @@ ssize_t cx18_v4l2_read(struct file *filp, char __user *buf, size_t count, unsigned int cx18_v4l2_enc_poll(struct file *filp, poll_table *wait) { - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); struct cx18_open_id *id = file2id(filp); struct cx18 *cx = id->cx; struct cx18_stream *s = &cx->streams[id->type]; diff --git a/drivers/media/pci/ivtv/ivtv-fileops.c b/drivers/media/pci/ivtv/ivtv-fileops.c index c9bd018e53de..22217ef30bd6 100644 --- a/drivers/media/pci/ivtv/ivtv-fileops.c +++ b/drivers/media/pci/ivtv/ivtv-fileops.c @@ -766,7 +766,7 @@ unsigned int ivtv_v4l2_dec_poll(struct file *filp, poll_table *wait) unsigned int ivtv_v4l2_enc_poll(struct file *filp, poll_table *wait) { - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); struct ivtv_open_id *id = fh2id(filp->private_data); struct ivtv *itv = id->itv; struct ivtv_stream *s = &itv->streams[id->type]; diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c index f21c245a54f7..ab75e5e19884 100644 --- a/drivers/media/pci/saa7164/saa7164-encoder.c +++ b/drivers/media/pci/saa7164/saa7164-encoder.c @@ -911,7 +911,7 @@ err: static unsigned int fops_poll(struct file *file, poll_table *wait) { - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); struct saa7164_encoder_fh *fh = (struct saa7164_encoder_fh *)file->private_data; struct saa7164_port *port = fh->port; diff --git a/drivers/media/platform/fsl-viu.c b/drivers/media/platform/fsl-viu.c index dba21215dc84..1e9c1f05d057 100644 --- a/drivers/media/platform/fsl-viu.c +++ b/drivers/media/platform/fsl-viu.c @@ -1268,7 +1268,7 @@ static unsigned int viu_poll(struct file *file, struct poll_table_struct *wait) struct viu_fh *fh = file->private_data; struct videobuf_queue *q = &fh->vb_vidq; struct viu_dev *dev = fh->dev; - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); unsigned int res = v4l2_ctrl_poll(file, wait); if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type) diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c index 7575e5370a49..7a6b3efefedb 100644 --- a/drivers/media/radio/radio-cadet.c +++ b/drivers/media/radio/radio-cadet.c @@ -484,7 +484,7 @@ static int cadet_release(struct file *file) static unsigned int cadet_poll(struct file *file, struct poll_table_struct *wait) { struct cadet *dev = video_drvdata(file); - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); unsigned int res = v4l2_ctrl_poll(file, wait); poll_wait(file, &dev->read_queue, wait); diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c index 271f725b17e8..fc1bcda38c69 100644 --- a/drivers/media/radio/radio-si476x.c +++ b/drivers/media/radio/radio-si476x.c @@ -1153,7 +1153,7 @@ static unsigned int si476x_radio_fops_poll(struct file *file, struct poll_table_struct *pts) { struct si476x_radio *radio = video_drvdata(file); - unsigned long req_events = poll_requested_events(pts); + __poll_t req_events = poll_requested_events(pts); unsigned int err = v4l2_ctrl_poll(file, pts); if (req_events & (POLLIN | POLLRDNORM)) { diff --git a/drivers/media/radio/si470x/radio-si470x-common.c b/drivers/media/radio/si470x/radio-si470x-common.c index c89a7d5b8c55..b430bbc475fe 100644 --- a/drivers/media/radio/si470x/radio-si470x-common.c +++ b/drivers/media/radio/si470x/radio-si470x-common.c @@ -511,7 +511,7 @@ static unsigned int si470x_fops_poll(struct file *file, struct poll_table_struct *pts) { struct si470x_device *radio = video_drvdata(file); - unsigned long req_events = poll_requested_events(pts); + __poll_t req_events = poll_requested_events(pts); int retval = v4l2_ctrl_poll(file, pts); if (req_events & (POLLIN | POLLRDNORM)) { diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c index d538fa407742..80231bdee366 100644 --- a/drivers/media/usb/cx231xx/cx231xx-417.c +++ b/drivers/media/usb/cx231xx/cx231xx-417.c @@ -1815,7 +1815,7 @@ static ssize_t mpeg_read(struct file *file, char __user *data, static unsigned int mpeg_poll(struct file *file, struct poll_table_struct *wait) { - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); struct cx231xx_fh *fh = file->private_data; struct cx231xx *dev = fh->dev; unsigned int res = 0; diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c index 226059fc672b..3c11ed45d679 100644 --- a/drivers/media/usb/cx231xx/cx231xx-video.c +++ b/drivers/media/usb/cx231xx/cx231xx-video.c @@ -2008,7 +2008,7 @@ cx231xx_v4l2_read(struct file *filp, char __user *buf, size_t count, */ static unsigned int cx231xx_v4l2_poll(struct file *filp, poll_table *wait) { - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); struct cx231xx_fh *fh = filp->private_data; struct cx231xx *dev = fh->dev; unsigned res = 0; diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c index 961343873fd0..8ebf96f9a3a2 100644 --- a/drivers/media/usb/gspca/gspca.c +++ b/drivers/media/usb/gspca/gspca.c @@ -1865,7 +1865,7 @@ out: static unsigned int dev_poll(struct file *file, poll_table *wait) { struct gspca_dev *gspca_dev = video_drvdata(file); - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); int ret = 0; PDEBUG(D_FRAM, "poll"); diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c index 7fb036d6a86e..35f8a834c76c 100644 --- a/drivers/media/usb/hdpvr/hdpvr-video.c +++ b/drivers/media/usb/hdpvr/hdpvr-video.c @@ -523,7 +523,7 @@ err: static unsigned int hdpvr_poll(struct file *filp, poll_table *wait) { - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); struct hdpvr_buffer *buf = NULL; struct hdpvr_device *dev = video_drvdata(filp); unsigned int mask = v4l2_ctrl_poll(filp, wait); diff --git a/drivers/media/usb/tm6000/tm6000-video.c b/drivers/media/usb/tm6000/tm6000-video.c index 9fa25de6b5a9..16c9dcf3f2cb 100644 --- a/drivers/media/usb/tm6000/tm6000-video.c +++ b/drivers/media/usb/tm6000/tm6000-video.c @@ -1426,7 +1426,7 @@ tm6000_read(struct file *file, char __user *data, size_t count, loff_t *pos) static unsigned int __tm6000_poll(struct file *file, struct poll_table_struct *wait) { - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); struct tm6000_fh *fh = file->private_data; struct tm6000_buffer *buf; int res = 0; diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c index f62e68aa04c4..bc6b8f5953be 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -502,7 +502,7 @@ unsigned int v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct poll_table_struct *wait) { struct video_device *vfd = video_devdata(file); - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); struct vb2_queue *src_q, *dst_q; struct vb2_buffer *src_vb = NULL, *dst_vb = NULL; unsigned int rc = 0; diff --git a/drivers/media/v4l2-core/videobuf-core.c b/drivers/media/v4l2-core/videobuf-core.c index 1dbf6f7785bb..83918bfda167 100644 --- a/drivers/media/v4l2-core/videobuf-core.c +++ b/drivers/media/v4l2-core/videobuf-core.c @@ -1122,7 +1122,7 @@ unsigned int videobuf_poll_stream(struct file *file, struct videobuf_queue *q, poll_table *wait) { - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); struct videobuf_buffer *buf = NULL; unsigned int rc = 0; diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index cb115ba6a1d2..1a297aea084b 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -2021,7 +2021,7 @@ EXPORT_SYMBOL_GPL(vb2_core_queue_release); unsigned int vb2_core_poll(struct vb2_queue *q, struct file *file, poll_table *wait) { - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); struct vb2_buffer *vb = NULL; unsigned long flags; diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c index 0c0669976bdc..f7cdc66a06e1 100644 --- a/drivers/media/v4l2-core/videobuf2-v4l2.c +++ b/drivers/media/v4l2-core/videobuf2-v4l2.c @@ -674,7 +674,7 @@ EXPORT_SYMBOL_GPL(vb2_queue_release); unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) { struct video_device *vfd = video_devdata(file); - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); unsigned int res = 0; if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) { diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index e825f013e54e..4f704641c574 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c @@ -544,7 +544,7 @@ static long mei_compat_ioctl(struct file *file, */ static unsigned int mei_poll(struct file *file, poll_table *wait) { - unsigned long req_events = poll_requested_events(wait); + __poll_t req_events = poll_requested_events(wait); struct mei_cl *cl = file->private_data; struct mei_device *dev; unsigned int mask = 0; diff --git a/fs/select.c b/fs/select.c index ffc16fd3673e..8d6d47912134 100644 --- a/fs/select.c +++ b/fs/select.c @@ -438,7 +438,7 @@ get_max: static inline void wait_key_set(poll_table *wait, unsigned long in, unsigned long out, unsigned long bit, - unsigned int ll_flag) + __poll_t ll_flag) { wait->_key = POLLEX_SET | ll_flag; if (in & bit) @@ -454,7 +454,7 @@ static int do_select(int n, fd_set_bits *fds, struct timespec64 *end_time) poll_table *wait; int retval, i, timed_out = 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; rcu_read_lock(); diff --git a/include/linux/poll.h b/include/linux/poll.h index d384f12abdd5..8927e2282633 100644 --- a/include/linux/poll.h +++ b/include/linux/poll.h @@ -37,7 +37,7 @@ typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_ */ typedef struct poll_table_struct { poll_queue_proc _qproc; - unsigned long _key; + __poll_t _key; } poll_table; static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p) @@ -62,15 +62,15 @@ static inline bool poll_does_not_wait(const poll_table *p) * to be started implicitly on poll(). You typically only want to do that * if the application is actually polling for POLLIN and/or POLLOUT. */ -static inline unsigned long poll_requested_events(const poll_table *p) +static inline __poll_t poll_requested_events(const poll_table *p) { - return p ? p->_key : ~0UL; + return p ? p->_key : ~(__poll_t)0; } static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc) { pt->_qproc = qproc; - pt->_key = ~0UL; /* all events enabled */ + pt->_key = ~(__poll_t)0; /* all events enabled */ } struct poll_table_entry { -- cgit v1.2.3 From 076ccb76e1a6cf0aa5371132efdd502a11e806f1 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 3 Jul 2017 01:02:18 -0400 Subject: fs: annotate ->poll() instances Signed-off-by: Al Viro --- fs/cachefiles/daemon.c | 6 +++--- fs/coda/psdev.c | 4 ++-- fs/debugfs/file.c | 2 +- fs/dlm/plock.c | 4 ++-- fs/dlm/user.c | 2 +- fs/ecryptfs/miscdev.c | 4 ++-- fs/eventfd.c | 4 ++-- fs/eventpoll.c | 2 +- fs/fuse/dev.c | 4 ++-- fs/fuse/file.c | 2 +- fs/fuse/fuse_i.h | 2 +- fs/kernfs/file.c | 2 +- fs/notify/fanotify/fanotify_user.c | 4 ++-- fs/notify/inotify/inotify_user.c | 4 ++-- fs/ocfs2/dlmfs/dlmfs.c | 4 ++-- fs/orangefs/devorangefs-req.c | 4 ++-- fs/pipe.c | 4 ++-- fs/proc/inode.c | 2 +- fs/proc/kmsg.c | 2 +- fs/proc/proc_sysctl.c | 4 ++-- fs/proc_namespace.c | 4 ++-- fs/signalfd.c | 4 ++-- fs/timerfd.c | 4 ++-- fs/userfaultfd.c | 4 ++-- 24 files changed, 41 insertions(+), 41 deletions(-) (limited to 'fs') diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c index 1ee54ffd3a24..7edbd0679952 100644 --- a/fs/cachefiles/daemon.c +++ b/fs/cachefiles/daemon.c @@ -31,7 +31,7 @@ static ssize_t cachefiles_daemon_read(struct file *, char __user *, size_t, loff_t *); static ssize_t cachefiles_daemon_write(struct file *, const char __user *, size_t, loff_t *); -static unsigned int cachefiles_daemon_poll(struct file *, +static __poll_t cachefiles_daemon_poll(struct file *, struct poll_table_struct *); static int cachefiles_daemon_frun(struct cachefiles_cache *, char *); static int cachefiles_daemon_fcull(struct cachefiles_cache *, char *); @@ -291,11 +291,11 @@ found_command: * poll for culling state * - use POLLOUT to indicate culling state */ -static unsigned int cachefiles_daemon_poll(struct file *file, +static __poll_t cachefiles_daemon_poll(struct file *file, struct poll_table_struct *poll) { struct cachefiles_cache *cache = file->private_data; - unsigned int mask; + __poll_t mask; poll_wait(file, &cache->daemon_pollwq, poll); mask = 0; diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index f40e3953e7fe..49d3c6fda89a 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c @@ -61,10 +61,10 @@ static struct class *coda_psdev_class; * Device operations */ -static unsigned int coda_psdev_poll(struct file *file, poll_table * wait) +static __poll_t coda_psdev_poll(struct file *file, poll_table * wait) { struct venus_comm *vcp = (struct venus_comm *) file->private_data; - unsigned int mask = POLLOUT | POLLWRNORM; + __poll_t mask = POLLOUT | POLLWRNORM; poll_wait(file, &vcp->vc_waitq, wait); mutex_lock(&vcp->vc_mutex); diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 2571404a072b..6fdbf21be318 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -206,7 +206,7 @@ FULL_PROXY_FUNC(unlocked_ioctl, long, filp, PROTO(struct file *filp, unsigned int cmd, unsigned long arg), ARGS(filp, cmd, arg)); -static unsigned int full_proxy_poll(struct file *filp, +static __poll_t full_proxy_poll(struct file *filp, struct poll_table_struct *wait) { struct dentry *dentry = F_DENTRY(filp); diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c index e631b1689228..a4c63e9e6385 100644 --- a/fs/dlm/plock.c +++ b/fs/dlm/plock.c @@ -463,9 +463,9 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count, return count; } -static unsigned int dev_poll(struct file *file, poll_table *wait) +static __poll_t dev_poll(struct file *file, poll_table *wait) { - unsigned int mask = 0; + __poll_t mask = 0; poll_wait(file, &send_wq, wait); diff --git a/fs/dlm/user.c b/fs/dlm/user.c index d18e7a539f11..662432af8ce8 100644 --- a/fs/dlm/user.c +++ b/fs/dlm/user.c @@ -887,7 +887,7 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count, return rv; } -static unsigned int device_poll(struct file *file, poll_table *wait) +static __poll_t device_poll(struct file *file, poll_table *wait) { struct dlm_user_proc *proc = file->private_data; diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c index f09cacaf8c80..7423e792a092 100644 --- a/fs/ecryptfs/miscdev.c +++ b/fs/ecryptfs/miscdev.c @@ -38,11 +38,11 @@ static atomic_t ecryptfs_num_miscdev_opens; * * Returns the poll mask */ -static unsigned int +static __poll_t ecryptfs_miscdev_poll(struct file *file, poll_table *pt) { struct ecryptfs_daemon *daemon = file->private_data; - unsigned int mask = 0; + __poll_t mask = 0; mutex_lock(&daemon->mux); if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) { diff --git a/fs/eventfd.c b/fs/eventfd.c index 2fb4eadaa118..6318a9b57e53 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -114,10 +114,10 @@ static int eventfd_release(struct inode *inode, struct file *file) return 0; } -static unsigned int eventfd_poll(struct file *file, poll_table *wait) +static __poll_t eventfd_poll(struct file *file, poll_table *wait) { struct eventfd_ctx *ctx = file->private_data; - unsigned int events = 0; + __poll_t events = 0; u64 count; poll_wait(file, &ctx->wqh, wait); diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 21e6fee00e8b..67fb3b850c99 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -920,7 +920,7 @@ static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head, return 0; } -static unsigned int ep_eventpoll_poll(struct file *file, poll_table *wait) +static __poll_t ep_eventpoll_poll(struct file *file, poll_table *wait) { struct eventpoll *ep = file->private_data; int depth = 0; diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 17f0d05bfd4c..aa089a6925d0 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2004,9 +2004,9 @@ out: return ret; } -static unsigned fuse_dev_poll(struct file *file, poll_table *wait) +static __poll_t fuse_dev_poll(struct file *file, poll_table *wait) { - unsigned mask = POLLOUT | POLLWRNORM; + __poll_t mask = POLLOUT | POLLWRNORM; struct fuse_iqueue *fiq; struct fuse_dev *fud = fuse_get_dev(file); diff --git a/fs/fuse/file.c b/fs/fuse/file.c index cb7dff5c45d7..fa4ca6bd2c96 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2751,7 +2751,7 @@ static void fuse_register_polled_file(struct fuse_conn *fc, spin_unlock(&fc->lock); } -unsigned fuse_file_poll(struct file *file, poll_table *wait) +__poll_t fuse_file_poll(struct file *file, poll_table *wait) { struct fuse_file *ff = file->private_data; struct fuse_conn *fc = ff->fc; diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index d5773ca67ad2..c4c093bbf456 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -951,7 +951,7 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, unsigned int flags); long fuse_ioctl_common(struct file *file, unsigned int cmd, unsigned long arg, unsigned int flags); -unsigned fuse_file_poll(struct file *file, poll_table *wait); +__poll_t fuse_file_poll(struct file *file, poll_table *wait); int fuse_dev_release(struct inode *inode, struct file *file); bool fuse_write_update_size(struct inode *inode, loff_t pos); diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 9698e51656b1..c53d9cc5ae7a 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -832,7 +832,7 @@ void kernfs_drain_open_files(struct kernfs_node *kn) * to see if it supports poll (Neither 'poll' nor 'select' return * an appropriate error code). When in doubt, set a suitable timeout value. */ -static unsigned int kernfs_fop_poll(struct file *filp, poll_table *wait) +static __poll_t kernfs_fop_poll(struct file *filp, poll_table *wait) { struct kernfs_open_file *of = kernfs_of(filp); struct kernfs_node *kn = kernfs_dentry_node(filp->f_path.dentry); diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index d0d4bc4c4b70..ef08d64c84b8 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -239,10 +239,10 @@ out_close_fd: } /* intofiy userspace file descriptor functions */ -static unsigned int fanotify_poll(struct file *file, poll_table *wait) +static __poll_t fanotify_poll(struct file *file, poll_table *wait) { struct fsnotify_group *group = file->private_data; - int ret = 0; + __poll_t ret = 0; poll_wait(file, &group->notification_waitq, wait); spin_lock(&group->notification_lock); diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index d3c20e0bb046..5c29bf16814f 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -107,10 +107,10 @@ static inline u32 inotify_mask_to_arg(__u32 mask) } /* intofiy userspace file descriptor functions */ -static unsigned int inotify_poll(struct file *file, poll_table *wait) +static __poll_t inotify_poll(struct file *file, poll_table *wait) { struct fsnotify_group *group = file->private_data; - int ret = 0; + __poll_t ret = 0; poll_wait(file, &group->notification_waitq, wait); spin_lock(&group->notification_lock); diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c index 9c7c18c0e129..385fcefa8bc5 100644 --- a/fs/ocfs2/dlmfs/dlmfs.c +++ b/fs/ocfs2/dlmfs/dlmfs.c @@ -220,9 +220,9 @@ static int dlmfs_file_setattr(struct dentry *dentry, struct iattr *attr) return 0; } -static unsigned int dlmfs_file_poll(struct file *file, poll_table *wait) +static __poll_t dlmfs_file_poll(struct file *file, poll_table *wait) { - int event = 0; + __poll_t event = 0; struct inode *inode = file_inode(file); struct dlmfs_inode_private *ip = DLMFS_I(inode); diff --git a/fs/orangefs/devorangefs-req.c b/fs/orangefs/devorangefs-req.c index a324dc584bf7..109fffd6d153 100644 --- a/fs/orangefs/devorangefs-req.c +++ b/fs/orangefs/devorangefs-req.c @@ -814,10 +814,10 @@ void orangefs_dev_cleanup(void) ORANGEFS_REQDEVICE_NAME); } -static unsigned int orangefs_devreq_poll(struct file *file, +static __poll_t orangefs_devreq_poll(struct file *file, struct poll_table_struct *poll_table) { - int poll_revent_mask = 0; + __poll_t poll_revent_mask = 0; poll_wait(file, &orangefs_request_list_waitq, poll_table); diff --git a/fs/pipe.c b/fs/pipe.c index 6d98566201ef..a449ca0ec0c6 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -515,10 +515,10 @@ static long pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) } /* No kernel lock held - fine */ -static unsigned int +static __poll_t pipe_poll(struct file *filp, poll_table *wait) { - unsigned int mask; + __poll_t mask; struct pipe_inode_info *pipe = filp->private_data; int nrbufs; diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 149fd4d75db6..5e6f160d96a2 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -234,7 +234,7 @@ static ssize_t proc_reg_write(struct file *file, const char __user *buf, size_t return rv; } -static unsigned int proc_reg_poll(struct file *file, struct poll_table_struct *pts) +static __poll_t proc_reg_poll(struct file *file, struct poll_table_struct *pts) { struct proc_dir_entry *pde = PDE(file_inode(file)); __poll_t rv = DEFAULT_POLLMASK; diff --git a/fs/proc/kmsg.c b/fs/proc/kmsg.c index e0f8774acd65..f0bfb45c3f9f 100644 --- a/fs/proc/kmsg.c +++ b/fs/proc/kmsg.c @@ -40,7 +40,7 @@ static ssize_t kmsg_read(struct file *file, char __user *buf, return do_syslog(SYSLOG_ACTION_READ, buf, count, SYSLOG_FROM_PROC); } -static unsigned int kmsg_poll(struct file *file, poll_table *wait) +static __poll_t kmsg_poll(struct file *file, poll_table *wait) { poll_wait(file, &log_wait, wait); if (do_syslog(SYSLOG_ACTION_SIZE_UNREAD, NULL, 0, SYSLOG_FROM_PROC)) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index c5cbbdff3c3d..63325377621a 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -630,12 +630,12 @@ static int proc_sys_open(struct inode *inode, struct file *filp) return 0; } -static unsigned int proc_sys_poll(struct file *filp, poll_table *wait) +static __poll_t proc_sys_poll(struct file *filp, poll_table *wait) { struct inode *inode = file_inode(filp); struct ctl_table_header *head = grab_header(inode); struct ctl_table *table = PROC_I(inode)->sysctl_entry; - unsigned int ret = DEFAULT_POLLMASK; + __poll_t ret = DEFAULT_POLLMASK; unsigned long event; /* sysctl was unregistered */ diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c index 7b635d173213..7a3d0ff9b7a8 100644 --- a/fs/proc_namespace.c +++ b/fs/proc_namespace.c @@ -18,12 +18,12 @@ #include "pnode.h" #include "internal.h" -static unsigned mounts_poll(struct file *file, poll_table *wait) +static __poll_t mounts_poll(struct file *file, poll_table *wait) { struct seq_file *m = file->private_data; struct proc_mounts *p = m->private; struct mnt_namespace *ns = p->ns; - unsigned res = POLLIN | POLLRDNORM; + __poll_t res = POLLIN | POLLRDNORM; int event; poll_wait(file, &p->ns->poll, wait); diff --git a/fs/signalfd.c b/fs/signalfd.c index 5f1ff8756595..31e923bec99a 100644 --- a/fs/signalfd.c +++ b/fs/signalfd.c @@ -58,10 +58,10 @@ static int signalfd_release(struct inode *inode, struct file *file) return 0; } -static unsigned int signalfd_poll(struct file *file, poll_table *wait) +static __poll_t signalfd_poll(struct file *file, poll_table *wait) { struct signalfd_ctx *ctx = file->private_data; - unsigned int events = 0; + __poll_t events = 0; poll_wait(file, ¤t->sighand->signalfd_wqh, wait); diff --git a/fs/timerfd.c b/fs/timerfd.c index 040612ec9598..0510717f3a53 100644 --- a/fs/timerfd.c +++ b/fs/timerfd.c @@ -227,10 +227,10 @@ static int timerfd_release(struct inode *inode, struct file *file) return 0; } -static unsigned int timerfd_poll(struct file *file, poll_table *wait) +static __poll_t timerfd_poll(struct file *file, poll_table *wait) { struct timerfd_ctx *ctx = file->private_data; - unsigned int events = 0; + __poll_t events = 0; unsigned long flags; poll_wait(file, &ctx->wqh, wait); diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index ac9a4e65ca49..c0a5d9c47c6d 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -921,10 +921,10 @@ static inline struct userfaultfd_wait_queue *find_userfault_evt( return find_userfault_in(&ctx->event_wqh); } -static unsigned int userfaultfd_poll(struct file *file, poll_table *wait) +static __poll_t userfaultfd_poll(struct file *file, poll_table *wait) { struct userfaultfd_ctx *ctx = file->private_data; - unsigned int ret; + __poll_t ret; poll_wait(file, &ctx->fd_wqh, wait); -- cgit v1.2.3 From 5dc533c66b131726a1a747eb3c92b20a9ede9219 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 16 Jul 2017 22:14:00 -0400 Subject: ->si_band gets POLL... bitmap stored into a user-visible long field Signed-off-by: Al Viro --- fs/fcntl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fs') diff --git a/fs/fcntl.c b/fs/fcntl.c index 0522e283a4f4..afe731c7a5a8 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -690,7 +690,7 @@ COMPAT_SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, /* Table to convert sigio signal codes into poll band bitmaps */ -static const long band_table[NSIGPOLL] = { +static const __poll_t band_table[NSIGPOLL] = { POLLIN | POLLRDNORM, /* POLL_IN */ POLLOUT | POLLWRNORM | POLLWRBAND, /* POLL_OUT */ POLLIN | POLLRDNORM | POLLMSG, /* POLL_MSG */ @@ -758,7 +758,7 @@ static void send_sigio_to_task(struct task_struct *p, if (reason - POLL_IN >= NSIGPOLL) si.si_band = ~0L; else - si.si_band = band_table[reason - POLL_IN]; + si.si_band = (__force long)band_table[reason - POLL_IN]; si.si_fd = fd; if (!do_send_sig_info(signum, &si, p, group)) break; -- cgit v1.2.3 From fb3679372bd7967f39ea48e701fcd1e8f55e75cd Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 16 Jul 2017 23:51:03 -0400 Subject: annotate poll(2) guts struct pollfd contains two 16bit fields (mask and result) that encode the POLL... bitmaps. Signed-off-by: Al Viro --- fs/select.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'fs') 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 */ -- cgit v1.2.3 From bec1a502d34dcd4d4350a4d9c14fe07561c9516d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 28 Nov 2017 19:43:33 -0500 Subject: eventpoll: constify struct epoll_event pointers Signed-off-by: Al Viro --- fs/eventpoll.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'fs') diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 67fb3b850c99..92f6c30a1dbb 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -874,7 +874,8 @@ static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead, * the ep->mtx so we need to start from depth=1, such that mutex_lock_nested() * is correctly annotated. */ -static unsigned int ep_item_poll(struct epitem *epi, poll_table *pt, int depth) +static unsigned int ep_item_poll(const struct epitem *epi, poll_table *pt, + int depth) { struct eventpoll *ep; bool locked; @@ -1410,7 +1411,7 @@ static noinline void ep_destroy_wakeup_source(struct epitem *epi) /* * Must be called with "mtx" held. */ -static int ep_insert(struct eventpoll *ep, struct epoll_event *event, +static int ep_insert(struct eventpoll *ep, const struct epoll_event *event, struct file *tfile, int fd, int full_check) { int error, revents, pwake = 0; @@ -1541,7 +1542,8 @@ error_create_wakeup_source: * Modify the interest event mask by dropping an event if the new mask * has a match in the current file status. Must be called with "mtx" held. */ -static int ep_modify(struct eventpoll *ep, struct epitem *epi, struct epoll_event *event) +static int ep_modify(struct eventpoll *ep, struct epitem *epi, + const struct epoll_event *event) { int pwake = 0; unsigned int revents; -- cgit v1.2.3 From 69112736e2f025ff3ba280cf81c36e25cf7cc59f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 28 Nov 2017 19:56:15 -0500 Subject: eventpoll: no need to mask the result of epi_item_poll() again two callers that do so don't need to bother - we'd already masked it with epi->event.events, which * couldn't have changed since we are holding ->mtx * had been set to event->events * is still equal to event->events, since *event is never changed by anything. Signed-off-by: Al Viro --- fs/eventpoll.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'fs') diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 92f6c30a1dbb..42e35a6977c9 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1488,7 +1488,7 @@ static int ep_insert(struct eventpoll *ep, const struct epoll_event *event, ep_set_busy_poll_napi_id(epi); /* If the file is already "ready" we drop it inside the ready list */ - if ((revents & event->events) && !ep_is_linked(&epi->rdllink)) { + if (revents && !ep_is_linked(&epi->rdllink)) { list_add_tail(&epi->rdllink, &ep->rdllist); ep_pm_stay_awake(epi); @@ -1546,7 +1546,6 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, const struct epoll_event *event) { int pwake = 0; - unsigned int revents; poll_table pt; init_poll_funcptr(&pt, NULL); @@ -1588,14 +1587,10 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, /* * Get current event bits. We can safely use the file* here because * its usage count has been increased by the caller of this function. - */ - revents = ep_item_poll(epi, &pt, 1); - - /* * If the item is "hot" and it is not registered inside the ready * list, push it inside. */ - if (revents & event->events) { + if (ep_item_poll(epi, &pt, 1)) { spin_lock_irq(&ep->lock); if (!ep_is_linked(&epi->rdllink)) { list_add_tail(&epi->rdllink, &ep->rdllist); -- cgit v1.2.3 From c71d227fc4133f949dae620ed5e3a250b43f2415 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 29 Nov 2017 19:00:41 -0500 Subject: make kernel-side POLL... arch-independent mangle/demangle on the way to/from userland Signed-off-by: Al Viro --- arch/blackfin/include/uapi/asm/poll.h | 19 ++++++++++++++++++- arch/frv/include/uapi/asm/poll.h | 19 +++++++++++++++++-- arch/m68k/include/uapi/asm/poll.h | 17 +++++++++++++++++ arch/mips/include/uapi/asm/poll.h | 17 +++++++++++++++++ arch/sparc/include/uapi/asm/poll.h | 20 ++++++++++++++++++++ arch/xtensa/include/uapi/asm/poll.h | 17 +++++++++++++++++ fs/fcntl.c | 2 +- fs/fuse/file.c | 4 ++-- fs/select.c | 4 ++-- include/uapi/asm-generic/poll.h | 14 ++++++++++++++ 10 files changed, 125 insertions(+), 8 deletions(-) (limited to 'fs') diff --git a/arch/blackfin/include/uapi/asm/poll.h b/arch/blackfin/include/uapi/asm/poll.h index 961e49056b0a..3b162f2d2970 100644 --- a/arch/blackfin/include/uapi/asm/poll.h +++ b/arch/blackfin/include/uapi/asm/poll.h @@ -9,8 +9,25 @@ #ifndef _UAPI__BFIN_POLL_H #define _UAPI__BFIN_POLL_H -#define POLLWRNORM (__force __poll_t)4 /* POLLOUT */ +#ifndef __KERNEL__ +#define POLLWRNORM POLLOUT #define POLLWRBAND (__force __poll_t)256 +#else +#define __ARCH_HAS_MANGLED_POLL +static inline __u16 mangle_poll(__poll_t val) +{ + __u16 v = (__force __u16)val; + /* bit 9 -> bit 8, bit 8 -> bit 2 */ + return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6); +} + +static inline __poll_t demangle_poll(__u16 v) +{ + /* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */ + return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) | + ((v & 4) << 6)); +} +#endif #include diff --git a/arch/frv/include/uapi/asm/poll.h b/arch/frv/include/uapi/asm/poll.h index d7053ada7c69..a44c8f0ebee7 100644 --- a/arch/frv/include/uapi/asm/poll.h +++ b/arch/frv/include/uapi/asm/poll.h @@ -2,12 +2,27 @@ #ifndef _ASM_POLL_H #define _ASM_POLL_H +#ifndef __KERNEL__ #define POLLWRNORM POLLOUT #define POLLWRBAND (__force __poll_t)256 +#else +#define __ARCH_HAS_MANGLED_POLL +static inline __u16 mangle_poll(__poll_t val) +{ + __u16 v = (__force __u16)val; + /* bit 9 -> bit 8, bit 8 -> bit 2 */ + return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6); +} -#include +static inline __poll_t demangle_poll(__u16 v) +{ + /* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */ + return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) | + ((v & 4) << 6)); +} +#endif +#include #undef POLLREMOVE #endif - diff --git a/arch/m68k/include/uapi/asm/poll.h b/arch/m68k/include/uapi/asm/poll.h index 99314937fe5c..d8be239e8141 100644 --- a/arch/m68k/include/uapi/asm/poll.h +++ b/arch/m68k/include/uapi/asm/poll.h @@ -2,8 +2,25 @@ #ifndef __m68k_POLL_H #define __m68k_POLL_H +#ifndef __KERNEL__ #define POLLWRNORM POLLOUT #define POLLWRBAND (__force __poll_t)256 +#else +#define __ARCH_HAS_MANGLED_POLL +static inline __u16 mangle_poll(__poll_t val) +{ + __u16 v = (__force __u16)val; + /* bit 9 -> bit 8, bit 8 -> bit 2 */ + return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6); +} + +static inline __poll_t demangle_poll(__u16 v) +{ + /* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */ + return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) | + ((v & 4) << 6)); +} +#endif #include diff --git a/arch/mips/include/uapi/asm/poll.h b/arch/mips/include/uapi/asm/poll.h index e937f8b1b007..3173f8917128 100644 --- a/arch/mips/include/uapi/asm/poll.h +++ b/arch/mips/include/uapi/asm/poll.h @@ -2,8 +2,25 @@ #ifndef __ASM_POLL_H #define __ASM_POLL_H +#ifndef __KERNEL__ #define POLLWRNORM POLLOUT #define POLLWRBAND (__force __poll_t)0x0100 +#else +#define __ARCH_HAS_MANGLED_POLL +static inline __u16 mangle_poll(__poll_t val) +{ + __u16 v = (__force __u16)val; + /* bit 9 -> bit 8, bit 8 -> bit 2 */ + return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6); +} + +static inline __poll_t demangle_poll(__u16 v) +{ + /* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */ + return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) | + ((v & 4) << 6)); +} +#endif #include diff --git a/arch/sparc/include/uapi/asm/poll.h b/arch/sparc/include/uapi/asm/poll.h index 595cb12df1f1..2a81e79aa3ea 100644 --- a/arch/sparc/include/uapi/asm/poll.h +++ b/arch/sparc/include/uapi/asm/poll.h @@ -2,11 +2,31 @@ #ifndef __SPARC_POLL_H #define __SPARC_POLL_H +#ifndef __KERNEL__ #define POLLWRNORM POLLOUT #define POLLWRBAND (__force __poll_t)256 #define POLLMSG (__force __poll_t)512 #define POLLREMOVE (__force __poll_t)1024 #define POLLRDHUP (__force __poll_t)2048 +#else +#define __ARCH_HAS_MANGLED_POLL +static inline __u16 mangle_poll(__poll_t val) +{ + __u16 v = (__force __u16)val; + /* bit 9 -> bit 8, bit 8 -> bit 2, bit 13 -> bit 11 */ + return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6) | + ((v & 0x2000) >> 2); + + +} + +static inline __poll_t demangle_poll(__u16 v) +{ + /* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */ + return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) | + ((v & 4) << 6) | ((v & 0x800) << 2)); +} +#endif #include diff --git a/arch/xtensa/include/uapi/asm/poll.h b/arch/xtensa/include/uapi/asm/poll.h index 22bbc48b9f85..e3246d41182c 100644 --- a/arch/xtensa/include/uapi/asm/poll.h +++ b/arch/xtensa/include/uapi/asm/poll.h @@ -12,9 +12,26 @@ #ifndef _XTENSA_POLL_H #define _XTENSA_POLL_H +#ifndef __KERNEL__ #define POLLWRNORM POLLOUT #define POLLWRBAND (__force __poll_t)0x0100 #define POLLREMOVE (__force __poll_t)0x0800 +#else +#define __ARCH_HAS_MANGLED_POLL +static inline __u16 mangle_poll(__poll_t val) +{ + __u16 v = (__force __u16)val; + /* bit 9 -> bit 8, bit 8 -> bit 2 */ + return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6); +} + +static inline __poll_t demangle_poll(__u16 v) +{ + /* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */ + return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) | + ((v & 4) << 6)); +} +#endif #include diff --git a/fs/fcntl.c b/fs/fcntl.c index afe731c7a5a8..84bab55b4712 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -758,7 +758,7 @@ static void send_sigio_to_task(struct task_struct *p, if (reason - POLL_IN >= NSIGPOLL) si.si_band = ~0L; else - si.si_band = (__force long)band_table[reason - POLL_IN]; + si.si_band = mangle_poll(band_table[reason - POLL_IN]); si.si_fd = fd; if (!do_send_sig_info(signum, &si, p, group)) break; diff --git a/fs/fuse/file.c b/fs/fuse/file.c index fa4ca6bd2c96..e85e974dd211 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2764,7 +2764,7 @@ __poll_t fuse_file_poll(struct file *file, poll_table *wait) return DEFAULT_POLLMASK; poll_wait(file, &ff->poll_wait, wait); - inarg.events = (__u32)poll_requested_events(wait); + inarg.events = mangle_poll(poll_requested_events(wait)); /* * Ask for notification iff there's someone waiting for it. @@ -2786,7 +2786,7 @@ __poll_t fuse_file_poll(struct file *file, poll_table *wait) err = fuse_simple_request(fc, &args); if (!err) - return outarg.revents; + return demangle_poll(outarg.revents); if (err == -ENOSYS) { fc->no_poll = 1; return DEFAULT_POLLMASK; diff --git a/fs/select.c b/fs/select.c index b2deeb215dbe..ec14171dd78a 100644 --- a/fs/select.c +++ b/fs/select.c @@ -817,7 +817,7 @@ static inline __poll_t do_pollfd(struct pollfd *pollfd, poll_table *pwait, mask = POLLNVAL; if (f.file) { /* userland u16 ->events contains POLL... bitmap */ - __poll_t filter = (__force __poll_t)pollfd->events | + __poll_t filter = demangle_poll(pollfd->events) | POLLERR | POLLHUP; mask = DEFAULT_POLLMASK; if (f.file->f_op->poll) { @@ -833,7 +833,7 @@ static inline __poll_t do_pollfd(struct pollfd *pollfd, poll_table *pwait, } } /* ... and so does ->revents */ - pollfd->revents = (__force u16)mask; + pollfd->revents = mangle_poll(mask); return mask; } diff --git a/include/uapi/asm-generic/poll.h b/include/uapi/asm-generic/poll.h index 8c0e9dd384b6..639fade14b23 100644 --- a/include/uapi/asm-generic/poll.h +++ b/include/uapi/asm-generic/poll.h @@ -33,6 +33,20 @@ #define POLL_BUSY_LOOP (__force __poll_t)0x8000 +#ifdef __KERNEL__ +#ifndef __ARCH_HAS_MANGLED_POLL +static inline __u16 mangle_poll(__poll_t val) +{ + return (__force __u16)val; +} + +static inline __poll_t demangle_poll(__u16 v) +{ + return (__force __poll_t)v; +} +#endif +#endif + struct pollfd { int fd; short events; -- cgit v1.2.3