aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/termios.h
diff options
context:
space:
mode:
authorDave Miller <davem@davemloft.net>2008-02-07 03:13:27 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:16 -0500
commitf8a4c3b5250496f072d9098a641fd5642146d999 (patch)
tree827d2cca761a6b98bed158747eccc98bd2e5b6cf /include/asm-x86/termios.h
parent94b3e03c875f25c19ede9600c66d74a30b81957d (diff)
tty: fix tty network driver interactions with TCGET/TCSET calls (x86 fix)
And to go with it Dave's type checking x86 termios headers. I've updated these as the original sent by Dave had some wrong types in it. Signed-off-by: Alan Cox <alan@redhat.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Jeff Garzik <jeff@garzik.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-x86/termios.h')
-rw-r--r--include/asm-x86/termios.h74
1 files changed, 45 insertions, 29 deletions
diff --git a/include/asm-x86/termios.h b/include/asm-x86/termios.h
index d501748700d2..f72956331c49 100644
--- a/include/asm-x86/termios.h
+++ b/include/asm-x86/termios.h
@@ -41,6 +41,8 @@ struct termio {
41 41
42#ifdef __KERNEL__ 42#ifdef __KERNEL__
43 43
44#include <asm/uaccess.h>
45
44/* intr=^C quit=^\ erase=del kill=^U 46/* intr=^C quit=^\ erase=del kill=^U
45 eof=^D vtime=\0 vmin=\1 sxtc=\0 47 eof=^D vtime=\0 vmin=\1 sxtc=\0
46 start=^Q stop=^S susp=^Z eol=\0 48 start=^Q stop=^S susp=^Z eol=\0
@@ -58,39 +60,53 @@ struct termio {
58 *(unsigned short *) &(termios)->x = __tmp; \ 60 *(unsigned short *) &(termios)->x = __tmp; \
59} 61}
60 62
61#define user_termio_to_kernel_termios(termios, termio) \ 63static inline int user_termio_to_kernel_termios(struct ktermios *termios,
62({ \ 64 struct termio __user *termio)
63 SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \ 65{
64 SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \ 66 SET_LOW_TERMIOS_BITS(termios, termio, c_iflag);
65 SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \ 67 SET_LOW_TERMIOS_BITS(termios, termio, c_oflag);
66 SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \ 68 SET_LOW_TERMIOS_BITS(termios, termio, c_cflag);
67 copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \ 69 SET_LOW_TERMIOS_BITS(termios, termio, c_lflag);
68}) 70 return copy_from_user(termios->c_cc, termio->c_cc, NCC);
71}
69 72
70/* 73/*
71 * Translate a "termios" structure into a "termio". Ugh. 74 * Translate a "termios" structure into a "termio". Ugh.
72 */ 75 */
73#define kernel_termios_to_user_termio(termio, termios) \ 76static inline int kernel_termios_to_user_termio(struct termio __user *termio,
74({ \ 77 struct ktermios *termios)
75 put_user((termios)->c_iflag, &(termio)->c_iflag); \ 78{
76 put_user((termios)->c_oflag, &(termio)->c_oflag); \ 79 put_user((termios)->c_iflag, &(termio)->c_iflag);
77 put_user((termios)->c_cflag, &(termio)->c_cflag); \ 80 put_user((termios)->c_oflag, &(termio)->c_oflag);
78 put_user((termios)->c_lflag, &(termio)->c_lflag); \ 81 put_user((termios)->c_cflag, &(termio)->c_cflag);
79 put_user((termios)->c_line, &(termio)->c_line); \ 82 put_user((termios)->c_lflag, &(termio)->c_lflag);
80 copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \ 83 put_user((termios)->c_line, &(termio)->c_line);
81}) 84 return copy_to_user((termio)->c_cc, (termios)->c_cc, NCC);
82 85}
83#define user_termios_to_kernel_termios(k, u) \ 86
84 copy_from_user(k, u, sizeof(struct termios2)) 87static inline int user_termios_to_kernel_termios(struct ktermios *k,
85 88 struct termios2 __user *u)
86#define kernel_termios_to_user_termios(u, k) \ 89{
87 copy_to_user(u, k, sizeof(struct termios2)) 90 return copy_from_user(k, u, sizeof(struct termios2));
88 91}
89#define user_termios_to_kernel_termios_1(k, u) \ 92
90 copy_from_user(k, u, sizeof(struct termios)) 93static inline int kernel_termios_to_user_termios(struct termios2 __user *u,
91 94 struct ktermios *k)
92#define kernel_termios_to_user_termios_1(u, k) \ 95{
93 copy_to_user(u, k, sizeof(struct termios)) 96 return copy_to_user(u, k, sizeof(struct termios2));
97}
98
99static inline int user_termios_to_kernel_termios_1(struct ktermios *k,
100 struct termios __user *u)
101{
102 return copy_from_user(k, u, sizeof(struct termios));
103}
104
105static inline int kernel_termios_to_user_termios_1(struct termios __user *u,
106 struct ktermios *k)
107{
108 return copy_to_user(u, k, sizeof(struct termios));
109}
94 110
95#endif /* __KERNEL__ */ 111#endif /* __KERNEL__ */
96 112