提交 9a8baec7 编写于 作者: A Alan Cox 提交者: Greg Kroah-Hartman

USB: serial: belkin_sa: Various needed fixes

Use the baud rate stuff from the kernel don't parse CBAUD directly
Remove pointless and wrong 'no change' check

Could do with some good testing as well but again better than adding &&
BROKEN

(The use of BELKIN_SA_BAUD() might seem a bit odd but x/a = b and x/b =
a (rounded for integers)).
Signed-off-by: NAlan Cox <alan@redhat.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 568c24ad
...@@ -349,6 +349,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios ...@@ -349,6 +349,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
unsigned long flags; unsigned long flags;
unsigned long control_state; unsigned long control_state;
int bad_flow_control; int bad_flow_control;
speed_t baud;
if ((!port->tty) || (!port->tty->termios)) { if ((!port->tty) || (!port->tty->termios)) {
dbg ("%s - no tty or termios structure", __FUNCTION__); dbg ("%s - no tty or termios structure", __FUNCTION__);
...@@ -364,16 +365,8 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios ...@@ -364,16 +365,8 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
bad_flow_control = priv->bad_flow_control; bad_flow_control = priv->bad_flow_control;
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
/* check that they really want us to change something */ old_iflag = old_termios->c_iflag;
if (old_termios) { old_cflag = old_termios->c_cflag;
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;
}
old_iflag = old_termios->c_iflag;
old_cflag = old_termios->c_cflag;
}
/* Set the baud rate */ /* Set the baud rate */
if( (cflag&CBAUD) != (old_cflag&CBAUD) ) { if( (cflag&CBAUD) != (old_cflag&CBAUD) ) {
...@@ -387,38 +380,30 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios ...@@ -387,38 +380,30 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0) if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0)
err("Set RTS error"); err("Set RTS error");
} }
}
switch(cflag & CBAUD) { baud = tty_get_baud_rate(port->tty);
case B0: /* handled below */ break; urb_value = BELKIN_SA_BAUD(baud);
case B300: urb_value = BELKIN_SA_BAUD(300); break; /* Clip to maximum speed */
case B600: urb_value = BELKIN_SA_BAUD(600); break; if (urb_value == 0)
case B1200: urb_value = BELKIN_SA_BAUD(1200); break; urb_value = 1;
case B2400: urb_value = BELKIN_SA_BAUD(2400); break; /* Turn it back into a resulting real baud rate */
case B4800: urb_value = BELKIN_SA_BAUD(4800); break; baud = BELKIN_SA_BAUD(urb_value);
case B9600: urb_value = BELKIN_SA_BAUD(9600); break; /* FIXME: Once the tty updates are done then push this back to the tty */
case B19200: urb_value = BELKIN_SA_BAUD(19200); break;
case B38400: urb_value = BELKIN_SA_BAUD(38400); break; if ((cflag & CBAUD) != B0 ) {
case B57600: urb_value = BELKIN_SA_BAUD(57600); break; if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0)
case B115200: urb_value = BELKIN_SA_BAUD(115200); break; err("Set baudrate error");
case B230400: urb_value = BELKIN_SA_BAUD(230400); break; } else {
default: err("BELKIN USB Serial Adapter: unsupported baudrate request, using default of 9600"); /* Disable flow control */
urb_value = BELKIN_SA_BAUD(9600); break; if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, BELKIN_SA_FLOW_NONE) < 0)
} err("Disable flowcontrol error");
if ((cflag & CBAUD) != B0 ) { /* Drop RTS and DTR */
if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) control_state &= ~(TIOCM_DTR | TIOCM_RTS);
err("Set baudrate error"); if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0)
} else { err("DTR LOW error");
/* Disable flow control */ if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0)
if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, BELKIN_SA_FLOW_NONE) < 0) err("RTS LOW error");
err("Disable flowcontrol error");
/* Drop RTS and DTR */
control_state &= ~(TIOCM_DTR | TIOCM_RTS);
if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0)
err("DTR LOW error");
if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0)
err("RTS LOW error");
}
} }
/* set the parity */ /* set the parity */
...@@ -438,7 +423,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios ...@@ -438,7 +423,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
case CS6: urb_value = BELKIN_SA_DATA_BITS(6); break; case CS6: urb_value = BELKIN_SA_DATA_BITS(6); break;
case CS7: urb_value = BELKIN_SA_DATA_BITS(7); break; case CS7: urb_value = BELKIN_SA_DATA_BITS(7); break;
case CS8: urb_value = BELKIN_SA_DATA_BITS(8); break; case CS8: urb_value = BELKIN_SA_DATA_BITS(8); break;
default: err("CSIZE was not CS5-CS8, using default of 8"); default: dbg("CSIZE was not CS5-CS8, using default of 8");
urb_value = BELKIN_SA_DATA_BITS(8); urb_value = BELKIN_SA_DATA_BITS(8);
break; break;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册