Skip to content

Commit 168fe32

Browse files
committed
Merge branch 'misc.poll' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull poll annotations from Al Viro: "This introduces a __bitwise type for POLL### bitmap, and propagates the annotations through the tree. Most of that stuff is as simple as 'make ->poll() instances return __poll_t and do the same to local variables used to hold the future return value'. Some of the obvious brainos found in process are fixed (e.g. POLLIN misspelled as POLL_IN). At that point the amount of sparse warnings is low and most of them are for genuine bugs - e.g. ->poll() instance deciding to return -EINVAL instead of a bitmap. I hadn't touched those in this series - it's large enough as it is. Another problem it has caught was eventpoll() ABI mess; select.c and eventpoll.c assumed that corresponding POLL### and EPOLL### were equal. That's true for some, but not all of them - EPOLL### are arch-independent, but POLL### are not. The last commit in this series separates userland POLL### values from the (now arch-independent) kernel-side ones, converting between them in the few places where they are copied to/from userland. AFAICS, this is the least disruptive fix preserving poll(2) ABI and making epoll() work on all architectures. As it is, it's simply broken on sparc - try to give it EPOLLWRNORM and it will trigger only on what would've triggered EPOLLWRBAND on other architectures. EPOLLWRBAND and EPOLLRDHUP, OTOH, are never triggered at all on sparc. With this patch they should work consistently on all architectures" * 'misc.poll' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (37 commits) make kernel-side POLL... arch-independent eventpoll: no need to mask the result of epi_item_poll() again eventpoll: constify struct epoll_event pointers debugging printk in sg_poll() uses %x to print POLL... bitmap annotate poll(2) guts 9p: untangle ->poll() mess ->si_band gets POLL... bitmap stored into a user-visible long field ring_buffer_poll_wait() return value used as return value of ->poll() the rest of drivers/*: annotate ->poll() instances media: annotate ->poll() instances fs: annotate ->poll() instances ipc, kernel, mm: annotate ->poll() instances net: annotate ->poll() instances apparmor: annotate ->poll() instances tomoyo: annotate ->poll() instances sound: annotate ->poll() instances acpi: annotate ->poll() instances crypto: annotate ->poll() instances block: annotate ->poll() instances x86: annotate ->poll() instances ...
2 parents 13ddd16 + c71d227 commit 168fe32

File tree

387 files changed

+928
-810
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

387 files changed

+928
-810
lines changed

arch/alpha/include/uapi/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
include include/uapi/asm-generic/Kbuild.asm
33

44
generic-y += bpf_perf_event.h
5+
generic-y += poll.h

arch/alpha/include/uapi/asm/poll.h

Lines changed: 0 additions & 2 deletions
This file was deleted.

arch/blackfin/include/uapi/asm/poll.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,25 @@
99
#ifndef _UAPI__BFIN_POLL_H
1010
#define _UAPI__BFIN_POLL_H
1111

12-
#define POLLWRNORM 4 /* POLLOUT */
13-
#define POLLWRBAND 256
12+
#ifndef __KERNEL__
13+
#define POLLWRNORM POLLOUT
14+
#define POLLWRBAND (__force __poll_t)256
15+
#else
16+
#define __ARCH_HAS_MANGLED_POLL
17+
static inline __u16 mangle_poll(__poll_t val)
18+
{
19+
__u16 v = (__force __u16)val;
20+
/* bit 9 -> bit 8, bit 8 -> bit 2 */
21+
return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6);
22+
}
23+
24+
static inline __poll_t demangle_poll(__u16 v)
25+
{
26+
/* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */
27+
return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) |
28+
((v & 4) << 6));
29+
}
30+
#endif
1431

1532
#include <asm-generic/poll.h>
1633

arch/cris/arch-v10/drivers/gpio.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static ssize_t gpio_write(struct file *file, const char __user *buf,
5050
size_t count, loff_t *off);
5151
static int gpio_open(struct inode *inode, struct file *filp);
5252
static int gpio_release(struct inode *inode, struct file *filp);
53-
static unsigned int gpio_poll(struct file *filp, struct poll_table_struct *wait);
53+
static __poll_t gpio_poll(struct file *filp, struct poll_table_struct *wait);
5454

5555
/* private data per open() of this driver */
5656

@@ -141,9 +141,9 @@ static unsigned long dir_g_shadow; /* 1=output */
141141
#define USE_PORTS(priv) ((priv)->minor <= GPIO_MINOR_B)
142142

143143

