Commit a30fa793 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

tty-usb-ti-usb: Coding style

Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0487b583
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* For questions or problems with this driver, contact Texas Instruments * For questions or problems with this driver, contact Texas Instruments
* technical support, or Al Borchers <alborchers@steinerpoint.com>, or * technical support, or Al Borchers <alborchers@steinerpoint.com>, or
* Peter Berger <pberger@brimson.com>. * Peter Berger <pberger@brimson.com>.
* *
* This driver needs this hotplug script in /etc/hotplug/usb/ti_usb_3410_5052 * This driver needs this hotplug script in /etc/hotplug/usb/ti_usb_3410_5052
* or in /etc/hotplug.d/usb/ti_usb_3410_5052.hotplug to set the device * or in /etc/hotplug.d/usb/ti_usb_3410_5052.hotplug to set the device
* configuration. * configuration.
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
#include <linux/serial.h> #include <linux/serial.h>
#include <linux/circ_buf.h> #include <linux/circ_buf.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <asm/uaccess.h> #include <linux/uaccess.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/usb/serial.h> #include <linux/usb/serial.h>
#include <linux/firmware.h> #include <linux/firmware.h>
...@@ -151,21 +151,22 @@ struct ti_device { ...@@ -151,21 +151,22 @@ struct ti_device {
static int ti_startup(struct usb_serial *serial); static int ti_startup(struct usb_serial *serial);
static void ti_shutdown(struct usb_serial *serial); static void ti_shutdown(struct usb_serial *serial);
static int ti_open(struct tty_struct *tty, struct usb_serial_port *port, static int ti_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *file); struct file *file);
static void ti_close(struct tty_struct *tty, struct usb_serial_port *port, static void ti_close(struct tty_struct *tty, struct usb_serial_port *port,
struct file *file); struct file *file);
static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, static int ti_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *data, int count); const unsigned char *data, int count);
static int ti_write_room(struct tty_struct *tty); static int ti_write_room(struct tty_struct *tty);
static int ti_chars_in_buffer(struct tty_struct *tty); static int ti_chars_in_buffer(struct tty_struct *tty);
static void ti_throttle(struct tty_struct *tty); static void ti_throttle(struct tty_struct *tty);
static void ti_unthrottle(struct tty_struct *tty); static void ti_unthrottle(struct tty_struct *tty);
static int ti_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); static int ti_ioctl(struct tty_struct *tty, struct file *file,
static void ti_set_termios(struct tty_struct *tty, struct usb_serial_port *port, unsigned int cmd, unsigned long arg);
struct ktermios *old_termios); static void ti_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios);
static int ti_tiocmget(struct tty_struct *tty, struct file *file); static int ti_tiocmget(struct tty_struct *tty, struct file *file);
static int ti_tiocmset(struct tty_struct *tty, struct file *file, static int ti_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear); unsigned int set, unsigned int clear);
static void ti_break(struct tty_struct *tty, int break_state); static void ti_break(struct tty_struct *tty, int break_state);
static void ti_interrupt_callback(struct urb *urb); static void ti_interrupt_callback(struct urb *urb);
static void ti_bulk_in_callback(struct urb *urb); static void ti_bulk_in_callback(struct urb *urb);
...@@ -327,19 +328,25 @@ module_param(debug, bool, S_IRUGO | S_IWUSR); ...@@ -327,19 +328,25 @@ module_param(debug, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes"); MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes");
module_param(low_latency, bool, S_IRUGO | S_IWUSR); module_param(low_latency, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(low_latency, "TTY low_latency flag, 0=off, 1=on, default is off"); MODULE_PARM_DESC(low_latency,
"TTY low_latency flag, 0=off, 1=on, default is off");
module_param(closing_wait, int, S_IRUGO | S_IWUSR); module_param(closing_wait, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(closing_wait, "Maximum wait for data to drain in close, in .01 secs, default is 4000"); MODULE_PARM_DESC(closing_wait,
"Maximum wait for data to drain in close, in .01 secs, default is 4000");
module_param_array(vendor_3410, ushort, &vendor_3410_count, S_IRUGO); module_param_array(vendor_3410, ushort, &vendor_3410_count, S_IRUGO);
MODULE_PARM_DESC(vendor_3410, "Vendor ids for 3410 based devices, 1-5 short integers"); MODULE_PARM_DESC(vendor_3410,
"Vendor ids for 3410 based devices, 1-5 short integers");
module_param_array(product_3410, ushort, &product_3410_count, S_IRUGO); module_param_array(product_3410, ushort, &product_3410_count, S_IRUGO);
MODULE_PARM_DESC(product_3410, "Product ids for 3410 based devices, 1-5 short integers"); MODULE_PARM_DESC(product_3410,
"Product ids for 3410 based devices, 1-5 short integers");
module_param_array(vendor_5052, ushort, &vendor_5052_count, S_IRUGO); module_param_array(vendor_5052, ushort, &vendor_5052_count, S_IRUGO);
MODULE_PARM_DESC(vendor_5052, "Vendor ids for 5052 based devices, 1-5 short integers"); MODULE_PARM_DESC(vendor_5052,
"Vendor ids for 5052 based devices, 1-5 short integers");
module_param_array(product_5052, ushort, &product_5052_count, S_IRUGO); module_param_array(product_5052, ushort, &product_5052_count, S_IRUGO);
MODULE_PARM_DESC(product_5052, "Product ids for 5052 based devices, 1-5 short integers"); MODULE_PARM_DESC(product_5052,
"Product ids for 5052 based devices, 1-5 short integers");
MODULE_DEVICE_TABLE(usb, ti_id_table_combined); MODULE_DEVICE_TABLE(usb, ti_id_table_combined);
...@@ -348,18 +355,18 @@ MODULE_DEVICE_TABLE(usb, ti_id_table_combined); ...@@ -348,18 +355,18 @@ MODULE_DEVICE_TABLE(usb, ti_id_table_combined);
static int __init ti_init(void) static int __init ti_init(void)
{ {
int i,j; int i, j;
int ret; int ret;
/* insert extra vendor and product ids */ /* insert extra vendor and product ids */
j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1; j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1;
for (i=0; i<min(vendor_3410_count,product_3410_count); i++,j++) { for (i = 0; i < min(vendor_3410_count, product_3410_count); i++, j++) {
ti_id_table_3410[j].idVendor = vendor_3410[i]; ti_id_table_3410[j].idVendor = vendor_3410[i];
ti_id_table_3410[j].idProduct = product_3410[i]; ti_id_table_3410[j].idProduct = product_3410[i];
ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE; ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
} }
j = ARRAY_SIZE(ti_id_table_5052) - TI_EXTRA_VID_PID_COUNT - 1; j = ARRAY_SIZE(ti_id_table_5052) - TI_EXTRA_VID_PID_COUNT - 1;
for (i=0; i<min(vendor_5052_count,product_5052_count); i++,j++) { for (i = 0; i < min(vendor_5052_count, product_5052_count); i++, j++) {
ti_id_table_5052[j].idVendor = vendor_5052[i]; ti_id_table_5052[j].idVendor = vendor_5052[i];
ti_id_table_5052[j].idProduct = product_5052[i]; ti_id_table_5052[j].idProduct = product_5052[i];
ti_id_table_5052[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE; ti_id_table_5052[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
...@@ -428,7 +435,8 @@ static int ti_startup(struct usb_serial *serial) ...@@ -428,7 +435,8 @@ static int ti_startup(struct usb_serial *serial)
/* determine device type */ /* determine device type */
if (usb_match_id(serial->interface, ti_id_table_3410)) if (usb_match_id(serial->interface, ti_id_table_3410))
tdev->td_is_3410 = 1; tdev->td_is_3410 = 1;
dbg("%s - device type is %s", __func__, tdev->td_is_3410 ? "3410" : "5052"); dbg("%s - device type is %s", __func__,
tdev->td_is_3410 ? "3410" : "5052");
/* if we have only 1 configuration, download firmware */ /* if we have only 1 configuration, download firmware */
if (dev->descriptor.bNumConfigurations == 1) { if (dev->descriptor.bNumConfigurations == 1) {
...@@ -447,7 +455,7 @@ static int ti_startup(struct usb_serial *serial) ...@@ -447,7 +455,7 @@ static int ti_startup(struct usb_serial *serial)
status = -ENODEV; status = -ENODEV;
goto free_tdev; goto free_tdev;
} }
/* the second configuration must be set (in sysfs by hotplug script) */ /* the second configuration must be set (in sysfs by hotplug script) */
if (dev->actconfig->desc.bConfigurationValue == TI_BOOT_CONFIG) { if (dev->actconfig->desc.bConfigurationValue == TI_BOOT_CONFIG) {
...@@ -464,7 +472,8 @@ static int ti_startup(struct usb_serial *serial) ...@@ -464,7 +472,8 @@ static int ti_startup(struct usb_serial *serial)
goto free_tports; goto free_tports;
} }
spin_lock_init(&tport->tp_lock); spin_lock_init(&tport->tp_lock);
tport->tp_uart_base_addr = (i == 0 ? TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR); tport->tp_uart_base_addr = (i == 0 ?
TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR);
tport->tp_flags = low_latency ? ASYNC_LOW_LATENCY : 0; tport->tp_flags = low_latency ? ASYNC_LOW_LATENCY : 0;
tport->tp_closing_wait = closing_wait; tport->tp_closing_wait = closing_wait;
init_waitqueue_head(&tport->tp_msr_wait); init_waitqueue_head(&tport->tp_msr_wait);
...@@ -481,11 +490,11 @@ static int ti_startup(struct usb_serial *serial) ...@@ -481,11 +490,11 @@ static int ti_startup(struct usb_serial *serial)
usb_set_serial_port_data(serial->port[i], tport); usb_set_serial_port_data(serial->port[i], tport);
tport->tp_uart_mode = 0; /* default is RS232 */ tport->tp_uart_mode = 0; /* default is RS232 */
} }
return 0; return 0;
free_tports: free_tports:
for (--i; i>=0; --i) { for (--i; i >= 0; --i) {
tport = usb_get_serial_port_data(serial->port[i]); tport = usb_get_serial_port_data(serial->port[i]);
ti_buf_free(tport->tp_write_buf); ti_buf_free(tport->tp_write_buf);
kfree(tport); kfree(tport);
...@@ -506,7 +515,7 @@ static void ti_shutdown(struct usb_serial *serial) ...@@ -506,7 +515,7 @@ static void ti_shutdown(struct usb_serial *serial)
dbg("%s", __func__); dbg("%s", __func__);
for (i=0; i < serial->num_ports; ++i) { for (i = 0; i < serial->num_ports; ++i) {
tport = usb_get_serial_port_data(serial->port[i]); tport = usb_get_serial_port_data(serial->port[i]);
if (tport) { if (tport) {
ti_buf_free(tport->tp_write_buf); ti_buf_free(tport->tp_write_buf);
...@@ -529,8 +538,8 @@ static int ti_open(struct tty_struct *tty, ...@@ -529,8 +538,8 @@ static int ti_open(struct tty_struct *tty,
struct urb *urb; struct urb *urb;
int port_number; int port_number;
int status; int status;
__u16 open_settings = (__u8)(TI_PIPE_MODE_CONTINOUS | __u16 open_settings = (__u8)(TI_PIPE_MODE_CONTINOUS |
TI_PIPE_TIMEOUT_ENABLE | TI_PIPE_TIMEOUT_ENABLE |
(TI_TRANSFER_TIMEOUT << 2)); (TI_TRANSFER_TIMEOUT << 2));
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
...@@ -561,7 +570,8 @@ static int ti_open(struct tty_struct *tty, ...@@ -561,7 +570,8 @@ static int ti_open(struct tty_struct *tty,
dbg("%s - start interrupt in urb", __func__); dbg("%s - start interrupt in urb", __func__);
urb = tdev->td_serial->port[0]->interrupt_in_urb; urb = tdev->td_serial->port[0]->interrupt_in_urb;
if (!urb) { if (!urb) {
dev_err(&port->dev, "%s - no interrupt urb\n", __func__); dev_err(&port->dev, "%s - no interrupt urb\n",
__func__);
status = -EINVAL; status = -EINVAL;
goto release_lock; goto release_lock;
} }
...@@ -570,7 +580,9 @@ static int ti_open(struct tty_struct *tty, ...@@ -570,7 +580,9 @@ static int ti_open(struct tty_struct *tty,
urb->dev = dev; urb->dev = dev;
status = usb_submit_urb(urb, GFP_KERNEL); status = usb_submit_urb(urb, GFP_KERNEL);
if (status) { if (status) {
dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __func__, status); dev_err(&port->dev,
"%s - submit interrupt urb failed, %d\n",
__func__, status);
goto release_lock; goto release_lock;
} }
} }
...@@ -582,7 +594,8 @@ static int ti_open(struct tty_struct *tty, ...@@ -582,7 +594,8 @@ static int ti_open(struct tty_struct *tty,
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) {
dev_err(&port->dev, "%s - cannot send open command, %d\n", __func__, status); dev_err(&port->dev, "%s - cannot send open command, %d\n",
__func__, status);
goto unlink_int_urb; goto unlink_int_urb;
} }
...@@ -590,7 +603,8 @@ static int ti_open(struct tty_struct *tty, ...@@ -590,7 +603,8 @@ static int ti_open(struct tty_struct *tty,
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) {
dev_err(&port->dev, "%s - cannot send start command, %d\n", __func__, status); dev_err(&port->dev, "%s - cannot send start command, %d\n",
__func__, status);
goto unlink_int_urb; goto unlink_int_urb;
} }
...@@ -598,13 +612,15 @@ static int ti_open(struct tty_struct *tty, ...@@ -598,13 +612,15 @@ static int ti_open(struct tty_struct *tty,
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) {
dev_err(&port->dev, "%s - cannot clear input buffers, %d\n", __func__, status); dev_err(&port->dev, "%s - cannot clear input buffers, %d\n",
__func__, status);
goto unlink_int_urb; goto unlink_int_urb;
} }
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_OUTPUT, NULL, 0); (__u8)(TI_UART1_PORT + port_number), TI_PURGE_OUTPUT, NULL, 0);
if (status) { if (status) {
dev_err(&port->dev, "%s - cannot clear output buffers, %d\n", __func__, status); dev_err(&port->dev, "%s - cannot clear output buffers, %d\n",
__func__, status);
goto unlink_int_urb; goto unlink_int_urb;
} }
...@@ -620,7 +636,8 @@ static int ti_open(struct tty_struct *tty, ...@@ -620,7 +636,8 @@ static int ti_open(struct tty_struct *tty,
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) {
dev_err(&port->dev, "%s - cannot send open command (2), %d\n", __func__, status); dev_err(&port->dev, "%s - cannot send open command (2), %d\n",
__func__, status);
goto unlink_int_urb; goto unlink_int_urb;
} }
...@@ -628,7 +645,8 @@ static int ti_open(struct tty_struct *tty, ...@@ -628,7 +645,8 @@ static int ti_open(struct tty_struct *tty,
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) {
dev_err(&port->dev, "%s - cannot send start command (2), %d\n", __func__, status); dev_err(&port->dev, "%s - cannot send start command (2), %d\n",
__func__, status);
goto unlink_int_urb; goto unlink_int_urb;
} }
...@@ -646,7 +664,8 @@ static int ti_open(struct tty_struct *tty, ...@@ -646,7 +664,8 @@ static int ti_open(struct tty_struct *tty,
urb->dev = dev; urb->dev = dev;
status = usb_submit_urb(urb, GFP_KERNEL); status = usb_submit_urb(urb, GFP_KERNEL);
if (status) { if (status) {
dev_err(&port->dev, "%s - submit read urb failed, %d\n", __func__, status); dev_err(&port->dev, "%s - submit read urb failed, %d\n",
__func__, status);
goto unlink_int_urb; goto unlink_int_urb;
} }
...@@ -675,7 +694,7 @@ static void ti_close(struct tty_struct *tty, struct usb_serial_port *port, ...@@ -675,7 +694,7 @@ static void ti_close(struct tty_struct *tty, struct usb_serial_port *port,
int do_unlock; int do_unlock;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
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) if (tdev == NULL || tport == NULL)
...@@ -695,7 +714,9 @@ static void ti_close(struct tty_struct *tty, struct usb_serial_port *port, ...@@ -695,7 +714,9 @@ static void ti_close(struct tty_struct *tty, struct usb_serial_port *port,
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)
dev_err(&port->dev, "%s - cannot send close port command, %d\n" , __func__, status); dev_err(&port->dev,
"%s - cannot send close port command, %d\n"
, __func__, status);
/* if mutex_lock is interrupted, continue anyway */ /* if mutex_lock is interrupted, continue anyway */
do_unlock = !mutex_lock_interruptible(&tdev->td_open_close_lock); do_unlock = !mutex_lock_interruptible(&tdev->td_open_close_lock);
...@@ -749,7 +770,7 @@ static int ti_write_room(struct tty_struct *tty) ...@@ -749,7 +770,7 @@ static int ti_write_room(struct tty_struct *tty)
if (tport == NULL) if (tport == NULL)
return -ENODEV; return -ENODEV;
spin_lock_irqsave(&tport->tp_lock, flags); spin_lock_irqsave(&tport->tp_lock, flags);
room = ti_buf_space_avail(tport->tp_write_buf); room = ti_buf_space_avail(tport->tp_write_buf);
spin_unlock_irqrestore(&tport->tp_lock, flags); spin_unlock_irqrestore(&tport->tp_lock, flags);
...@@ -810,7 +831,8 @@ static void ti_unthrottle(struct tty_struct *tty) ...@@ -810,7 +831,8 @@ static void ti_unthrottle(struct tty_struct *tty)
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)
dev_err(&port->dev, "%s - cannot restart read, %d\n", __func__, status); dev_err(&port->dev, "%s - cannot restart read, %d\n",
__func__, status);
} }
} }
...@@ -829,44 +851,42 @@ static int ti_ioctl(struct tty_struct *tty, struct file *file, ...@@ -829,44 +851,42 @@ static int ti_ioctl(struct tty_struct *tty, struct file *file,
return -ENODEV; return -ENODEV;
switch (cmd) { switch (cmd) {
case TIOCGSERIAL: case TIOCGSERIAL:
dbg("%s - (%d) TIOCGSERIAL", __func__, port->number); dbg("%s - (%d) TIOCGSERIAL", __func__, port->number);
return ti_get_serial_info(tport, (struct serial_struct __user *)arg); return ti_get_serial_info(tport,
break; (struct serial_struct __user *)arg);
case TIOCSSERIAL:
case TIOCSSERIAL: dbg("%s - (%d) TIOCSSERIAL", __func__, port->number);
dbg("%s - (%d) TIOCSSERIAL", __func__, port->number); return ti_set_serial_info(tport,
return ti_set_serial_info(tport, (struct serial_struct __user *)arg); (struct serial_struct __user *)arg);
break; case TIOCMIWAIT:
dbg("%s - (%d) TIOCMIWAIT", __func__, port->number);
case TIOCMIWAIT: cprev = tport->tp_icount;
dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); while (1) {
cprev = tport->tp_icount; interruptible_sleep_on(&tport->tp_msr_wait);
while (1) { if (signal_pending(current))
interruptible_sleep_on(&tport->tp_msr_wait); return -ERESTARTSYS;
if (signal_pending(current)) cnow = tport->tp_icount;
return -ERESTARTSYS; if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
cnow = tport->tp_icount; cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && return -EIO; /* no change => error */
cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
return -EIO; /* no change => error */ ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)))
((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || return 0;
((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) { cprev = cnow;
return 0; }
} break;
cprev = cnow; case TIOCGICOUNT:
} dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d",
break; __func__, port->number,
tport->tp_icount.rx, tport->tp_icount.tx);
case TIOCGICOUNT: if (copy_to_user((void __user *)arg, &tport->tp_icount,
dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, port->number, tport->tp_icount.rx, tport->tp_icount.tx); sizeof(tport->tp_icount)))
if (copy_to_user((void __user *)arg, &tport->tp_icount, sizeof(tport->tp_icount))) return -EFAULT;
return -EFAULT; return 0;
return 0;
} }
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
...@@ -876,7 +896,7 @@ static void ti_set_termios(struct tty_struct *tty, ...@@ -876,7 +896,7 @@ static void ti_set_termios(struct tty_struct *tty,
{ {
struct ti_port *tport = usb_get_serial_port_data(port); struct ti_port *tport = usb_get_serial_port_data(port);
struct ti_uart_config *config; struct ti_uart_config *config;
tcflag_t cflag,iflag; tcflag_t cflag, iflag;
int baud; int baud;
int status; int status;
int port_number = port->number - port->serial->minor; int port_number = port->number - port->serial->minor;
...@@ -888,7 +908,8 @@ static void ti_set_termios(struct tty_struct *tty, ...@@ -888,7 +908,8 @@ static void ti_set_termios(struct tty_struct *tty,
iflag = tty->termios->c_iflag; iflag = tty->termios->c_iflag;
dbg("%s - cflag %08x, iflag %08x", __func__, cflag, iflag); dbg("%s - cflag %08x, iflag %08x", __func__, cflag, iflag);
dbg("%s - old clfag %08x, old iflag %08x", __func__, old_termios->c_cflag, old_termios->c_iflag); dbg("%s - old clfag %08x, old iflag %08x", __func__,
old_termios->c_cflag, old_termios->c_iflag);
if (tport == NULL) if (tport == NULL)
return; return;
...@@ -907,19 +928,19 @@ static void ti_set_termios(struct tty_struct *tty, ...@@ -907,19 +928,19 @@ static void ti_set_termios(struct tty_struct *tty,
config->bUartMode = (__u8)(tport->tp_uart_mode); config->bUartMode = (__u8)(tport->tp_uart_mode);
switch (cflag & CSIZE) { switch (cflag & CSIZE) {
case CS5: case CS5:
config->bDataBits = TI_UART_5_DATA_BITS; config->bDataBits = TI_UART_5_DATA_BITS;
break; break;
case CS6: case CS6:
config->bDataBits = TI_UART_6_DATA_BITS; config->bDataBits = TI_UART_6_DATA_BITS;
break; break;
case CS7: case CS7:
config->bDataBits = TI_UART_7_DATA_BITS; config->bDataBits = TI_UART_7_DATA_BITS;
break; break;
default: default:
case CS8: case CS8:
config->bDataBits = TI_UART_8_DATA_BITS; config->bDataBits = TI_UART_8_DATA_BITS;
break; break;
} }
/* CMSPAR isn't supported by this driver */ /* CMSPAR isn't supported by this driver */
...@@ -935,7 +956,7 @@ static void ti_set_termios(struct tty_struct *tty, ...@@ -935,7 +956,7 @@ static void ti_set_termios(struct tty_struct *tty,
} }
} else { } else {
config->wFlags &= ~TI_UART_ENABLE_PARITY_CHECKING; config->wFlags &= ~TI_UART_ENABLE_PARITY_CHECKING;
config->bParity = TI_UART_NO_PARITY; config->bParity = TI_UART_NO_PARITY;
} }
if (cflag & CSTOPB) if (cflag & CSTOPB)
...@@ -988,7 +1009,8 @@ static void ti_set_termios(struct tty_struct *tty, ...@@ -988,7 +1009,8 @@ static void ti_set_termios(struct tty_struct *tty,
(__u8)(TI_UART1_PORT + port_number), 0, (__u8 *)config, (__u8)(TI_UART1_PORT + port_number), 0, (__u8 *)config,
sizeof(*config)); sizeof(*config));
if (status) if (status)
dev_err(&port->dev, "%s - cannot set config on port %d, %d\n", __func__, port_number, status); dev_err(&port->dev, "%s - cannot set config on port %d, %d\n",
__func__, port_number, status);
/* 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;
...@@ -997,7 +1019,9 @@ static void ti_set_termios(struct tty_struct *tty, ...@@ -997,7 +1019,9 @@ static void ti_set_termios(struct tty_struct *tty,
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)
dev_err(&port->dev, "%s - cannot set modem control on port %d, %d\n", __func__, port_number, status); dev_err(&port->dev,
"%s - cannot set modem control on port %d, %d\n",
__func__, port_number, status);
kfree(config); kfree(config);
} }
...@@ -1139,10 +1163,12 @@ static void ti_interrupt_callback(struct urb *urb) ...@@ -1139,10 +1163,12 @@ static void ti_interrupt_callback(struct urb *urb)
port_number = TI_GET_PORT_FROM_CODE(data[0]); port_number = TI_GET_PORT_FROM_CODE(data[0]);
function = TI_GET_FUNC_FROM_CODE(data[0]); function = TI_GET_FUNC_FROM_CODE(data[0]);
dbg("%s - port_number %d, function %d, data 0x%02X", __func__, port_number, function, data[1]); dbg("%s - port_number %d, function %d, data 0x%02X",
__func__, port_number, function, data[1]);
if (port_number >= serial->num_ports) { if (port_number >= serial->num_ports) {
dev_err(dev, "%s - bad port number, %d\n", __func__, port_number); dev_err(dev, "%s - bad port number, %d\n",
__func__, port_number);
goto exit; goto exit;
} }
...@@ -1154,7 +1180,8 @@ static void ti_interrupt_callback(struct urb *urb) ...@@ -1154,7 +1180,8 @@ static void ti_interrupt_callback(struct urb *urb)
switch (function) { switch (function) {
case TI_CODE_DATA_ERROR: case TI_CODE_DATA_ERROR:
dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n", __func__, port_number, data[1]); dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n",
__func__, port_number, data[1]);
break; break;
case TI_CODE_MODEM_STATUS: case TI_CODE_MODEM_STATUS:
...@@ -1164,7 +1191,8 @@ static void ti_interrupt_callback(struct urb *urb) ...@@ -1164,7 +1191,8 @@ static void ti_interrupt_callback(struct urb *urb)
break; break;
default: default:
dev_err(dev, "%s - unknown interrupt code, 0x%02X\n", __func__, data[1]); dev_err(dev, "%s - unknown interrupt code, 0x%02X\n",
__func__, data[1]);
break; break;
} }
...@@ -1198,7 +1226,7 @@ static void ti_bulk_in_callback(struct urb *urb) ...@@ -1198,7 +1226,7 @@ static void ti_bulk_in_callback(struct urb *urb)
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; tport->tp_tdev->td_urb_error = 1;
wake_up_interruptible(&tport->tp_write_wait); wake_up_interruptible(&tport->tp_write_wait);
} }
...@@ -1218,8 +1246,9 @@ static void ti_bulk_in_callback(struct urb *urb) ...@@ -1218,8 +1246,9 @@ static void ti_bulk_in_callback(struct urb *urb)
if (!tport->tp_is_open) if (!tport->tp_is_open)
dbg("%s - port closed, dropping data", __func__); dbg("%s - port closed, dropping data", __func__);
else else
ti_recv(&urb->dev->dev, port->port.tty, urb->transfer_buffer, ti_recv(&urb->dev->dev, port->port.tty,
urb->actual_length); urb->transfer_buffer,
urb->actual_length);
spin_lock(&tport->tp_lock); spin_lock(&tport->tp_lock);
tport->tp_icount.rx += urb->actual_length; tport->tp_icount.rx += urb->actual_length;
...@@ -1283,8 +1312,9 @@ static void ti_recv(struct device *dev, struct tty_struct *tty, ...@@ -1283,8 +1312,9 @@ static void ti_recv(struct device *dev, struct tty_struct *tty,
do { do {
cnt = tty_buffer_request_room(tty, length); cnt = tty_buffer_request_room(tty, length);
if (cnt < length) { if (cnt < length) {
dev_err(dev, "%s - dropping data, %d bytes lost\n", __func__, length - cnt); dev_err(dev, "%s - dropping data, %d bytes lost\n",
if(cnt == 0) __func__, length - cnt);
if (cnt == 0)
break; break;
} }
tty_insert_flip_string(tty, data, cnt); tty_insert_flip_string(tty, data, cnt);
...@@ -1326,7 +1356,8 @@ static void ti_send(struct ti_port *tport) ...@@ -1326,7 +1356,8 @@ static void ti_send(struct ti_port *tport)
spin_unlock_irqrestore(&tport->tp_lock, flags); spin_unlock_irqrestore(&tport->tp_lock, flags);
usb_serial_debug_data(debug, &port->dev, __func__, count, port->write_urb->transfer_buffer); usb_serial_debug_data(debug, &port->dev, __func__, count,
port->write_urb->transfer_buffer);
usb_fill_bulk_urb(port->write_urb, port->serial->dev, usb_fill_bulk_urb(port->write_urb, port->serial->dev,
usb_sndbulkpipe(port->serial->dev, usb_sndbulkpipe(port->serial->dev,
...@@ -1336,8 +1367,9 @@ static void ti_send(struct ti_port *tport) ...@@ -1336,8 +1367,9 @@ static void ti_send(struct ti_port *tport)
result = usb_submit_urb(port->write_urb, GFP_ATOMIC); result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
if (result) { if (result) {
dev_err(&port->dev, "%s - submit write urb failed, %d\n", __func__, result); dev_err(&port->dev, "%s - submit write urb failed, %d\n",
tport->tp_write_urb_in_use = 0; __func__, result);
tport->tp_write_urb_in_use = 0;
/* TODO: reschedule ti_send */ /* TODO: reschedule ti_send */
} else { } else {
spin_lock_irqsave(&tport->tp_lock, flags); spin_lock_irqsave(&tport->tp_lock, flags);
...@@ -1372,7 +1404,7 @@ static int ti_set_mcr(struct ti_port *tport, unsigned int mcr) ...@@ -1372,7 +1404,7 @@ static int ti_set_mcr(struct ti_port *tport, unsigned int mcr)
static int ti_get_lsr(struct ti_port *tport) static int ti_get_lsr(struct ti_port *tport)
{ {
int size,status; int size, status;
struct ti_device *tdev = tport->tp_tdev; struct ti_device *tdev = tport->tp_tdev;
struct usb_serial_port *port = tport->tp_port; struct usb_serial_port *port = tport->tp_port;
int port_number = port->number - port->serial->minor; int port_number = port->number - port->serial->minor;
...@@ -1390,7 +1422,9 @@ static int ti_get_lsr(struct ti_port *tport) ...@@ -1390,7 +1422,9 @@ static int ti_get_lsr(struct ti_port *tport)
status = ti_command_in_sync(tdev, TI_GET_PORT_STATUS, status = ti_command_in_sync(tdev, TI_GET_PORT_STATUS,
(__u8)(TI_UART1_PORT+port_number), 0, (__u8 *)data, size); (__u8)(TI_UART1_PORT+port_number), 0, (__u8 *)data, size);
if (status) { if (status) {
dev_err(&port->dev, "%s - get port status command failed, %d\n", __func__, status); dev_err(&port->dev,
"%s - get port status command failed, %d\n",
__func__, status);
goto free_data; goto free_data;
} }
...@@ -1626,7 +1660,8 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr, ...@@ -1626,7 +1660,8 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
struct ti_write_data_bytes *data; struct ti_write_data_bytes *data;
struct device *dev = &tdev->td_serial->dev->dev; struct device *dev = &tdev->td_serial->dev->dev;
dbg("%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X", __func__, addr, mask, byte); dbg("%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X",
__func__, addr, mask, byte);
size = sizeof(struct ti_write_data_bytes) + 2; size = sizeof(struct ti_write_data_bytes) + 2;
data = kmalloc(size, GFP_KERNEL); data = kmalloc(size, GFP_KERNEL);
...@@ -1663,12 +1698,12 @@ static int ti_do_download(struct usb_device *dev, int pipe, ...@@ -1663,12 +1698,12 @@ static int ti_do_download(struct usb_device *dev, int pipe,
struct ti_firmware_header *header; struct ti_firmware_header *header;
int status; int status;
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((__u16)(size
- sizeof(struct ti_firmware_header))); - sizeof(struct ti_firmware_header)));
header->bCheckSum = cs; header->bCheckSum = cs;
...@@ -1714,7 +1749,8 @@ static int ti_download_firmware(struct ti_device *tdev, int type) ...@@ -1714,7 +1749,8 @@ static int ti_download_firmware(struct ti_device *tdev, int type)
} }
release_firmware(fw_p); release_firmware(fw_p);
if (status) { if (status) {
dev_err(&dev->dev, "%s - error downloading firmware, %d\n", __func__, status); dev_err(&dev->dev, "%s - error downloading firmware, %d\n",
__func__, status);
return status; return status;
} }
...@@ -1786,7 +1822,7 @@ static void ti_buf_clear(struct circ_buf *cb) ...@@ -1786,7 +1822,7 @@ static void ti_buf_clear(struct circ_buf *cb)
static int ti_buf_data_avail(struct circ_buf *cb) static int ti_buf_data_avail(struct circ_buf *cb)
{ {
return CIRC_CNT(cb->head,cb->tail,TI_WRITE_BUF_SIZE); return CIRC_CNT(cb->head, cb->tail, TI_WRITE_BUF_SIZE);
} }
...@@ -1799,7 +1835,7 @@ static int ti_buf_data_avail(struct circ_buf *cb) ...@@ -1799,7 +1835,7 @@ static int ti_buf_data_avail(struct circ_buf *cb)
static int ti_buf_space_avail(struct circ_buf *cb) static int ti_buf_space_avail(struct circ_buf *cb)
{ {
return CIRC_SPACE(cb->head,cb->tail,TI_WRITE_BUF_SIZE); return CIRC_SPACE(cb->head, cb->tail, TI_WRITE_BUF_SIZE);
} }
......
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