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
This commit is contained in:
Bart Van Assche
2018-11-04 20:58:42 +00:00
parent ad5bfbe4e2
commit 058fba5f2a
3 changed files with 35 additions and 14 deletions

View File

@@ -297,6 +297,27 @@ enum {
};
#endif
/* <linux/eventpoll.h> */
#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
/* <linux/fs.h> */
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0) && \

View File

@@ -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;
}

View File

@@ -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;
}