144-
static unsigned int gpio_poll(struct file *file, poll_table *wait)
144+
static __poll_t gpio_poll(struct file *file, poll_table *wait)
145145
{
146-
unsigned int mask = 0;
146+
__poll_t mask = 0;
147147
struct gpio_private *priv = file->private_data;
148148
unsigned long data;
149149
unsigned long flags;

arch/cris/arch-v10/drivers/sync_serial.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static inline int sync_data_avail(struct sync_port *port);
157157

158158
static int sync_serial_open(struct inode *inode, struct file *file);
159159
static int sync_serial_release(struct inode *inode, struct file *file);
160-
static unsigned int sync_serial_poll(struct file *filp, poll_table *wait);
160+
static __poll_t sync_serial_poll(struct file *filp, poll_table *wait);
161161

162162
static long sync_serial_ioctl(struct file *file,
163163
unsigned int cmd, unsigned long arg);
@@ -654,12 +654,12 @@ static int sync_serial_release(struct inode *inode, struct file *file)
654654

655655

656656

657-
static unsigned int sync_serial_poll(struct file *file, poll_table *wait)
657+
static __poll_t sync_serial_poll(struct file *file, poll_table *wait)
658658
{
659659
int dev = MINOR(file_inode(file)->i_rdev);
660-
unsigned int mask = 0;
660+
__poll_t mask = 0;
661661
struct sync_port *port;
662-
DEBUGPOLL(static unsigned int prev_mask = 0);
662+
DEBUGPOLL(static __poll_t prev_mask = 0);
663663

664664
port = &ports[dev];
665665
poll_wait(file, &port->out_wait_q, wait);

arch/cris/arch-v32/drivers/sync_serial.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static inline int sync_data_avail(struct sync_port *port);
178178

179179
static int sync_serial_open(struct inode *, struct file *);
180180
static int sync_serial_release(struct inode *, struct file *);
181-
static unsigned int sync_serial_poll(struct file *filp, poll_table *wait);
181+
static __poll_t sync_serial_poll(struct file *filp, poll_table *wait);
182182

183183
static long sync_serial_ioctl(struct file *file,
184184
unsigned int cmd, unsigned long arg);
@@ -555,13 +555,13 @@ static int sync_serial_release(struct inode *inode, struct file *file)
555555
return 0;
556556
}
557557

558-
static unsigned int sync_serial_poll(struct file *file, poll_table *wait)
558+
static __poll_t sync_serial_poll(struct file *file, poll_table *wait)
559559
{
560560
int dev = iminor(file_inode(file));
561-
unsigned int mask = 0;
561+
__poll_t mask = 0;
562562
struct sync_port *port;
563563
DEBUGPOLL(
564-
static unsigned int prev_mask;
564+
static __poll_t prev_mask;
565565
);
566566

567567
port = &ports[dev];

arch/frv/include/uapi/asm/poll.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,27 @@
22
#ifndef _ASM_POLL_H
33
#define _ASM_POLL_H
44

5+
#ifndef __KERNEL__
56
#define POLLWRNORM POLLOUT
6-
#define POLLWRBAND 256
7+
#define POLLWRBAND (__force __poll_t)256
8+
#else
9+
#define __ARCH_HAS_MANGLED_POLL
10+
static inline __u16 mangle_poll(__poll_t val)
11+
{
12+
__u16 v = (__force __u16)val;
13+
/* bit 9 -> bit 8, bit 8 -> bit 2 */
14+
return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6);
15+
}
716

8-
#include <asm-generic/poll.h>
17+
static inline __poll_t demangle_poll(__u16 v)
18+
{
19+
/* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */
20+
return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) |
21+
((v & 4) << 6));
22+
}
23+
#endif
924

25+
#include <asm-generic/poll.h>
1026
#undef POLLREMOVE
1127

1228
#endif
13-

arch/ia64/include/uapi/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ include include/uapi/asm-generic/Kbuild.asm
33

44
generic-y += bpf_perf_event.h
55
generic-y += kvm_para.h
6+
generic-y += poll.h

arch/ia64/include/uapi/asm/poll.h

Lines changed: 0 additions & 2 deletions
This file was deleted.

arch/ia64/kernel/perfmon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,12 +1644,12 @@ pfm_write(struct file *file, const char __user *ubuf,
16441644
return -EINVAL;
16451645
}
16461646

