summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2018-02-01 15:13:18 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-02-11 17:37:22 -0500
commit7a163b2195cda0cddf47b5caf14a7229d4e2bea3 (patch)
tree5867e113f0232679d5125ca7d42ae4558dd0d554
parenta9a08845e9acbd224e4ee466f5c1275ed50054e8 (diff)
unify {de,}mangle_poll(), get rid of kernel-side POLL...
except, again, POLLFREE and POLL_BUSY_LOOP. With this, we finally get to the promised end result: - POLL{IN,OUT,...} are plain integers and *not* in __poll_t, so any stray instances of ->poll() still using those will be caught by sparse. - eventpoll.c and select.c warning-free wrt __poll_t - no more kernel-side definitions of POLL... - userland ones are visible through the entire kernel (and used pretty much only for mangle/demangle) - same behavior as after the first series (i.e. sparc et.al. epoll(2) working correctly). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/blackfin/include/uapi/asm/poll.h19
-rw-r--r--arch/frv/include/uapi/asm/poll.h19
-rw-r--r--arch/m68k/include/uapi/asm/poll.h19
-rw-r--r--arch/mips/include/uapi/asm/poll.h19
-rw-r--r--arch/sparc/include/uapi/asm/poll.h28
-rw-r--r--arch/xtensa/include/uapi/asm/poll.h21
-rw-r--r--include/linux/poll.h24
-rw-r--r--include/uapi/asm-generic/poll.h40
8 files changed, 47 insertions, 142 deletions
diff --git a/arch/blackfin/include/uapi/asm/poll.h b/arch/blackfin/include/uapi/asm/poll.h
index 3b162f2d2970..cd2f1a78aba5 100644
--- a/arch/blackfin/include/uapi/asm/poll.h
+++ b/arch/blackfin/include/uapi/asm/poll.h
@@ -9,25 +9,8 @@
9#ifndef _UAPI__BFIN_POLL_H 9#ifndef _UAPI__BFIN_POLL_H
10#define _UAPI__BFIN_POLL_H 10#define _UAPI__BFIN_POLL_H
11 11
12#ifndef __KERNEL__
13#define POLLWRNORM POLLOUT 12#define POLLWRNORM POLLOUT
14#define POLLWRBAND (__force __poll_t)256 13#define POLLWRBAND 256
15#else
16#define __ARCH_HAS_MANGLED_POLL
17static 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
24static 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
31 14
32#include <asm-generic/poll.h> 15#include <asm-generic/poll.h>
33 16
diff --git a/arch/frv/include/uapi/asm/poll.h b/arch/frv/include/uapi/asm/poll.h
index a44c8f0ebee7..f55b45f475ec 100644
--- a/arch/frv/include/uapi/asm/poll.h
+++ b/arch/frv/include/uapi/asm/poll.h
@@ -2,25 +2,8 @@
2#ifndef _ASM_POLL_H 2#ifndef _ASM_POLL_H
3#define _ASM_POLL_H 3#define _ASM_POLL_H
4 4
5#ifndef __KERNEL__
6#define POLLWRNORM POLLOUT 5#define POLLWRNORM POLLOUT
7#define POLLWRBAND (__force __poll_t)256 6#define POLLWRBAND 256
8#else
9#define __ARCH_HAS_MANGLED_POLL
10static 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
17static 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
24 7
25#include <asm-generic/poll.h> 8#include <asm-generic/poll.h>
26#undef POLLREMOVE 9#undef POLLREMOVE
diff --git a/arch/m68k/include/uapi/asm/poll.h b/arch/m68k/include/uapi/asm/poll.h
index d8be239e8141..c3e3fcc15e1d 100644
--- a/arch/m68k/include/uapi/asm/poll.h
+++ b/arch/m68k/include/uapi/asm/poll.h
@@ -2,25 +2,8 @@
2#ifndef __m68k_POLL_H 2#ifndef __m68k_POLL_H
3#define __m68k_POLL_H 3#define __m68k_POLL_H
4 4
5#ifndef __KERNEL__
6#define POLLWRNORM POLLOUT 5#define POLLWRNORM POLLOUT
7#define POLLWRBAND (__force __poll_t)256 6#define POLLWRBAND 256
8#else
9#define __ARCH_HAS_MANGLED_POLL
10static 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
17static 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
24 7
25#include <asm-generic/poll.h> 8#include <asm-generic/poll.h>
26 9
diff --git a/arch/mips/include/uapi/asm/poll.h b/arch/mips/include/uapi/asm/poll.h
index 3173f8917128..ad289d7b7434 100644
--- a/arch/mips/include/uapi/asm/poll.h
+++ b/arch/mips/include/uapi/asm/poll.h
@@ -2,25 +2,8 @@
2#ifndef __ASM_POLL_H 2#ifndef __ASM_POLL_H
3#define __ASM_POLL_H 3#define __ASM_POLL_H
4 4
5#ifndef __KERNEL__
6#define POLLWRNORM POLLOUT 5#define POLLWRNORM POLLOUT
7#define POLLWRBAND (__force __poll_t)0x0100 6#define POLLWRBAND 0x0100
8#else
9#define __ARCH_HAS_MANGLED_POLL
10static 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
17static 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
24 7
25#include <asm-generic/poll.h> 8#include <asm-generic/poll.h>
26 9
diff --git a/arch/sparc/include/uapi/asm/poll.h b/arch/sparc/include/uapi/asm/poll.h
index 2a81e79aa3ea..72356c999125 100644
--- a/arch/sparc/include/uapi/asm/poll.h
+++ b/arch/sparc/include/uapi/asm/poll.h
@@ -2,31 +2,11 @@
2#ifndef __SPARC_POLL_H 2#ifndef __SPARC_POLL_H
3#define __SPARC_POLL_H 3#define __SPARC_POLL_H
4 4
5#ifndef __KERNEL__
6#define POLLWRNORM POLLOUT 5#define POLLWRNORM POLLOUT
7#define POLLWRBAND (__force __poll_t)256 6#define POLLWRBAND 256
8#define POLLMSG (__force __poll_t)512 7#define POLLMSG 512
9#define POLLREMOVE (__force __poll_t)1024 8#define POLLREMOVE 1024
10#define POLLRDHUP (__force __poll_t)2048 9#define POLLRDHUP 2048
11#else
12#define __ARCH_HAS_MANGLED_POLL
13static inline __u16 mangle_poll(__poll_t val)
14{
15 __u16 v = (__force __u16)val;
16 /* bit 9 -> bit 8, bit 8 -> bit 2, bit 13 -> bit 11 */
17 return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6) |
18 ((v & 0x2000) >> 2);
19
20
21}
22
23static inline __poll_t demangle_poll(__u16 v)
24{
25 /* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */
26 return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) |
27 ((v & 4) << 6) | ((v & 0x800) << 2));
28}
29#endif
30 10
31#include <asm-generic/poll.h> 11#include <asm-generic/poll.h>
32 12
diff --git a/arch/xtensa/include/uapi/asm/poll.h b/arch/xtensa/include/uapi/asm/poll.h
index e3246d41182c..4d249040b33d 100644
--- a/arch/xtensa/include/uapi/asm/poll.h
+++ b/arch/xtensa/include/uapi/asm/poll.h
@@ -12,26 +12,9 @@
12#ifndef _XTENSA_POLL_H 12#ifndef _XTENSA_POLL_H
13#define _XTENSA_POLL_H 13#define _XTENSA_POLL_H
14 14
15#ifndef __KERNEL__
16#define POLLWRNORM POLLOUT 15#define POLLWRNORM POLLOUT
17#define POLLWRBAND (__force __poll_t)0x0100 16#define POLLWRBAND 0x0100
18#define POLLREMOVE (__force __poll_t)0x0800 17#define POLLREMOVE 0x0800
19#else
20#define __ARCH_HAS_MANGLED_POLL
21static inline __u16 mangle_poll(__poll_t val)
22{
23 __u16 v = (__force __u16)val;
24 /* bit 9 -> bit 8, bit 8 -> bit 2 */
25 return (v & ~0x300) | ((v & 0x200) >> 1) | ((v & 0x100) >> 6);
26}
27
28static inline __poll_t demangle_poll(__u16 v)
29{
30 /* bit 8 -> bit 9, bit 2 -> bits 2 and 8 */
31 return (__force __poll_t)((v & ~0x100) | ((v & 0x100) << 1) |
32 ((v & 4) << 6));
33}
34#endif
35 18
36#include <asm-generic/poll.h> 19#include <asm-generic/poll.h>
37 20
diff --git a/include/linux/poll.h b/include/linux/poll.h
index d23104b32931..f45ebd017eaa 100644
--- a/include/linux/poll.h
+++ b/include/linux/poll.h
@@ -108,4 +108,28 @@ extern int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp,
108extern int poll_select_set_timeout(struct timespec64 *to, time64_t sec, 108extern int poll_select_set_timeout(struct timespec64 *to, time64_t sec,
109 long nsec); 109 long nsec);
110 110
111#define __MAP(v, from, to) \
112 (from < to ? (v & from) * (to/from) : (v & from) / (from/to))
113
114static inline __u16 mangle_poll(__poll_t val)
115{
116 __u16 v = (__force __u16)val;
117#define M(X) __MAP(v, (__force __u16)EPOLL##X, POLL##X)
118 return M(IN) | M(OUT) | M(PRI) | M(ERR) | M(NVAL) |
119 M(RDNORM) | M(RDBAND) | M(WRNORM) | M(WRBAND) |
120 M(HUP) | M(RDHUP) | M(MSG);
121#undef M
122}
123
124static inline __poll_t demangle_poll(u16 val)
125{
126#define M(X) (__force __poll_t)__MAP(val, POLL##X, (__force __u16)EPOLL##X)
127 return M(IN) | M(OUT) | M(PRI) | M(ERR) | M(NVAL) |
128 M(RDNORM) | M(RDBAND) | M(WRNORM) | M(WRBAND) |
129 M(HUP) | M(RDHUP) | M(MSG);
130#undef M
131}
132#undef __MAP
133
134
111#endif /* _LINUX_POLL_H */ 135#endif /* _LINUX_POLL_H */
diff --git a/include/uapi/asm-generic/poll.h b/include/uapi/asm-generic/poll.h
index 639fade14b23..41b509f410bf 100644
--- a/include/uapi/asm-generic/poll.h
+++ b/include/uapi/asm-generic/poll.h
@@ -3,50 +3,36 @@
3#define __ASM_GENERIC_POLL_H 3#define __ASM_GENERIC_POLL_H
4 4
5/* These are specified by iBCS2 */ 5/* These are specified by iBCS2 */
6#define POLLIN (__force __poll_t)0x0001 6#define POLLIN 0x0001
7#define POLLPRI (__force __poll_t)0x0002 7#define POLLPRI 0x0002
8#define POLLOUT (__force __poll_t)0x0004 8#define POLLOUT 0x0004
9#define POLLERR (__force __poll_t)0x0008 9#define POLLERR 0x0008
10#define POLLHUP (__force __poll_t)0x0010 10#define POLLHUP 0x0010
11#define POLLNVAL (__force __poll_t)0x0020 11#define POLLNVAL 0x0020
12 12
13/* The rest seem to be more-or-less nonstandard. Check them! */ 13/* The rest seem to be more-or-less nonstandard. Check them! */
14#define POLLRDNORM (__force __poll_t)0x0040 14#define POLLRDNORM 0x0040
15#define POLLRDBAND (__force __poll_t)0x0080 15#define POLLRDBAND 0x0080
16#ifndef POLLWRNORM 16#ifndef POLLWRNORM
17#define POLLWRNORM (__force __poll_t)0x0100 17#define POLLWRNORM 0x0100
18#endif 18#endif
19#ifndef POLLWRBAND 19#ifndef POLLWRBAND
20#define POLLWRBAND (__force __poll_t)0x0200 20#define POLLWRBAND 0x0200
21#endif 21#endif
22#ifndef POLLMSG 22#ifndef POLLMSG
23#define POLLMSG (__force __poll_t)0x0400 23#define POLLMSG 0x0400
24#endif 24#endif
25#ifndef POLLREMOVE 25#ifndef POLLREMOVE
26#define POLLREMOVE (__force __poll_t)0x1000 26#define POLLREMOVE 0x1000
27#endif 27#endif
28#ifndef POLLRDHUP 28#ifndef POLLRDHUP
29#define POLLRDHUP (__force __poll_t)0x2000 29#define POLLRDHUP 0x2000
30#endif 30#endif
31 31
32#define POLLFREE (__force __poll_t)0x4000 /* currently only for epoll */ 32#define POLLFREE (__force __poll_t)0x4000 /* currently only for epoll */
33 33
34#define POLL_BUSY_LOOP (__force __poll_t)0x8000 34#define POLL_BUSY_LOOP (__force __poll_t)0x8000
35 35
36#ifdef __KERNEL__
37#ifndef __ARCH_HAS_MANGLED_POLL
38static inline __u16 mangle_poll(__poll_t val)
39{
40 return (__force __u16)val;
41}
42
43static inline __poll_t demangle_poll(__u16 v)
44{
45 return (__force __poll_t)v;
46}
47#endif
48#endif
49
50struct pollfd { 36struct pollfd {
51 int fd; 37 int fd;
52 short events; 38 short events;