termios.h cleanups
Subsystems (19)
RFC PATCH 1/1 termios.h cleanups
[resurrecting a patchset from back in 2018]
asm/termios.h has tons of duplication and rather convoluted
logics re includes.
asm/termios.h has both UAPI and internal variants. On seven
architectures (alpha, ia64, mips, parisc, powerpc, s390, sparc) both variants exist and internal one pulls the UAPI one by #include <uapi/asm/termios.h>. That is done very early in the internal header. Everything else has neither UAPI nor internal termios.h. Due to mandatory-y += termios.h
in include/uapi/asm-generic/Kbuild they get generated/uapi/asm/termios.h that consists of #include <asm-generic/termios.h>, which resolves to include/asm-generic/termios.h. That header serves as default internal asm/termios.h and it contains
#include <uapi/asm-generic/termios.h>, resolving to include/uapi/asm-generic/termios.h - default UAPI asm/termios.h. As with other internal asm/termios.h instances, that include happens very early in the file.
On loongarch there's a generated/asm/termios.h with the contents identical to what's in generated/uapi/asm/termios.h. Completely pointless, but it's hard to blame the loongarch folks here - the situation's much too confusing...
Besides the include of UAPI asm/termios.h, non-UAPI ones contain
the following:
* definition of INIT_C_CC
* definitions of conversion helpers:
user_termio_to_kernel_termios(), kernel_termios_to_user_termio(), user_termios_to_kernel_termios(), kernel_termios_to_user_termios()
* (possibly) definitions of more conversion helpers:
user_termios_to_kernel_termios_1(), kernel_termios_to_user_termios_1()
* (possibly) include of linux/uaccess.h [generic, mips, powerpc, s390]
* (possibly) include of linux/string.h [mips only]
The thing is, conversion headers are used only in one file -drivers/tty/tty_ioctl.c. INIT_C_CC has more users - all three of them:drivers/tty/hvc/hvcs.c, drivers/tty/tty_io.c and drivers/tty/vcc.c. All other users of termios.h (and there's quite a few of them, in particular due include in linux/tty.h) actually want the UAPI variant and, perhaps, indirect include of uaccess.h and/or string.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.
Patchset attempts to untangle that mess.
It takes the helpers and INIT_C_CC into new header (termios-internal.h), with defaults being in linux/termios-internal.h, unless an arch-specific variant is provided in asm/termios-internal.h (only alpha and sparc end up needing that). Files that need that stuff (all 4 of them) include linux/termios-internal.h.
asm/termios.h and linux/termios.h become UAPI-only after that.
This stuff lives ingit://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git work.termios
Individual patches in followups. Please, review; if nobody yells, this will go into -next.
Shortlog:
Al Viro (7):
loongarch: remove generic-y += termios.h
termios: get rid of stray asm/termios.h include in n_hdlc.c start unifying INIT_C_CC and termios convertors
termios: consolidate values for VDISCARD in INIT_C_CC make generic INIT_C_CC a bit more generic
termios: convert the last (sparc) INIT_C_CC to array
termios: get rid of non-UAPI asm/termios.h
Diffstat:
arch/Kconfig | 3 + arch/alpha/Kconfig | 1 + arch/alpha/include/asm/termios-internal.h | 70 ++++++++++++++ arch/alpha/include/asm/termios.h | 87 ------------------ arch/arm/mach-ep93xx/core.c | 1 + arch/arm/mach-versatile/integrator_ap.c | 1 + arch/ia64/include/asm/termios.h | 58 ------------ arch/loongarch/include/asm/Kbuild | 1 - arch/mips/include/asm/termios.h | 105 --------------------- arch/parisc/include/asm/termios.h | 52 ----------- arch/powerpc/include/asm/termios.h | 18 ---- arch/s390/include/asm/termios.h | 26 ------ arch/sparc/Kconfig | 1 + arch/sparc/include/asm/termios-internal.h | 132 +++++++++++++++++++++++++++ arch/sparc/include/asm/termios.h | 147 ------------------------------ drivers/net/wwan/wwan_core.c | 1 + drivers/tty/hvc/hvcs.c | 1 + drivers/tty/n_hdlc.c | 1 - drivers/tty/tty_io.c | 2 +- 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/serdev.h | 1 + include/linux/termios_internal.h | 131 ++++++++++++++++++++++++++ include/linux/tty_driver.h | 1 + 26 files changed, 347 insertions(+), 682 deletions(-)
PATCH 1/7 loongarch: remove generic-y += termios.h
not really needed - UAPI mandatory-y += termios.h is sufficient...
--- arch/loongarch/include/asm/Kbuild | 1 - 1 file changed, 1 deletion(-)
arch/loongarch/include/asm/Kbuild +0 -1
@@ -21,7 +21,6 @@ generic-y += shmbuf.h generic-y += statfs.h generic-y += socket.h generic-y += sockios.h -generic-y += termios.h generic-y += termbits.h generic-y += poll.h generic-y += param.h
Signature · 1 line
2.30.2
PATCH 2/7 termios: get rid of stray asm/termios.h include in n_hdlc.c
that's the only one outside of include/uapi/linux/termios.h and it's not even needed there - we have linux/tty.h already pulled and that pulls linux/termios.h
Normally I would not consider that a sufficient reason, but there's a plenty of linux/tty.h users, and this is the only one that follows that with asm/termios.h. The situation with termios.h is genuinely convoluted, and this complicates it for no good reason.
--- drivers/tty/n_hdlc.c | 1 - 1 file changed, 1 deletion(-)
drivers/tty/n_hdlc.c +0 -1
@@ -98,7 +98,6 @@#include <linux/if.h> #include <linux/bitops.h> -#include <asm/termios.h> #include <linux/uaccess.h> #include "tty.h"
Signature · 1 line
2.30.2
PATCH 3/7 start unifying INIT_C_CC and termios convertors
In reply to Al Viro* new header (linut/termios_internal.h), pulled by the users of those suckers
* defaults for INIT_C_CC and conversion helpers moved over there
* remove termios-base.h (empty now)
--- arch/alpha/include/asm/termios.h | 110 +++++++-------- arch/ia64/include/asm/termios.h | 45 ------ arch/mips/include/asm/termios.h | 81 ----------- arch/parisc/include/asm/termios.h | 45 ------ arch/powerpc/include/asm/termios.h | 2 - arch/s390/include/asm/termios.h | 14 -- arch/sparc/include/asm/termios.h | 217 ++++++++++++++--------------- drivers/tty/hvc/hvcs.c | 1 + drivers/tty/tty_io.c | 2 +- drivers/tty/tty_ioctl.c | 1 + drivers/tty/vcc.c | 1 + include/asm-generic/termios-base.h | 78 ----------- include/asm-generic/termios.h | 99 ------------- include/linux/termios_internal.h | 109 +++++++++++++++ 14 files changed, 272 insertions(+), 533 deletions(-) delete mode 100644 include/asm-generic/termios-base.h create mode 100644 include/linux/termios_internal.h
arch/alpha/include/asm/termios.h +52 -58
@@ -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,72 +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)); \ -}) - -#define user_termios_to_kernel_termios (k, u) \ - copy_from_user(k, u, sizeof(struct termios2)) +static inline int kernel_termios_to_user_termio (struct termio __user *termio, +struct ktermios *termios) +{ +struct termio v; +bool canon; -#define kernel_termios_to_user_termios (u, k) \ - copy_to_user(u, k, sizeof(struct termios2)) +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; -#define user_termios_to_kernel_termios_1 (k, u) \ - copy_from_user(k, u, sizeof(struct termios)) + 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 ]; -#define kernel_termios_to_user_termios_1 (u, k) \ - copy_to_user(u, k, sizeof(struct termios)) +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 -45
49 lines not on this page · raw message
arch/mips/include/asm/termios.h +0 -81
85 lines not on this page · raw message
arch/parisc/include/asm/termios.h +0 -45
49 lines not on this page · raw message
arch/powerpc/include/asm/termios.h +0 -2
@@ -13,6 +13,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 -14
@@ -9,18 +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" - -#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 +107 -110
237 lines not on this page · raw message
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 -1
@@ -99,8 +99,8 @@#include <linux/serial.h> #include <linux/ratelimit.h> #include <linux/compat.h> -#include <linux/uaccess.h> +#include <linux/termios_internal.h> #include <linux/kbd_kern.h> #include <linux/vt_kern.h>
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 "tty.h" #include <asm/io.h>
drivers/tty/vcc.c +1 -0
@@ -11,6 +11,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-base.h deleted +0 -78
78 lines not on this page · raw message
include/asm-generic/termios.h +0 -99
103 lines not on this page · raw message
include/linux/termios_internal.h new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH 4/7 termios: consolidate values for VDISCARD in INIT_C_CC
In reply to Al ViroOn old systems it used to be ^O. Linux had never actually used the value, but INIT_C_CC (on i386) did initialize it to ^O; unfortunately, it had a typo in the comment claiming that to be ^U. Most of the architectures copied the (correct) definition along with mistaken comment. alpha, powerpc and sparc tried to make the definition match comment.
However, util-linux still resets it to ^O on any architecture, ^O is the historical value, kernel ignores it anyway and finally, Linus said "Just change everybody to do the same, nobody cares about VDISCARD".
--- arch/alpha/include/asm/termios.h | 4 ++-- arch/mips/include/asm/termios.h | 2 +- arch/powerpc/include/asm/termios.h | 4 ++-- arch/sparc/include/asm/termios.h | 4 ++-- include/linux/termios_internal.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-)
arch/alpha/include/asm/termios.h +2 -2
@@ -8,10 +8,10 @@/* 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 +start=^Q stop=^S lnext=^V discard=^O 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 "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\017\001\000"/* * Translate a "termio" structure into a "termios". Ugh.
arch/mips/include/asm/termios.h +1 -1
@@ -16,7 +16,7 @@* 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 +* reprint=^R discard=^O 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"
arch/powerpc/include/asm/termios.h +2 -2
@@ -10,7 +10,7 @@#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" +/* ^C ^\ del ^U ^D 1 0 0 0 0 ^W ^R ^Z ^Q ^S ^V ^O */ +#define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\017"#endif /* _ASM_POWERPC_TERMIOS_H */
arch/sparc/include/asm/termios.h +2 -2
@@ -20,10 +20,10 @@/* 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 +reprint=^R discard=^O 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 "\003\034\177\025\004\000\000\000\021\023\032\031\022\017\027\026\001"/* * Translate a "termios" structure into a "termio". Ugh.
include/linux/termios_internal.h +1 -1
@@ -9,7 +9,7 @@/* 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 */ #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
Signature · 1 line
2.30.2
Re: [PATCH 4/7] termios: consolidate values for VDISCARD in INIT_C_CC
Quoted 5 lines · Al Viro
However, util-linux still resets it to ^O on any architecture, ^O is the historical value, kernel ignores it anyway and finally, Linus said "Just change everybody to do the same, nobody cares about VDISCARD".
Heh. Grepping for DISCARD_CHAR() shows that there literally doesn't seem to be any user.
I guess some user space program could care what the initial value is, but it seems very unlikely.
Linus
Re: [PATCH 4/7] termios: consolidate values for VDISCARD in INIT_C_CC
Quoted 7 lines · Linus Torvalds
Quoted 5 lines · Al Viro
However, util-linux still resets it to ^O on any architecture, ^O is the historical value, kernel ignores it anyway and finally, Linus said "Just change everybody to do the same, nobody cares about VDISCARD".
Quoted 5 lines
Heh. Grepping for
DISCARD_CHAR()shows that there literally doesn't seem to be any user.I guess some user space program could care what the initial value is, but it seems very unlikely.
Quite, especially since those programs would have to run before
getty gets a chance to reset the sucker to ^O...
PATCH 5/7 make generic INIT_C_CC a bit more generic
In reply to Al Viroturn it into an array initializer; then alpha, mips and powerpc variants fold into it.
--- arch/alpha/include/asm/termios.h | 8 -------- arch/mips/include/asm/termios.h | 9 --------- arch/powerpc/include/asm/termios.h | 3 --- include/linux/termios_internal.h | 15 ++++++++++++++- 4 files changed, 14 insertions(+), 21 deletions(-)
arch/alpha/include/asm/termios.h +0 -8
@@ -5,14 +5,6 @@#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> -start=^Q stop=^S lnext=^V discard=^O -vmin=\1 vtime=\0 -*/ -#define INIT_C_CC "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\017\001\000" -/* * Translate a "termio" structure into a "termios". Ugh. */
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=^O 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 */
arch/powerpc/include/asm/termios.h +0 -3
@@ -10,7 +10,4 @@#include <uapi/asm/termios.h> -/* ^C ^\ del ^U ^D 1 0 0 0 0 ^W ^R ^Z ^Q ^S ^V ^O */ -#define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\017" -#endif /* _ASM_POWERPC_TERMIOS_H */
include/linux/termios_internal.h +14 -1
@@ -12,7 +12,20 @@reprint=^R discard=^O 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.30.2
PATCH 6/7 termios: convert the last (sparc) INIT_C_CC to array
In reply to Al Viro--- arch/sparc/include/asm/termios.h | 8 -------- include/linux/termios_internal.h | 10 ++++++++-- 2 files changed, 8 insertions(+), 10 deletions(-)
arch/sparc/include/asm/termios.h +0 -8
@@ -17,14 +17,6 @@#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=^O 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\017\027\026\001" -/* * Translate a "termios" structure into a "termio". Ugh. *
include/linux/termios_internal.h +8 -2
@@ -5,13 +5,19 @@#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=^O werase=^W lnext=^V eol2=\0 */ + +#ifdef VDSUSP +#define INIT_C_CC_VDSUSP_EXTRA [VDSUSP] = 'Y'-0x40, +#else +#define INIT_C_CC_VDSUSP_EXTRA +#endif +#define INIT_C_CC { \ [VINTR] = 'C'-0x40, \ [VQUIT] = '\\'-0x40, \
@@ -25,8 +31,8 @@ [VDISCARD] = 'O'-0x40, \ [VWERASE] = 'W'-0x40, \ [VLNEXT ] ='V' -0x40 , \ +INIT_C_CC_VDSUSP_EXTRA \ [VMIN] = 1 } -#endif #ifndef user_termio_to_kernel_termios/*
Signature · 1 line
2.30.2
PATCH 7/7 termios: get rid of non-UAPI asm/termios.h
In reply to Al Viro There are exactly two places where we include <asm/termios.h> -include/uapi/linux/termios.h and include/linux/termios-internal.h. The latter cares about the conversion functions; the former does not.
So take those into asm/termios-internal.h and havelinux/termios-internal.h include that in addition to asm/termios.h (conditional upon the config symbol selected by the both architectures where such non-default functions exist - alpha and sparc, that is).
That would leave non-UAPI asm/termios.h consisting of include
of its UAPI counterpart and possibly an include of linux/uaccess.h.
The latter can't be simply removed, even though nothing inlinux/termios.h doesn't depend upon it anymore - there are several places that rely upon that indirect chain of includes to pull linux/uaccess.h. So the include needs to be lifted out of there - we lift into tty_driver.h, serdev.h and places that pull asm/termios.h, but none of
* linux/uaccess.h (obvious)
* net/sock.h (pulls uaccess.h)
* linux/{tty,tty_driver,serdev}.h (tty.h pulls tty_driver.h)
That leaves us just with the include of UAPI asm/termios.h, which is what <asm/termios.h> will resolve to if we simply remove non-UAPI header.
---
arch/Kconfig | 3 +++
arch/alpha/Kconfig | 1 +
.../include/asm/{termios.h => termios-internal.h} | 3 ---
arch/arm/mach-ep93xx/core.c | 1 +
arch/arm/mach-versatile/integrator_ap.c | 1 +
arch/ia64/include/asm/termios.h | 13 -------------
arch/mips/include/asm/termios.h | 15 ---------------
arch/parisc/include/asm/termios.h | 7 -------
arch/powerpc/include/asm/termios.h | 13 -------------
arch/s390/include/asm/termios.h | 12 ------------
arch/sparc/Kconfig | 1 +
.../include/asm/{termios.h => termios-internal.h} | 4 ----
drivers/net/wwan/wwan_core.c | 1 +
include/asm-generic/termios.h | 9 ---------
include/linux/serdev.h | 1 +
include/linux/termios_internal.h | 3 +++
include/linux/tty_driver.h | 1 +
17 files changed, 13 insertions(+), 76 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
delete mode 100644 arch/powerpc/include/asm/termios.h
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
@@ -1416,6 +1416,9 @@ config DYNAMIC_SIGFRAME config HAVE_ARCH_NODE_DEV_GROUP bool +config ARCH_HAS_TERMIOS_INTERNAL + bool + source "kernel/gcov/Kconfig" source "scripts/gcc-plugins/Kconfig"
arch/alpha/Kconfig +1 -0
@@ -35,6 +35,7 @@ config ALPHA select MMU_GATHER_NO_RANGE select SPARSEMEM_EXTREME if SPARSEMEM select ZONE_DMA + select ARCH_HAS_TERMIOS_INTERNAL help The Alpha is a 64-bit general-purpose processor designed and marketed by the Digital Equipment Corporation of blessed memory,
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> -/* * Translate a "termio" structure into a "termios". Ugh. */
arch/arm/mach-ep93xx/core.c +1 -0
@@ -22,6 +22,7 @@#include <linux/io.h> #include <linux/gpio.h> #include <linux/leds.h> +#include <linux/uaccess.h> #include <linux/termios.h> #include <linux/amba/bus.h> #include <linux/amba/serial.h>
arch/arm/mach-versatile/integrator_ap.c +1 -0
@@ -11,6 +11,7 @@#include <linux/of_irq.h> #include <linux/of_address.h> #include <linux/of_platform.h> +#include <linux/uaccess.h> #include <linux/termios.h> #include <linux/mfd/syscon.h> #include <linux/regmap.h>
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/include/asm/termios.h deleted +0 -13
@@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* -* 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). -*/ -#ifndef _ASM_POWERPC_TERMIOS_H -#define _ASM_POWERPC_TERMIOS_H - -#include <uapi/asm/termios.h> - -#endif /* _ASM_POWERPC_TERMIOS_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
@@ -47,6 +47,7 @@ config SPARC select NEED_DMA_MAP_STATE select NEED_SG_DMA_LENGTH select TRACE_IRQFLAGS_SUPPORT + select ARCH_HAS_TERMIOS_INTERNAL config SPARC32 def_bool !64BIT
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/net/wwan/wwan_core.c +1 -0
@@ -13,6 +13,7 @@#include <linux/skbuff.h> #include <linux/slab.h> #include <linux/types.h> +#include <linux/uaccess.h> #include <linux/termios.h> #include <linux/wwan.h> #include <net/rtnetlink.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/serdev.h +1 -0
@@ -7,6 +7,7 @@#include <linux/types.h> #include <linux/device.h> +#include <linux/uaccess.h> #include <linux/termios.h> #include <linux/delay.h>
include/linux/termios_internal.h +3 -0
@@ -4,6 +4,9 @@#include <linux/uaccess.h> #include <asm/termios.h> +#ifdef CONFIG_ARCH_HAS_TERMIOS_INTERNAL +#include <asm/termios-internal.h> +#endif /* intr=^C quit=^\ erase=del kill=^U eof=^D vtime=\0 vmin=\1 sxtc=\0
include/linux/tty_driver.h +1 -0
@@ -7,6 +7,7 @@#include <linux/kref.h> #include <linux/list.h> #include <linux/cdev.h> +#include <linux/uaccess.h> #include <linux/termios.h> #include <linux/seq_file.h>
Signature · 1 line
2.30.2
Quoted 6 lines · Al Viro
It takes the helpers and
INIT_C_CCinto new header (termios-internal.h), with defaults being inlinux/termios-internal.h, unless an arch-specific variant is provided inasm/termios-internal.h(only alpha and sparc end up needing that). Files that need that stuff (all 4 of them) includelinux/termios-internal.h.
I don't see anything obviously wrong here, and my main reaction is actually that I wish this went a bit further, and moved the whole kernel_termios_to_user_termios stuff into C code rather than having them in headers.
I don't think it's really worth inlining those things, and I wonder if we could just have the default "just copy directly to/from user space" as __weak functions, and then allow sparc and alpha to override them?
Linus
Quoted 8 lines · Linus Torvalds
Quoted 6 lines · Al Viro
It takes the helpers and
INIT_C_CCinto new header (termios-internal.h), with defaults being inlinux/termios-internal.h, unless an arch-specific variant is provided inasm/termios-internal.h(only alpha and sparc end up needing that). Files that need that stuff (all 4 of them) includelinux/termios-internal.h.
Quoted 8 lines
I don't see anything obviously wrong here, and my main reaction is actually that I wish this went a bit further, and moved the whole
kernel_termios_to_user_termiosstuff into C code rather than having them in headers.I don't think it's really worth inlining those things, and I wonder if we could just have the default "just copy directly to/from user space" as
__weakfunctions, and then allow sparc and alpha to override them?
Umm... Might as well, I guess... Where to put those, though?drivers/tty/tty_ioctl.c is not an option, unfortunately - it'll pick the local definitions, __weak or no __weak. drivers/tty/termios.c just for those? Looks just as convoluted as having those as inlines...
Quoted 4 lines · Al Viro
Umm... Might as well, I guess... Where to put those, though?
drivers/tty/tty_ioctl.cis not an option, unfortunately - it'll pick the local definitions,__weakor no__weak.
IThat bug is ancient history, and tty_ioctl.c is just fine.
Yes, we used to have the "you can't have __weak function definitions in the same file that uses them" rule.
But it was due to a bug in gcc-4.1, which would inline weak functions.
But we long since gave up on gcc-4.1, and we have __weak functions declarations in the same file as the use in multiple places. See for example arch_release_task_struct() in kernel/fork.c.
Linus
Quoted 8 lines · Linus Torvalds
Quoted 4 lines · Al Viro
Umm... Might as well, I guess... Where to put those, though?
drivers/tty/tty_ioctl.cis not an option, unfortunately - it'll pick the local definitions,__weakor no__weak.IThat bug is ancient history, and
tty_ioctl.cis just fine.
Quoted 8 lines
Yes, we used to have the "you can't have
__weakfunction definitions in the same file that uses them" rule.But it was due to a bug in gcc-4.1, which would inline weak functions.
But we long since gave up on gcc-4.1, and we have
__weakfunctions declarations in the same file as the use in multiple places. See for examplearch_release_task_struct()inkernel/fork.c.
OK, that allows to reorder the whole thing better... See #work.termios2 (very lightly tested)
PATCH v2 1/8 loongarch: remove generic-y += termios.h
not really needed - UAPI mandatory-y += termios.h is sufficient...
--- arch/loongarch/include/asm/Kbuild | 1 - 1 file changed, 1 deletion(-)
arch/loongarch/include/asm/Kbuild +0 -1
@@ -21,7 +21,6 @@ generic-y += shmbuf.h generic-y += statfs.h generic-y += socket.h generic-y += sockios.h -generic-y += termios.h generic-y += termbits.h generic-y += poll.h generic-y += param.h
Signature · 1 line
2.30.2
PATCH v2 2/8 termios: get rid of stray asm/termios.h include in n_hdlc.c
that's the only one outside of include/uapi/linux/termios.h and it's not even needed there - we have linux/tty.h already pulled and that pulls linux/termios.h
Normally I would not consider that a sufficient reason, but there's a plenty of linux/tty.h users, and this is the only one that follows that with asm/termios.h. The situation with termios.h is genuinely convoluted, and this complicates it for no good reason.
--- drivers/tty/n_hdlc.c | 1 - 1 file changed, 1 deletion(-)
drivers/tty/n_hdlc.c +0 -1
@@ -98,7 +98,6 @@#include <linux/if.h> #include <linux/bitops.h> -#include <asm/termios.h> #include <linux/uaccess.h> #include "tty.h"
Signature · 1 line
2.30.2
PATCH v2 3/8 termios: uninline conversion helpers
In reply to Al Virodefault go into drivers/tty/tty_ioctl.c, unusual - into arch/*/kernel/termios.c (only alpha and sparc have those).
--- arch/alpha/include/asm/termios.h | 77 ++-------------- arch/alpha/kernel/Makefile | 2 +- arch/alpha/kernel/termios.c | 57 ++++++++++++ arch/ia64/include/asm/termios.h | 41 ++------- arch/mips/include/asm/termios.h | 84 ++---------------- arch/parisc/include/asm/termios.h | 41 ++------- arch/sparc/include/asm/termios.h | 136 ++--------------------------- arch/sparc/kernel/Makefile | 4 +- arch/sparc/kernel/termios.c | 115 ++++++++++++++++++++++++ drivers/tty/tty_ioctl.c | 74 ++++++++++++++++ include/asm-generic/termios-base.h | 69 ++------------- include/asm-generic/termios.h | 42 ++------- 12 files changed, 294 insertions(+), 448 deletions(-) create mode 100644 arch/alpha/kernel/termios.c create mode 100644 arch/sparc/kernel/termios.c
arch/alpha/include/asm/termios.h +6 -71
@@ -12,76 +12,11 @@*/ #define INIT_C_CC "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\025\001\000" -/* -* 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; \ -}) - -/* -* 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)); \ -}) - -#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)) +int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); +int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); +int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); +int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); +int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); +int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *);#endif /* _ALPHA_TERMIOS_H */
arch/alpha/kernel/Makefile +1 -1
@@ -9,7 +9,7 @@ ccflags-y := -Wno-sign-compare obj-y := entry.o traps.o process.o osf_sys.o irq.o \ irq_alpha.o signal.o setup.o ptrace.o time.o \ - systbls.o err_common.o io.o bugs.o + systbls.o err_common.o io.o bugs.o termios.o obj-$(CONFIG_VGA_HOSE) += console.o obj-$(CONFIG_SMP) += smp.o
arch/alpha/kernel/termios.c new file +57 -0
57 lines not on this page · raw message
arch/ia64/include/asm/termios.h +6 -35
46 lines not on this page · raw message
arch/mips/include/asm/termios.h +6 -78
89 lines not on this page · raw message
arch/parisc/include/asm/termios.h +6 -35
46 lines not on this page · raw message
arch/sparc/include/asm/termios.h +6 -130
147 lines not on this page · raw message
arch/sparc/kernel/Makefile +3 -1
@@ -87,12 +87,13 @@ obj-$(CONFIG_SPARC64_SMP) += hvtramp.o obj-y += auxio_$(BITS).o obj-$(CONFIG_SUN_PM) += apc.o pmc.o +obj-y += termios.o + obj-$(CONFIG_MODULES) += module.o obj-$(CONFIG_MODULES) += sparc_ksyms.o obj-$(CONFIG_SPARC_LED) += led.o obj-$(CONFIG_KGDB) += kgdb_$(BITS).o - obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
@@ -104,6 +105,7 @@ obj-$(CONFIG_SPARC64_PCI) += pci_psycho.o pci_sabre.o pci_schizo.o obj-$(CONFIG_SPARC64_PCI) += pci_sun4v.o pci_sun4v_asm.o pci_fire.o obj-$(CONFIG_SPARC64_PCI_MSI) += pci_msi.o + obj-$(CONFIG_COMPAT) += sys32.o sys_sparc32.o signal32.o obj-$(CONFIG_US3_MC) += chmc.o
arch/sparc/kernel/termios.c new file +115 -0
115 lines not on this page · raw message
drivers/tty/tty_ioctl.c +74 -0
80 lines not on this page · raw message
include/asm-generic/termios-base.h +6 -63
75 lines not on this page · raw message
include/asm-generic/termios.h +8 -34
50 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerRe: [PATCH v2 3/8] termios: uninline conversion helpers
Quoted 4 lines · Al Viro
default go into
drivers/tty/tty_ioctl.c, unusual - intoarch/*/kernel/termios.c(only alpha and sparc have those).Signed-off-by Al Viro <[email protected]>
Quoted 16 lines
--- arch/alpha/include/asm/termios.h | 77 ++-------------- arch/alpha/kernel/Makefile | 2 +- arch/alpha/kernel/termios.c | 57 ++++++++++++ arch/ia64/include/asm/termios.h | 41 ++------- arch/mips/include/asm/termios.h | 84 ++---------------- arch/parisc/include/asm/termios.h | 41 ++------- arch/sparc/include/asm/termios.h | 136 ++--------------------------- arch/sparc/kernel/Makefile | 4 +- arch/sparc/kernel/termios.c | 115 ++++++++++++++++++++++++ drivers/tty/tty_ioctl.c | 74 ++++++++++++++++ include/asm-generic/termios-base.h | 69 ++------------- include/asm-generic/termios.h | 42 ++------- 12 files changed, 294 insertions(+), 448 deletions(-) create mode 100644 arch/alpha/kernel/termios.c create mode 100644 arch/sparc/kernel/termios.c
The build blows up on me with this commit added to my tty-testing tree:
In file included from ./arch/x86/include/generated/uapi/asm/termios.h:1,
from ./include/uapi/linux/termios.h:6,
from ./include/linux/tty.h:7,
from ./include/linux/vt_kern.h:12,
from drivers/gpu/drm/vboxvideo/vbox_drv.c:12:
./include/asm-generic/termios.h:70:5: error: conflicting types for ‘user_termio_to_kernel_termios’; have ‘int(struct ktermios *, struct termio *)’
70 | int user_termio_to_kernel_termios(struct ktermios *, struct termio __user *);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/termios.h:20:19: note: previous definition of ‘user_termio_to_kernel_termios’ with type ‘int(struct ktermios *, const struct termio *)’
20 | static inline int user_termio_to_kernel_termios(struct ktermios *termios,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~Lots of stuff like that.
I'll take the first 2 in my tree, but stop here.
thanks,
greg k-h
Re: [PATCH v2 3/8] termios: uninline conversion helpers
Quoted 22 lines · Greg Kroah-Hartman
Quoted 4 lines · Al Viro
default go into
drivers/tty/tty_ioctl.c, unusual - intoarch/*/kernel/termios.c(only alpha and sparc have those).Signed-off-by Al Viro <[email protected]>Quoted 16 lines
--- arch/alpha/include/asm/termios.h | 77 ++-------------- arch/alpha/kernel/Makefile | 2 +- arch/alpha/kernel/termios.c | 57 ++++++++++++ arch/ia64/include/asm/termios.h | 41 ++------- arch/mips/include/asm/termios.h | 84 ++---------------- arch/parisc/include/asm/termios.h | 41 ++------- arch/sparc/include/asm/termios.h | 136 ++--------------------------- arch/sparc/kernel/Makefile | 4 +- arch/sparc/kernel/termios.c | 115 ++++++++++++++++++++++++ drivers/tty/tty_ioctl.c | 74 ++++++++++++++++ include/asm-generic/termios-base.h | 69 ++------------- include/asm-generic/termios.h | 42 ++------- 12 files changed, 294 insertions(+), 448 deletions(-) create mode 100644 arch/alpha/kernel/termios.c create mode 100644 arch/sparc/kernel/termios.c
Quoted 1 line
The build blows up on me with this commit added to my tty-testing tree:
My apologies - reordering damage. inlines in include/asm-generic/termios.h should've been removed in this commit, not in the next one.
Anyway, fixed branch rebased on top of your #tty-next; see vfs.git #work.termios2. Individual patches in followups...
PATCH v3 1/6 termios: uninline conversion helpers
From 8fac9645e1d22389a65a13f1b506356bcfbb0f14 Mon Sep 17 00:00:00 2001
From: Al Viro <[email protected]>
Date: Sat, 20 Aug 2022 19:36:09 -0400
Subject: [PATCH v3 1/6] termios: uninline conversion helpers
default go into drivers/tty/tty_ioctl.c, unusual - into arch/*/kernel/termios.c (only alpha and sparc have those).
--- arch/alpha/include/asm/termios.h | 77 ++-------------- arch/alpha/kernel/Makefile | 2 +- arch/alpha/kernel/termios.c | 57 ++++++++++++ arch/ia64/include/asm/termios.h | 41 ++------- arch/mips/include/asm/termios.h | 84 ++---------------- arch/parisc/include/asm/termios.h | 41 ++------- arch/sparc/include/asm/termios.h | 136 ++--------------------------- arch/sparc/kernel/Makefile | 4 +- arch/sparc/kernel/termios.c | 115 ++++++++++++++++++++++++ drivers/tty/tty_ioctl.c | 74 ++++++++++++++++ include/asm-generic/termios-base.h | 69 ++------------- include/asm-generic/termios.h | 95 ++------------------ 12 files changed, 294 insertions(+), 501 deletions(-) create mode 100644 arch/alpha/kernel/termios.c create mode 100644 arch/sparc/kernel/termios.c
arch/alpha/include/asm/termios.h +6 -71
@@ -12,76 +12,11 @@*/ #define INIT_C_CC "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\025\001\000" -/* -* 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; \ -}) - -/* -* 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)); \ -}) - -#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)) +int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); +int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); +int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); +int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); +int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); +int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *);#endif /* _ALPHA_TERMIOS_H */
arch/alpha/kernel/Makefile +1 -1
@@ -9,7 +9,7 @@ ccflags-y := -Wno-sign-compare obj-y := entry.o traps.o process.o osf_sys.o irq.o \ irq_alpha.o signal.o setup.o ptrace.o time.o \ - systbls.o err_common.o io.o bugs.o + systbls.o err_common.o io.o bugs.o termios.o obj-$(CONFIG_VGA_HOSE) += console.o obj-$(CONFIG_SMP) += smp.o
arch/alpha/kernel/termios.c new file +57 -0
57 lines not on this page · raw message
arch/ia64/include/asm/termios.h +6 -35
46 lines not on this page · raw message
arch/mips/include/asm/termios.h +6 -78
89 lines not on this page · raw message
arch/parisc/include/asm/termios.h +6 -35
46 lines not on this page · raw message
arch/sparc/include/asm/termios.h +6 -130
147 lines not on this page · raw message
arch/sparc/kernel/Makefile +3 -1
@@ -87,12 +87,13 @@ obj-$(CONFIG_SPARC64_SMP) += hvtramp.o obj-y += auxio_$(BITS).o obj-$(CONFIG_SUN_PM) += apc.o pmc.o +obj-y += termios.o + obj-$(CONFIG_MODULES) += module.o obj-$(CONFIG_MODULES) += sparc_ksyms.o obj-$(CONFIG_SPARC_LED) += led.o obj-$(CONFIG_KGDB) += kgdb_$(BITS).o - obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
@@ -104,6 +105,7 @@ obj-$(CONFIG_SPARC64_PCI) += pci_psycho.o pci_sabre.o pci_schizo.o obj-$(CONFIG_SPARC64_PCI) += pci_sun4v.o pci_sun4v_asm.o pci_fire.o obj-$(CONFIG_SPARC64_PCI_MSI) += pci_msi.o + obj-$(CONFIG_COMPAT) += sys32.o sys_sparc32.o signal32.o obj-$(CONFIG_US3_MC) += chmc.o
arch/sparc/kernel/termios.c new file +115 -0
115 lines not on this page · raw message
drivers/tty/tty_ioctl.c +74 -0
80 lines not on this page · raw message
include/asm-generic/termios-base.h +6 -63
75 lines not on this page · raw message
include/asm-generic/termios.h +8 -87
103 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v3 2/6 termios: start unifying non-UAPI parts of asm/termios.h
In reply to Al ViroFrom 73e0c06d136dff9b5f7be354b1c46c45fb581a9d Mon Sep 17 00:00:00 2001
From: Al Viro <[email protected]>
Date: Thu, 16 Aug 2018 11:47:53 -0400
Subject: [PATCH v3 2/6] termios: start unifying non-UAPI parts of
asm/termios.h
* new header (linut/termios_internal.h), pulled by the users of those suckers
* defaults for INIT_C_CC and externs for conversion helpers moved over there
* remove termios-base.h (empty now)
--- arch/alpha/include/asm/termios.h | 8 +------- arch/alpha/kernel/termios.c | 3 +-- arch/ia64/include/asm/termios.h | 16 ---------------- arch/mips/include/asm/termios.h | 9 --------- arch/parisc/include/asm/termios.h | 16 ---------------- arch/powerpc/include/asm/termios.h | 2 -- arch/s390/include/asm/termios.h | 14 -------------- arch/sparc/include/asm/termios.h | 8 +------- arch/sparc/kernel/termios.c | 4 ++-- drivers/tty/hvc/hvcs.c | 1 + drivers/tty/tty_io.c | 2 +- drivers/tty/tty_ioctl.c | 1 + drivers/tty/vcc.c | 1 + include/asm-generic/termios-base.h | 21 --------------------- include/asm-generic/termios.h | 20 -------------------- include/linux/termios_internal.h | 30 ++++++++++++++++++++++++++++++ 16 files changed, 39 insertions(+), 117 deletions(-) delete mode 100644 include/asm-generic/termios-base.h create mode 100644 include/linux/termios_internal.h
arch/alpha/include/asm/termios.h +1 -7
@@ -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
@@ -12,11 +13,4 @@*/ #define INIT_C_CC "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\025\001\000" -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#endif /* _ALPHA_TERMIOS_H */
arch/alpha/kernel/termios.c +1 -2
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/uaccess.h> -#include <linux/termios.h> +#include <linux/termios_internal.h> int user_termio_to_kernel_termios (struct ktermios *termios,struct termio __user *termio)
arch/ia64/include/asm/termios.h +0 -16
@@ -10,20 +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" - -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#endif /* _ASM_IA64_TERMIOS_H */
arch/mips/include/asm/termios.h +0 -9
@@ -21,13 +21,4 @@*/ #define INIT_C_CC "\003\034\177\025\1\0\0\0\021\023\032\0\022\017\027\026\004\0" -#include <linux/string.h> - -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#endif /* _ASM_TERMIOS_H */
arch/parisc/include/asm/termios.h +0 -16
@@ -4,20 +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" - -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#endif /* _PARISC_TERMIOS_H */
arch/powerpc/include/asm/termios.h +0 -2
@@ -13,6 +13,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 -14
@@ -9,18 +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" - -#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 +1 -7
@@ -3,6 +3,7 @@#define _SPARC_TERMIOS_H#include <uapi/asm/termios.h> +#include <linux/uaccess.h> /* intr=^C quit=^\ erase=del kill=^U
@@ -13,11 +14,4 @@*/ #define INIT_C_CC "\003\034\177\025\004\000\000\000\021\023\032\031\022\025\027\026\001" -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#endif /* _SPARC_TERMIOS_H */
arch/sparc/kernel/termios.c +2 -2
@@ -1,5 +1,5 @@ -#include <linux/uaccess.h> -#include <linux/termios.h> +// SPDX-License-Identifier: GPL-2.0 +#include <linux/termios_internal.h> /* * c_cc characters in the termio structure. Oh, how I love being
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 -1
@@ -99,8 +99,8 @@#include <linux/serial.h> #include <linux/ratelimit.h> #include <linux/compat.h> -#include <linux/uaccess.h> +#include <linux/termios_internal.h> #include <linux/kbd_kern.h> #include <linux/vt_kern.h>
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 "tty.h" #include <asm/io.h>
drivers/tty/vcc.c +1 -0
@@ -11,6 +11,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-base.h deleted +0 -21
@@ -1,21 +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> - -#ifndef __ARCH_TERMIO_GETPUT - -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); - -#endif /* __ARCH_TERMIO_GETPUT */ - -#endif /* _ASM_GENERIC_TERMIOS_BASE_H */
include/asm-generic/termios.h +0 -20
@@ -6,24 +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" - -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -#ifdef TCGETS2 -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#else /* TCGETS2 */ -int user_termios_to_kernel_termios (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios (struct termios __user *,struct ktermios *); -#endif /* TCGETS2 */ -#endif /* _ASM_GENERIC_TERMIOS_H */
include/linux/termios_internal.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_TERMIOS_CONV_H +#define _LINUX_TERMIOS_CONV_H + +#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 + +int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); +int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); +#ifdef TCGETS2 +int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); +int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); +int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); +int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); +#else /* TCGETS2 */ +int user_termios_to_kernel_termios (struct ktermios *,struct termios __user *); +int kernel_termios_to_user_termios (struct termios __user *,struct ktermios *); +#endif /* TCGETS2 */ + +#endif /* _LINUX_TERMIOS_CONV_H */
Signature · 1 line
2.30.2
PATCH v3 3/6 termios: consolidate values for VDISCARD in INIT_C_CC
In reply to Al ViroFrom 8333c84c3a05dea5f70d0a200180cd445f316fb0 Mon Sep 17 00:00:00 2001
From: Al Viro <[email protected]>
Date: Tue, 9 Aug 2022 17:17:04 -0400
Subject: [PATCH v3 3/6] termios: consolidate values for VDISCARD in INIT_C_CC
On old systems it used to be ^O. Linux had never actually used the value, but INIT_C_CC (on i386) did initialize it to ^O; unfortunately, it had a typo in the comment claiming that to be ^U. Most of the architectures copied the (correct) definition along with mistaken comment. alpha, powerpc and sparc tried to make the definition match comment.
However, util-linux still resets it to ^O on any architecture, ^O is the historical value, kernel ignores it anyway and finally, Linus said "Just change everybody to do the same, nobody cares about VDISCARD".
--- arch/alpha/include/asm/termios.h | 4 ++-- arch/mips/include/asm/termios.h | 2 +- arch/powerpc/include/asm/termios.h | 4 ++-- arch/sparc/include/asm/termios.h | 4 ++-- include/linux/termios_internal.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-)
arch/alpha/include/asm/termios.h +2 -2
@@ -8,9 +8,9 @@/* 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 +start=^Q stop=^S lnext=^V discard=^O 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 "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\017\001\000"#endif /* _ALPHA_TERMIOS_H */
arch/mips/include/asm/termios.h +1 -1
@@ -16,7 +16,7 @@* 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 +* reprint=^R discard=^O 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"
arch/powerpc/include/asm/termios.h +2 -2
@@ -10,7 +10,7 @@#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" +/* ^C ^\ del ^U ^D 1 0 0 0 0 ^W ^R ^Z ^Q ^S ^V ^O */ +#define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\017"#endif /* _ASM_POWERPC_TERMIOS_H */
arch/sparc/include/asm/termios.h +2 -2
@@ -9,9 +9,9 @@/* 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 +reprint=^R discard=^O 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 "\003\034\177\025\004\000\000\000\021\023\032\031\022\017\027\026\001"#endif /* _SPARC_TERMIOS_H */
include/linux/termios_internal.h +1 -1
@@ -9,7 +9,7 @@/* 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 */ #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
Signature · 1 line
2.30.2
PATCH v3 4/6 make generic INIT_C_CC a bit more generic
In reply to Al ViroFrom 54bdf984b1bb317f732a49ff8c1db59f8534de4f Mon Sep 17 00:00:00 2001
From: Al Viro <[email protected]>
Date: Sun, 9 Sep 2018 17:57:42 -0400
Subject: [PATCH v3 4/6] make generic INIT_C_CC a bit more generic
turn it into an array initializer; then alpha, mips and powerpc variants fold into it.
--- arch/alpha/include/asm/termios.h | 8 -------- arch/mips/include/asm/termios.h | 9 --------- arch/powerpc/include/asm/termios.h | 3 --- include/linux/termios_internal.h | 15 ++++++++++++++- 4 files changed, 14 insertions(+), 21 deletions(-)
arch/alpha/include/asm/termios.h +0 -8
@@ -5,12 +5,4 @@#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> -start=^Q stop=^S lnext=^V discard=^O -vmin=\1 vtime=\0 -*/ -#define INIT_C_CC "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\017\001\000" -#endif /* _ALPHA_TERMIOS_H */
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=^O 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 */
arch/powerpc/include/asm/termios.h +0 -3
@@ -10,7 +10,4 @@#include <uapi/asm/termios.h> -/* ^C ^\ del ^U ^D 1 0 0 0 0 ^W ^R ^Z ^Q ^S ^V ^O */ -#define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\017" -#endif /* _ASM_POWERPC_TERMIOS_H */
include/linux/termios_internal.h +14 -1
@@ -12,7 +12,20 @@reprint=^R discard=^O 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 int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *);
Signature · 1 line
2.30.2
PATCH v3 5/6 termios: convert the last (sparc) INIT_C_CC to array
In reply to Al ViroFrom e2de253547334986545fe270aa7218ef470ad77f Mon Sep 17 00:00:00 2001
From: Al Viro <[email protected]>
Date: Tue, 9 Aug 2022 19:41:40 -0400
Subject: [PATCH v3 5/6] termios: convert the last (sparc) INIT_C_CC to array
--- arch/sparc/include/asm/termios.h | 9 --------- include/linux/termios_internal.h | 10 ++++++++-- 2 files changed, 8 insertions(+), 11 deletions(-)
arch/sparc/include/asm/termios.h +0 -9
@@ -5,13 +5,4 @@#include <uapi/asm/termios.h> #include <linux/uaccess.h> - -/* 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=^O 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\017\027\026\001" -#endif /* _SPARC_TERMIOS_H */
include/linux/termios_internal.h +8 -2
@@ -5,13 +5,19 @@#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=^O werase=^W lnext=^V eol2=\0 */ + +#ifdef VDSUSP +#define INIT_C_CC_VDSUSP_EXTRA [VDSUSP] = 'Y'-0x40, +#else +#define INIT_C_CC_VDSUSP_EXTRA +#endif +#define INIT_C_CC { \ [VINTR] = 'C'-0x40, \ [VQUIT] = '\\'-0x40, \
@@ -25,8 +31,8 @@ [VDISCARD] = 'O'-0x40, \ [VWERASE] = 'W'-0x40, \ [VLNEXT ] ='V' -0x40 , \ +INIT_C_CC_VDSUSP_EXTRA \ [VMIN] = 1 } -#endif int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *);int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *);
Signature · 1 line
2.30.2
PATCH v3 6/6 termios: get rid of non-UAPI asm/termios.h
In reply to Al ViroFrom 4290f5a9c37a3c7eeafcab26ef9a56a026c2f782 Mon Sep 17 00:00:00 2001
From: Al Viro <[email protected]>
Date: Tue, 9 Aug 2022 19:41:40 -0400
Subject: [PATCH v3 6/6] termios: get rid of non-UAPI asm/termios.h
All non-UAPI asm/termios.h consist of include of UAPI counterpart
and, possibly, include of linux/uaccess.h
The latter can't be simply removed, even though nothing inlinux/termios.h doesn't depend upon it anymore - there are several places that rely upon that indirect chain of includes to pull linux/uaccess.h. So the include needs to be lifted out of there - we lift into tty_driver.h, serdev.h and places that pull asm/termios.h, but none of
* linux/uaccess.h (obvious)
* net/sock.h (pulls uaccess.h)
* linux/{tty,tty_driver,serdev}.h (tty.h pulls tty_driver.h)
That leaves us just with the include of UAPI asm/termios.h, which is what <asm/termios.h> will resolve to if we simply remove non-UAPI header.
--- arch/alpha/include/asm/termios.h | 8 -------- arch/arm/mach-ep93xx/core.c | 1 + arch/arm/mach-versatile/integrator_ap.c | 1 + arch/ia64/include/asm/termios.h | 13 ------------- arch/mips/include/asm/termios.h | 15 --------------- arch/parisc/include/asm/termios.h | 7 ------- arch/powerpc/include/asm/termios.h | 13 ------------- arch/s390/include/asm/termios.h | 12 ------------ arch/sparc/include/asm/termios.h | 8 -------- drivers/net/wwan/wwan_core.c | 1 + include/asm-generic/termios.h | 9 --------- include/linux/serdev.h | 1 + include/linux/tty_driver.h | 1 + 13 files changed, 5 insertions(+), 85 deletions(-) delete mode 100644 arch/alpha/include/asm/termios.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 delete mode 100644 arch/powerpc/include/asm/termios.h delete mode 100644 arch/s390/include/asm/termios.h delete mode 100644 arch/sparc/include/asm/termios.h delete mode 100644 include/asm-generic/termios.h
arch/alpha/include/asm/termios.h deleted +0 -8
@@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ALPHA_TERMIOS_H -#define _ALPHA_TERMIOS_H - -#include <linux/uaccess.h> -#include <uapi/asm/termios.h> - -#endif /* _ALPHA_TERMIOS_H */
arch/arm/mach-ep93xx/core.c +1 -0
@@ -22,6 +22,7 @@#include <linux/io.h> #include <linux/gpio.h> #include <linux/leds.h> +#include <linux/uaccess.h> #include <linux/termios.h> #include <linux/amba/bus.h> #include <linux/amba/serial.h>
arch/arm/mach-versatile/integrator_ap.c +1 -0
@@ -11,6 +11,7 @@#include <linux/of_irq.h> #include <linux/of_address.h> #include <linux/of_platform.h> +#include <linux/uaccess.h> #include <linux/termios.h> #include <linux/mfd/syscon.h> #include <linux/regmap.h>
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/include/asm/termios.h deleted +0 -13
@@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* -* 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). -*/ -#ifndef _ASM_POWERPC_TERMIOS_H -#define _ASM_POWERPC_TERMIOS_H - -#include <uapi/asm/termios.h> - -#endif /* _ASM_POWERPC_TERMIOS_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/include/asm/termios.h deleted +0 -8
@@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _SPARC_TERMIOS_H -#define _SPARC_TERMIOS_H - -#include <uapi/asm/termios.h> -#include <linux/uaccess.h> - -#endif /* _SPARC_TERMIOS_H */
drivers/net/wwan/wwan_core.c +1 -0
@@ -13,6 +13,7 @@#include <linux/skbuff.h> #include <linux/slab.h> #include <linux/types.h> +#include <linux/uaccess.h> #include <linux/termios.h> #include <linux/wwan.h> #include <net/rtnetlink.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/serdev.h +1 -0
@@ -7,6 +7,7 @@#include <linux/types.h> #include <linux/device.h> +#include <linux/uaccess.h> #include <linux/termios.h> #include <linux/delay.h>
include/linux/tty_driver.h +1 -0
@@ -7,6 +7,7 @@#include <linux/kref.h> #include <linux/list.h> #include <linux/cdev.h> +#include <linux/uaccess.h> #include <linux/termios.h> #include <linux/seq_file.h>
Signature · 1 line
2.30.2
[PATCH v3 7/6] termios: kill uapi termios.h that are identical to generic one
mandatory-y will have the generic picked for architectures that don't have uapi/asm/termios.h of their own. ia64, parisc and s390 ones are identical to generic, so...
---
arch/ia64/include/uapi/asm/termios.h deleted +0 -51
@@ -1,51 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* -* Modified 1999 -* David Mosberger-Tang <[email protected]>, Hewlett-Packard Co -* -* 99/01/28 Added N_IRDA and N_SMSBLOCK -*/ -#ifndef _UAPI_ASM_IA64_TERMIOS_H -#define _UAPI_ASM_IA64_TERMIOS_H - - -#include <asm/termbits.h> -#include <asm/ioctls.h> - -struct winsize { -unsigned short ws_row; -unsigned short ws_col; -unsigned short ws_xpixel; -unsigned short ws_ypixel; -}; - -#define NCC 8 -struct termio { -unsigned short c_iflag;/* input mode flags */ -unsigned short c_oflag;/* output mode flags */ -unsigned short c_cflag;/* control mode flags */ -unsigned short c_lflag;/* local mode flags */ -unsigned char c_line;/* line discipline */ -unsigned char c_cc[NCC ];/* control characters */ -}; - -/* modem lines */ -#define TIOCM_LE 0x001 -#define TIOCM_DTR 0x002 -#define TIOCM_RTS 0x004 -#define TIOCM_ST 0x008 -#define TIOCM_SR 0x010 -#define TIOCM_CTS 0x020 -#define TIOCM_CAR 0x040 -#define TIOCM_RNG 0x080 -#define TIOCM_DSR 0x100 -#define TIOCM_CD TIOCM_CAR -#define TIOCM_RI TIOCM_RNG -#define TIOCM_OUT1 0x2000 -#define TIOCM_OUT2 0x4000 -#define TIOCM_LOOP 0x8000 - -/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ - - -#endif /* _UAPI_ASM_IA64_TERMIOS_H */
arch/parisc/include/uapi/asm/termios.h deleted +0 -44
44 lines not on this page · raw message
arch/s390/include/uapi/asm/termios.h deleted +0 -50
50 lines not on this page · raw message
Greg Kroah-Hartman
maintainerRe: [PATCH v2 3/8] termios: uninline conversion helpers
In reply to Al ViroQuoted 23 lines · Al Viro
Quoted 22 lines · Greg Kroah-Hartman
Quoted 20 lines · Al Viro
default go into
drivers/tty/tty_ioctl.c, unusual - intoarch/*/kernel/termios.c(only alpha and sparc have those).Signed-off-by Al Viro <[email protected]>--- arch/alpha/include/asm/termios.h | 77 ++-------------- arch/alpha/kernel/Makefile | 2 +- arch/alpha/kernel/termios.c | 57 ++++++++++++ arch/ia64/include/asm/termios.h | 41 ++------- arch/mips/include/asm/termios.h | 84 ++---------------- arch/parisc/include/asm/termios.h | 41 ++------- arch/sparc/include/asm/termios.h | 136 ++--------------------------- arch/sparc/kernel/Makefile | 4 +- arch/sparc/kernel/termios.c | 115 ++++++++++++++++++++++++ drivers/tty/tty_ioctl.c | 74 ++++++++++++++++ include/asm-generic/termios-base.h | 69 ++------------- include/asm-generic/termios.h | 42 ++------- 12 files changed, 294 insertions(+), 448 deletions(-) create mode 100644 arch/alpha/kernel/termios.c create mode 100644 arch/sparc/kernel/termios.c
Quoted 7 lines
Quoted 1 line
The build blows up on me with this commit added to my tty-testing tree:
My apologies - reordering damage. inlines in
include/asm-generic/termios.hshould've been removed in this commit, not in the next one.Anyway, fixed branch rebased on top of your #tty-next; see vfs.git #work.termios2. Individual patches in followups...
Thanks, much better, I've applied these and let's see if 0-day has any problems with them...
greg k-h
PATCH v2 4/8 termios: start unifying non-UAPI parts of asm/termios.h
In reply to Al Viro* new header (linut/termios_internal.h), pulled by the users of those suckers
* defaults for INIT_C_CC and externs for conversion helpers moved over there
* remove termios-base.h (empty now)
--- arch/alpha/include/asm/termios.h | 8 +--- arch/ia64/include/asm/termios.h | 16 ------- arch/mips/include/asm/termios.h | 9 ---- arch/parisc/include/asm/termios.h | 16 ------- arch/powerpc/include/asm/termios.h | 2 - arch/s390/include/asm/termios.h | 14 ------ arch/sparc/include/asm/termios.h | 8 +--- drivers/tty/hvc/hvcs.c | 1 + drivers/tty/tty_io.c | 2 +- drivers/tty/tty_ioctl.c | 1 + drivers/tty/vcc.c | 1 + include/asm-generic/termios-base.h | 21 --------- include/asm-generic/termios.h | 73 ------------------------------ include/linux/termios_internal.h | 30 ++++++++++++ 14 files changed, 36 insertions(+), 166 deletions(-) delete mode 100644 include/asm-generic/termios-base.h create mode 100644 include/linux/termios_internal.h
arch/alpha/include/asm/termios.h +1 -7
@@ -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
@@ -12,11 +13,4 @@*/ #define INIT_C_CC "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\025\001\000" -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#endif /* _ALPHA_TERMIOS_H */
arch/ia64/include/asm/termios.h +0 -16
@@ -10,20 +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" - -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#endif /* _ASM_IA64_TERMIOS_H */
arch/mips/include/asm/termios.h +0 -9
@@ -21,13 +21,4 @@*/ #define INIT_C_CC "\003\034\177\025\1\0\0\0\021\023\032\0\022\017\027\026\004\0" -#include <linux/string.h> - -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#endif /* _ASM_TERMIOS_H */
arch/parisc/include/asm/termios.h +0 -16
@@ -4,20 +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" - -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#endif /* _PARISC_TERMIOS_H */
arch/powerpc/include/asm/termios.h +0 -2
@@ -13,6 +13,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 -14
@@ -9,18 +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" - -#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 +1 -7
@@ -3,6 +3,7 @@#define _SPARC_TERMIOS_H#include <uapi/asm/termios.h> +#include <linux/uaccess.h> /* intr=^C quit=^\ erase=del kill=^U
@@ -13,11 +14,4 @@*/ #define INIT_C_CC "\003\034\177\025\004\000\000\000\021\023\032\031\022\025\027\026\001" -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#endif /* _SPARC_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 -1
@@ -99,8 +99,8 @@#include <linux/serial.h> #include <linux/ratelimit.h> #include <linux/compat.h> -#include <linux/uaccess.h> +#include <linux/termios_internal.h> #include <linux/kbd_kern.h> #include <linux/vt_kern.h>
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 "tty.h" #include <asm/io.h>
drivers/tty/vcc.c +1 -0
@@ -11,6 +11,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-base.h deleted +0 -21
@@ -1,21 +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> - -#ifndef __ARCH_TERMIO_GETPUT - -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); - -#endif /* __ARCH_TERMIO_GETPUT */ - -#endif /* _ASM_GENERIC_TERMIOS_BASE_H */
include/asm-generic/termios.h +0 -73
77 lines not on this page · raw message
include/linux/termios_internal.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_TERMIOS_CONV_H +#define _LINUX_TERMIOS_CONV_H + +#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 + +int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); +int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); +#ifdef TCGETS2 +int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); +int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); +int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); +int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); +#else /* TCGETS2 */ +int user_termios_to_kernel_termios (struct ktermios *,struct termios __user *); +int kernel_termios_to_user_termios (struct termios __user *,struct ktermios *); +#endif /* TCGETS2 */ + +#endif /* _LINUX_TERMIOS_CONV_H */
Signature · 1 line
2.30.2
Re: [PATCH v2 4/8] termios: start unifying non-UAPI parts of asm/termios.h
[with braino fixed]
termios: start unifying non-UAPI parts of asm/termios.h
* new header (linut/termios_internal.h), pulled by the users of those suckers
* defaults for INIT_C_CC and externs for conversion helpers moved over there
* remove termios-base.h (empty now)
---
arch/alpha/include/asm/termios.h +1 -7
@@ -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
@@ -12,11 +13,4 @@*/ #define INIT_C_CC "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\025\001\000" -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#endif /* _ALPHA_TERMIOS_H */
arch/alpha/kernel/termios.c +1 -2
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 -#include <linux/uaccess.h> -#include <linux/termios.h> +#include <linux/termios_internal.h> int user_termio_to_kernel_termios (struct ktermios *termios,struct termio __user *termio)
arch/ia64/include/asm/termios.h +0 -16
@@ -10,20 +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" - -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#endif /* _ASM_IA64_TERMIOS_H */
arch/mips/include/asm/termios.h +0 -9
@@ -21,13 +21,4 @@*/ #define INIT_C_CC "\003\034\177\025\1\0\0\0\021\023\032\0\022\017\027\026\004\0" -#include <linux/string.h> - -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#endif /* _ASM_TERMIOS_H */
arch/parisc/include/asm/termios.h +0 -16
@@ -4,20 +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" - -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#endif /* _PARISC_TERMIOS_H */
arch/powerpc/include/asm/termios.h +0 -2
@@ -13,6 +13,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 -14
@@ -9,18 +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" - -#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 +1 -7
@@ -3,6 +3,7 @@#define _SPARC_TERMIOS_H#include <uapi/asm/termios.h> +#include <linux/uaccess.h> /* intr=^C quit=^\ erase=del kill=^U
@@ -13,11 +14,4 @@*/ #define INIT_C_CC "\003\034\177\025\004\000\000\000\021\023\032\031\022\025\027\026\001" -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); -#endif /* _SPARC_TERMIOS_H */
arch/sparc/kernel/termios.c +2 -2
@@ -1,5 +1,5 @@ -#include <linux/uaccess.h> -#include <linux/termios.h> +// SPDX-License-Identifier: GPL-2.0 +#include <linux/termios_internal.h> /* * c_cc characters in the termio structure. Oh, how I love being
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 -1
@@ -99,8 +99,8 @@#include <linux/serial.h> #include <linux/ratelimit.h> #include <linux/compat.h> -#include <linux/uaccess.h> +#include <linux/termios_internal.h> #include <linux/kbd_kern.h> #include <linux/vt_kern.h>
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 "tty.h" #include <asm/io.h>
drivers/tty/vcc.c +1 -0
@@ -11,6 +11,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-base.h deleted +0 -21
@@ -1,21 +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> - -#ifndef __ARCH_TERMIO_GETPUT - -int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); -int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); -int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); -int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); -int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); -int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); - -#endif /* __ARCH_TERMIO_GETPUT */ - -#endif /* _ASM_GENERIC_TERMIOS_BASE_H */
include/asm-generic/termios.h +0 -73
77 lines not on this page · raw message
include/linux/termios_internal.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_TERMIOS_CONV_H +#define _LINUX_TERMIOS_CONV_H + +#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 + +int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *); +int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *); +#ifdef TCGETS2 +int user_termios_to_kernel_termios (struct ktermios *,struct termios2 __user *); +int kernel_termios_to_user_termios (struct termios2 __user *,struct ktermios *); +int user_termios_to_kernel_termios_1 (struct ktermios *,struct termios __user *); +int kernel_termios_to_user_termios_1 (struct termios __user *,struct ktermios *); +#else /* TCGETS2 */ +int user_termios_to_kernel_termios (struct ktermios *,struct termios __user *); +int kernel_termios_to_user_termios (struct termios __user *,struct ktermios *); +#endif /* TCGETS2 */ + +#endif /* _LINUX_TERMIOS_CONV_H */
PATCH v2 5/8 termios: consolidate values for VDISCARD in INIT_C_CC
In reply to Al ViroOn old systems it used to be ^O. Linux had never actually used the value, but INIT_C_CC (on i386) did initialize it to ^O; unfortunately, it had a typo in the comment claiming that to be ^U. Most of the architectures copied the (correct) definition along with mistaken comment. alpha, powerpc and sparc tried to make the definition match comment.
However, util-linux still resets it to ^O on any architecture, ^O is the historical value, kernel ignores it anyway and finally, Linus said "Just change everybody to do the same, nobody cares about VDISCARD".
--- arch/alpha/include/asm/termios.h | 4 ++-- arch/mips/include/asm/termios.h | 2 +- arch/powerpc/include/asm/termios.h | 4 ++-- arch/sparc/include/asm/termios.h | 4 ++-- include/linux/termios_internal.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-)
arch/alpha/include/asm/termios.h +2 -2
@@ -8,9 +8,9 @@/* 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 +start=^Q stop=^S lnext=^V discard=^O 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 "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\017\001\000"#endif /* _ALPHA_TERMIOS_H */
arch/mips/include/asm/termios.h +1 -1
@@ -16,7 +16,7 @@* 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 +* reprint=^R discard=^O 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"
arch/powerpc/include/asm/termios.h +2 -2
@@ -10,7 +10,7 @@#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" +/* ^C ^\ del ^U ^D 1 0 0 0 0 ^W ^R ^Z ^Q ^S ^V ^O */ +#define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\017"#endif /* _ASM_POWERPC_TERMIOS_H */
arch/sparc/include/asm/termios.h +2 -2
@@ -9,9 +9,9 @@/* 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 +reprint=^R discard=^O 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 "\003\034\177\025\004\000\000\000\021\023\032\031\022\017\027\026\001"#endif /* _SPARC_TERMIOS_H */
include/linux/termios_internal.h +1 -1
@@ -9,7 +9,7 @@/* 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 */ #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
Signature · 1 line
2.30.2
PATCH v2 6/8 make generic INIT_C_CC a bit more generic
In reply to Al Viroturn it into an array initializer; then alpha, mips and powerpc variants fold into it.
--- arch/alpha/include/asm/termios.h | 8 -------- arch/mips/include/asm/termios.h | 9 --------- arch/powerpc/include/asm/termios.h | 3 --- include/linux/termios_internal.h | 15 ++++++++++++++- 4 files changed, 14 insertions(+), 21 deletions(-)
arch/alpha/include/asm/termios.h +0 -8
@@ -5,12 +5,4 @@#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> -start=^Q stop=^S lnext=^V discard=^O -vmin=\1 vtime=\0 -*/ -#define INIT_C_CC "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\017\001\000" -#endif /* _ALPHA_TERMIOS_H */
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=^O 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 */
arch/powerpc/include/asm/termios.h +0 -3
@@ -10,7 +10,4 @@#include <uapi/asm/termios.h> -/* ^C ^\ del ^U ^D 1 0 0 0 0 ^W ^R ^Z ^Q ^S ^V ^O */ -#define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\017" -#endif /* _ASM_POWERPC_TERMIOS_H */
include/linux/termios_internal.h +14 -1
@@ -12,7 +12,20 @@reprint=^R discard=^O 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 int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *);
Signature · 1 line
2.30.2
PATCH v2 7/8 termios: convert the last (sparc) INIT_C_CC to array
In reply to Al Viro--- arch/sparc/include/asm/termios.h | 9 --------- include/linux/termios_internal.h | 10 ++++++++-- 2 files changed, 8 insertions(+), 11 deletions(-)
arch/sparc/include/asm/termios.h +0 -9
@@ -5,13 +5,4 @@#include <uapi/asm/termios.h> #include <linux/uaccess.h> - -/* 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=^O 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\017\027\026\001" -#endif /* _SPARC_TERMIOS_H */
include/linux/termios_internal.h +8 -2
@@ -5,13 +5,19 @@#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=^O werase=^W lnext=^V eol2=\0 */ + +#ifdef VDSUSP +#define INIT_C_CC_VDSUSP_EXTRA [VDSUSP] = 'Y'-0x40, +#else +#define INIT_C_CC_VDSUSP_EXTRA +#endif +#define INIT_C_CC { \ [VINTR] = 'C'-0x40, \ [VQUIT] = '\\'-0x40, \
@@ -25,8 +31,8 @@ [VDISCARD] = 'O'-0x40, \ [VWERASE] = 'W'-0x40, \ [VLNEXT ] ='V' -0x40 , \ +INIT_C_CC_VDSUSP_EXTRA \ [VMIN] = 1 } -#endif int user_termio_to_kernel_termios (struct ktermios *,struct termio __user *);int kernel_termios_to_user_termio (struct termio __user *,struct ktermios *);
Signature · 1 line
2.30.2
PATCH v2 8/8 termios: get rid of non-UAPI asm/termios.h
In reply to Al Viro All non-UAPI asm/termios.h consist of include of UAPI counterpart
and, possibly, include of linux/uaccess.h
The latter can't be simply removed, even though nothing inlinux/termios.h doesn't depend upon it anymore - there are several places that rely upon that indirect chain of includes to pull linux/uaccess.h. So the include needs to be lifted out of there - we lift into tty_driver.h, serdev.h and places that pull asm/termios.h, but none of
* linux/uaccess.h (obvious)
* net/sock.h (pulls uaccess.h)
* linux/{tty,tty_driver,serdev}.h (tty.h pulls tty_driver.h)
That leaves us just with the include of UAPI asm/termios.h, which is what <asm/termios.h> will resolve to if we simply remove non-UAPI header.
--- arch/alpha/include/asm/termios.h | 8 -------- arch/arm/mach-ep93xx/core.c | 1 + arch/arm/mach-versatile/integrator_ap.c | 1 + arch/ia64/include/asm/termios.h | 13 ------------- arch/mips/include/asm/termios.h | 15 --------------- arch/parisc/include/asm/termios.h | 7 ------- arch/powerpc/include/asm/termios.h | 13 ------------- arch/s390/include/asm/termios.h | 12 ------------ arch/sparc/include/asm/termios.h | 8 -------- drivers/net/wwan/wwan_core.c | 1 + include/asm-generic/termios.h | 9 --------- include/linux/serdev.h | 1 + include/linux/tty_driver.h | 1 + 13 files changed, 5 insertions(+), 85 deletions(-) delete mode 100644 arch/alpha/include/asm/termios.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 delete mode 100644 arch/powerpc/include/asm/termios.h delete mode 100644 arch/s390/include/asm/termios.h delete mode 100644 arch/sparc/include/asm/termios.h delete mode 100644 include/asm-generic/termios.h
arch/alpha/include/asm/termios.h deleted +0 -8
@@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ALPHA_TERMIOS_H -#define _ALPHA_TERMIOS_H - -#include <linux/uaccess.h> -#include <uapi/asm/termios.h> - -#endif /* _ALPHA_TERMIOS_H */
arch/arm/mach-ep93xx/core.c +1 -0
@@ -22,6 +22,7 @@#include <linux/io.h> #include <linux/gpio.h> #include <linux/leds.h> +#include <linux/uaccess.h> #include <linux/termios.h> #include <linux/amba/bus.h> #include <linux/amba/serial.h>
arch/arm/mach-versatile/integrator_ap.c +1 -0
@@ -11,6 +11,7 @@#include <linux/of_irq.h> #include <linux/of_address.h> #include <linux/of_platform.h> +#include <linux/uaccess.h> #include <linux/termios.h> #include <linux/mfd/syscon.h> #include <linux/regmap.h>
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/include/asm/termios.h deleted +0 -13
@@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* -* 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). -*/ -#ifndef _ASM_POWERPC_TERMIOS_H -#define _ASM_POWERPC_TERMIOS_H - -#include <uapi/asm/termios.h> - -#endif /* _ASM_POWERPC_TERMIOS_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/include/asm/termios.h deleted +0 -8
@@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _SPARC_TERMIOS_H -#define _SPARC_TERMIOS_H - -#include <uapi/asm/termios.h> -#include <linux/uaccess.h> - -#endif /* _SPARC_TERMIOS_H */
drivers/net/wwan/wwan_core.c +1 -0
@@ -13,6 +13,7 @@#include <linux/skbuff.h> #include <linux/slab.h> #include <linux/types.h> +#include <linux/uaccess.h> #include <linux/termios.h> #include <linux/wwan.h> #include <net/rtnetlink.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/serdev.h +1 -0
@@ -7,6 +7,7 @@#include <linux/types.h> #include <linux/device.h> +#include <linux/uaccess.h> #include <linux/termios.h> #include <linux/delay.h>
include/linux/tty_driver.h +1 -0
@@ -7,6 +7,7 @@#include <linux/kref.h> #include <linux/list.h> #include <linux/cdev.h> +#include <linux/uaccess.h> #include <linux/termios.h> #include <linux/seq_file.h>
Signature · 1 line
2.30.2
Re: [PATCH v2 1/8] loongarch: remove generic-y += termios.h
In reply to Al ViroQuoted 23 lines · Al Viro
not really needed - UAPI mandatory-y +=
termios.his sufficient...Signed-off-by Al Viro <[email protected]>--- arch/loongarch/include/asm/Kbuild | 1 - 1 file changed, 1 deletion(-)arch/loongarch/include/asm/Kbuild +0
-2@@ -21,7 +21,6 @@ generic-y += shmbuf.h generic-y += statfs.h generic-y += socket.h generic-y += sockios.h -generic-y += termios.h generic-y += termbits.h generic-y += poll.h generic-y += param.h --2.30.2
Re: [PATCH v2 1/8] loongarch: remove generic-y += termios.h
Quoted 27 lines · Huacai Chen
Acked-by chenhuacai <[email protected]>Quoted 23 lines · Al Viro
not really needed - UAPI mandatory-y +=
termios.his sufficient...Signed-off-by Al Viro <[email protected]>--- arch/loongarch/include/asm/Kbuild | 1 - 1 file changed, 1 deletion(-)arch/loongarch/include/asm/Kbuild +0
-2@@ -21,7 +21,6 @@ generic-y += shmbuf.h generic-y += statfs.h generic-y += socket.h generic-y += sockios.h -generic-y += termios.h generic-y += termbits.h generic-y += poll.h generic-y += param.h --2.30.2