1647-
static unsigned int
1647+
static __poll_t
16481648
pfm_poll(struct file *filp, poll_table * wait)
16491649
{
16501650
pfm_context_t *ctx;
16511651
unsigned long flags;
1652-
unsigned int mask = 0;
1652+
__poll_t mask = 0;
16531653

16541654
if (PFM_IS_FILE(filp) == 0) {
16551655
printk(KERN_ERR "perfmon: pfm_poll: bad magic [%d]\n", task_pid_nr(current));

arch/m32r/include/uapi/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ include include/uapi/asm-generic/Kbuild.asm
33

44
generic-y += bpf_perf_event.h
55
generic-y += kvm_para.h
6+
generic-y += poll.h
67
generic-y += siginfo.h

arch/m32r/include/uapi/asm/poll.h

Lines changed: 0 additions & 2 deletions
This file was deleted.

arch/m68k/include/uapi/asm/poll.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,25 @@
22
#ifndef __m68k_POLL_H
33
#define __m68k_POLL_H
44

5+
#ifndef __KERNEL__
56
#define POLLWRNORM POLLOUT
6-
#define POLLWRBAND 256
7+
#define POLLWRBAND (__force __poll_t)256
8+
#else
9+
#define __ARCH_HAS_MANGLED_POLL
10+
static inline __u16 mangle_poll(__poll_t val)
11+
{
12+
__u16 v = (__force __u16)val;
13+
/* bit 9 -> bit 8, bit 8 -> bit 2 */
14+
return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6);
15+
}
16+
17+
static inline __poll_t demangle_poll(__u16 v)
18+
{
19+
/* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */
20+
return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) |
21+
((v & 4) << 6));
22+
}
23+
#endif
724

825
#include <asm-generic/poll.h>
926

arch/mips/include/uapi/asm/poll.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,25 @@
22
#ifndef __ASM_POLL_H
33
#define __ASM_POLL_H
44

5+
#ifndef __KERNEL__
56
#define POLLWRNORM POLLOUT
6-
#define POLLWRBAND 0x0100
7+
#define POLLWRBAND (__force __poll_t)0x0100
8+
#else
9+
#define __ARCH_HAS_MANGLED_POLL
10+
static inline __u16 mangle_poll(__poll_t val)
11+
{
12+
__u16 v = (__force __u16)val;
13+
/* bit 9 -> bit 8, bit 8 -> bit 2 */
14+
return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6);
15+
}
16+
17+
static inline __poll_t demangle_poll(__u16 v)
18+
{
19+
/* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */
20+
return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) |
21+
((v & 4) << 6));
22+
}
23+
#endif
724

825
#include <asm-generic/poll.h>
926

arch/mips/kernel/rtlx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,10 @@ static int file_release(struct inode *inode, struct file *filp)
336336
return rtlx_release(iminor(inode));
337337
}
338338

