USB-serial updates for 5.2-rc1

Here are the USB-serial updates for 5.2-rc1, including:
 
  - flow-control related fixes for pl2303
  - fix for an initial-termios issue
  - fix for a couple of unthrottle() races
  - fix for f81232 interrupt-handling issues
  - improved f81232 overrun handling
  - support for higher f81232 line speeds
  - support for f81232 break control
 
 Included are also various clean ups.
 
 All but the last four commits have been in linux-next and with no
 reported issues.
 
 Signed-off-by: Johan Hovold <johan@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQQHbPq+cpGvN/peuzMLxc3C7H1lCAUCXMxfIgAKCRALxc3C7H1l
 CMtcAP9uZf9T10gph5fEFVmMeL5TbXF/jdi0ovK6Yl2hwlcJvwEAi/iL8pjNEmdk
 Bjy9ocYKsGixXqKi9b5+OEB39QFsZwI=
 =LovK
 -----END PGP SIGNATURE-----

Merge tag 'usb-serial-5.2-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-next

Johan writes:

USB-serial updates for 5.2-rc1

Here are the USB-serial updates for 5.2-rc1, including:

 - flow-control related fixes for pl2303
 - fix for an initial-termios issue
 - fix for a couple of unthrottle() races
 - fix for f81232 interrupt-handling issues
 - improved f81232 overrun handling
 - support for higher f81232 line speeds
 - support for f81232 break control

Included are also various clean ups.

All but the last four commits have been in linux-next and with no
reported issues.

Signed-off-by: Johan Hovold <johan@kernel.org>

* tag 'usb-serial-5.2-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial: (22 commits)
  USB: serial: f81232: implement break control
  USB: serial: f81232: add high baud rate support
  USB: serial: f81232: clear overrun flag
  USB: serial: f81232: fix interrupt worker not stop
  USB: serial: io_edgeport: fix up switch fall-through comments
  USB: serial: drop unused iflag macro
  USB: serial: drop unnecessary goto
  USB: serial: clean up throttle handling
  USB: serial: fix unthrottle races
  USB: serial: spcp8x5: simplify init_termios
  USB: serial: oti6858: simplify init_termios
  USB: serial: iuu_phoenix: simplify init_termios
  USB: serial: iuu_phoenix: drop bogus initial cflag
  USB: serial: cypress_m8: clean up initial-termios handling
  USB: serial: cypress_m8: drop unused termios
  USB: serial: cypress_m8: drop unused driver data flag
  USB: serial: ark3116: drop redundant init_termios
  USB: serial: fix initial-termios handling
  USB: serial: digi_acceleport: clean up set_termios
  USB: serial: digi_acceleport: clean up modem-control handling
  ...
This commit is contained in:
Greg Kroah-Hartman 2019-05-03 18:00:15 +02:00
commit 6f6a407a59
12 changed files with 324 additions and 179 deletions

View File

