Commit ac9720c37e8795317e8be3adad63cb0d5522a640
Committed by
Linus Torvalds
1 parent
e136e3036b
tty: Fix the HSO termios handling a bit
Init the tty structure once Don't set ->low_latency twice in a row Don't force bits we should be leaving to the user Don't allocate termios arrays as these are in fact allocated by the tty layer for you and just overwrite the ones allocated in the driver Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 31 additions and 24 deletions Side-by-side Diff
drivers/net/usb/hso.c
... | ... | @@ -362,8 +362,6 @@ |
362 | 362 | static struct hso_device *serial_table[HSO_SERIAL_TTY_MINORS]; |
363 | 363 | static struct hso_device *network_table[HSO_MAX_NET_DEVICES]; |
364 | 364 | static spinlock_t serial_table_lock; |
365 | -static struct ktermios *hso_serial_termios[HSO_SERIAL_TTY_MINORS]; | |
366 | -static struct ktermios *hso_serial_termios_locked[HSO_SERIAL_TTY_MINORS]; | |
367 | 365 | |
368 | 366 | static const s32 default_port_spec[] = { |
369 | 367 | HSO_INTF_MUX | HSO_PORT_NETWORK, |
370 | 368 | |
371 | 369 | |
... | ... | @@ -1009,23 +1007,11 @@ |
1009 | 1007 | |
1010 | 1008 | /* Serial driver functions */ |
1011 | 1009 | |
1012 | -static void _hso_serial_set_termios(struct tty_struct *tty, | |
1013 | - struct ktermios *old) | |
1010 | +static void hso_init_termios(struct ktermios *termios) | |
1014 | 1011 | { |
1015 | - struct hso_serial *serial = get_serial_by_tty(tty); | |
1016 | - struct ktermios *termios; | |
1017 | - | |
1018 | - if (!serial) { | |
1019 | - printk(KERN_ERR "%s: no tty structures", __func__); | |
1020 | - return; | |
1021 | - } | |
1022 | - | |
1023 | - D4("port %d", serial->minor); | |
1024 | - | |
1025 | 1012 | /* |
1026 | 1013 | * The default requirements for this device are: |
1027 | 1014 | */ |
1028 | - termios = tty->termios; | |
1029 | 1015 | termios->c_iflag &= |
1030 | 1016 | ~(IGNBRK /* disable ignore break */ |
1031 | 1017 | | BRKINT /* disable break causes interrupt */ |
1032 | 1018 | |
1033 | 1019 | |
1034 | 1020 | |
... | ... | @@ -1057,15 +1043,38 @@ |
1057 | 1043 | termios->c_cflag |= CS8; /* character size 8 bits */ |
1058 | 1044 | |
1059 | 1045 | /* baud rate 115200 */ |
1060 | - tty_encode_baud_rate(tty, 115200, 115200); | |
1046 | + tty_termios_encode_baud_rate(termios, 115200, 115200); | |
1047 | +} | |
1061 | 1048 | |
1049 | +static void _hso_serial_set_termios(struct tty_struct *tty, | |
1050 | + struct ktermios *old) | |
1051 | +{ | |
1052 | + struct hso_serial *serial = get_serial_by_tty(tty); | |
1053 | + struct ktermios *termios; | |
1054 | + | |
1055 | + if (!serial) { | |
1056 | + printk(KERN_ERR "%s: no tty structures", __func__); | |
1057 | + return; | |
1058 | + } | |
1059 | + | |
1060 | + D4("port %d", serial->minor); | |
1061 | + | |
1062 | 1062 | /* |
1063 | - * Force low_latency on; otherwise the pushes are scheduled; | |
1064 | - * this is bad as it opens up the possibility of dropping bytes | |
1065 | - * on the floor. We don't want to drop bytes on the floor. :) | |
1063 | + * Fix up unsupported bits | |
1066 | 1064 | */ |
1067 | - tty->low_latency = 1; | |
1068 | - return; | |
1065 | + termios = tty->termios; | |
1066 | + termios->c_iflag &= ~IXON; /* disable enable XON/XOFF flow control */ | |
1067 | + | |
1068 | + termios->c_cflag &= | |
1069 | + ~(CSIZE /* no size */ | |
1070 | + | PARENB /* disable parity bit */ | |
1071 | + | CBAUD /* clear current baud rate */ | |
1072 | + | CBAUDEX); /* clear current buad rate */ | |
1073 | + | |
1074 | + termios->c_cflag |= CS8; /* character size 8 bits */ | |
1075 | + | |
1076 | + /* baud rate 115200 */ | |
1077 | + tty_encode_baud_rate(tty, 115200, 115200); | |
1069 | 1078 | } |
1070 | 1079 | |
1071 | 1080 | static void hso_resubmit_rx_bulk_urb(struct hso_serial *serial, struct urb *urb) |
... | ... | @@ -2969,9 +2978,7 @@ |
2969 | 2978 | tty_drv->subtype = SERIAL_TYPE_NORMAL; |
2970 | 2979 | tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; |
2971 | 2980 | tty_drv->init_termios = tty_std_termios; |
2972 | - tty_drv->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; | |
2973 | - tty_drv->termios = hso_serial_termios; | |
2974 | - tty_drv->termios_locked = hso_serial_termios_locked; | |
2981 | + hso_init_termios(&tty_drv->init_termios); | |
2975 | 2982 | tty_set_operations(tty_drv, &hso_serial_ops); |
2976 | 2983 | |
2977 | 2984 | /* register the tty driver */ |