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>

authored by Al Viro and committed by Linus Torvalds 7a163b21 a9a08845

Changed files
+47 -142
arch
blackfin
include
uapi
asm
frv
include
uapi
asm
m68k
include
uapi
asm
mips
include
uapi
asm
sparc
include
uapi
asm
xtensa
include
uapi
asm
include
linux
uapi
asm-generic
+1 -18
arch/blackfin/include/uapi/asm/poll.h
··· 9 9 #ifndef _UAPI__BFIN_POLL_H 10 10 #define _UAPI__BFIN_POLL_H 11 11 12 - #ifndef __KERNEL__ 13 12 #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 13 + #define POLLWRBAND 256 31 14 32 15 #include <asm-generic/poll.h> 33 16
+1 -18
arch/frv/include/uapi/asm/poll.h
··· 2 2 #ifndef _ASM_POLL_H 3 3 #define _ASM_POLL_H 4 4 5 - #ifndef __KERNEL__ 6 5 #define POLLWRNORM POLLOUT 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 6 + #define POLLWRBAND 256 24 7 25 8 #include <asm-generic/poll.h> 26 9 #undef POLLREMOVE
+1 -18
arch/m68k/include/uapi/asm/poll.h
··· 2 2 #ifndef __m68k_POLL_H 3 3 #define __m68k_POLL_H 4 4 5 - #ifndef __KERNEL__ 6 5 #define POLLWRNORM POLLOUT 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 6 + #define POLLWRBAND 256 24 7 25 8 #include <asm-generic/poll.h> 26 9
+1 -18
arch/mips/include/uapi/asm/poll.h
··· 2 2 #ifndef __ASM_POLL_H 3 3 #define __ASM_POLL_H 4 4 5 - #ifndef __KERNEL__ 6 5 #define POLLWRNORM POLLOUT 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 6 + #define POLLWRBAND 0x0100 24 7 25 8 #include <asm-generic/poll.h> 26 9
+4 -24
arch/sparc/include/uapi/asm/poll.h
··· 2 2 #ifndef __SPARC_POLL_H 3 3 #define __SPARC_POLL_H 4 4 5 - #ifndef __KERNEL__ 6 5 #define POLLWRNORM POLLOUT 7 - #define POLLWRBAND (__force __poll_t)256 8 - #define POLLMSG (__force __poll_t)512 9 - #define POLLREMOVE (__force __poll_t)1024 10 - #define POLLRDHUP (__force __poll_t)2048 11 - #else 12 - #define __ARCH_HAS_MANGLED_POLL 13 - static 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 - 23 - static 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 6 + #define POLLWRBAND 256 7 + #define POLLMSG 512 8 + #define POLLREMOVE 1024 9 + #define POLLRDHUP 2048 30 10 31 11 #include <asm-generic/poll.h> 32 12
+2 -19
arch/xtensa/include/uapi/asm/poll.h
··· 12 12 #ifndef _XTENSA_POLL_H 13 13 #define _XTENSA_POLL_H 14 14 15 - #ifndef __KERNEL__ 16 15 #define POLLWRNORM POLLOUT 17 - #define POLLWRBAND (__force __poll_t)0x0100 18 - #define POLLREMOVE (__force __poll_t)0x0800 19 - #else 20 - #define __ARCH_HAS_MANGLED_POLL 21 - static 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 - 28 - static 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 16 + #define POLLWRBAND 0x0100 17 + #define POLLREMOVE 0x0800 35 18 36 19 #include <asm-generic/poll.h> 37 20
+24
include/linux/poll.h
··· 108 108 extern int poll_select_set_timeout(struct timespec64 *to, time64_t sec, 109 109 long nsec); 110 110 111 + #define __MAP(v, from, to) \ 112 + (from < to ? (v & from) * (to/from) : (v & from) / (from/to)) 113 + 114 + static 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 + 124 + static 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 135 #endif /* _LINUX_POLL_H */
+13 -27
include/uapi/asm-generic/poll.h
··· 3 3 #define __ASM_GENERIC_POLL_H 4 4 5 5 /* These are specified by iBCS2 */ 6 - #define POLLIN (__force __poll_t)0x0001 7 - #define POLLPRI (__force __poll_t)0x0002 8 - #define POLLOUT (__force __poll_t)0x0004 9 - #define POLLERR (__force __poll_t)0x0008 10 - #define POLLHUP (__force __poll_t)0x0010 11 - #define POLLNVAL (__force __poll_t)0x0020 6 + #define POLLIN 0x0001 7 + #define POLLPRI 0x0002 8 + #define POLLOUT 0x0004 9 + #define POLLERR 0x0008 10 + #define POLLHUP 0x0010 11 + #define POLLNVAL 0x0020 12 12 13 13 /* The rest seem to be more-or-less nonstandard. Check them! */ 14 - #define POLLRDNORM (__force __poll_t)0x0040 15 - #define POLLRDBAND (__force __poll_t)0x0080 14 + #define POLLRDNORM 0x0040 15 + #define POLLRDBAND 0x0080 16 16 #ifndef POLLWRNORM 17 - #define POLLWRNORM (__force __poll_t)0x0100 17 + #define POLLWRNORM 0x0100 18 18 #endif 19 19 #ifndef POLLWRBAND 20 - #define POLLWRBAND (__force __poll_t)0x0200 20 + #define POLLWRBAND 0x0200 21 21 #endif 22 22 #ifndef POLLMSG 23 - #define POLLMSG (__force __poll_t)0x0400 23 + #define POLLMSG 0x0400 24 24 #endif 25 25 #ifndef POLLREMOVE 26 - #define POLLREMOVE (__force __poll_t)0x1000 26 + #define POLLREMOVE 0x1000 27 27 #endif 28 28 #ifndef POLLRDHUP 29 - #define POLLRDHUP (__force __poll_t)0x2000 29 + #define POLLRDHUP 0x2000 30 30 #endif 31 31 32 32 #define POLLFREE (__force __poll_t)0x4000 /* currently only for epoll */ 33 33 34 34 #define POLL_BUSY_LOOP (__force __poll_t)0x8000 35 - 36 - #ifdef __KERNEL__ 37 - #ifndef __ARCH_HAS_MANGLED_POLL 38 - static inline __u16 mangle_poll(__poll_t val) 39 - { 40 - return (__force __u16)val; 41 - } 42 - 43 - static inline __poll_t demangle_poll(__u16 v) 44 - { 45 - return (__force __poll_t)v; 46 - } 47 - #endif 48 - #endif 49 35 50 36 struct pollfd { 51 37 int fd;