Skip to content

Commit

Permalink
vfs: do bulk POLL* -> EPOLL* replacement
Browse files Browse the repository at this point in the history
This is the mindless scripted replacement of kernel use of POLL*
variables as described by Al, done by this script:

    for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
        L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
        for f in $L; do sed -i "-es/^\([^\"]*\)\(\<POLL$V\>\)/\\1E\\2/" $f; done
    done

with de-mangling cleanups yet to come.

NOTE! On almost all architectures, the EPOLL* constants have the same
values as the POLL* constants do.  But they keyword here is "almost".
For various bad reasons they aren't the same, and epoll() doesn't
actually work quite correctly in some cases due to this on Sparc et al.

The next patch from Al will sort out the final differences, and we
should be all done.

Scripted-by: Al Viro <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
torvalds committed Feb 11, 2018
1 parent ee5daa1 commit a9a0884
Show file tree
Hide file tree
Showing 297 changed files with 913 additions and 913 deletions.
2 changes: 1 addition & 1 deletion arch/cris/arch-v10/drivers/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static __poll_t gpio_poll(struct file *file, poll_table *wait)

if ((data & priv->highalarm) ||
(~data & priv->lowalarm)) {
mask = POLLIN|POLLRDNORM;
mask = EPOLLIN|EPOLLRDNORM;
}

out:
Expand Down
8 changes: 4 additions & 4 deletions arch/cris/arch-v10/drivers/sync_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,16 +666,16 @@ static __poll_t sync_serial_poll(struct file *file, poll_table *wait)
poll_wait(file, &port->in_wait_q, wait);
/* Some room to write */
if (port->out_count < OUT_BUFFER_SIZE)
mask |= POLLOUT | POLLWRNORM;
mask |= EPOLLOUT | EPOLLWRNORM;
/* At least an inbufchunk of data */
if (sync_data_avail(port) >= port->inbufchunk)
mask |= POLLIN | POLLRDNORM;
mask |= EPOLLIN | EPOLLRDNORM;

DEBUGPOLL(if (mask != prev_mask)
printk(KERN_DEBUG "sync_serial_poll: mask 0x%08X %s %s\n",
mask,
mask & POLLOUT ? "POLLOUT" : "",
mask & POLLIN ? "POLLIN" : "");
mask & EPOLLOUT ? "POLLOUT" : "",
mask & EPOLLIN ? "POLLIN" : "");
prev_mask = mask;
);
return mask;
Expand Down
10 changes: 5 additions & 5 deletions arch/cris/arch-v32/drivers/sync_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,24 +574,24 @@ static __poll_t sync_serial_poll(struct file *file, poll_table *wait)

/* No active transfer, descriptors are available */
if (port->output && !port->tr_running)
mask |= POLLOUT | POLLWRNORM;
mask |= EPOLLOUT | EPOLLWRNORM;

/* Descriptor and buffer space available. */
if (port->output &&
port->active_tr_descr != port->catch_tr_descr &&
port->out_buf_count < OUT_BUFFER_SIZE)
mask |= POLLOUT | POLLWRNORM;
mask |= EPOLLOUT | EPOLLWRNORM;

/* At least an inbufchunk of data */
if (port->input && sync_data_avail(port) >= port->inbufchunk)
mask |= POLLIN | POLLRDNORM;
mask |= EPOLLIN | EPOLLRDNORM;

DEBUGPOLL(
if (mask != prev_mask)
pr_info("sync_serial_poll: mask 0x%08X %s %s\n",
mask,
mask & POLLOUT ? "POLLOUT" : "",
mask & POLLIN ? "POLLIN" : "");
mask & EPOLLOUT ? "POLLOUT" : "",
mask & EPOLLIN ? "POLLIN" : "");
prev_mask = mask;
);
return mask;
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/kernel/perfmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@ pfm_poll(struct file *filp, poll_table * wait)
PROTECT_CTX(ctx, flags);

if (PFM_CTXQ_EMPTY(ctx) == 0)
mask = POLLIN | POLLRDNORM;
mask = EPOLLIN | EPOLLRDNORM;

UNPROTECT_CTX(ctx, flags);

Expand Down
4 changes: 2 additions & 2 deletions arch/mips/kernel/rtlx.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,11 @@ static __poll_t file_poll(struct file *file, poll_table *wait)

/* data available to read? */
if (rtlx_read_poll(minor, 0))
mask |= POLLIN | POLLRDNORM;
mask |= EPOLLIN | EPOLLRDNORM;

/* space to write */
if (rtlx_write_poll(minor))
mask |= POLLOUT | POLLWRNORM;
mask |= EPOLLOUT | EPOLLWRNORM;

