提交 568c24ad 编写于 作者: A Alan Cox 提交者: Greg Kroah-Hartman

USB: serial: ark3116.c: Mixed fixups

o	Don't parse the cflag for baud rates, its not valid to do so
	any more and this driver got it wrong anyway
o	Don't do clever termios change checks in drivers and get them
	wrong (arguably we should do some smart ones in the tty core but
	stty to change nothing is *not* a common or critical path

I don't have the hardware so if you can test this carefully please do. I
thought fixing it up this far was better than marking it and other bits of
USB serial && BROKEN
Signed-off-by: NAlan Cox <alan@redhat.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 9e85c5f6
...@@ -172,7 +172,7 @@ static void ark3116_set_termios(struct usb_serial_port *port, ...@@ -172,7 +172,7 @@ static void ark3116_set_termios(struct usb_serial_port *port,
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
if ((!port->tty) || (!port->tty->termios)) { if (!port->tty || !port->tty->termios) {
dbg("%s - no tty structures", __FUNCTION__); dbg("%s - no tty structures", __FUNCTION__);
return; return;
} }
...@@ -188,16 +188,6 @@ static void ark3116_set_termios(struct usb_serial_port *port, ...@@ -188,16 +188,6 @@ static void ark3116_set_termios(struct usb_serial_port *port,
cflag = port->tty->termios->c_cflag; cflag = port->tty->termios->c_cflag;
/* check that they really want us to change something: */
if (old_termios) {
if ((cflag == old_termios->c_cflag) &&
(RELEVANT_IFLAG(port->tty->termios->c_iflag) ==
RELEVANT_IFLAG(old_termios->c_iflag))) {
dbg("%s - nothing to change...", __FUNCTION__);
return;
}
}
buf = kmalloc(1, GFP_KERNEL); buf = kmalloc(1, GFP_KERNEL);
if (!buf) { if (!buf) {
dbg("error kmalloc"); dbg("error kmalloc");
...@@ -220,7 +210,7 @@ static void ark3116_set_termios(struct usb_serial_port *port, ...@@ -220,7 +210,7 @@ static void ark3116_set_termios(struct usb_serial_port *port,
dbg("setting CS7"); dbg("setting CS7");
break; break;
default: default:
err("CSIZE was set but not CS5-CS8, using CS8!"); dbg("CSIZE was set but not CS5-CS8, using CS8!");
/* fall through */ /* fall through */
case CS8: case CS8:
config |= 0x03; config |= 0x03;
...@@ -251,38 +241,33 @@ static void ark3116_set_termios(struct usb_serial_port *port, ...@@ -251,38 +241,33 @@ static void ark3116_set_termios(struct usb_serial_port *port,
} }
/* set baudrate */ /* set baudrate */
baud = 0; baud = tty_get_baud_rate(port->tty);
switch (cflag & CBAUD) {
case B0: switch (baud) {
err("can't set 0 baud, using 9600 instead"); case 75:
break; case 150:
case B75: baud = 75; break; case 300:
case B150: baud = 150; break; case 600:
case B300: baud = 300; break; case 1200:
case B600: baud = 600; break; case 1800:
case B1200: baud = 1200; break; case 2400:
case B1800: baud = 1800; break; case 4800:
case B2400: baud = 2400; break; case 9600:
case B4800: baud = 4800; break; case 19200:
case B9600: baud = 9600; break; case 38400:
case B19200: baud = 19200; break; case 57600:
case B38400: baud = 38400; break; case 115200:
case B57600: baud = 57600; break; case 230400:
case B115200: baud = 115200; break; case 460800:
case B230400: baud = 230400; break;
case B460800: baud = 460800; break;
default:
dbg("does not support the baudrate requested (fix it)");
break; break;
}
/* set 9600 as default (if given baudrate is invalid for example) */ /* set 9600 as default (if given baudrate is invalid for example) */
if (baud == 0) default:
baud = 9600; baud = 9600;
}
/* /*
* found by try'n'error, be careful, maybe there are other options * found by try'n'error, be careful, maybe there are other options
* for multiplicator etc! * for multiplicator etc! (3.5 for example)
*/ */
if (baud == 460800) if (baud == 460800)
/* strange, for 460800 the formula is wrong /* strange, for 460800 the formula is wrong
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册