339-
static unsigned int file_poll(struct file *file, poll_table *wait)
339+
static __poll_t file_poll(struct file *file, poll_table *wait)
340340
{
341341
int minor = iminor(file_inode(file));
342-
unsigned int mask = 0;
342+
__poll_t mask = 0;
343343

344344
poll_wait(file, &channel_wqs[minor].rt_queue, wait);
345345
poll_wait(file, &channel_wqs[minor].lx_queue, wait);

arch/mn10300/include/uapi/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
include include/uapi/asm-generic/Kbuild.asm
33

44
generic-y += bpf_perf_event.h
5+
generic-y += poll.h
56
generic-y += siginfo.h

arch/mn10300/include/uapi/asm/poll.h

Lines changed: 0 additions & 2 deletions
This file was deleted.

arch/powerpc/kernel/rtasd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static ssize_t rtas_log_read(struct file * file, char __user * buf,
388388
return error;
389389
}
390390

391-
static unsigned int rtas_log_poll(struct file *file, poll_table * wait)
391+
static __poll_t rtas_log_poll(struct file *file, poll_table * wait)
392392
{
393393
poll_wait(file, &rtas_log_wait, wait);
394394
if (rtas_log_size)

arch/powerpc/platforms/cell/spufs/backing_ops.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ static u32 spu_backing_mbox_stat_read(struct spu_context *ctx)
8686
return ctx->csa.prob.mb_stat_R;
8787
}
8888

89-
static unsigned int spu_backing_mbox_stat_poll(struct spu_context *ctx,
90-
unsigned int events)
89+
static __poll_t spu_backing_mbox_stat_poll(struct spu_context *ctx,
90+
__poll_t events)
9191
{
92-
int ret;
92+
__poll_t ret;
9393
u32 stat;
9494

9595
ret = 0;

arch/powerpc/platforms/cell/spufs/file.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -762,10 +762,10 @@ static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
762762
return count;
763763
}
764764

765-
static unsigned int spufs_ibox_poll(struct file *file, poll_table *wait)
765+
static __poll_t spufs_ibox_poll(struct file *file, poll_table *wait)
766766
{
767767
struct spu_context *ctx = file->private_data;
768-
unsigned int mask;
768+
__poll_t mask;
769769

770770
poll_wait(file, &ctx->ibox_wq, wait);
771771

@@ -898,10 +898,10 @@ static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
898898
return count;
899899
}
900900

901-
static unsigned int spufs_wbox_poll(struct file *file, poll_table *wait)
901+
static __poll_t spufs_wbox_poll(struct file *file, poll_table *wait)
902902
{
903903
struct spu_context *ctx = file->private_data;
904-
unsigned int mask;
904+
__poll_t mask;
905905

906906
poll_wait(file, &ctx->wbox_wq, wait);
907907

@@ -1690,11 +1690,11 @@ static ssize_t spufs_mfc_write(struct file *file, const char __user *buffer,
16901690
return ret;
16911691
}
16921692

1693-
static unsigned int spufs_mfc_poll(struct file *file,poll_table *wait)
1693+
static __poll_t spufs_mfc_poll(struct file *file,poll_table *wait)
16941694
{
16951695
struct spu_context *ctx = file->private_data;
16961696
u32 free_elements, tagstatus;
1697-
unsigned int mask;
1697+
__poll_t mask;
16981698

16991699
poll_wait(file, &ctx->mfc_wq, wait);
17001700

@@ -2455,11 +2455,11 @@ static ssize_t spufs_switch_log_read(struct file *file, char __user *buf,
24552455
return cnt == 0 ? error : cnt;
24562456
}
24572457

2458-
static unsigned int spufs_switch_log_poll(struct file *file, poll_table *wait)
2458+
static __poll_t spufs_switch_log_poll(struct file *file, poll_table *wait)
24592459
{
24602460
struct inode *inode = file_inode(file);
24612461
struct spu_context *ctx = SPUFS_I(inode)->i_ctx;
2462-
unsigned int mask = 0;
2462+
__poll_t mask = 0;
24632463
int rc;
24642464

24652465
poll_wait(file, &ctx->switch_log->wait, wait);

arch/powerpc/platforms/cell/spufs/hw_ops.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,10 @@ static u32 spu_hw_mbox_stat_read(struct spu_context *ctx)
5656
return in_be32(&ctx->spu->problem->mb_stat_R);
5757
}
5858

59-
static unsigned int spu_hw_mbox_stat_poll(struct spu_context *ctx,
60-
unsigned int events)
59+
static __poll_t spu_hw_mbox_stat_poll(struct spu_context *ctx, __poll_t events)
6160
{
6261
struct spu *spu = ctx->spu;
63-
int ret = 0;
62+
__poll_t ret = 0;
6463
u32 stat;
6564

6665
spin_lock_irq(&spu->register_lock);

arch/powerpc/platforms/cell/spufs/spufs.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,7 @@ struct mfc_dma_command {
185185
struct spu_context_ops {
186186
int (*mbox_read) (struct spu_context * ctx, u32 * data);
187187
u32(*mbox_stat_read) (struct spu_context * ctx);
188-
unsigned int (*mbox_stat_poll)(struct spu_context *ctx,
189-
unsigned int events);
188+
__poll_t (*mbox_stat_poll)(struct spu_context *ctx, __poll_t events);
190189
int (*ibox_read) (struct spu_context * ctx, u32 * data);
191190
int (*wbox_write) (struct spu_context * ctx, u32 data);
192191
u32(*signal1_read) (struct spu_context * ctx);

arch/powerpc/platforms/powernv/opal-prd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static bool opal_msg_queue_empty(void)
147147
return ret;
148148
}
149149

150-
static unsigned int opal_prd_poll(struct file *file,
150+
static __poll_t opal_prd_poll(struct file *file,
151151
struct poll_table_struct *wait)
152152
{
153153
poll_wait(file, &opal_prd_msg_wait, wait);

arch/score/include/uapi/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
include include/uapi/asm-generic/Kbuild.asm
33

44
generic-y += bpf_perf_event.h
5+
generic-y += poll.h
56
generic-y += siginfo.h

arch/score/include/uapi/asm/poll.h

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)