Skip to content

Commit

Permalink
Merge tag 'usb-serial-4.11-rc1' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/johan/usb-serial into usb-next

Johan writes:

USB-serial updates for v4.11-rc1

These updates include

 - a new driver for Renesas uPD78F0730-based devices

 - several fixes of failures to check for short transfers, some of which could
   lead to minor information leaks, and in one case a loop-condition underflow

 - a fix of a long-standing regression in the ftdi_sio driver which resulted
   in excessive bulk-in interrupts

 - a fix for ftdi_sio line-status over-reporting which could lead to an
   endless stream of NULL-characters being forwarded to user space

 - a fix for a regression in the console driver

 - a fix for another mos7840 NULL-pointer dereference due to a missing endpoint
   sanity check

Included are also some clean ups and fixes for various minor issues, as well as
a couple of new device IDs that came in late.

All but the final patch have been in linux-next with no reported issues.

Signed-off-by: Johan Hovold <[email protected]>
  • Loading branch information
gregkh committed Feb 9, 2017
2 parents 2553482 + 5182c2c commit 54a2190
Show file tree
Hide file tree
Showing 27 changed files with 772 additions and 388 deletions.
9 changes: 9 additions & 0 deletions drivers/usb/serial/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,15 @@ config USB_SERIAL_QT2
To compile this driver as a module, choose M here: the
module will be called quatech-serial.

config USB_SERIAL_UPD78F0730
tristate "USB Renesas uPD78F0730 Single Port Serial Driver"
help
Say Y here if you want to use the Renesas uPD78F0730
serial driver.

To compile this driver as a module, choose M here: the
module will be called upd78f0730.

config USB_SERIAL_DEBUG
tristate "USB Debugging Device"
help
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/serial/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ obj-$(CONFIG_USB_SERIAL_SSU100) += ssu100.o
obj-$(CONFIG_USB_SERIAL_SYMBOL) += symbolserial.o
obj-$(CONFIG_USB_SERIAL_WWAN) += usb_wwan.o
obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o
obj-$(CONFIG_USB_SERIAL_UPD78F0730) += upd78f0730.o
obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o
obj-$(CONFIG_USB_SERIAL_WISHBONE) += wishbone-serial.o
obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o
Expand Down
74 changes: 42 additions & 32 deletions drivers/usb/serial/ark3116.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,17 @@ static int ark3116_read_reg(struct usb_serial *serial,
usb_rcvctrlpipe(serial->dev, 0),
0xfe, 0xc0, 0, reg,
buf, 1, ARK_TIMEOUT);
if (result < 0)
if (result < 1) {
dev_err(&serial->interface->dev,
"failed to read register %u: %d\n",
reg, result);
if (result >= 0)
result = -EIO;

return result;
else
return buf[0];
}

return buf[0];
}

static inline int calc_divisor(int bps)
Expand All @@ -118,17 +125,11 @@ static inline int calc_divisor(int bps)
static int ark3116_attach(struct usb_serial *serial)
{
/* make sure we have our end-points */
if ((serial->num_bulk_in == 0) ||
(serial->num_bulk_out == 0) ||
(serial->num_interrupt_in == 0)) {
dev_err(&serial->dev->dev,
"%s - missing endpoint - "
"bulk in: %d, bulk out: %d, int in %d\n",
KBUILD_MODNAME,
serial->num_bulk_in,
serial->num_bulk_out,
serial->num_interrupt_in);
return -EINVAL;
if (serial->num_bulk_in == 0 ||
serial->num_bulk_out == 0 ||
serial->num_interrupt_in == 0) {
dev_err(&serial->interface->dev, "missing endpoint\n");
return -ENODEV;
}

return 0;
Expand Down Expand Up @@ -186,10 +187,8 @@ static int ark3116_port_probe(struct usb_serial_port *port)
if (priv->irda)
ark3116_write_reg(serial, 0x9, 0);

dev_info(&serial->dev->dev,
"%s using %s mode\n",
KBUILD_MODNAME,
priv->irda ? "IrDA" : "RS232");
dev_info(&port->dev, "using %s mode\n", priv->irda ? "IrDA" : "RS232");

return 0;
}

Expand Down Expand Up @@ -325,9 +324,8 @@ static void ark3116_set_termios(struct tty_struct *tty,

/* check for software flow control */
if (I_IXOFF(tty) || I_IXON(tty)) {
dev_warn(&serial->dev->dev,
"%s: don't know how to do software flow control\n",
KBUILD_MODNAME);
dev_warn(&port->dev,
"software flow control not implemented\n");
}

/* Don't rewrite B0 */
Expand All @@ -346,8 +344,8 @@ static void ark3116_close(struct usb_serial_port *port)
ark3116_write_reg(serial, UART_IER, 0);

usb_serial_generic_close(port);
if (serial->num_interrupt_in)
usb_kill_urb(port->interrupt_in_urb);

usb_kill_urb(port->interrupt_in_urb);
}

static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
Expand All @@ -366,23 +364,29 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
dev_dbg(&port->dev,
"%s - usb_serial_generic_open failed: %d\n",
__func__, result);
goto err_out;
goto err_free;
}

/* remove any data still left: also clears error state */
ark3116_read_reg(serial, UART_RX, buf);

/* read modem status */
priv->msr = ark3116_read_reg(serial, UART_MSR, buf);
result = ark3116_read_reg(serial, UART_MSR, buf);
if (result < 0)
goto err_close;
priv->msr = *buf;

/* read line status */
priv->lsr = ark3116_read_reg(serial, UART_LSR, buf);
result = ark3116_read_reg(serial, UART_LSR, buf);
if (result < 0)
goto err_close;
priv->lsr = *buf;

result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
if (result) {
dev_err(&port->dev, "submit irq_in urb failed %d\n",
result);
ark3116_close(port);
goto err_out;
goto err_close;
}

/* activate interrupts */
Expand All @@ -395,8 +399,15 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
if (tty)
ark3116_set_termios(tty, port, NULL);

err_out:
kfree(buf);

return 0;

err_close:
usb_serial_generic_close(port);
err_free:
kfree(buf);

return result;
}

Expand Down Expand Up @@ -602,9 +613,8 @@ static void ark3116_read_int_callback(struct urb *urb)

result = usb_submit_urb(urb, GFP_ATOMIC);
if (result)
dev_err(&urb->dev->dev,
"%s - Error %d submitting interrupt urb\n",
__func__, result);
dev_err(&port->dev, "failed to resubmit interrupt urb: %d\n",
result);
}


Expand Down
Loading

0 comments on commit 54a2190

Please sign in to comment.