1 #ifndef _ASM_GENERIC_TERMIOS_H
2 #define _ASM_GENERIC_TERMIOS_H
5 #include <asm/uaccess.h>
6 #include <uapi/asm-generic/termios.h>
8 /* intr=^C quit=^\ erase=del kill=^U
9 eof=^D vtime=\0 vmin=\1 sxtc=\0
10 start=^Q stop=^S susp=^Z eol=\0
11 reprint=^R discard=^U werase=^W lnext=^V
14 #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
17 * Translate a "termio" structure into a "termios". Ugh.
19 static inline int user_termio_to_kernel_termios(struct ktermios
*termios
,
20 const struct termio __user
*termio
)
24 if (get_user(tmp
, &termio
->c_iflag
) < 0)
26 termios
->c_iflag
= (0xffff0000 & termios
->c_iflag
) | tmp
;
28 if (get_user(tmp
, &termio
->c_oflag
) < 0)
30 termios
->c_oflag
= (0xffff0000 & termios
->c_oflag
) | tmp
;
32 if (get_user(tmp
, &termio
->c_cflag
) < 0)
34 termios
->c_cflag
= (0xffff0000 & termios
->c_cflag
) | tmp
;
36 if (get_user(tmp
, &termio
->c_lflag
) < 0)
38 termios
->c_lflag
= (0xffff0000 & termios
->c_lflag
) | tmp
;
40 if (get_user(termios
->c_line
, &termio
->c_line
) < 0)
43 if (copy_from_user(termios
->c_cc
, termio
->c_cc
, NCC
) != 0)
53 * Translate a "termios" structure into a "termio". Ugh.
55 static inline int kernel_termios_to_user_termio(struct termio __user
*termio
,
56 struct ktermios
*termios
)
58 if (put_user(termios
->c_iflag
, &termio
->c_iflag
) < 0 ||
59 put_user(termios
->c_oflag
, &termio
->c_oflag
) < 0 ||
60 put_user(termios
->c_cflag
, &termio
->c_cflag
) < 0 ||
61 put_user(termios
->c_lflag
, &termio
->c_lflag
) < 0 ||
62 put_user(termios
->c_line
, &termio
->c_line
) < 0 ||
63 copy_to_user(termio
->c_cc
, termios
->c_cc
, NCC
) != 0)
70 static inline int user_termios_to_kernel_termios(struct ktermios
*k
,
71 struct termios2 __user
*u
)
73 return copy_from_user(k
, u
, sizeof(struct termios2
));
76 static inline int kernel_termios_to_user_termios(struct termios2 __user
*u
,
79 return copy_to_user(u
, k
, sizeof(struct termios2
));
82 static inline int user_termios_to_kernel_termios_1(struct ktermios
*k
,
83 struct termios __user
*u
)
85 return copy_from_user(k
, u
, sizeof(struct termios
));
88 static inline int kernel_termios_to_user_termios_1(struct termios __user
*u
,
91 return copy_to_user(u
, k
, sizeof(struct termios
));
94 static inline int user_termios_to_kernel_termios(struct ktermios
*k
,
95 struct termios __user
*u
)
97 return copy_from_user(k
, u
, sizeof(struct termios
));
100 static inline int kernel_termios_to_user_termios(struct termios __user
*u
,
103 return copy_to_user(u
, k
, sizeof(struct termios
));
107 #endif /* _ASM_GENERIC_TERMIOS_H */