@ -189,16 +189,6 @@ static int ark3116_port_remove(struct usb_serial_port *port)
return 0;
}
static void ark3116_init_termios(struct tty_struct *tty)
{
struct ktermios *termios = &tty->termios;
*termios = tty_std_termios;
termios->c_cflag = B9600 | CS8
| CREAD | HUPCL | CLOCAL;
termios->c_ispeed = 9600;
termios->c_ospeed = 9600;
}
static void ark3116_set_termios(struct tty_struct *tty,
struct usb_serial_port *port,
struct ktermios *old_termios)
@ -645,7 +635,6 @@ static struct usb_serial_driver ark3116_device = {
.port_probe = ark3116_port_probe,
.port_remove = ark3116_port_remove,
.set_termios = ark3116_set_termios,
.init_termios = ark3116_init_termios,
.get_serial = ark3116_get_serial_info,
.tiocmget = ark3116_tiocmget,
.tiocmset = ark3116_tiocmset,

View File

@ -98,7 +98,6 @@ struct cypress_private {
int write_urb_interval; /* interval to use for write urb */
int read_urb_interval; /* interval to use for read urb */
int comm_is_ok; /* true if communication is (still) ok */
int termios_initialized;
__u8 line_control; /* holds dtr / rts value */
__u8 current_status; /* received from last read - info on dsr,cts,cd,ri,etc */
__u8 current_config; /* stores the current configuration byte */
@ -107,11 +106,7 @@ struct cypress_private {
int get_cfg_unsafe; /* If true, the CYPRESS_GET_CONFIG is unsafe */
int baud_rate; /* stores current baud rate in
integer form */
int isthrottled; /* if throttled, discard reads */
char prev_status; /* used for TIOCMIWAIT */
/* we pass a pointer to this as the argument sent to
cypress_set_termios old_termios */
struct ktermios tmp_termios; /* stores the old termios settings */
};
/* function prototypes for the Cypress USB to serial device */
@ -126,6 +121,7 @@ static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count);
static void cypress_send(struct usb_serial_port *port);
static int cypress_write_room(struct tty_struct *tty);
static void cypress_earthmate_init_termios(struct tty_struct *tty);
static void cypress_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old);
static int cypress_tiocmget(struct tty_struct *tty);
@ -153,6 +149,7 @@ static struct usb_serial_driver cypress_earthmate_device = {
.dtr_rts = cypress_dtr_rts,
.write = cypress_write,
.write_room = cypress_write_room,
.init_termios = cypress_earthmate_init_termios,
.set_termios = cypress_set_termios,
.tiocmget = cypress_tiocmget,
.tiocmset = cypress_tiocmset,
@ -467,7 +464,6 @@ static int cypress_generic_port_probe(struct usb_serial_port *port)
priv->cmd_ctrl = 0;
priv->line_control = 0;
priv->termios_initialized = 0;
priv->rx_flags = 0;
/* Default packet format setting is determined by packet size.
Anything with a size larger then 9 must have a separate
@ -604,7 +600,7 @@ static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port)
cypress_send(port);
if (tty)
cypress_set_termios(tty, port, &priv->tmp_termios);
cypress_set_termios(tty, port, NULL);
/* setup the port and start reading from the device */
usb_fill_int_urb(port->interrupt_in_urb, serial->dev,
@ -857,6 +853,11 @@ static int cypress_tiocmset(struct tty_struct *tty,
return cypress_write(tty, port, NULL, 0);
}
static void cypress_earthmate_init_termios(struct tty_struct *tty)
{
tty_encode_baud_rate(tty, 4800, 4800);
}
static void cypress_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios)
{
@ -868,45 +869,11 @@ static void cypress_set_termios(struct tty_struct *tty,
__u8 oldlines;
int linechange = 0;
spin_lock_irqsave(&priv->lock, flags);
/* We can't clean this one up as we don't know the device type
early enough */
if (!priv->termios_initialized) {
if (priv->chiptype == CT_EARTHMATE) {
tty->termios = tty_std_termios;
tty->termios.c_cflag = B4800 | CS8 | CREAD | HUPCL |
CLOCAL;
tty->termios.c_ispeed = 4800;
tty->termios.c_ospeed = 4800;
} else if (priv->chiptype == CT_CYPHIDCOM) {
tty->termios = tty_std_termios;
tty->termios.c_cflag = B9600 | CS8 | CREAD | HUPCL |
CLOCAL;
tty->termios.c_ispeed = 9600;
tty->termios.c_ospeed = 9600;
} else if (priv->chiptype == CT_CA42V2) {
tty->termios = tty_std_termios;
tty->termios.c_cflag = B9600 | CS8 | CREAD | HUPCL |
CLOCAL;
tty->termios.c_ispeed = 9600;
tty->termios.c_ospeed = 9600;
}
priv->termios_initialized = 1;
}
spin_unlock_irqrestore(&priv->lock, flags);
/* Unsupported features need clearing */
tty->termios.c_cflag &= ~(CMSPAR|CRTSCTS);
cflag = tty->termios.c_cflag;
/* check if there are new settings */
if (old_termios) {
spin_lock_irqsave(&priv->lock, flags);
priv->tmp_termios = tty->termios;
spin_unlock_irqrestore(&priv->lock, flags);
}
/* set number of data bits, parity, stop bits */
/* when parity is disabled the parity type bit is ignored */

View File

@ -569,9 +569,9 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC);
if (ret == 0) {
oob_priv->dp_write_urb_in_use = 1;
port_priv->dp_modem_signals =
(port_priv->dp_modem_signals&~(TIOCM_DTR|TIOCM_RTS))
| (modem_signals&(TIOCM_DTR|TIOCM_RTS));
port_priv->dp_modem_signals &= ~(TIOCM_DTR | TIOCM_RTS);
port_priv->dp_modem_signals |=
modem_signals & (TIOCM_DTR | TIOCM_RTS);
}
spin_unlock(&port_priv->dp_port_lock);
spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags);
@ -740,9 +740,9 @@ static void digi_set_termios(struct tty_struct *tty,
/* set parity */
tty->termios.c_cflag &= ~CMSPAR;
if ((cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD))) {
if (cflag&PARENB) {
if (cflag&PARODD)
if ((cflag & (PARENB | PARODD)) != (old_cflag & (PARENB | PARODD))) {
if (cflag & PARENB) {
if (cflag & PARODD)
arg = DIGI_PARITY_ODD;
else
arg = DIGI_PARITY_EVEN;
@ -755,9 +755,9 @@ static void digi_set_termios(struct tty_struct *tty,
buf[i++] = 0;
}
/* set word size */
if ((cflag&CSIZE) != (old_cflag&CSIZE)) {
if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
arg = -1;
switch (cflag&CSIZE) {
switch (cflag & CSIZE) {
case CS5: arg = DIGI_WORD_SIZE_5; break;
case CS6: arg = DIGI_WORD_SIZE_6; break;
case CS7: arg = DIGI_WORD_SIZE_7; break;
@ -765,7 +765,7 @@ static void digi_set_termios(struct tty_struct *tty,
default:
dev_dbg(dev,
"digi_set_termios: can't handle word size %d\n",
(cflag&CSIZE));
cflag & CSIZE);
break;
}
@ -779,9 +779,9 @@ static void digi_set_termios(struct tty_struct *tty,
}
/* set stop bits */
if ((cflag&CSTOPB) != (old_cflag&CSTOPB)) {
if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) {
if ((cflag&CSTOPB))
if ((cflag & CSTOPB))
arg = DIGI_STOP_BITS_2;
else
arg = DIGI_STOP_BITS_1;
@ -794,15 +794,15 @@ static void digi_set_termios(struct tty_struct *tty,
}
/* set input flow control */
if ((iflag&IXOFF) != (old_iflag&IXOFF)
|| (cflag&CRTSCTS) != (old_cflag&CRTSCTS)) {
if ((iflag & IXOFF) != (old_iflag & IXOFF) ||
(cflag & CRTSCTS) != (old_cflag & CRTSCTS)) {
arg = 0;
if (iflag&IXOFF)
if (iflag & IXOFF)
arg |= DIGI_INPUT_FLOW_CONTROL_XON_XOFF;
else
arg &= ~DIGI_INPUT_FLOW_CONTROL_XON_XOFF;
if (cflag&CRTSCTS) {
if (cflag & CRTSCTS) {
arg |= DIGI_INPUT_FLOW_CONTROL_RTS;
/* On USB-4 it is necessary to assert RTS prior */
@ -822,19 +822,18 @@ static void digi_set_termios(struct tty_struct *tty,
}
/* set output flow control */
if ((iflag & IXON) != (old_iflag & IXON)
|| (cflag & CRTSCTS) != (old_cflag & CRTSCTS)) {
if ((iflag & IXON) != (old_iflag & IXON) ||
(cflag & CRTSCTS) != (old_cflag & CRTSCTS)) {
arg = 0;
if (iflag & IXON)
arg |= DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF;
else
arg &= ~DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF;
if (cflag & CRTSCTS) {
if (cflag & CRTSCTS)
arg |= DIGI_OUTPUT_FLOW_CONTROL_CTS;
} else {
else
arg &= ~DIGI_OUTPUT_FLOW_CONTROL_CTS;
}
buf[i++] = DIGI_CMD_SET_OUTPUT_FLOW_CONTROL;
buf[i++] = priv->dp_port_num;
@ -1084,7 +1083,7 @@ static int digi_chars_in_buffer(struct tty_struct *tty)
static void digi_dtr_rts(struct usb_serial_port *port, int on)
{
/* Adjust DTR and RTS */
digi_set_modem_signals(port, on * (TIOCM_DTR|TIOCM_RTS), 1);
digi_set_modem_signals(port, on * (TIOCM_DTR | TIOCM_RTS), 1);
}
static int digi_open(struct tty_struct *tty, struct usb_serial_port *port)

View File

@ -28,7 +28,8 @@ static const struct usb_device_id id_table[] = {
MODULE_DEVICE_TABLE(usb, id_table);
/* Maximum baudrate for F81232 */
#define F81232_MAX_BAUDRATE 115200
#define F81232_MAX_BAUDRATE 1500000
#define F81232_DEF_BAUDRATE 9600
/* USB Control EP parameter */
#define F81232_REGISTER_REQUEST 0xa0
@ -41,19 +42,46 @@ MODULE_DEVICE_TABLE(usb, id_table);
#define FIFO_CONTROL_REGISTER (0x02 + SERIAL_BASE_ADDRESS)
#define LINE_CONTROL_REGISTER (0x03 + SERIAL_BASE_ADDRESS)
#define MODEM_CONTROL_REGISTER (0x04 + SERIAL_BASE_ADDRESS)
#define LINE_STATUS_REGISTER (0x05 + SERIAL_BASE_ADDRESS)
#define MODEM_STATUS_REGISTER (0x06 + SERIAL_BASE_ADDRESS)
/*
* F81232 Clock registers (106h)
*
* Bit1-0: Clock source selector
* 00: 1.846MHz.
* 01: 18.46MHz.
* 10: 24MHz.
* 11: 14.77MHz.
*/
#define F81232_CLK_REGISTER 0x106
#define F81232_CLK_1_846_MHZ 0
#define F81232_CLK_18_46_MHZ BIT(0)
#define F81232_CLK_24_MHZ BIT(1)
#define F81232_CLK_14_77_MHZ (BIT(1) | BIT(0))
#define F81232_CLK_MASK GENMASK(1, 0)
struct f81232_private {
struct mutex lock;
u8 modem_control;
u8 modem_status;
u8 shadow_lcr;
speed_t baud_base;
struct work_struct lsr_work;
struct work_struct interrupt_work;
struct usb_serial_port *port;
};
static int calc_baud_divisor(speed_t baudrate)
static u32 const baudrate_table[] = { 115200, 921600, 1152000, 1500000 };
static u8 const clock_table[] = { F81232_CLK_1_846_MHZ, F81232_CLK_14_77_MHZ,
F81232_CLK_18_46_MHZ, F81232_CLK_24_MHZ };
static int calc_baud_divisor(speed_t baudrate, speed_t clockrate)
{
return DIV_ROUND_CLOSEST(F81232_MAX_BAUDRATE, baudrate);
if (!baudrate)
return 0;
return DIV_ROUND_CLOSEST(clockrate, baudrate);
}
static int f81232_get_register(struct usb_serial_port *port, u16 reg, u8 *val)
@ -127,6 +155,21 @@ static int f81232_set_register(struct usb_serial_port *port, u16 reg, u8 val)
return status;
}
static int f81232_set_mask_register(struct usb_serial_port *port, u16 reg,
u8 mask, u8 val)
{
int status;
u8 tmp;
status = f81232_get_register(port, reg, &tmp);
if (status)
return status;
tmp = (tmp & ~mask) | (val & mask);
return f81232_set_register(port, reg, tmp);
}
static void f81232_read_msr(struct usb_serial_port *port)
{
int status;
@ -282,6 +325,7 @@ exit:
static void f81232_process_read_urb(struct urb *urb)
{
struct usb_serial_port *port = urb->context;
struct f81232_private *priv = usb_get_serial_port_data(port);
unsigned char *data = urb->transfer_buffer;
char tty_flag;
unsigned int i;
@ -315,6 +359,7 @@ static void f81232_process_read_urb(struct urb *urb)
if (lsr & UART_LSR_OE) {
port->icount.overrun++;
schedule_work(&priv->lsr_work);
tty_insert_flip_char(&port->port, 0,
TTY_OVERRUN);
}
@ -333,22 +378,72 @@ static void f81232_process_read_urb(struct urb *urb)
static void f81232_break_ctl(struct tty_struct *tty, int break_state)
{
/* FIXME - Stubbed out for now */
struct usb_serial_port *port = tty->driver_data;
struct f81232_private *priv = usb_get_serial_port_data(port);
int status;
/*
* break_state = -1 to turn on break, and 0 to turn off break
* see drivers/char/tty_io.c to see it used.
* last_set_data_urb_value NEVER has the break bit set in it.
*/
mutex_lock(&priv->lock);
if (break_state)
priv->shadow_lcr |= UART_LCR_SBC;
else
priv->shadow_lcr &= ~UART_LCR_SBC;
status = f81232_set_register(port, LINE_CONTROL_REGISTER,
priv->shadow_lcr);
if (status)
dev_err(&port->dev, "set break failed: %d\n", status);
mutex_unlock(&priv->lock);
}
static void f81232_set_baudrate(struct usb_serial_port *port, speed_t baudrate)
static int f81232_find_clk(speed_t baudrate)
{
int idx;
for (idx = 0; idx < ARRAY_SIZE(baudrate_table); ++idx) {
if (baudrate <= baudrate_table[idx] &&
baudrate_table[idx] % baudrate == 0)
return idx;
}
return -EINVAL;
}
static void f81232_set_baudrate(struct tty_struct *tty,
struct usb_serial_port *port, speed_t baudrate,
speed_t old_baudrate)
{
struct f81232_private *priv = usb_get_serial_port_data(port);
u8 lcr;
int divisor;
int status = 0;
int i;
int idx;
speed_t baud_list[] = { baudrate, old_baudrate, F81232_DEF_BAUDRATE };
divisor = calc_baud_divisor(baudrate);
for (i = 0; i < ARRAY_SIZE(baud_list); ++i) {
idx = f81232_find_clk(baud_list[i]);
if (idx >= 0) {
baudrate = baud_list[i];
tty_encode_baud_rate(tty, baudrate, baudrate);
break;
}
}
if (idx < 0)
return;
priv->baud_base = baudrate_table[idx];
divisor = calc_baud_divisor(baudrate, priv->baud_base);
status = f81232_set_mask_register(port, F81232_CLK_REGISTER,
F81232_CLK_MASK, clock_table[idx]);
if (status) {
dev_err(&port->dev, "%s failed to set CLK_REG: %d\n",
__func__, status);
return;
}
status = f81232_get_register(port, LINE_CONTROL_REGISTER,
&lcr); /* get LCR */
@ -435,9 +530,11 @@ static int f81232_port_disable(struct usb_serial_port *port)
static void f81232_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios)
{
struct f81232_private *priv = usb_get_serial_port_data(port);
u8 new_lcr = 0;
int status = 0;
speed_t baudrate;
speed_t old_baud;
/* Don't change anything if nothing has changed */
if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios))
@ -450,11 +547,12 @@ static void f81232_set_termios(struct tty_struct *tty,
baudrate = tty_get_baud_rate(tty);
if (baudrate > 0) {
if (baudrate > F81232_MAX_BAUDRATE) {
baudrate = F81232_MAX_BAUDRATE;
tty_encode_baud_rate(tty, baudrate, baudrate);
}
f81232_set_baudrate(port, baudrate);
if (old_termios)
old_baud = tty_termios_baud_rate(old_termios);
else
old_baud = F81232_DEF_BAUDRATE;
f81232_set_baudrate(tty, port, baudrate, old_baud);
}
if (C_PARENB(tty)) {
@ -486,11 +584,18 @@ static void f81232_set_termios(struct tty_struct *tty,
break;
}
mutex_lock(&priv->lock);
new_lcr |= (priv->shadow_lcr & UART_LCR_SBC);
status = f81232_set_register(port, LINE_CONTROL_REGISTER, new_lcr);
if (status) {
dev_err(&port->dev, "%s failed to set LCR: %d\n",
__func__, status);
}
priv->shadow_lcr = new_lcr;
mutex_unlock(&priv->lock);
}
static int f81232_tiocmget(struct tty_struct *tty)
@ -556,9 +661,13 @@ static int f81232_open(struct tty_struct *tty, struct usb_serial_port *port)
static void f81232_close(struct usb_serial_port *port)
{
struct f81232_private *port_priv = usb_get_serial_port_data(port);
f81232_port_disable(port);
usb_serial_generic_close(port);
usb_kill_urb(port->interrupt_in_urb);
flush_work(&port_priv->interrupt_work);
flush_work(&port_priv->lsr_work);
}
static void f81232_dtr_rts(struct usb_serial_port *port, int on)
@ -587,11 +696,12 @@ static int f81232_get_serial_info(struct tty_struct *tty,
struct serial_struct *ss)
{
struct usb_serial_port *port = tty->driver_data;
struct f81232_private *priv = usb_get_serial_port_data(port);
ss->type = PORT_16550A;
ss->line = port->minor;
ss->port = port->port_number;
ss->baud_base = F81232_MAX_BAUDRATE;
ss->baud_base = priv->baud_base;
return 0;
}
@ -603,6 +713,21 @@ static void f81232_interrupt_work(struct work_struct *work)
f81232_read_msr(priv->port);
}
static void f81232_lsr_worker(struct work_struct *work)
{
struct f81232_private *priv;
struct usb_serial_port *port;
int status;
u8 tmp;
priv = container_of(work, struct f81232_private, lsr_work);
port = priv->port;
status = f81232_get_register(port, LINE_STATUS_REGISTER, &tmp);
if (status)
dev_warn(&port->dev, "read LSR failed: %d\n", status);
}
static int f81232_port_probe(struct usb_serial_port *port)
{
struct f81232_private *priv;
@ -613,6 +738,7 @@ static int f81232_port_probe(struct usb_serial_port *port)
mutex_init(&priv->lock);
INIT_WORK(&priv->interrupt_work, f81232_interrupt_work);
INIT_WORK(&priv->lsr_work, f81232_lsr_worker);
usb_set_serial_port_data(port, priv);
@ -632,6 +758,42 @@ static int f81232_port_remove(struct usb_serial_port *port)
return 0;
}
static int f81232_suspend(struct usb_serial *serial, pm_message_t message)
{
struct usb_serial_port *port = serial->port[0];
struct f81232_private *port_priv = usb_get_serial_port_data(port);
int i;
for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i)
usb_kill_urb(port->read_urbs[i]);
usb_kill_urb(port->interrupt_in_urb);
if (port_priv) {
flush_work(&port_priv->interrupt_work);
flush_work(&port_priv->lsr_work);
}
return 0;
}
static int f81232_resume(struct usb_serial *serial)
{
struct usb_serial_port *port = serial->port[0];
int result;
if (tty_port_initialized(&port->port)) {
result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
if (result) {
dev_err(&port->dev, "submit interrupt urb failed: %d\n",
result);
return result;
}
}
return usb_serial_generic_resume(serial);
}
static struct usb_serial_driver f81232_device = {
.driver = {
.owner = THIS_MODULE,
@ -655,6 +817,8 @@ static struct usb_serial_driver f81232_device = {
.read_int_callback = f81232_read_int_callback,
.port_probe = f81232_port_probe,
.port_remove = f81232_port_remove,
.suspend = f81232_suspend,
.resume = f81232_resume,
};
static struct usb_serial_driver * const serial_drivers[] = {

View File

@ -106,12 +106,8 @@ void usb_serial_generic_deregister(void)
int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port)
{
int result = 0;
unsigned long flags;
spin_lock_irqsave(&port->lock, flags);
port->throttled = 0;
port->throttle_req = 0;
spin_unlock_irqrestore(&port->lock, flags);
clear_bit(USB_SERIAL_THROTTLED, &port->flags);
if (port->bulk_in_size)
result = usb_serial_generic_submit_read_urbs(port, GFP_KERNEL);
@ -375,7 +371,7 @@ void usb_serial_generic_read_bulk_callback(struct urb *urb)
{
struct usb_serial_port *port = urb->context;
unsigned char *data = urb->transfer_buffer;
unsigned long flags;
bool stopped = false;
int status = urb->status;
int i;
@ -383,42 +379,55 @@ void usb_serial_generic_read_bulk_callback(struct urb *urb)
if (urb == port->read_urbs[i])
break;
}
set_bit(i, &port->read_urbs_free);
dev_dbg(&port->dev, "%s - urb %d, len %d\n", __func__, i,
urb->actual_length);
switch (status) {
case 0:
usb_serial_debug_data(&port->dev, __func__, urb->actual_length,
data);
port->serial->type->process_read_urb(urb);
break;
case -ENOENT:
case -ECONNRESET:
case -ESHUTDOWN:
dev_dbg(&port->dev, "%s - urb stopped: %d\n",
__func__, status);
return;
stopped = true;
break;
case -EPIPE:
dev_err(&port->dev, "%s - urb stopped: %d\n",
__func__, status);
return;
stopped = true;
break;
default:
dev_dbg(&port->dev, "%s - nonzero urb status: %d\n",
__func__, status);
goto resubmit;
break;
}
usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
port->serial->type->process_read_urb(urb);
/*
* Make sure URB processing is done before marking as free to avoid
* racing with unthrottle() on another CPU. Matches the barriers
* implied by the test_and_clear_bit() in
* usb_serial_generic_submit_read_urb().
*/
smp_mb__before_atomic();
set_bit(i, &port->read_urbs_free);
/*
* Make sure URB is marked as free before checking the throttled flag
* to avoid racing with unthrottle() on another CPU. Matches the
* smp_mb() in unthrottle().
*/
smp_mb__after_atomic();
resubmit:
/* Throttle the device if requested by tty */
spin_lock_irqsave(&port->lock, flags);
port->throttled = port->throttle_req;
if (!port->throttled) {
spin_unlock_irqrestore(&port->lock, flags);
usb_serial_generic_submit_read_urb(port, i, GFP_ATOMIC);
} else {
spin_unlock_irqrestore(&port->lock, flags);
}
if (stopped)
return;
if (test_bit(USB_SERIAL_THROTTLED, &port->flags))
return;
usb_serial_generic_submit_read_urb(port, i, GFP_ATOMIC);
}
EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback);
@ -454,10 +463,9 @@ void usb_serial_generic_write_bulk_callback(struct urb *urb)
default:
dev_err_console(port, "%s - nonzero urb status: %d\n",
__func__, status);
goto resubmit;
break;
}
resubmit:
usb_serial_generic_write_start(port, GFP_ATOMIC);
usb_serial_port_softint(port);
}
@ -466,26 +474,24 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback);
void usb_serial_generic_throttle(struct tty_struct *tty)
{
struct usb_serial_port *port = tty->driver_data;
unsigned long flags;
spin_lock_irqsave(&port->lock, flags);
port->throttle_req = 1;
spin_unlock_irqrestore(&port->lock, flags);
set_bit(USB_SERIAL_THROTTLED, &port->flags);
}
EXPORT_SYMBOL_GPL(usb_serial_generic_throttle);
void usb_serial_generic_unthrottle(struct tty_struct *tty)
{
struct usb_serial_port *port = tty->driver_data;
int was_throttled;
spin_lock_irq(&port->lock);
was_throttled = port->throttled;
port->throttled = port->throttle_req = 0;
spin_unlock_irq(&port->lock);
clear_bit(USB_SERIAL_THROTTLED, &port->flags);
if (was_throttled)
usb_serial_generic_submit_read_urbs(port, GFP_KERNEL);
/*
* Matches the smp_mb__after_atomic() in
* usb_serial_generic_read_bulk_callback().
*/
smp_mb();
usb_serial_generic_submit_read_urbs(port, GFP_KERNEL);
}
EXPORT_SYMBOL_GPL(usb_serial_generic_unthrottle);

View File

@ -1751,7 +1751,7 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial,
edge_serial->rxState = EXPECT_HDR2;
break;
}
/* otherwise, drop on through */
/* Fall through */
case EXPECT_HDR2:
edge_serial->rxHeader2 = *buffer;
++buffer;
@ -1790,29 +1790,20 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial,
edge_serial->rxHeader2, 0);
edge_serial->rxState = EXPECT_HDR1;
break;
} else {
edge_serial->rxPort =
IOSP_GET_HDR_PORT(edge_serial->rxHeader1);
edge_serial->rxBytesRemaining =
IOSP_GET_HDR_DATA_LEN(
edge_serial->rxHeader1,
edge_serial->rxHeader2);
dev_dbg(dev, "%s - Data for Port %u Len %u\n",
__func__,
edge_serial->rxPort,
edge_serial->rxBytesRemaining);
/* ASSERT(DevExt->RxPort < DevExt->NumPorts);
* ASSERT(DevExt->RxBytesRemaining <
* IOSP_MAX_DATA_LENGTH);
*/
if (bufferLength == 0) {
edge_serial->rxState = EXPECT_DATA;
break;
}
/* Else, drop through */
}
edge_serial->rxPort = IOSP_GET_HDR_PORT(edge_serial->rxHeader1);
edge_serial->rxBytesRemaining = IOSP_GET_HDR_DATA_LEN(edge_serial->rxHeader1,
edge_serial->rxHeader2);
dev_dbg(dev, "%s - Data for Port %u Len %u\n", __func__,
edge_serial->rxPort,
edge_serial->rxBytesRemaining);
if (bufferLength == 0) {
edge_serial->rxState = EXPECT_DATA;
break;
}
/* Fall through */
case EXPECT_DATA: /* Expect data */
if (bufferLength < edge_serial->rxBytesRemaining) {
rxLen = bufferLength;

View File

@ -942,9 +942,7 @@ static void iuu_close(struct usb_serial_port *port)
static void iuu_init_termios(struct tty_struct *tty)
{
tty->termios = tty_std_termios;
tty->termios.c_cflag = CLOCAL | CREAD | CS8 | B9600
| TIOCM_CTS | CSTOPB | PARENB;
tty->termios.c_cflag = B9600 | CS8 | CSTOPB | CREAD | PARENB | CLOCAL;
tty->termios.c_ispeed = 9600;
tty->termios.c_ospeed = 9600;
tty->termios.c_lflag = 0;

View File

@ -393,10 +393,7 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty)
static void oti6858_init_termios(struct tty_struct *tty)
{
tty->termios = tty_std_termios;
tty->termios.c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL;
tty->termios.c_ispeed = 38400;
tty->termios.c_ospeed = 38400;
tty_encode_baud_rate(tty, 38400, 38400);
}
static void oti6858_set_termios(struct tty_struct *tty,

View File

@ -145,6 +145,8 @@ MODULE_DEVICE_TABLE(usb, id_table);
#define UART_OVERRUN_ERROR 0x40
#define UART_CTS 0x80
#define PL2303_FLOWCTRL_MASK 0xf0
static void pl2303_set_break(struct usb_serial_port *port, bool enable);
enum pl2303_type {
@ -156,6 +158,7 @@ enum pl2303_type {
struct pl2303_type_data {
speed_t max_baud_rate;
unsigned long quirks;
unsigned int no_autoxonxoff:1;
};
struct pl2303_serial_private {
@ -173,11 +176,12 @@ struct pl2303_private {
static const struct pl2303_type_data pl2303_type_data[TYPE_COUNT] = {
[TYPE_01] = {
.max_baud_rate = 1228800,
.quirks = PL2303_QUIRK_LEGACY,
.max_baud_rate = 1228800,
.quirks = PL2303_QUIRK_LEGACY,
.no_autoxonxoff = true,
},
[TYPE_HX] = {
.max_baud_rate = 12000000,
.max_baud_rate = 12000000,
},
};
@ -223,6 +227,29 @@ static int pl2303_vendor_write(struct usb_serial *serial, u16 value, u16 index)
return 0;
}
static int pl2303_update_reg(struct usb_serial *serial, u8 reg, u8 mask, u8 val)
{
int ret = 0;
u8 *buf;
buf = kmalloc(1, GFP_KERNEL);
if (!buf)
return -ENOMEM;
ret = pl2303_vendor_read(serial, reg | 0x80, buf);
if (ret)
goto out_free;
*buf &= ~mask;
*buf |= val & mask;
ret = pl2303_vendor_write(serial, reg, *buf);
out_free:
kfree(buf);
return ret;
}
static int pl2303_probe(struct usb_serial *serial,
const struct usb_device_id *id)
{
@ -552,6 +579,20 @@ static bool pl2303_termios_change(const struct ktermios *a, const struct ktermio
return tty_termios_hw_change(a, b) || ixon_change;
}
static bool pl2303_enable_xonxoff(struct tty_struct *tty, const struct pl2303_type_data *type)
{
if (!I_IXON(tty) || I_IXANY(tty))
return false;
if (START_CHAR(tty) != 0x11 || STOP_CHAR(tty) != 0x13)
return false;
if (type->no_autoxonxoff)
return false;
return true;
}
static void pl2303_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios)
{
@ -678,14 +719,13 @@ static void pl2303_set_termios(struct tty_struct *tty,
if (C_CRTSCTS(tty)) {
if (spriv->quirks & PL2303_QUIRK_LEGACY)
pl2303_vendor_write(serial, 0x0, 0x41);
pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0x40);
else
pl2303_vendor_write(serial, 0x0, 0x61);
} else if (I_IXON(tty) && !I_IXANY(tty) && START_CHAR(tty) == 0x11 &&
STOP_CHAR(tty) == 0x13) {
pl2303_vendor_write(serial, 0x0, 0xc0);
pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0x60);
} else if (pl2303_enable_xonxoff(tty, spriv->type)) {
pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0xc0);
} else {
pl2303_vendor_write(serial, 0x0, 0x0);
pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0);
}
kfree(buf);

View File

@ -281,10 +281,7 @@ static void spcp8x5_dtr_rts(struct usb_serial_port *port, int on)
static void spcp8x5_init_termios(struct tty_struct *tty)
{
tty->termios = tty_std_termios;
tty->termios.c_cflag = B115200 | CS8 | CREAD | HUPCL | CLOCAL;
tty->termios.c_ispeed = 115200;
tty->termios.c_ospeed = 115200;
tty_encode_baud_rate(tty, 115200, 115200);
}
static void spcp8x5_set_termios(struct tty_struct *tty,

View File

@ -164,9 +164,9 @@ void usb_serial_put(struct usb_serial *serial)
* @driver: the driver (USB in our case)
* @tty: the tty being created
*
* Create the termios objects for this tty. We use the default
* Initialise the termios structure for this tty. We use the default
* USB serial settings but permit them to be overridden by
* serial->type->init_termios.
* serial->type->init_termios on first open.
*
* This is the first place a new tty gets used. Hence this is where we
* acquire references to the usb_serial structure and the driver module,
@ -178,6 +178,7 @@ static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
int idx = tty->index;
struct usb_serial *serial;
struct usb_serial_port *port;
bool init_termios;
int retval = -ENODEV;
port = usb_serial_port_get_by_minor(idx);
@ -192,14 +193,16 @@ static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
if (retval)
goto error_get_interface;
init_termios = (driver->termios[idx] == NULL);
retval = tty_standard_install(driver, tty);
if (retval)
goto error_init_termios;
mutex_unlock(&serial->disc_mutex);
/* allow the driver to update the settings */
if (serial->type->init_termios)
/* allow the driver to update the initial settings */
if (init_termios && serial->type->init_termios)
serial->type->init_termios(tty);
tty->driver_data = port;

View File

@ -23,11 +23,9 @@
/* The maximum number of ports one device can grab at once */
#define MAX_NUM_PORTS 16
/* parity check flag */
#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
/* USB serial flags */
#define USB_SERIAL_WRITE_BUSY 0
#define USB_SERIAL_THROTTLED 1
/**
* usb_serial_port: structure for the specific ports of a device.
@ -67,8 +65,6 @@
* @flags: usb serial port flags
* @write_wait: a wait_queue_head_t used by the port.
* @work: work queue entry for the line discipline waking up.
* @throttled: nonzero if the read urb is inactive to throttle the device
* @throttle_req: nonzero if the tty wants to throttle us
* @dev: pointer to the serial device
*
* This structure is used by the usb-serial core and drivers for the specific
@ -115,8 +111,6 @@ struct usb_serial_port {
unsigned long flags;
wait_queue_head_t write_wait;
struct work_struct work;
char throttled;
char throttle_req;
unsigned long sysrq; /* sysrq timeout */
struct device dev;
};