Commit eddde288 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'usb-serial-4.9-rc1' of...

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

Johan writes:

USB-serial updates for v4.9-rc1

More clean ups, including a second set of changes from Mathieu as part
of a major overhaul of the ti_usb_3410_5052 driver.
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parents eeb7df27 61fc5136
...@@ -30,12 +30,12 @@ ...@@ -30,12 +30,12 @@
#include <linux/usb/ezusb.h> #include <linux/usb/ezusb.h>
/* make a simple define to handle if we are compiling keyspan_pda or xircom support */ /* make a simple define to handle if we are compiling keyspan_pda or xircom support */
#if defined(CONFIG_USB_SERIAL_KEYSPAN_PDA) || defined(CONFIG_USB_SERIAL_KEYSPAN_PDA_MODULE) #if IS_ENABLED(CONFIG_USB_SERIAL_KEYSPAN_PDA)
#define KEYSPAN #define KEYSPAN
#else #else
#undef KEYSPAN #undef KEYSPAN
#endif #endif
#if defined(CONFIG_USB_SERIAL_XIRCOM) || defined(CONFIG_USB_SERIAL_XIRCOM_MODULE) #if IS_ENABLED(CONFIG_USB_SERIAL_XIRCOM)
#define XIRCOM #define XIRCOM
#else #else
#undef XIRCOM #undef XIRCOM
......
...@@ -179,23 +179,23 @@ ...@@ -179,23 +179,23 @@
/* Config struct */ /* Config struct */
struct ti_uart_config { struct ti_uart_config {
__u16 wBaudRate; __be16 wBaudRate;
__u16 wFlags; __be16 wFlags;
__u8 bDataBits; u8 bDataBits;
__u8 bParity; u8 bParity;
__u8 bStopBits; u8 bStopBits;
char cXon; char cXon;
char cXoff; char cXoff;
__u8 bUartMode; u8 bUartMode;
} __packed; } __packed;
/* Get port status */ /* Get port status */
struct ti_port_status { struct ti_port_status {
__u8 bCmdCode; u8 bCmdCode;
__u8 bModuleId; u8 bModuleId;
__u8 bErrorCode; u8 bErrorCode;
__u8 bMSR; u8 bMSR;
__u8 bLSR; u8 bLSR;
} __packed; } __packed;
/* Purge modes */ /* Purge modes */
...@@ -218,12 +218,12 @@ struct ti_port_status { ...@@ -218,12 +218,12 @@ struct ti_port_status {
#define TI_RW_DATA_DOUBLE_WORD 0x04 #define TI_RW_DATA_DOUBLE_WORD 0x04
struct ti_write_data_bytes { struct ti_write_data_bytes {
__u8 bAddrType; u8 bAddrType;
__u8 bDataType; u8 bDataType;
__u8 bDataCounter; u8 bDataCounter;
__be16 wBaseAddrHi; __be16 wBaseAddrHi;
__be16 wBaseAddrLo; __be16 wBaseAddrLo;
__u8 bData[0]; u8 bData[0];
} __packed; } __packed;
struct ti_read_data_request { struct ti_read_data_request {
...@@ -258,7 +258,7 @@ struct ti_interrupt { ...@@ -258,7 +258,7 @@ struct ti_interrupt {
/* Firmware image header */ /* Firmware image header */
struct ti_firmware_header { struct ti_firmware_header {
__le16 wLength; __le16 wLength;
__u8 bCheckSum; u8 bCheckSum;
} __packed; } __packed;
/* UART addresses */ /* UART addresses */
...@@ -276,9 +276,6 @@ struct ti_firmware_header { ...@@ -276,9 +276,6 @@ struct ti_firmware_header {
#define TI_DEFAULT_CLOSING_WAIT 4000 /* in .01 secs */ #define TI_DEFAULT_CLOSING_WAIT 4000 /* in .01 secs */
/* supported setserial flags */
#define TI_SET_SERIAL_FLAGS 0
/* read urb states */ /* read urb states */
#define TI_READ_URB_RUNNING 0 #define TI_READ_URB_RUNNING 0
#define TI_READ_URB_STOPPING 1 #define TI_READ_URB_STOPPING 1
...@@ -288,11 +285,10 @@ struct ti_firmware_header { ...@@ -288,11 +285,10 @@ struct ti_firmware_header {
struct ti_port { struct ti_port {
int tp_is_open; int tp_is_open;
__u8 tp_msr; u8 tp_msr;
__u8 tp_shadow_mcr; u8 tp_shadow_mcr;
__u8 tp_uart_mode; /* 232 or 485 modes */ u8 tp_uart_mode; /* 232 or 485 modes */
unsigned int tp_uart_base_addr; unsigned int tp_uart_base_addr;
int tp_flags;
struct ti_device *tp_tdev; struct ti_device *tp_tdev;
struct usb_serial_port *tp_port; struct usb_serial_port *tp_port;
spinlock_t tp_lock; spinlock_t tp_lock;
...@@ -306,7 +302,6 @@ struct ti_device { ...@@ -306,7 +302,6 @@ struct ti_device {
struct usb_serial *td_serial; struct usb_serial *td_serial;
int td_is_3410; int td_is_3410;
bool td_rs485_only; bool td_rs485_only;
int td_urb_error;
}; };
static int ti_startup(struct usb_serial *serial); static int ti_startup(struct usb_serial *serial);
...@@ -343,7 +338,7 @@ static int ti_get_serial_info(struct ti_port *tport, ...@@ -343,7 +338,7 @@ static int ti_get_serial_info(struct ti_port *tport,
struct serial_struct __user *ret_arg); struct serial_struct __user *ret_arg);
static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport, static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport,
struct serial_struct __user *new_arg); struct serial_struct __user *new_arg);
static void ti_handle_new_msr(struct ti_port *tport, __u8 msr); static void ti_handle_new_msr(struct ti_port *tport, u8 msr);
static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty); static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty);
static int ti_restart_read(struct ti_port *tport, struct tty_struct *tty); static int ti_restart_read(struct ti_port *tport, struct tty_struct *tty);
...@@ -354,7 +349,7 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command, ...@@ -354,7 +349,7 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command,
__u16 moduleid, __u16 value, __u8 *data, int size); __u16 moduleid, __u16 value, __u8 *data, int size);
static int ti_write_byte(struct usb_serial_port *port, struct ti_device *tdev, static int ti_write_byte(struct usb_serial_port *port, struct ti_device *tdev,
unsigned long addr, __u8 mask, __u8 byte); unsigned long addr, u8 mask, u8 byte);
static int ti_download_firmware(struct ti_device *tdev); static int ti_download_firmware(struct ti_device *tdev);
...@@ -647,12 +642,11 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -647,12 +642,11 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
struct urb *urb; struct urb *urb;
int port_number; int port_number;
int status; int status;
__u16 open_settings = (__u8)(TI_PIPE_MODE_CONTINUOUS | u16 open_settings;
TI_PIPE_TIMEOUT_ENABLE |
(TI_TRANSFER_TIMEOUT << 2));
if (tport == NULL) open_settings = (TI_PIPE_MODE_CONTINUOUS |
return -ENODEV; TI_PIPE_TIMEOUT_ENABLE |
(TI_TRANSFER_TIMEOUT << 2));
dev = port->serial->dev; dev = port->serial->dev;
tdev = tport->tp_tdev; tdev = tport->tp_tdev;
...@@ -686,7 +680,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -686,7 +680,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
if (tty) if (tty)
ti_set_termios(tty, port, &tty->termios); ti_set_termios(tty, port, &tty->termios);
dev_dbg(&port->dev, "%s - sending TI_OPEN_PORT\n", __func__);
status = ti_command_out_sync(tdev, TI_OPEN_PORT, status = ti_command_out_sync(tdev, TI_OPEN_PORT,
(__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0);
if (status) { if (status) {
...@@ -695,7 +688,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -695,7 +688,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
goto unlink_int_urb; goto unlink_int_urb;
} }
dev_dbg(&port->dev, "%s - sending TI_START_PORT\n", __func__);
status = ti_command_out_sync(tdev, TI_START_PORT, status = ti_command_out_sync(tdev, TI_START_PORT,
(__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0);
if (status) { if (status) {
...@@ -704,7 +696,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -704,7 +696,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
goto unlink_int_urb; goto unlink_int_urb;
} }
dev_dbg(&port->dev, "%s - sending TI_PURGE_PORT\n", __func__);
status = ti_command_out_sync(tdev, TI_PURGE_PORT, status = ti_command_out_sync(tdev, TI_PURGE_PORT,
(__u8)(TI_UART1_PORT + port_number), TI_PURGE_INPUT, NULL, 0); (__u8)(TI_UART1_PORT + port_number), TI_PURGE_INPUT, NULL, 0);
if (status) { if (status) {
...@@ -728,7 +719,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -728,7 +719,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
if (tty) if (tty)
ti_set_termios(tty, port, &tty->termios); ti_set_termios(tty, port, &tty->termios);
dev_dbg(&port->dev, "%s - sending TI_OPEN_PORT (2)\n", __func__);
status = ti_command_out_sync(tdev, TI_OPEN_PORT, status = ti_command_out_sync(tdev, TI_OPEN_PORT,
(__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0);
if (status) { if (status) {
...@@ -737,7 +727,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -737,7 +727,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
goto unlink_int_urb; goto unlink_int_urb;
} }
dev_dbg(&port->dev, "%s - sending TI_START_PORT (2)\n", __func__);
status = ti_command_out_sync(tdev, TI_START_PORT, status = ti_command_out_sync(tdev, TI_START_PORT,
(__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0);
if (status) { if (status) {
...@@ -747,7 +736,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -747,7 +736,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
} }
/* start read urb */ /* start read urb */
dev_dbg(&port->dev, "%s - start read urb\n", __func__);
urb = port->read_urb; urb = port->read_urb;
if (!urb) { if (!urb) {
dev_err(&port->dev, "%s - no read urb\n", __func__); dev_err(&port->dev, "%s - no read urb\n", __func__);
...@@ -773,7 +761,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -773,7 +761,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
usb_kill_urb(port->serial->port[0]->interrupt_in_urb); usb_kill_urb(port->serial->port[0]->interrupt_in_urb);
release_lock: release_lock:
mutex_unlock(&tdev->td_open_close_lock); mutex_unlock(&tdev->td_open_close_lock);
dev_dbg(&port->dev, "%s - exit %d\n", __func__, status);
return status; return status;
} }
...@@ -789,8 +776,6 @@ static void ti_close(struct usb_serial_port *port) ...@@ -789,8 +776,6 @@ static void ti_close(struct usb_serial_port *port)
tdev = usb_get_serial_data(port->serial); tdev = usb_get_serial_data(port->serial);
tport = usb_get_serial_port_data(port); tport = usb_get_serial_port_data(port);
if (tdev == NULL || tport == NULL)
return;
tport->tp_is_open = 0; tport->tp_is_open = 0;
...@@ -803,7 +788,6 @@ static void ti_close(struct usb_serial_port *port) ...@@ -803,7 +788,6 @@ static void ti_close(struct usb_serial_port *port)
port_number = port->port_number; port_number = port->port_number;
dev_dbg(&port->dev, "%s - sending TI_CLOSE_PORT\n", __func__);
status = ti_command_out_sync(tdev, TI_CLOSE_PORT, status = ti_command_out_sync(tdev, TI_CLOSE_PORT,
(__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0);
if (status) if (status)
...@@ -830,11 +814,10 @@ static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, ...@@ -830,11 +814,10 @@ static int ti_write(struct tty_struct *tty, struct usb_serial_port *port,
struct ti_port *tport = usb_get_serial_port_data(port); struct ti_port *tport = usb_get_serial_port_data(port);
if (count == 0) { if (count == 0) {
dev_dbg(&port->dev, "%s - write request of 0 bytes\n", __func__);
return 0; return 0;
} }
if (tport == NULL || !tport->tp_is_open) if (!tport->tp_is_open)
return -ENODEV; return -ENODEV;
count = kfifo_in_locked(&port->write_fifo, data, count, count = kfifo_in_locked(&port->write_fifo, data, count,
...@@ -852,9 +835,6 @@ static int ti_write_room(struct tty_struct *tty) ...@@ -852,9 +835,6 @@ static int ti_write_room(struct tty_struct *tty)
int room = 0; int room = 0;
unsigned long flags; unsigned long flags;
if (tport == NULL)
return 0;
spin_lock_irqsave(&tport->tp_lock, flags); spin_lock_irqsave(&tport->tp_lock, flags);
room = kfifo_avail(&port->write_fifo); room = kfifo_avail(&port->write_fifo);
spin_unlock_irqrestore(&tport->tp_lock, flags); spin_unlock_irqrestore(&tport->tp_lock, flags);
...@@ -871,9 +851,6 @@ static int ti_chars_in_buffer(struct tty_struct *tty) ...@@ -871,9 +851,6 @@ static int ti_chars_in_buffer(struct tty_struct *tty)
int chars = 0; int chars = 0;
unsigned long flags; unsigned long flags;
if (tport == NULL)
return 0;
spin_lock_irqsave(&tport->tp_lock, flags); spin_lock_irqsave(&tport->tp_lock, flags);
chars = kfifo_len(&port->write_fifo); chars = kfifo_len(&port->write_fifo);
spin_unlock_irqrestore(&tport->tp_lock, flags); spin_unlock_irqrestore(&tport->tp_lock, flags);
...@@ -900,9 +877,6 @@ static void ti_throttle(struct tty_struct *tty) ...@@ -900,9 +877,6 @@ static void ti_throttle(struct tty_struct *tty)
struct usb_serial_port *port = tty->driver_data; struct usb_serial_port *port = tty->driver_data;
struct ti_port *tport = usb_get_serial_port_data(port); struct ti_port *tport = usb_get_serial_port_data(port);
if (tport == NULL)
return;
if (I_IXOFF(tty) || C_CRTSCTS(tty)) if (I_IXOFF(tty) || C_CRTSCTS(tty))
ti_stop_read(tport, tty); ti_stop_read(tport, tty);
...@@ -915,9 +889,6 @@ static void ti_unthrottle(struct tty_struct *tty) ...@@ -915,9 +889,6 @@ static void ti_unthrottle(struct tty_struct *tty)
struct ti_port *tport = usb_get_serial_port_data(port); struct ti_port *tport = usb_get_serial_port_data(port);
int status; int status;
if (tport == NULL)
return;
if (I_IXOFF(tty) || C_CRTSCTS(tty)) { if (I_IXOFF(tty) || C_CRTSCTS(tty)) {
status = ti_restart_read(tport, tty); status = ti_restart_read(tport, tty);
if (status) if (status)
...@@ -932,16 +903,11 @@ static int ti_ioctl(struct tty_struct *tty, ...@@ -932,16 +903,11 @@ static int ti_ioctl(struct tty_struct *tty,
struct usb_serial_port *port = tty->driver_data; struct usb_serial_port *port = tty->driver_data;
struct ti_port *tport = usb_get_serial_port_data(port); struct ti_port *tport = usb_get_serial_port_data(port);
if (tport == NULL)
return -ENODEV;
switch (cmd) { switch (cmd) {
case TIOCGSERIAL: case TIOCGSERIAL:
dev_dbg(&port->dev, "%s - TIOCGSERIAL\n", __func__);
return ti_get_serial_info(tport, return ti_get_serial_info(tport,
(struct serial_struct __user *)arg); (struct serial_struct __user *)arg);
case TIOCSSERIAL: case TIOCSSERIAL:
dev_dbg(&port->dev, "%s - TIOCSSERIAL\n", __func__);
return ti_set_serial_info(tty, tport, return ti_set_serial_info(tty, tport,
(struct serial_struct __user *)arg); (struct serial_struct __user *)arg);
} }
...@@ -959,6 +925,8 @@ static void ti_set_termios(struct tty_struct *tty, ...@@ -959,6 +925,8 @@ static void ti_set_termios(struct tty_struct *tty,
int status; int status;
int port_number = port->port_number; int port_number = port->port_number;
unsigned int mcr; unsigned int mcr;
u16 wbaudrate;
u16 wflags = 0;
cflag = tty->termios.c_cflag; cflag = tty->termios.c_cflag;
iflag = tty->termios.c_iflag; iflag = tty->termios.c_iflag;
...@@ -967,21 +935,16 @@ static void ti_set_termios(struct tty_struct *tty, ...@@ -967,21 +935,16 @@ static void ti_set_termios(struct tty_struct *tty,
dev_dbg(&port->dev, "%s - old clfag %08x, old iflag %08x\n", __func__, dev_dbg(&port->dev, "%s - old clfag %08x, old iflag %08x\n", __func__,
old_termios->c_cflag, old_termios->c_iflag); old_termios->c_cflag, old_termios->c_iflag);
if (tport == NULL)
return;
config = kmalloc(sizeof(*config), GFP_KERNEL); config = kmalloc(sizeof(*config), GFP_KERNEL);
if (!config) if (!config)
return; return;
config->wFlags = 0;
/* these flags must be set */ /* these flags must be set */
config->wFlags |= TI_UART_ENABLE_MS_INTS; wflags |= TI_UART_ENABLE_MS_INTS;
config->wFlags |= TI_UART_ENABLE_AUTO_START_DMA; wflags |= TI_UART_ENABLE_AUTO_START_DMA;
config->bUartMode = (__u8)(tport->tp_uart_mode); config->bUartMode = tport->tp_uart_mode;
switch (cflag & CSIZE) { switch (C_CSIZE(tty)) {
case CS5: case CS5:
config->bDataBits = TI_UART_5_DATA_BITS; config->bDataBits = TI_UART_5_DATA_BITS;
break; break;
...@@ -1000,29 +963,29 @@ static void ti_set_termios(struct tty_struct *tty, ...@@ -1000,29 +963,29 @@ static void ti_set_termios(struct tty_struct *tty,
/* CMSPAR isn't supported by this driver */ /* CMSPAR isn't supported by this driver */
tty->termios.c_cflag &= ~CMSPAR; tty->termios.c_cflag &= ~CMSPAR;
if (cflag & PARENB) { if (C_PARENB(tty)) {
if (cflag & PARODD) { if (C_PARODD(tty)) {
config->wFlags |= TI_UART_ENABLE_PARITY_CHECKING; wflags |= TI_UART_ENABLE_PARITY_CHECKING;
config->bParity = TI_UART_ODD_PARITY; config->bParity = TI_UART_ODD_PARITY;
} else { } else {
config->wFlags |= TI_UART_ENABLE_PARITY_CHECKING; wflags |= TI_UART_ENABLE_PARITY_CHECKING;
config->bParity = TI_UART_EVEN_PARITY; config->bParity = TI_UART_EVEN_PARITY;
} }
} else { } else {
config->wFlags &= ~TI_UART_ENABLE_PARITY_CHECKING; wflags &= ~TI_UART_ENABLE_PARITY_CHECKING;
config->bParity = TI_UART_NO_PARITY; config->bParity = TI_UART_NO_PARITY;
} }
if (cflag & CSTOPB) if (C_CSTOPB(tty))
config->bStopBits = TI_UART_2_STOP_BITS; config->bStopBits = TI_UART_2_STOP_BITS;
else else
config->bStopBits = TI_UART_1_STOP_BITS; config->bStopBits = TI_UART_1_STOP_BITS;
if (cflag & CRTSCTS) { if (C_CRTSCTS(tty)) {
/* RTS flow control must be off to drop RTS for baud rate B0 */ /* RTS flow control must be off to drop RTS for baud rate B0 */
if ((cflag & CBAUD) != B0) if ((C_BAUD(tty)) != B0)
config->wFlags |= TI_UART_ENABLE_RTS_IN; wflags |= TI_UART_ENABLE_RTS_IN;
config->wFlags |= TI_UART_ENABLE_CTS_OUT; wflags |= TI_UART_ENABLE_CTS_OUT;
} else { } else {
ti_restart_read(tport, tty); ti_restart_read(tport, tty);
} }
...@@ -1032,34 +995,34 @@ static void ti_set_termios(struct tty_struct *tty, ...@@ -1032,34 +995,34 @@ static void ti_set_termios(struct tty_struct *tty,
config->cXoff = STOP_CHAR(tty); config->cXoff = STOP_CHAR(tty);
if (I_IXOFF(tty)) if (I_IXOFF(tty))
config->wFlags |= TI_UART_ENABLE_X_IN; wflags |= TI_UART_ENABLE_X_IN;
else else
ti_restart_read(tport, tty); ti_restart_read(tport, tty);
if (I_IXON(tty)) if (I_IXON(tty))
config->wFlags |= TI_UART_ENABLE_X_OUT; wflags |= TI_UART_ENABLE_X_OUT;
} }
baud = tty_get_baud_rate(tty); baud = tty_get_baud_rate(tty);
if (!baud) if (!baud)
baud = 9600; baud = 9600;
if (tport->tp_tdev->td_is_3410) if (tport->tp_tdev->td_is_3410)
config->wBaudRate = (__u16)((923077 + baud/2) / baud); wbaudrate = (923077 + baud/2) / baud;
else else
config->wBaudRate = (__u16)((461538 + baud/2) / baud); wbaudrate = (461538 + baud/2) / baud;
/* FIXME: Should calculate resulting baud here and report it back */ /* FIXME: Should calculate resulting baud here and report it back */
if ((cflag & CBAUD) != B0) if ((C_BAUD(tty)) != B0)
tty_encode_baud_rate(tty, baud, baud); tty_encode_baud_rate(tty, baud, baud);
dev_dbg(&port->dev, dev_dbg(&port->dev,
"%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d\n", "%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d\n",
__func__, baud, config->wBaudRate, config->wFlags, __func__, baud, wbaudrate, wflags,
config->bDataBits, config->bParity, config->bStopBits, config->bDataBits, config->bParity, config->bStopBits,
config->cXon, config->cXoff, config->bUartMode); config->cXon, config->cXoff, config->bUartMode);
cpu_to_be16s(&config->wBaudRate); config->wBaudRate = cpu_to_be16(wbaudrate);
cpu_to_be16s(&config->wFlags); config->wFlags = cpu_to_be16(wflags);
status = ti_command_out_sync(tport->tp_tdev, TI_SET_CONFIG, status = ti_command_out_sync(tport->tp_tdev, TI_SET_CONFIG,
(__u8)(TI_UART1_PORT + port_number), 0, (__u8 *)config, (__u8)(TI_UART1_PORT + port_number), 0, (__u8 *)config,
...@@ -1071,7 +1034,7 @@ static void ti_set_termios(struct tty_struct *tty, ...@@ -1071,7 +1034,7 @@ static void ti_set_termios(struct tty_struct *tty,
/* SET_CONFIG asserts RTS and DTR, reset them correctly */ /* SET_CONFIG asserts RTS and DTR, reset them correctly */
mcr = tport->tp_shadow_mcr; mcr = tport->tp_shadow_mcr;
/* if baud rate is B0, clear RTS and DTR */ /* if baud rate is B0, clear RTS and DTR */
if ((cflag & CBAUD) == B0) if (C_BAUD(tty) == B0)
mcr &= ~(TI_MCR_DTR | TI_MCR_RTS); mcr &= ~(TI_MCR_DTR | TI_MCR_RTS);
status = ti_set_mcr(tport, mcr); status = ti_set_mcr(tport, mcr);
if (status) if (status)
...@@ -1092,9 +1055,6 @@ static int ti_tiocmget(struct tty_struct *tty) ...@@ -1092,9 +1055,6 @@ static int ti_tiocmget(struct tty_struct *tty)
unsigned int mcr; unsigned int mcr;
unsigned long flags; unsigned long flags;
if (tport == NULL)
return -ENODEV;
spin_lock_irqsave(&tport->tp_lock, flags); spin_lock_irqsave(&tport->tp_lock, flags);
msr = tport->tp_msr; msr = tport->tp_msr;
mcr = tport->tp_shadow_mcr; mcr = tport->tp_shadow_mcr;
...@@ -1122,9 +1082,6 @@ static int ti_tiocmset(struct tty_struct *tty, ...@@ -1122,9 +1082,6 @@ static int ti_tiocmset(struct tty_struct *tty,
unsigned int mcr; unsigned int mcr;
unsigned long flags; unsigned long flags;
if (tport == NULL)
return -ENODEV;
spin_lock_irqsave(&tport->tp_lock, flags); spin_lock_irqsave(&tport->tp_lock, flags);
mcr = tport->tp_shadow_mcr; mcr = tport->tp_shadow_mcr;
...@@ -1155,9 +1112,6 @@ static void ti_break(struct tty_struct *tty, int break_state) ...@@ -1155,9 +1112,6 @@ static void ti_break(struct tty_struct *tty, int break_state)
dev_dbg(&port->dev, "%s - state = %d\n", __func__, break_state); dev_dbg(&port->dev, "%s - state = %d\n", __func__, break_state);
if (tport == NULL)
return;
status = ti_write_byte(port, tport->tp_tdev, status = ti_write_byte(port, tport->tp_tdev,
tport->tp_uart_base_addr + TI_UART_OFFSET_LCR, tport->tp_uart_base_addr + TI_UART_OFFSET_LCR,
TI_LCR_BREAK, break_state == -1 ? TI_LCR_BREAK : 0); TI_LCR_BREAK, break_state == -1 ? TI_LCR_BREAK : 0);
...@@ -1189,7 +1143,7 @@ static void ti_interrupt_callback(struct urb *urb) ...@@ -1189,7 +1143,7 @@ static void ti_interrupt_callback(struct urb *urb)
int function; int function;
int status = urb->status; int status = urb->status;
int retval; int retval;
__u8 msr; u8 msr;
switch (status) { switch (status) {
case 0: case 0:
...@@ -1198,11 +1152,9 @@ static void ti_interrupt_callback(struct urb *urb) ...@@ -1198,11 +1152,9 @@ static void ti_interrupt_callback(struct urb *urb)
case -ENOENT: case -ENOENT:
case -ESHUTDOWN: case -ESHUTDOWN:
dev_dbg(dev, "%s - urb shutting down, %d\n", __func__, status); dev_dbg(dev, "%s - urb shutting down, %d\n", __func__, status);
tdev->td_urb_error = 1;
return; return;
default: default:
dev_err(dev, "%s - nonzero urb status, %d\n", __func__, status); dev_err(dev, "%s - nonzero urb status, %d\n", __func__, status);
tdev->td_urb_error = 1;
goto exit; goto exit;
} }
...@@ -1275,12 +1227,10 @@ static void ti_bulk_in_callback(struct urb *urb) ...@@ -1275,12 +1227,10 @@ static void ti_bulk_in_callback(struct urb *urb)
case -ENOENT: case -ENOENT:
case -ESHUTDOWN: case -ESHUTDOWN:
dev_dbg(dev, "%s - urb shutting down, %d\n", __func__, status); dev_dbg(dev, "%s - urb shutting down, %d\n", __func__, status);
tport->tp_tdev->td_urb_error = 1;
return; return;
default: default:
dev_err(dev, "%s - nonzero urb status, %d\n", dev_err(dev, "%s - nonzero urb status, %d\n",
__func__, status); __func__, status);
tport->tp_tdev->td_urb_error = 1;
} }
if (status == -EPIPE) if (status == -EPIPE)
...@@ -1335,12 +1285,10 @@ static void ti_bulk_out_callback(struct urb *urb) ...@@ -1335,12 +1285,10 @@ static void ti_bulk_out_callback(struct urb *urb)
case -ENOENT: case -ENOENT:
case -ESHUTDOWN: case -ESHUTDOWN:
dev_dbg(&port->dev, "%s - urb shutting down, %d\n", __func__, status); dev_dbg(&port->dev, "%s - urb shutting down, %d\n", __func__, status);
tport->tp_tdev->td_urb_error = 1;
return; return;
default: default:
dev_err_console(port, "%s - nonzero urb status, %d\n", dev_err_console(port, "%s - nonzero urb status, %d\n",
__func__, status); __func__, status);
tport->tp_tdev->td_urb_error = 1;
} }
/* send any buffered data */ /* send any buffered data */
...@@ -1490,7 +1438,6 @@ static int ti_get_serial_info(struct ti_port *tport, ...@@ -1490,7 +1438,6 @@ static int ti_get_serial_info(struct ti_port *tport,
ret_serial.type = PORT_16550A; ret_serial.type = PORT_16550A;
ret_serial.line = port->minor; ret_serial.line = port->minor;
ret_serial.port = port->port_number; ret_serial.port = port->port_number;
ret_serial.flags = tport->tp_flags;
ret_serial.xmit_fifo_size = kfifo_size(&port->write_fifo); ret_serial.xmit_fifo_size = kfifo_size(&port->write_fifo);
ret_serial.baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800; ret_serial.baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800;
ret_serial.closing_wait = cwait; ret_serial.closing_wait = cwait;
...@@ -1515,14 +1462,13 @@ static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport, ...@@ -1515,14 +1462,13 @@ static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport,
if (cwait != ASYNC_CLOSING_WAIT_NONE) if (cwait != ASYNC_CLOSING_WAIT_NONE)
cwait = msecs_to_jiffies(10 * new_serial.closing_wait); cwait = msecs_to_jiffies(10 * new_serial.closing_wait);
tport->tp_flags = new_serial.flags & TI_SET_SERIAL_FLAGS;
tport->tp_port->port.closing_wait = cwait; tport->tp_port->port.closing_wait = cwait;
return 0; return 0;
} }
static void ti_handle_new_msr(struct ti_port *tport, __u8 msr) static void ti_handle_new_msr(struct ti_port *tport, u8 msr)
{ {
struct async_icount *icount; struct async_icount *icount;
struct tty_struct *tty; struct tty_struct *tty;
...@@ -1634,8 +1580,8 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command, ...@@ -1634,8 +1580,8 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command,
static int ti_write_byte(struct usb_serial_port *port, static int ti_write_byte(struct usb_serial_port *port,
struct ti_device *tdev, unsigned long addr, struct ti_device *tdev, unsigned long addr,
__u8 mask, __u8 byte) u8 mask, u8 byte)
{ {
int status; int status;
unsigned int size; unsigned int size;
...@@ -1679,11 +1625,10 @@ static int ti_do_download(struct usb_device *dev, int pipe, ...@@ -1679,11 +1625,10 @@ static int ti_do_download(struct usb_device *dev, int pipe,
int len; int len;
for (pos = sizeof(struct ti_firmware_header); pos < size; pos++) for (pos = sizeof(struct ti_firmware_header); pos < size; pos++)
cs = (__u8)(cs + buffer[pos]); cs = (u8)(cs + buffer[pos]);
header = (struct ti_firmware_header *)buffer; header = (struct ti_firmware_header *)buffer;
header->wLength = cpu_to_le16((__u16)(size header->wLength = cpu_to_le16(size - sizeof(*header));
- sizeof(struct ti_firmware_header)));
header->bCheckSum = cs; header->bCheckSum = cs;
dev_dbg(&dev->dev, "%s - downloading firmware\n", __func__); dev_dbg(&dev->dev, "%s - downloading firmware\n", __func__);
...@@ -1701,7 +1646,7 @@ static int ti_download_firmware(struct ti_device *tdev) ...@@ -1701,7 +1646,7 @@ static int ti_download_firmware(struct ti_device *tdev)
{ {
int status; int status;
int buffer_size; int buffer_size;
__u8 *buffer; u8 *buffer;
struct usb_device *dev = tdev->td_serial->dev; struct usb_device *dev = tdev->td_serial->dev;
unsigned int pipe = usb_sndbulkpipe(dev, unsigned int pipe = usb_sndbulkpipe(dev,
tdev->td_serial->port[0]->bulk_out_endpointAddress); tdev->td_serial->port[0]->bulk_out_endpointAddress);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment