From 058fba5f2afa10b2efaabb0cd230b57db6c9b1fe Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 4 Nov 2018 20:58:42 +0000 Subject: [PATCH] scst_user, scst_event: Convert to __poll_t git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7791 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 21 +++++++++++++++++++++ scst/src/dev_handlers/scst_user.c | 16 ++++++++-------- scst/src/scst_event.c | 12 ++++++------ 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/scst/include/backport.h b/scst/include/backport.h index b5929aed0..dd1b7a2c1 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -297,6 +297,27 @@ enum { }; #endif +/* */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0) +typedef unsigned int __bitwise __poll_t; +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) +#define EPOLLIN (__force __poll_t)0x00000001 +#define EPOLLPRI (__force __poll_t)0x00000002 +#define EPOLLOUT (__force __poll_t)0x00000004 +#define EPOLLERR (__force __poll_t)0x00000008 +#define EPOLLHUP (__force __poll_t)0x00000010 +#define EPOLLNVAL (__force __poll_t)0x00000020 +#define EPOLLRDNORM (__force __poll_t)0x00000040 +#define EPOLLRDBAND (__force __poll_t)0x00000080 +#define EPOLLWRNORM (__force __poll_t)0x00000100 +#define EPOLLWRBAND (__force __poll_t)0x00000200 +#define EPOLLMSG (__force __poll_t)0x00000400 +#define EPOLLRDHUP (__force __poll_t)0x00002000 +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0) && \ diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index 911796c3a..e2aa37682 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -188,7 +188,7 @@ static int __dev_user_set_opt(struct scst_user_dev *dev, static int dev_user_set_opt(struct file *file, const struct scst_user_opt *opt); static int dev_user_get_opt(struct file *file, void __user *arg); -static unsigned int dev_user_poll(struct file *filp, poll_table *wait); +static __poll_t dev_user_poll(struct file *filp, poll_table *wait); static long dev_user_ioctl(struct file *file, unsigned int cmd, unsigned long arg); static int dev_user_release(struct inode *inode, struct file *file); @@ -2586,23 +2586,23 @@ out: return res; } -static unsigned int dev_user_poll(struct file *file, poll_table *wait) +static __poll_t dev_user_poll(struct file *file, poll_table *wait) { - int res = 0; + __poll_t res; struct scst_user_dev *dev; TRACE_ENTRY(); + res = EPOLLNVAL; dev = file->private_data; - res = dev_user_check_reg(dev); - if (unlikely(res != 0)) + if (unlikely(dev_user_check_reg(dev) != 0)) goto out; spin_lock_irq(&dev->udev_cmd_threads.cmd_list_lock); if (!list_empty(&dev->ready_cmd_list) || !list_empty(&dev->udev_cmd_threads.active_cmd_list)) { - res |= POLLIN | POLLRDNORM; + res = EPOLLIN | EPOLLRDNORM; goto out_unlock; } @@ -2616,7 +2616,7 @@ static unsigned int dev_user_poll(struct file *file, poll_table *wait) if (!list_empty(&dev->ready_cmd_list) || !list_empty(&dev->udev_cmd_threads.active_cmd_list)) { - res |= POLLIN | POLLRDNORM; + res = EPOLLIN | EPOLLRDNORM; goto out_unlock; } @@ -2624,7 +2624,7 @@ out_unlock: spin_unlock_irq(&dev->udev_cmd_threads.cmd_list_lock); out: - TRACE_EXIT_HRES(res); + TRACE_EXIT_HRES((__force unsigned int)res); return res; } diff --git a/scst/src/scst_event.c b/scst/src/scst_event.c index 310ec1073..7e88b20b7 100644 --- a/scst/src/scst_event.c +++ b/scst/src/scst_event.c @@ -965,9 +965,9 @@ out_unlock: return res; } -static unsigned int scst_event_poll(struct file *file, poll_table *wait) +static __poll_t scst_event_poll(struct file *file, poll_table *wait) { - int res = 0; + __poll_t res = 0; struct scst_event_priv *priv; TRACE_ENTRY(); @@ -977,12 +977,12 @@ static unsigned int scst_event_poll(struct file *file, poll_table *wait) priv = file->private_data; if (unlikely(priv == NULL)) { PRINT_ERROR("At least one allowed event must be set"); - res = -EINVAL; + res = EPOLLNVAL; goto out_unlock; } if (!list_empty(&priv->queued_events_list)) { - res |= POLLIN | POLLRDNORM; + res = EPOLLIN | EPOLLRDNORM; goto out_unlock; } @@ -995,14 +995,14 @@ static unsigned int scst_event_poll(struct file *file, poll_table *wait) mutex_lock(&scst_event_mutex); if (!list_empty(&priv->queued_events_list)) { - res |= POLLIN | POLLRDNORM; + res = EPOLLIN | EPOLLRDNORM; goto out_unlock; } out_unlock: mutex_unlock(&scst_event_mutex); - TRACE_EXIT_HRES(res); + TRACE_EXIT_HRES((__force unsigned int)res); return res; }