return mask;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/rtasd.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static __poll_t rtas_log_poll(struct file *file, poll_table * wait)
{
poll_wait(file, &rtas_log_wait, wait);
if (rtas_log_size)
return POLLIN | POLLRDNORM;
return EPOLLIN | EPOLLRDNORM;
return 0;
}

Expand Down
8 changes: 4 additions & 4 deletions arch/powerpc/platforms/cell/spufs/backing_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,19 @@ static __poll_t spu_backing_mbox_stat_poll(struct spu_context *ctx,
but first mark any pending interrupts as done so
we don't get woken up unnecessarily */

if (events & (POLLIN | POLLRDNORM)) {
if (events & (EPOLLIN | EPOLLRDNORM)) {
if (stat & 0xff0000)
ret |= POLLIN | POLLRDNORM;
ret |= EPOLLIN | EPOLLRDNORM;
else {
ctx->csa.priv1.int_stat_class2_RW &=
~CLASS2_MAILBOX_INTR;
ctx->csa.priv1.int_mask_class2_RW |=
CLASS2_ENABLE_MAILBOX_INTR;
}
}
if (events & (POLLOUT | POLLWRNORM)) {
if (events & (EPOLLOUT | EPOLLWRNORM)) {
if (stat & 0x00ff00)
ret = POLLOUT | POLLWRNORM;
ret = EPOLLOUT | EPOLLWRNORM;
else {
ctx->csa.priv1.int_stat_class2_RW &=
~CLASS2_MAILBOX_THRESHOLD_INTR;
Expand Down
10 changes: 5 additions & 5 deletions arch/powerpc/platforms/cell/spufs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ static __poll_t spufs_ibox_poll(struct file *file, poll_table *wait)
* that poll should not sleep. Will be fixed later.
*/
mutex_lock(&ctx->state_mutex);
mask = ctx->ops->mbox_stat_poll(ctx, POLLIN | POLLRDNORM);
mask = ctx->ops->mbox_stat_poll(ctx, EPOLLIN | EPOLLRDNORM);
spu_release(ctx);

return mask;
Expand Down Expand Up @@ -910,7 +910,7 @@ static __poll_t spufs_wbox_poll(struct file *file, poll_table *wait)
* that poll should not sleep. Will be fixed later.
*/
mutex_lock(&ctx->state_mutex);
mask = ctx->ops->mbox_stat_poll(ctx, POLLOUT | POLLWRNORM);
mask = ctx->ops->mbox_stat_poll(ctx, EPOLLOUT | EPOLLWRNORM);
spu_release(ctx);

return mask;
Expand Down Expand Up @@ -1710,9 +1710,9 @@ static __poll_t spufs_mfc_poll(struct file *file,poll_table *wait)

mask = 0;
if (free_elements & 0xffff)
mask |= POLLOUT | POLLWRNORM;
mask |= EPOLLOUT | EPOLLWRNORM;
if (tagstatus & ctx->tagwait)
mask |= POLLIN | POLLRDNORM;
mask |= EPOLLIN | EPOLLRDNORM;

pr_debug("%s: free %d tagstatus %d tagwait %d\n", __func__,
free_elements, tagstatus, ctx->tagwait);
Expand Down Expand Up @@ -2469,7 +2469,7 @@ static __poll_t spufs_switch_log_poll(struct file *file, poll_table *wait)
return rc;

if (spufs_switch_log_used(ctx) > 0)
mask |= POLLIN;
mask |= EPOLLIN;

spu_release(ctx);

Expand Down
8 changes: 4 additions & 4 deletions arch/powerpc/platforms/cell/spufs/hw_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ static __poll_t spu_hw_mbox_stat_poll(struct spu_context *ctx, __poll_t events)
but first mark any pending interrupts as done so
we don't get woken up unnecessarily */

if (events & (POLLIN | POLLRDNORM)) {
if (events & (EPOLLIN | EPOLLRDNORM)) {
if (stat & 0xff0000)
ret |= POLLIN | POLLRDNORM;
ret |= EPOLLIN | EPOLLRDNORM;
else {
spu_int_stat_clear(spu, 2, CLASS2_MAILBOX_INTR);
spu_int_mask_or(spu, 2, CLASS2_ENABLE_MAILBOX_INTR);
}
}
if (events & (POLLOUT | POLLWRNORM)) {
if (events & (EPOLLOUT | EPOLLWRNORM)) {
if (stat & 0x00ff00)
ret = POLLOUT | POLLWRNORM;
ret = EPOLLOUT | EPOLLWRNORM;
else {
spu_int_stat_clear(spu, 2,
CLASS2_MAILBOX_THRESHOLD_INTR);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/powernv/opal-prd.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static __poll_t opal_prd_poll(struct file *file,
poll_wait(file, &opal_prd_msg_wait, wait);

if (!opal_msg_queue_empty())
return POLLIN | POLLRDNORM;
return EPOLLIN | EPOLLRDNORM;

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/apm_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ static __poll_t do_poll(struct file *fp, poll_table *wait)
return 0;
poll_wait(fp, &apm_waitqueue, wait);
if (!queue_empty(as))
return POLLIN | POLLRDNORM;
return EPOLLIN | EPOLLRDNORM;
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions arch/x86/kernel/cpu/mcheck/dev-mcelog.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ static __poll_t mce_chrdev_poll(struct file *file, poll_table *wait)
{
poll_wait(file, &mce_chrdev_wait, wait);
if (READ_ONCE(mcelog.next))
return POLLIN | POLLRDNORM;
return EPOLLIN | EPOLLRDNORM;
if (!mce_apei_read_done && apei_check_mce())
return POLLIN | POLLRDNORM;
return EPOLLIN | EPOLLRDNORM;
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions block/bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -849,9 +849,9 @@ static __poll_t bsg_poll(struct file *file, poll_table *wait)

spin_lock_irq(&bd->lock);
if (!list_empty(&bd->done_list))
mask |= POLLIN | POLLRDNORM;
mask |= EPOLLIN | EPOLLRDNORM;
if (bd->queued_cmds < bd->max_queue)
mask |= POLLOUT;
mask |= EPOLLOUT;
spin_unlock_irq(&bd->lock);

return mask;
Expand Down
16 changes: 8 additions & 8 deletions crypto/af_alg.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,9 @@ void af_alg_wmem_wakeup(struct sock *sk)
rcu_read_lock();
wq = rcu_dereference(sk->sk_wq);
if (skwq_has_sleeper(wq))
wake_up_interruptible_sync_poll(&wq->wait, POLLIN |
POLLRDNORM |
POLLRDBAND);
wake_up_interruptible_sync_poll(&wq->wait, EPOLLIN |
EPOLLRDNORM |
EPOLLRDBAND);
sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
rcu_read_unlock();
}
Expand Down Expand Up @@ -800,9 +800,9 @@ void af_alg_data_wakeup(struct sock *sk)
rcu_read_lock();
wq = rcu_dereference(sk->sk_wq);
if (skwq_has_sleeper(wq))
wake_up_interruptible_sync_poll(&wq->wait, POLLOUT |
POLLRDNORM |
POLLRDBAND);
wake_up_interruptible_sync_poll(&wq->wait, EPOLLOUT |
EPOLLRDNORM |
EPOLLRDBAND);
sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT);
rcu_read_unlock();
}
Expand Down Expand Up @@ -1076,10 +1076,10 @@ __poll_t af_alg_poll(struct file *file, struct socket *sock,
mask = 0;

if (!ctx->more || ctx->used)
mask |= POLLIN | POLLRDNORM;
mask |= EPOLLIN | EPOLLRDNORM;

if (af_alg_writable(sk))
mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
mask |= EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND;

return mask;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/acpi_dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,9 @@ static __poll_t acpi_aml_poll(struct file *file, poll_table *wait)

poll_wait(file, &acpi_aml_io.wait, wait);
if (acpi_aml_user_readable())
masks |= POLLIN | POLLRDNORM;
masks |= EPOLLIN | EPOLLRDNORM;
if (acpi_aml_user_writable())
masks |= POLLOUT | POLLWRNORM;
masks |= EPOLLOUT | EPOLLWRNORM;

return masks;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/android/binder.c
Original file line number Diff line number Diff line change
Expand Up @@ -4371,7 +4371,7 @@ static int binder_thread_release(struct binder_proc *proc,
*/
if ((thread->looper & BINDER_LOOPER_STATE_POLL) &&
waitqueue_active(&thread->wait)) {
wake_up_poll(&thread->wait, POLLHUP | POLLFREE);
wake_up_poll(&thread->wait, EPOLLHUP | POLLFREE);
}

binder_inner_proc_unlock(thread->proc);
Expand Down Expand Up @@ -4401,7 +4401,7 @@ static __poll_t binder_poll(struct file *filp,
poll_wait(filp, &thread->wait, wait);

if (binder_has_work(thread, wait_for_proc_work))
return POLLIN;
return EPOLLIN;

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/bluetooth/hci_vhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ static __poll_t vhci_poll(struct file *file, poll_table *wait)
poll_wait(file, &data->read_wait, wait);

if (!skb_queue_empty(&data->readq))
return POLLIN | POLLRDNORM;
return EPOLLIN | EPOLLRDNORM;

return POLLOUT | POLLWRNORM;
return EPOLLOUT | EPOLLWRNORM;
}

static void vhci_open_timeout(struct work_struct *work)
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/apm-emulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ static __poll_t apm_poll(struct file *fp, poll_table * wait)
struct apm_user *as = fp->private_data;

poll_wait(fp, &apm_waitqueue, wait);
return queue_empty(&as->queue) ? 0 : POLLIN | POLLRDNORM;
return queue_empty(&as->queue) ? 0 : EPOLLIN | EPOLLRDNORM;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/dsp56k.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ static __poll_t dsp56k_poll(struct file *file, poll_table *wait)
{
case DSP56K_DEV_56001:
/* poll_wait(file, ???, wait); */
return POLLIN | POLLRDNORM | POLLOUT;
return EPOLLIN | EPOLLRDNORM | EPOLLOUT;

default:
printk("DSP56k driver: Unknown minor device: %d\n", dev);
Expand Down
6 changes: 3 additions & 3 deletions drivers/char/dtlk.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#include <linux/uaccess.h> /* for get_user, etc. */
#include <linux/wait.h> /* for wait_queue */
#include <linux/init.h> /* for __init, module_{init,exit} */
#include <linux/poll.h> /* for POLLIN, etc. */
#include <linux/poll.h> /* for EPOLLIN, etc. */
#include <linux/dtlk.h> /* local header file for DoubleTalk values */

#ifdef TRACING
Expand Down Expand Up @@ -244,11 +244,11 @@ static __poll_t dtlk_poll(struct file *file, poll_table * wait)

if (dtlk_has_indexing && dtlk_readable()) {
del_timer(&dtlk_timer);
mask = POLLIN | POLLRDNORM;
mask = EPOLLIN | EPOLLRDNORM;
}
if (dtlk_writeable()) {
del_timer(&dtlk_timer);
mask |= POLLOUT | POLLWRNORM;
mask |= EPOLLOUT | EPOLLWRNORM;
}
/* there are no exception conditions */

Expand Down
2 changes: 1 addition & 1 deletion drivers/char/hpet.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ static __poll_t hpet_poll(struct file *file, poll_table * wait)
spin_unlock_irq(&hpet_lock);

if (v != 0)
return POLLIN | POLLRDNORM;
return EPOLLIN | EPOLLRDNORM;

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/ipmi/bt-bmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@ static __poll_t bt_bmc_poll(struct file *file, poll_table *wait)
ctrl = bt_inb(bt_bmc, BT_CTRL);

if (ctrl & BT_CTRL_H2B_ATN)
mask |= POLLIN;
mask |= EPOLLIN;

if (!(ctrl & (BT_CTRL_H_BUSY | BT_CTRL_B2H_ATN)))
mask |= POLLOUT;
mask |= EPOLLOUT;

return mask;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ipmi/ipmi_devintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static __poll_t ipmi_poll(struct file *file, poll_table *wait)
spin_lock_irqsave(&priv->recv_msg_lock, flags);

if (!list_empty(&(priv->recv_msgs)))
mask |= (POLLIN | POLLRDNORM);
mask |= (EPOLLIN | EPOLLRDNORM);

spin_unlock_irqrestore(&priv->recv_msg_lock, flags);

Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ipmi/ipmi_watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ static __poll_t ipmi_poll(struct file *file, poll_table *wait)

spin_lock(&ipmi_read_lock);
if (data_to_read)
mask |= (POLLIN | POLLRDNORM);
mask |= (EPOLLIN | EPOLLRDNORM);
spin_unlock(&ipmi_read_lock);

return mask;
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/pcmcia/cm4040_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,9 @@ static __poll_t cm4040_poll(struct file *filp, poll_table *wait)
poll_wait(filp, &dev->poll_wait, wait);

if (test_and_clear_bit(BS_READABLE, &dev->buffer_status))
mask |= POLLIN | POLLRDNORM;
mask |= EPOLLIN | EPOLLRDNORM;
if (test_and_clear_bit(BS_WRITABLE, &dev->buffer_status))
mask |= POLLOUT | POLLWRNORM;
mask |= EPOLLOUT | EPOLLWRNORM;

DEBUGP(2, dev, "<- cm4040_poll(%u)\n", mask);

Expand Down
Loading

0 comments on commit a9a0884

Please sign in to comment.