termios.h cleanups
RFC PATCH 1/1 termios.h cleanups
asm/termios.h has tons of duplication and rather
convoluted logics re includes.
First of all, while everyone has uapi asm/termios.h,
some architectures have asm/termios.h and some do not. So include of <asm/termios.h> can go either to arch asm/termios.h, or to uapi/asm/termios.h.
In the former case asm/termios.h defines a bunch of
helpers (used in just one file) and a constant (3 more users) and includes uapi/asm/termios.h
In the latter... uapi/asm/termios.h is in generated-y
or equivalent to it. Which is to say, it ends up doing #include <asm-generic/termios.h>. Userland-side that would refer to uapi/asm-generic/termios.h, but kernel-side we end up with plain asm-generic/termios.h. Which defines the same set of helpers and a constant and pulls uapi/asm-generic/termios.h
Helpers in question are heavily shared; there is an attempt
to put them into a common header (termios-base.h), but not all instances use it. Another unpleasant thing is that said helpers tend to be macros, with very little typechecking. And all of that is pulled in by a lot more places than those that are actually interested - 500-odd instead of 4.
Below is an attempt to untangle that; the branch is vfs.git#work.termios,
patches in followups. FWIW, diffstat is
arch/Kconfig | 3 +
arch/alpha/Kconfig | 1 +
arch/alpha/include/asm/termios.h | 81 ------------
arch/alpha/include/asm/termios_internal.h | 72 ++++++++++
arch/ia64/include/asm/termios.h | 58 --------
arch/mips/include/asm/termios.h | 105 ---------------
arch/parisc/include/asm/termios.h | 52 --------
arch/powerpc/Kconfig | 1 +
.../include/asm/{termios.h => termios_internal.h} | 7 +-
arch/riscv/include/asm/Kbuild | 1 -
arch/s390/include/asm/termios.h | 26 ----
arch/sparc/Kconfig | 1 +
arch/sparc/include/asm/termios.h | 147 ---------------------
arch/sparc/include/asm/termios_internal.h | 134 +++++++++++++++++++
arch/x86/include/uapi/asm/Kbuild | 1 +
arch/x86/include/uapi/asm/termios.h | 1 -
drivers/tty/hvc/hvcs.c | 1 +
drivers/tty/n_hdlc.c | 1 -
drivers/tty/tty_io.c | 1 +
drivers/tty/tty_ioctl.c | 1 +
drivers/tty/vcc.c | 1 +
include/asm-generic/termios-base.h | 78 -----------
include/asm-generic/termios.h | 108 ---------------
include/linux/termios_internal.h | 137 +++++++++++++++++++
24 files changed, 355 insertions(+), 664 deletions(-)
delete mode 100644 arch/alpha/include/asm/termios.h
create mode 100644 arch/alpha/include/asm/termios_internal.h
delete mode 100644 arch/ia64/include/asm/termios.h
delete mode 100644 arch/mips/include/asm/termios.h
delete mode 100644 arch/parisc/include/asm/termios.h
rename arch/powerpc/include/asm/{termios.h => termios_internal.h} (70%)
delete mode 100644 arch/s390/include/asm/termios.h
delete mode 100644 arch/sparc/include/asm/termios.h
create mode 100644 arch/sparc/include/asm/termios_internal.h
delete mode 100644 arch/x86/include/uapi/asm/termios.h
delete mode 100644 include/asm-generic/termios-base.h
delete mode 100644 include/asm-generic/termios.h
create mode 100644 include/linux/termios_internal.hRFC PATCH 1/8 start unifying termios convertors
From: Al Viro <[email protected]>
* new header (linut/termios_internal.h), pulled by the sole user of those suckers
* defaults for user_termios_to_kernel_termios{,_1} and kernel_termios_to_user_termios{,_1} moved over there
--- arch/alpha/include/asm/termios.h | 6 -- arch/ia64/include/asm/termios.h | 5 -- arch/mips/include/asm/termios.h | 24 ------ arch/parisc/include/asm/termios.h | 5 -- arch/s390/include/asm/termios.h | 3 - arch/sparc/include/asm/termios.h | 165 ++++++++++++++++++++----------------- drivers/tty/tty_ioctl.c | 1 + include/asm-generic/termios-base.h | 11 --- include/asm-generic/termios.h | 38 --------- include/linux/termios_internal.h | 58 +++++++++++++ 10 files changed, 148 insertions(+), 168 deletions(-) create mode 100644 include/linux/termios_internal.h
arch/alpha/include/asm/termios.h +0 -6
@@ -72,10 +72,4 @@copy_to_user (u_termio, &k_termio,sizeof (k_termio)); \ }) -#define user_termios_to_kernel_termios (k, u) \ - copy_from_user(k, u, sizeof(struct termios)) - -#define kernel_termios_to_user_termios (u, k) \ - copy_to_user(u, k, sizeof(struct termios)) -#endif /* _ALPHA_TERMIOS_H */
arch/ia64/include/asm/termios.h +0 -5
@@ -50,9 +50,4 @@copy_to_user ((termio)->c_cc, (termios)->c_cc,NCC ); \ }) -#define user_termios_to_kernel_termios (k, u) copy_from_user(k, u, sizeof(struct termios2)) -#define kernel_termios_to_user_termios (u, k) copy_to_user(u, k, sizeof(struct termios2)) -#define user_termios_to_kernel_termios_1 (k, u) copy_from_user(k, u, sizeof(struct termios)) -#define kernel_termios_to_user_termios_1 (u, k) copy_to_user(u, k, sizeof(struct termios)) -#endif /* _ASM_IA64_TERMIOS_H */
arch/mips/include/asm/termios.h +0 -24
@@ -78,28 +78,4 @@ static inline int kernel_termios_to_user_termio(struct termio __user *termio, return 0; } -static inline int user_termios_to_kernel_termios (struct ktermios __user *k, -struct termios2 *u) -{ -return copy_from_user (k, u,sizeof (struct termios2 )) ? -EFAULT :0 ; -} - -static inline int kernel_termios_to_user_termios (struct termios2 __user *u, -struct ktermios *k) -{ -return copy_to_user (u, k,sizeof (struct termios2 )) ? -EFAULT :0 ; -} - -static inline int user_termios_to_kernel_termios_1 (struct ktermios *k, -struct termios __user *u) -{ -return copy_from_user (k, u,sizeof (struct termios )) ? -EFAULT :0 ; -} - -static inline int kernel_termios_to_user_termios_1 (struct termios __user *u, -struct ktermios *k) -{ -return copy_to_user (u, k,sizeof (struct termios )) ? -EFAULT :0 ; -} -#endif /* _ASM_TERMIOS_H */
arch/parisc/include/asm/termios.h +0 -5
@@ -44,9 +44,4 @@copy_to_user ((termio)->c_cc, (termios)->c_cc,NCC ); \ }) -#define user_termios_to_kernel_termios (k, u) copy_from_user(k, u, sizeof(struct termios2)) -#define kernel_termios_to_user_termios (u, k) copy_to_user(u, k, sizeof(struct termios2)) -#define user_termios_to_kernel_termios_1 (k, u) copy_from_user(k, u, sizeof(struct termios)) -#define kernel_termios_to_user_termios_1 (u, k) copy_to_user(u, k, sizeof(struct termios)) -#endif /* _PARISC_TERMIOS_H */
arch/s390/include/asm/termios.h +0 -3
@@ -18,9 +18,6 @@*/ #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" -#define user_termios_to_kernel_termios (k, u) copy_from_user(k, u, sizeof(struct termios2)) -#define kernel_termios_to_user_termios (u, k) copy_to_user(u, k, sizeof(struct termios2)) -#include <asm-generic/termios-base.h> #endif /* _S390_TERMIOS_H */
arch/sparc/include/asm/termios.h +89 -76
179 lines not on this page · raw message
drivers/tty/tty_ioctl.c +1 -0
@@ -21,6 +21,7 @@#include <linux/bitops.h> #include <linux/mutex.h> #include <linux/compat.h> +#include <linux/termios_internal.h> #include <asm/io.h> #include <linux/uaccess.h>
include/asm-generic/termios-base.h +0 -11
@@ -62,17 +62,6 @@ static inline int kernel_termios_to_user_termio(struct termio __user *termio,return 0 ; } -#ifndef user_termios_to_kernel_termios -#define user_termios_to_kernel_termios (k, u) copy_from_user(k, u, sizeof(struct termios)) -#endif - -#ifndef kernel_termios_to_user_termios -#define kernel_termios_to_user_termios (u, k) copy_to_user(u, k, sizeof(struct termios)) -#endif - -#define user_termios_to_kernel_termios_1 (k, u) copy_from_user(k, u, sizeof(struct termios)) -#define kernel_termios_to_user_termios_1 (u, k) copy_to_user(u, k, sizeof(struct termios)) -#endif /* __ARCH_TERMIO_GETPUT */ #endif /* _ASM_GENERIC_TERMIOS_BASE_H */
include/asm-generic/termios.h +0 -38
@@ -67,42 +67,4 @@ static inline int kernel_termios_to_user_termio(struct termio __user *termio, return 0; } -#ifdef TCGETS2 -static inline int user_termios_to_kernel_termios (struct ktermios *k, -struct termios2 __user *u) -{ -return copy_from_user (k, u,sizeof (struct termios2 )); -} - -static inline int kernel_termios_to_user_termios (struct termios2 __user *u, -struct ktermios *k) -{ -return copy_to_user (u, k,sizeof (struct termios2 )); -} - -static inline int user_termios_to_kernel_termios_1 (struct ktermios *k, -struct termios __user *u) -{ -return copy_from_user (k, u,sizeof (struct termios )); -} - -static inline int kernel_termios_to_user_termios_1 (struct termios __user *u, -struct ktermios *k) -{ -return copy_to_user (u, k,sizeof (struct termios )); -} -#else /* TCGETS2 */ -static inline int user_termios_to_kernel_termios (struct ktermios *k, -struct termios __user *u) -{ -return copy_from_user (k, u,sizeof (struct termios )); -} - -static inline int kernel_termios_to_user_termios (struct termios __user *u, -struct ktermios *k) -{ -return copy_to_user (u, k,sizeof (struct termios )); -} -#endif /* TCGETS2 */ -#endif /* _ASM_GENERIC_TERMIOS_H */
include/linux/termios_internal.h new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
2.11.0
RFC PATCH 2/8 move user_termio_to_kernel_termios/kernel_termios_to_user_termio
From: Al Viro <[email protected]>
--- arch/alpha/include/asm/termios.h | 104 ++++++++++++++++++++----------------- arch/ia64/include/asm/termios.h | 31 ----------- arch/mips/include/asm/termios.h | 57 -------------------- arch/parisc/include/asm/termios.h | 31 ----------- arch/sparc/include/asm/termios.h | 52 +++++++------------ include/asm-generic/termios-base.h | 57 -------------------- include/asm-generic/termios.h | 53 ------------------- include/linux/termios_internal.h | 41 +++++++++++++++ 8 files changed, 114 insertions(+), 312 deletions(-)
arch/alpha/include/asm/termios.h +55 -49
@@ -2,6 +2,7 @@#ifndef _ALPHA_TERMIOS_H#define _ALPHA_TERMIOS_H +#include <linux/uaccess.h> #include <uapi/asm/termios.h> /* eof=^D eol=\0 eol2=\0 erase=del
@@ -16,60 +17,65 @@* Translate a "termio" structure into a "termios". Ugh. */ -#define user_termio_to_kernel_termios (a_termios, u_termio) \ -({ \ - struct ktermios *k_termios = (a_termios); \ - struct termio k_termio; \ - int canon, ret; \ - \ - ret = copy_from_user(&k_termio, u_termio, sizeof(k_termio)); \ - if (!ret) { \ -/* Overwrite only the low bits. */ \ - *(unsigned short *)&k_termios->c_iflag = k_termio.c_iflag; \ - *(unsigned short *)&k_termios->c_oflag = k_termio.c_oflag; \ - *(unsigned short *)&k_termios->c_cflag = k_termio.c_cflag; \ - *(unsigned short *)&k_termios->c_lflag = k_termio.c_lflag; \ - canon = k_termio.c_lflag &ICANON ; \ - \ - k_termios->c_cc[VINTR ] = k_termio.c_cc[_VINTR]; \ - k_termios->c_cc[VQUIT ] = k_termio.c_cc[_VQUIT]; \ - k_termios->c_cc[VERASE ] = k_termio.c_cc[_VERASE]; \ - k_termios->c_cc[VKILL ] = k_termio.c_cc[_VKILL]; \ - k_termios->c_cc[VEOL2 ] = k_termio.c_cc[_VEOL2]; \ - k_termios->c_cc[VSWTC ] = k_termio.c_cc[_VSWTC]; \ - k_termios->c_cc[canon ?VEOF :VMIN ] = k_termio.c_cc[_VEOF]; \ - k_termios->c_cc[canon ?VEOL :VTIME ] = k_termio.c_cc[_VEOL]; \ - } \ - ret; \ -}) +static inline int user_termio_to_kernel_termios (struct ktermios *termios, +struct termio __user *termio) +{ +struct termio v; +bool canon; + +if (copy_from_user (&v, termio,sizeof (struct termio ))) +return -EFAULT ; + + termios->c_iflag = (0xffff0000 & termios->c_iflag) | v.c_iflag; + termios->c_oflag = (0xffff0000 & termios->c_oflag) | v.c_oflag; + termios->c_cflag = (0xffff0000 & termios->c_cflag) | v.c_cflag; + termios->c_lflag = (0xffff0000 & termios->c_lflag) | v.c_lflag; + termios->c_line = (0xffff0000 & termios->c_lflag) | v.c_line; + + canon = v.c_lflag &ICANON ; + termios->c_cc[VINTR ] = v.c_cc[_VINTR]; + termios->c_cc[VQUIT ] = v.c_cc[_VQUIT]; + termios->c_cc[VERASE ] = v.c_cc[_VERASE]; + termios->c_cc[VKILL ] = v.c_cc[_VKILL]; + termios->c_cc[VEOL2 ] = v.c_cc[_VEOL2]; + termios->c_cc[VSWTC ] = v.c_cc[_VSWTC]; + termios->c_cc[canon ?VEOF :VMIN ] = v.c_cc[_VEOF]; + termios->c_cc[canon ?VEOL :VTIME ] = v.c_cc[_VEOL]; + +return 0 ; +} +#define user_termio_to_kernel_termios user_termio_to_kernel_termios/* * Translate a "termios" structure into a "termio". Ugh. * * Note the "fun" _VMIN overloading. */ -#define kernel_termios_to_user_termio (u_termio, a_termios) \ -({ \ - struct ktermios *k_termios = (a_termios); \ - struct termio k_termio; \ - int canon; \ - \ - k_termio.c_iflag = k_termios->c_iflag; \ - k_termio.c_oflag = k_termios->c_oflag; \ - k_termio.c_cflag = k_termios->c_cflag; \ - canon = (k_termio.c_lflag = k_termios->c_lflag) & ICANON; \ - \ - k_termio.c_line = k_termios->c_line; \ - k_termio.c_cc[_VINTR] = k_termios->c_cc[VINTR]; \ - k_termio.c_cc[_VQUIT] = k_termios->c_cc[VQUIT]; \ - k_termio.c_cc[_VERASE] = k_termios->c_cc[VERASE]; \ - k_termio.c_cc[_VKILL] = k_termios->c_cc[VKILL]; \ - k_termio.c_cc[_VEOF] = k_termios->c_cc[canon ? VEOF : VMIN]; \ - k_termio.c_cc[_VEOL] = k_termios->c_cc[canon ? VEOL : VTIME]; \ - k_termio.c_cc[_VEOL2] = k_termios->c_cc[VEOL2]; \ - k_termio.c_cc[_VSWTC] = k_termios->c_cc[VSWTC]; \ - \ - copy_to_user(u_termio, &k_termio, sizeof(k_termio)); \ -}) +static inline int kernel_termios_to_user_termio (struct termio __user *termio, +struct ktermios *termios) +{ +struct termio v; +bool canon; + +memset (&v,0 ,sizeof (struct termio )); + v.c_iflag = termios->c_iflag; + v.c_oflag = termios->c_oflag; + v.c_cflag = termios->c_cflag; + v.c_lflag = termios->c_lflag; + v.c_line = termios->c_line; + + canon = v.c_lflag &ICANON ; + v.c_cc[_VINTR] = termios->c_cc[VINTR ]; + v.c_cc[_VQUIT] = termios->c_cc[VQUIT ]; + v.c_cc[_VERASE] = termios->c_cc[VERASE ]; + v.c_cc[_VKILL] = termios->c_cc[VKILL ]; + v.c_cc[_VEOF] = termios->c_cc[canon ?VEOF :VMIN ]; + v.c_cc[_VEOL] = termios->c_cc[canon ?VEOL :VTIME ]; + v.c_cc[_VEOL2] = termios->c_cc[VEOL2 ]; + v.c_cc[_VSWTC] = termios->c_cc[VSWTC ]; + +return copy_to_user (termio, &v,sizeof (struct termio )); +} +#define kernel_termios_to_user_termio kernel_termios_to_user_termio#endif /* _ALPHA_TERMIOS_H */
arch/ia64/include/asm/termios.h +0 -31
@@ -19,35 +19,4 @@*/ #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" -/* -* Translate a "termio" structure into a "termios". Ugh. -*/ -#define SET_LOW_TERMIOS_BITS (termios, termio, x) { \ - unsigned short __tmp; \ - get_user(__tmp,&(termio)->x); \ - *(unsigned short *) &(termios)->x = __tmp; \ -} - -#define user_termio_to_kernel_termios (termios, termio) \ -({ \ - SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \ - SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \ - SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \ - SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \ - copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \ -}) - -/* -* Translate a "termios" structure into a "termio". Ugh. -*/ -#define kernel_termios_to_user_termio (termio, termios) \ -({ \ - put_user((termios)->c_iflag, &(termio)->c_iflag); \ - put_user((termios)->c_oflag, &(termio)->c_oflag); \ - put_user((termios)->c_cflag, &(termio)->c_cflag); \ - put_user((termios)->c_lflag, &(termio)->c_lflag); \ - put_user((termios)->c_line, &(termio)->c_line); \ - copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \ -}) -#endif /* _ASM_IA64_TERMIOS_H */
arch/mips/include/asm/termios.h +0 -57
61 lines not on this page · raw message
arch/parisc/include/asm/termios.h +0 -31
@@ -13,35 +13,4 @@*/ #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" -/* -* Translate a "termio" structure into a "termios". Ugh. -*/ -#define SET_LOW_TERMIOS_BITS (termios, termio, x) { \ - unsigned short __tmp; \ - get_user(__tmp,&(termio)->x); \ - *(unsigned short *) &(termios)->x = __tmp; \ -} - -#define user_termio_to_kernel_termios (termios, termio) \ -({ \ - SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \ - SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \ - SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \ - SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \ - copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \ -}) - -/* -* Translate a "termios" structure into a "termio". Ugh. -*/ -#define kernel_termios_to_user_termio (termio, termios) \ -({ \ - put_user((termios)->c_iflag, &(termio)->c_iflag); \ - put_user((termios)->c_oflag, &(termio)->c_oflag); \ - put_user((termios)->c_cflag, &(termio)->c_cflag); \ - put_user((termios)->c_lflag, &(termio)->c_lflag); \ - put_user((termios)->c_line, &(termio)->c_line); \ - copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \ -}) -#endif /* _PARISC_TERMIOS_H */
arch/sparc/include/asm/termios.h +18 -34
62 lines not on this page · raw message
include/asm-generic/termios-base.h +0 -57
61 lines not on this page · raw message
include/asm-generic/termios.h +0 -53
57 lines not on this page · raw message
include/linux/termios_internal.h +41 -0
47 lines not on this page · raw message
Signature · 1 line
2.11.0
RFC PATCH 3/8 remove termios-base.h
In reply to Al ViroFrom: Al Viro <[email protected]>
empty now
--- arch/powerpc/include/asm/termios.h | 2 -- arch/s390/include/asm/termios.h | 2 -- include/asm-generic/termios-base.h | 10 ---------- 3 files changed, 14 deletions(-) delete mode 100644 include/asm-generic/termios-base.h
arch/powerpc/include/asm/termios.h +0 -2
@@ -17,6 +17,4 @@/* ^C ^\ del ^U ^D 1 0 0 0 0 ^W ^R ^Z ^Q ^S ^V ^U */ #define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\025" -#include <asm-generic/termios-base.h> -#endif /* _ASM_POWERPC_TERMIOS_H */
arch/s390/include/asm/termios.h +0 -2
@@ -18,6 +18,4 @@*/ #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" -#include <asm-generic/termios-base.h> -#endif /* _S390_TERMIOS_H */
include/asm-generic/termios-base.h deleted +0 -10
@@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* termios.h: generic termios/termio user copying/translation -*/ - -#ifndef _ASM_GENERIC_TERMIOS_BASE_H -#define _ASM_GENERIC_TERMIOS_BASE_H - -#include <linux/uaccess.h> - -#endif /* _ASM_GENERIC_TERMIOS_BASE_H */
Signature · 1 line
2.11.0
RFC PATCH 4/8 make users of INIT_C_CC pull linux/termios_internal.h
In reply to Al ViroFrom: Al Viro <[email protected]>
... and move the default definition in there
--- arch/ia64/include/asm/termios.h | 9 --------- arch/parisc/include/asm/termios.h | 9 --------- arch/s390/include/asm/termios.h | 9 --------- drivers/tty/hvc/hvcs.c | 1 + drivers/tty/tty_io.c | 1 + drivers/tty/vcc.c | 1 + include/asm-generic/termios.h | 8 -------- include/linux/termios_internal.h | 10 ++++++++++ 8 files changed, 13 insertions(+), 35 deletions(-)
arch/ia64/include/asm/termios.h +0 -9
@@ -10,13 +10,4 @@#include <uapi/asm/termios.h> - -/* intr=^C quit=^\ erase=del kill=^U -eof=^D vtime=\0 vmin=\1 sxtc=\0 -start=^Q stop=^S susp=^Z eol=\0 -reprint=^R discard=^U werase=^W lnext=^V -eol2=\0 -*/ -#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" -#endif /* _ASM_IA64_TERMIOS_H */
arch/parisc/include/asm/termios.h +0 -9
@@ -4,13 +4,4 @@#include <uapi/asm/termios.h> - -/* intr=^C quit=^\ erase=del kill=^U -eof=^D vtime=\0 vmin=\1 sxtc=\0 -start=^Q stop=^S susp=^Z eol=\0 -reprint=^R discard=^U werase=^W lnext=^V -eol2=\0 -*/ -#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" -#endif /* _PARISC_TERMIOS_H */
arch/s390/include/asm/termios.h +0 -9
@@ -9,13 +9,4 @@#include <uapi/asm/termios.h> - -/* intr=^C quit=^\ erase=del kill=^U -eof=^D vtime=\0 vmin=\1 sxtc=\0 -start=^Q stop=^S susp=^Z eol=\0 -reprint=^R discard=^U werase=^W lnext=^V -eol2=\0 -*/ -#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" -#endif /* _S390_TERMIOS_H */
drivers/tty/hvc/hvcs.c +1 -0
@@ -69,6 +69,7 @@#include <asm/hvconsole.h> #include <asm/hvcserver.h> #include <linux/uaccess.h> +#include <linux/termios_internal.h> #include <asm/vio.h> /*
drivers/tty/tty_io.c +1 -0
@@ -97,6 +97,7 @@#include <linux/seq_file.h> #include <linux/serial.h> #include <linux/ratelimit.h> +#include <linux/termios_internal.h> #include <linux/uaccess.h>
drivers/tty/vcc.c +1 -0
@@ -10,6 +10,7 @@#include <linux/sysfs.h> #include <linux/tty.h> #include <linux/tty_flip.h> +#include <linux/termios_internal.h> #include <asm/vio.h> #include <asm/ldc.h>
include/asm-generic/termios.h +0 -8
@@ -6,12 +6,4 @@#include <linux/uaccess.h> #include <uapi/asm-generic/termios.h> -/* intr=^C quit=^\ erase=del kill=^U -eof=^D vtime=\0 vmin=\1 sxtc=\0 -start=^Q stop=^S susp=^Z eol=\0 -reprint=^R discard=^U werase=^W lnext=^V -eol2=\0 -*/ -#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" -#endif /* _ASM_GENERIC_TERMIOS_H */
include/linux/termios_internal.h +10 -0
@@ -5,6 +5,16 @@#include <linux/uaccess.h> #include <asm/termios.h> +#ifndef INIT_C_CC +/* intr=^C quit=^\ erase=del kill=^U +eof=^D vtime=\0 vmin=\1 sxtc=\0 +start=^Q stop=^S susp=^Z eol=\0 +reprint=^R discard=^U werase=^W lnext=^V +eol2=\0 +*/ +#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" +#endif +#ifndef user_termio_to_kernel_termios/* * Translate a "termio" structure into a "termios". Ugh.
Signature · 1 line
2.11.0
RFC PATCH 5/8 make generic INIT_C_CC a bit more generic
In reply to Al ViroFrom: Al Viro <[email protected]>
turn it into an array initializer; then mips variant folds into it.
--- arch/mips/include/asm/termios.h | 9 --------- include/linux/termios_internal.h | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 10 deletions(-)
arch/mips/include/asm/termios.h +0 -9
@@ -12,13 +12,4 @@#include <linux/uaccess.h> #include <uapi/asm/termios.h> -/* -* intr=^C quit=^\ erase=del kill=^U -* vmin=\1 vtime=\0 eol2=\0 swtc=\0 -* start=^Q stop=^S susp=^Z vdsusp= -* reprint=^R discard=^U werase=^W lnext=^V -* eof=^D eol=\0 -*/ -#define INIT_C_CC "\003\034\177\025\1\0\0\0\021\023\032\0\022\017\027\026\004\0" -#endif /* _ASM_TERMIOS_H */
include/linux/termios_internal.h +14 -1
@@ -12,7 +12,20 @@reprint=^R discard=^U werase=^W lnext=^V eol2=\0 */ -#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" +#define INIT_C_CC { \ + [VINTR] = 'C'-0x40, \ + [VQUIT] = '\\'-0x40, \ + [VERASE] = '\177', \ + [VKILL] = 'U'-0x40, \ + [VEOF] = 'D'-0x40, \ + [VSTART] = 'Q'-0x40, \ + [VSTOP] = 'S'-0x40, \ + [VSUSP] = 'Z'-0x40, \ + [VREPRINT] = 'R'-0x40, \ + [VDISCARD] = 'O'-0x40, \ + [VWERASE] = 'W'-0x40, \ + [VLNEXT] = 'V'-0x40, \ + [VMIN] = 1 }#endif #ifndef user_termio_to_kernel_termios
Signature · 1 line
2.11.0
RFC PATCH 6/8 untangle asm/termios.h mess
In reply to Al ViroFrom: Al Viro <[email protected]>
Currently, asm/termios.h resolves either to uapi/asm/termios.h (on architectures that don't have it) or to the same plus the definitions that are only used by those who pull linux/termios_internal.h
That causes tons of inconveniences - e.g. we can't have generic asm/termios.h with non-generic uapi/asm/termios.h.
Let's do the following:
* rename asm/termios.h to asm/termios_internal.h and makelinux/termios_internal.h pull that; that way all includes of <asm/termios.h> will go directly to uapi/asm/termios.h
* all but 3 architectures actually have asm/termios.h completely
generic. Make those 3 select a new config symbol (HAVE_TERMIOS_INTERNAL) and make the include of asm/termios_internal.h conditional upon that. Remove all generic instances of asm/termios.h (including include/asm-generic one).
* get rid of one pointless include of <asm/termios.h> indrivers/tty.
---
arch/Kconfig | 3 +++
arch/alpha/Kconfig | 1 +
arch/alpha/include/asm/{termios.h => termios_internal.h} | 3 ---
arch/ia64/include/asm/termios.h | 13 -------------
arch/mips/include/asm/termios.h | 15 ---------------
arch/parisc/include/asm/termios.h | 7 -------
arch/powerpc/Kconfig | 1 +
.../powerpc/include/asm/{termios.h => termios_internal.h} | 2 --
arch/riscv/include/asm/Kbuild | 1 -
arch/s390/include/asm/termios.h | 12 ------------
arch/sparc/Kconfig | 1 +
arch/sparc/include/asm/{termios.h => termios_internal.h} | 4 ----
drivers/tty/n_hdlc.c | 1 -
include/asm-generic/termios.h | 9 ---------
include/linux/termios_internal.h | 3 +++
15 files changed, 9 insertions(+), 67 deletions(-)
rename arch/alpha/include/asm/{termios.h => termios_internal.h} (97%)
delete mode 100644 arch/ia64/include/asm/termios.h
delete mode 100644 arch/mips/include/asm/termios.h
delete mode 100644 arch/parisc/include/asm/termios.h
rename arch/powerpc/include/asm/{termios.h => termios_internal.h} (96%)
delete mode 100644 arch/s390/include/asm/termios.h
rename arch/sparc/include/asm/{termios.h => termios_internal.h} (98%)
delete mode 100644 include/asm-generic/termios.harch/Kconfig +3 -0
@@ -727,6 +727,9 @@ config OLD_SIGACTION config COMPAT_OLD_SIGACTION bool +config HAS_TERMIOS_INTERNAL + bool + config 64BIT_TIME def_bool ARCH_HAS_64BIT_TIME help
arch/alpha/Kconfig +1 -0
@@ -30,6 +30,7 @@ config ALPHA select MODULES_USE_ELF_RELA select ODD_RT_SIGACTION select OLD_SIGSUSPEND + select HAS_TERMIOS_INTERNAL select CPU_NO_EFFICIENT_FFS if !ALPHA_EV67 help The Alpha is a 64-bit general-purpose processor designed and
arch/alpha/include/asm/termios_internal.h renamed from arch/alpha/include/asm/termios.h +0 -3
@@ -2,9 +2,6 @@#ifndef _ALPHA_TERMIOS_H#define _ALPHA_TERMIOS_H -#include <linux/uaccess.h> -#include <uapi/asm/termios.h> -/* eof=^D eol=\0 eol2=\0 erase=del werase=^W kill=^U reprint=^R sxtc=\0 intr=^C quit=^\ susp=^Z <OSF/1 VDSUSP>
arch/ia64/include/asm/termios.h deleted +0 -13
@@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* -* Modified 1999 -* David Mosberger-Tang <[email protected]>, Hewlett-Packard Co -* -* 99/01/28 Added N_IRDA and N_SMSBLOCK -*/ -#ifndef _ASM_IA64_TERMIOS_H -#define _ASM_IA64_TERMIOS_H - -#include <uapi/asm/termios.h> - -#endif /* _ASM_IA64_TERMIOS_H */
arch/mips/include/asm/termios.h deleted +0 -15
@@ -1,15 +0,0 @@ -/* -* This file is subject to the terms and conditions of the GNU General Public -* License. See the file "COPYING" in the main directory of this archive -* for more details. -* -* Copyright (C) 1995, 1996, 2000, 2001 by Ralf Baechle -* Copyright (C) 2000, 2001 Silicon Graphics, Inc. -*/ -#ifndef _ASM_TERMIOS_H -#define _ASM_TERMIOS_H - -#include <linux/uaccess.h> -#include <uapi/asm/termios.h> - -#endif /* _ASM_TERMIOS_H */
arch/parisc/include/asm/termios.h deleted +0 -7
@@ -1,7 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _PARISC_TERMIOS_H -#define _PARISC_TERMIOS_H - -#include <uapi/asm/termios.h> - -#endif /* _PARISC_TERMIOS_H */
arch/powerpc/Kconfig +1 -0
@@ -223,6 +223,7 @@ config PPC select HAVE_VIRT_CPU_ACCOUNTING select HAVE_IRQ_TIME_ACCOUNTING select HAVE_RSEQ + select HAS_TERMIOS_INTERNAL select IOMMU_HELPER if PPC64 select IRQ_DOMAIN select IRQ_FORCED_THREADING
arch/powerpc/include/asm/termios_internal.h renamed from arch/powerpc/include/asm/termios.h +0 -2
@@ -12,8 +12,6 @@#ifndef _ASM_POWERPC_TERMIOS_H#define _ASM_POWERPC_TERMIOS_H -#include <uapi/asm/termios.h> -/* ^C ^\ del ^U ^D 1 0 0 0 0 ^W ^R ^Z ^Q ^S ^V ^U */ #define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\025"
arch/riscv/include/asm/Kbuild +0 -1
@@ -52,7 +52,6 @@ generic-y += stat.h generic-y += statfs.h generic-y += swab.h generic-y += termbits.h -generic-y += termios.h generic-y += topology.h generic-y += trace_clock.h generic-y += types.h
arch/s390/include/asm/termios.h deleted +0 -12
@@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* -* S390 version -* -* Derived from "include/asm-i386/termios.h" -*/ -#ifndef _S390_TERMIOS_H -#define _S390_TERMIOS_H - -#include <uapi/asm/termios.h> - -#endif /* _S390_TERMIOS_H */
arch/sparc/Kconfig +1 -0
@@ -33,6 +33,7 @@ config SPARC select HAVE_CBPF_JIT if SPARC32 select HAVE_EBPF_JIT if SPARC64 select HAVE_DEBUG_BUGVERBOSE + select HAS_TERMIOS_INTERNAL select GENERIC_SMP_IDLE_THREAD select GENERIC_CLOCKEVENTS select GENERIC_STRNCPY_FROM_USER
arch/sparc/include/asm/termios_internal.h renamed from arch/sparc/include/asm/termios.h +0 -4
@@ -2,10 +2,6 @@#ifndef _SPARC_TERMIOS_H#define _SPARC_TERMIOS_H -#include <uapi/asm/termios.h> -#include <linux/uaccess.h> - -/* * c_cc characters in the termio structure. Oh, how I love being * backwardly compatible. Notice that character 4 and 5 are
drivers/tty/n_hdlc.c +0 -1
@@ -101,7 +101,6 @@#include <linux/if.h> #include <linux/bitops.h> -#include <asm/termios.h> #include <linux/uaccess.h> /*
include/asm-generic/termios.h deleted +0 -9
@@ -1,9 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_GENERIC_TERMIOS_H -#define _ASM_GENERIC_TERMIOS_H - - -#include <linux/uaccess.h> -#include <uapi/asm-generic/termios.h> - -#endif /* _ASM_GENERIC_TERMIOS_H */
include/linux/termios_internal.h +3 -0
@@ -4,6 +4,9 @@#include <linux/uaccess.h> #include <asm/termios.h> +#ifdef CONFIG_HAS_TERMIOS_INTERNAL +#include <asm/termios_internal.h> +#endif #ifndef INIT_C_CC /* intr=^C quit=^\ erase=del kill=^U
Signature · 1 line
2.11.0
RFC PATCH 7/8 switch x86 to generic uapi asm/termios.h
In reply to Al ViroFrom: Al Viro <[email protected]>
--- arch/x86/include/uapi/asm/Kbuild | 1 + arch/x86/include/uapi/asm/termios.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 arch/x86/include/uapi/asm/termios.h
arch/x86/include/uapi/asm/Kbuild +1 -0
@@ -2,6 +2,7 @@ include include/uapi/asm-generic/Kbuild.asm generic-y += bpf_perf_event.h +generic-y += termios.h generated-y += unistd_32.h generated-y += unistd_64.h generated-y += unistd_x32.h
arch/x86/include/uapi/asm/termios.h deleted +0 -1
@@ -1 +0,0 @@ -#include <asm-generic/termios.h>
Signature · 1 line
2.11.0
RFC PATCH 8/8 really consolidate INIT_C_CC definitions
In reply to Al ViroFrom: Al Viro <[email protected]>
they vary in two respects (renumbering of fields aside):
* sparc (and nobody else) has dsusp; set to ^Y.
* original (on i386) has discard set to historical
value (^O), mistaken comment nonwithstanding. alpha, ppc and sparc have followed the comment. Not that we'd ever handled that thing anyway...
--- arch/alpha/include/asm/termios_internal.h | 8 +------- arch/powerpc/include/asm/termios_internal.h | 3 +-- arch/sparc/include/asm/termios_internal.h | 8 +------- include/linux/termios_internal.h | 16 ++++++++++++++-- 4 files changed, 17 insertions(+), 18 deletions(-)
arch/alpha/include/asm/termios_internal.h +1 -7
@@ -2,13 +2,7 @@#ifndef _ALPHA_TERMIOS_H#define _ALPHA_TERMIOS_H -/* eof=^D eol=\0 eol2=\0 erase=del -werase=^W kill=^U reprint=^R sxtc=\0 -intr=^C quit=^\ susp=^Z <OSF/1 VDSUSP> -start=^Q stop=^S lnext=^V discard=^U -vmin=\1 vtime=\0 -*/ -#define INIT_C_CC "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\025\001\000" +#define INIT_C_CC_VDISCARD 'U'-0x40/* * Translate a "termio" structure into a "termios". Ugh.
arch/powerpc/include/asm/termios_internal.h +1 -2
@@ -12,7 +12,6 @@#ifndef _ASM_POWERPC_TERMIOS_H#define _ASM_POWERPC_TERMIOS_H -/* ^C ^\ del ^U ^D 1 0 0 0 0 ^W ^R ^Z ^Q ^S ^V ^U */ -#define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\025" +#define INIT_C_CC_VDISCARD 'U'-0x40#endif /* _ASM_POWERPC_TERMIOS_H */
arch/sparc/include/asm/termios_internal.h +1 -7
@@ -13,13 +13,7 @@#define _VMIN 4#define _VTIME 5 -/* intr=^C quit=^\ erase=del kill=^U -eof=^D eol=\0 eol2=\0 sxtc=\0 -start=^Q stop=^S susp=^Z dsusp=^Y -reprint=^R discard=^U werase=^W lnext=^V -vmin=\1 vtime=\0 -*/ -#define INIT_C_CC "\003\034\177\025\004\000\000\000\021\023\032\031\022\025\027\026\001" +#define INIT_C_CC_VDISCARD 'U'-0x40/* * Translate a "termios" structure into a "termio". Ugh.
include/linux/termios_internal.h +14 -2
@@ -8,13 +8,24 @@#include <asm/termios_internal.h> #endif -#ifndef INIT_C_CC /* intr=^C quit=^\ erase=del kill=^U eof=^D vtime=\0 vmin=\1 sxtc=\0 start=^Q stop=^S susp=^Z eol=\0 reprint=^R discard=^U werase=^W lnext=^V eol2=\0 +... except that discard is actually ^O on most of them. */ +#ifndef INIT_C_CC_VDISCARD +#define INIT_C_CC_VDISCARD 'O'-0x40 +#endif + +#ifdef VDSUSP +#define INIT_C_CC_VDSUSP_EXTRA [VDSUSP] = 'Y'-0x40, +#else +#define INIT_C_CC_VDSUSP_EXTRA +#endif + +#ifndef INIT_C_CC #define INIT_C_CC { \ [VINTR] = 'C'-0x40, \ [VQUIT] = '\\'-0x40, \
@@ -25,9 +36,10 @@ [VSTOP] = 'S'-0x40, \ [VSUSP] = 'Z'-0x40, \ [VREPRINT] = 'R'-0x40, \ - [VDISCARD] = 'O'-0x40, \ + [VDISCARD] = INIT_C_CC_VDISCARD, \ [VWERASE] = 'W'-0x40, \ [VLNEXT ] ='V' -0x40 , \ +INIT_C_CC_VDSUSP_EXTRA \ [VMIN] = 1 } #endif
Signature · 1 line
2.11.0
Re: [RFC][PATCH 8/8] really consolidate INIT_C_CC definitions
include/linux/termios_internal.h line 20
Quoted 5 lines · Al Viro
*/
include/linux/termios_internal.h +3
-0+#ifndef INIT_C_CC_VDISCARD +#define INIT_C_CC_VDISCARD 'O'-0x40 +#endif
Just change everybody to do the same, nobody cares about VDISCARD.
We can change the value of VDISCARD because it doesn't actually have anything connected to it, so don't worry about "we used to have odd different values for it".
Linus
Re: [RFC][PATCH 8/8] really consolidate INIT_C_CC definitions
Quoted 9 lines · Linus Torvalds
Review
Quoted 5 lines · Al Viro
*/
(quoted diff) +3
-0+#ifndef INIT_C_CC_VDISCARD +#define INIT_C_CC_VDISCARD 'O'-0x40 +#endifJust change everybody to do the same, nobody cares about VDISCARD.
Quoted 3 lines
We can change the value of VDISCARD because it doesn't actually have anything connected to it, so don't worry about "we used to have odd different values for it".
Point... The following added and pushed:
commit 96202dddde4673cfd686b9812e5ab0790f907cd0
Author: Al Viro <[email protected]> Date: Mon Sep 10 10:42:59 2018 -0400
... and switch alpha/ppc/sparc to ^O for discard
it's
1) common for all other architectures
2) historical default for that thing and
3) ignored by the tty layer anyway.
arch/alpha/include/asm/termios_internal.h +0 -2
@@ -2,8 +2,6 @@#ifndef _ALPHA_TERMIOS_H#define _ALPHA_TERMIOS_H -#define INIT_C_CC_VDISCARD 'U'-0x40 -/* * Translate a "termio" structure into a "termios". Ugh. */
arch/powerpc/Kconfig +0 -1
@@ -223,7 +223,6 @@ config PPC select HAVE_VIRT_CPU_ACCOUNTING select HAVE_IRQ_TIME_ACCOUNTING select HAVE_RSEQ - select HAS_TERMIOS_INTERNAL select IOMMU_HELPER if PPC64 select IRQ_DOMAIN select IRQ_FORCED_THREADING
arch/powerpc/include/asm/termios_internal.h deleted +0 -17
@@ -1,17 +0,0 @@ -/* -* Liberally adapted from alpha/termios.h. In particular, the c_cc[] -* fields have been reordered so that termio & termios share the -* common subset in the same order (for brain dead programs that don't -* know or care about the differences). -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version -* 2 of the License, or (at your option) any later version. -*/ -#ifndef _ASM_POWERPC_TERMIOS_H -#define _ASM_POWERPC_TERMIOS_H - -#define INIT_C_CC_VDISCARD 'U'-0x40 - -#endif /* _ASM_POWERPC_TERMIOS_H */
arch/sparc/include/asm/termios_internal.h +0 -2
@@ -13,8 +13,6 @@#define _VMIN 4#define _VTIME 5 -#define INIT_C_CC_VDISCARD 'U'-0x40 -/* * Translate a "termios" structure into a "termio". Ugh. *
include/linux/termios_internal.h +2 -7
@@ -11,14 +11,9 @@/* intr=^C quit=^\ erase=del kill=^U eof=^D vtime=\0 vmin=\1 sxtc=\0 start=^Q stop=^S susp=^Z eol=\0 -reprint=^R discard=^U werase=^W lnext=^V +reprint=^R discard=^O werase=^W lnext=^V eol2=\0 -... except that discard is actually ^O on most of them. */ -#ifndef INIT_C_CC_VDISCARD -#define INIT_C_CC_VDISCARD 'O'-0x40 -#endif -#ifdef VDSUSP #define INIT_C_CC_VDSUSP_EXTRA [VDSUSP] = 'Y'-0x40,#else
@@ -36,7 +31,7 @@ [VSTOP] = 'S'-0x40, \ [VSUSP] = 'Z'-0x40, \ [VREPRINT] = 'R'-0x40, \ - [VDISCARD] = INIT_C_CC_VDISCARD, \ + [VDISCARD] = 'O'-0x40, \ [VWERASE] = 'W'-0x40, \ [VLNEXT ] ='V' -0x40 , \INIT_C_CC_VDSUSP_EXTRA \
Re: [RFC][PATCH 1/8] start unifying termios convertors
In reply to Al ViroQuoted 11 lines · Al Viro
arch/sparc/include/asm/termios.h +11
-0+static inline int kernel_termios_to_user_termios (struct termios2 __user *u, +struct ktermios *k) +{ +int err; + err =put_user (k->c_iflag, &u->c_iflag); + err |=put_user (k->c_oflag, &u->c_oflag); + err |=put_user (k->c_cflag, &u->c_cflag); + err |=put_user (k->c_lflag, &u->c_lflag); + err |=put_user (k->c_line, &u->c_line); + err |=copy_to_user (u->c_cc, k->c_cc,NCCS ); +if (!(k->c_lflag &ICANON )) {
arch/sparc/include/asm/termios.h line 112
Quoted 10 lines
arch/sparc/include/asm/termios.h +10
-0+ err |=put_user (k->c_cc[VMIN ], &u->c_cc[_VMIN]); + err |=put_user (k->c_cc[VTIME ], &u->c_cc[_VTIME]); + }else { + err |=put_user (k->c_cc[VEOF ], &u->c_cc[VEOF ]); + err |=put_user (k->c_cc[VEOL ], &u->c_cc[VEOL ]); + } + err |=put_user (k->c_ispeed, &u->c_ispeed); + err |=put_user (k->c_ospeed, &u->c_ospeed); +return err; +}
Can you make this use || instead of |= ? That way if put_user() uses a goto-out-of-asm it may be a lot more efficient, both in the normal case and the error case.
David