Skip to content

Commit d0ffb80

Browse files
H. Peter Anvin (Intel)gregkh
authored andcommitted
arch/alpha, termios: implement BOTHER, IBSHIFT and termios2
Alpha has had c_ispeed and c_ospeed, but still set speeds in c_cflags using arbitrary flags. Because BOTHER is not defined, the general Linux code doesn't allow setting arbitrary baud rates, and because CBAUDEX == 0, we can have an array overrun of the baud_rate[] table in drivers/tty/tty_baudrate.c if (c_cflags & CBAUD) == 037. Resolve both problems by #defining BOTHER to 037 on Alpha. However, userspace still needs to know if setting BOTHER is actually safe given legacy kernels (does anyone actually care about that on Alpha anymore?), so enable the TCGETS2/TCSETS*2 ioctls on Alpha, even though they use the same structure. Define struct termios2 just for compatibility; it is the exact same structure as struct termios. In a future patchset, this will be cleaned up so the uapi headers are usable from libc. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Cc: Jiri Slaby <jslaby@suse.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Matt Turner <mattst88@gmail.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Kate Stewart <kstewart@linuxfoundation.org> Cc: Philippe Ombredanne <pombredanne@nexb.com> Cc: Eugene Syromiatnikov <esyr@redhat.com> Cc: <linux-alpha@vger.kernel.org> Cc: <linux-serial@vger.kernel.org> Cc: Johan Hovold <johan@kernel.org> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 991a251 commit d0ffb80

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

arch/alpha/include/asm/termios.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,15 @@
7373
})
7474

7575
#define user_termios_to_kernel_termios(k, u) \
76-
copy_from_user(k, u, sizeof(struct termios))
76+
copy_from_user(k, u, sizeof(struct termios2))
7777

7878
#define kernel_termios_to_user_termios(u, k) \
79+
copy_to_user(u, k, sizeof(struct termios2))
80+
81+
#define user_termios_to_kernel_termios_1(k, u) \
82+
copy_from_user(k, u, sizeof(struct termios))
83+
84+
#define kernel_termios_to_user_termios_1(u, k) \
7985
copy_to_user(u, k, sizeof(struct termios))
8086

8187
#endif /* _ALPHA_TERMIOS_H */

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
#define TCXONC _IO('t', 30)
3333
#define TCFLSH _IO('t', 31)
3434

35+
#define TCGETS2 _IOR('T', 42, struct termios2)
36+
#define TCSETS2 _IOW('T', 43, struct termios2)
37+
#define TCSETSW2 _IOW('T', 44, struct termios2)
38+
#define TCSETSF2 _IOW('T', 45, struct termios2)
39+
3540
#define TIOCSWINSZ _IOW('t', 103, struct winsize)
3641
#define TIOCGWINSZ _IOR('t', 104, struct winsize)
3742
#define TIOCSTART _IO('t', 110) /* start output, like ^Q */

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ struct termios {
2626
speed_t c_ospeed; /* output speed */
2727
};
2828

29+
/* Alpha has identical termios and termios2 */
30+
31+
struct termios2 {
32+
tcflag_t c_iflag; /* input mode flags */
33+
tcflag_t c_oflag; /* output mode flags */
34+
tcflag_t c_cflag; /* control mode flags */
35+
tcflag_t c_lflag; /* local mode flags */
36+
cc_t c_cc[NCCS]; /* control characters */
37+
cc_t c_line; /* line discipline (== c_cc[19]) */
38+
speed_t c_ispeed; /* input speed */
39+
speed_t c_ospeed; /* output speed */
40+
};
41+
2942
/* Alpha has matching termios and ktermios */
3043

3144
struct ktermios {
@@ -152,6 +165,7 @@ struct ktermios {
152165
#define B3000000 00034
153166
#define B3500000 00035
154167
#define B4000000 00036
168+
#define BOTHER 00037
155169

156170
#define CSIZE 00001400
157171
#define CS5 00000000
@@ -169,6 +183,9 @@ struct ktermios {
169183
#define CMSPAR 010000000000 /* mark or space (stick) parity */
170184
#define CRTSCTS 020000000000 /* flow control */
171185

186+
#define CIBAUD 07600000
187+
#define IBSHIFT 16
188+
172189
/* c_lflag bits */
173190
#define ISIG 0x00000080
174191
#define ICANON 0x00000100

0 commit comments

Comments
 (0)