tty updates proposed for 2.6.27
Subsystems (13)
PATCH 35/70 empeg: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/empeg.c | 203 +++++++++++++++++++++++--------------------- 1 files changed, 107 insertions(+), 96 deletions(-)
drivers/usb/serial/empeg.c +107 -96
@@ -11,36 +11,39 @@* it under the terms of the GNU General Public License, as published by * the Free Software Foundation, version 2. * -* See Documentation/usb/usb-serial.txt for more information on using this driver -* +* See Documentation/usb/usb-serial.txt for more information on using this +* driver +* * (07/16/2001) gb -* remove unused code in empeg_close() (thanks to Oliver Neukum for pointing this -* out) and rewrote empeg_set_termios(). -* +* remove unused code in empeg_close() (thanks to Oliver Neukum for +* pointing this out) and rewrote empeg_set_termios(). +* * (05/30/2001) gkh -* switched from using spinlock to a semaphore, which fixes lots of problems. +* switched from using spinlock to a semaphore, which fixes lots of +* problems. * * (04/08/2001) gb * Identify version on module load. -* +* * (01/22/2001) gb -* Added write_room() and chars_in_buffer() support. -* +* Added write_room() and chars_in_buffer() support. +* * (12/21/2000) gb * Moved termio stuff inside the port->active check. * Moved MOD_DEC_USE_COUNT to end of empeg_close(). -* +* * (12/03/2000) gb -* Added port->port.tty->ldisc.set_termios(port->port.tty, NULL) to empeg_open() -* This notifies the tty driver that the termios have changed. -* +* Added port->port.tty->ldisc.set_termios(port->port.tty, NULL) to +* empeg_open(). This notifies the tty driver that the termios have +* changed. +* * (11/13/2000) gb -* Moved tty->low_latency = 1 from empeg_read_bulk_callback() to empeg_open() -* (It only needs to be set once - Doh!) -* +* Moved tty->low_latency = 1 from empeg_read_bulk_callback() to +* empeg_open() (It only needs to be set once - Doh!) +* * (11/11/2000) gb * Updated to work with id_table structure. -* +* * (11/04/2000) gb * Forked this from visor.c, and hacked it up to work with an * Empeg ltd. empeg-car player. Constructive criticism welcomed.
@@ -48,7 +51,7 @@* use of his code, and for his guidance, advice and patience. :) * A 'Thank You' is in order for John Ripley of Empeg ltd for his * advice, and patience too. -* +* */ #include <linux/kernel.h>
@@ -60,7 +63,7 @@#include <linux/tty_flip.h> #include <linux/module.h> #include <linux/spinlock.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/usb/serial.h>
@@ -77,27 +80,30 @@ static int debug;#define EMPEG_PRODUCT_ID 0x0001/* function prototypes for an empeg-car player */ -static int empeg_open (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp); -static void empeg_close (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp); -static int empeg_write (struct tty_struct *tty,struct usb_serial_port *port, -const unsigned char *buf, -int count); -static int empeg_write_room (struct tty_struct *tty); -static int empeg_chars_in_buffer (struct tty_struct *tty); -static void empeg_throttle (struct tty_struct *tty); -static void empeg_unthrottle (struct tty_struct *tty); -static int empeg_startup (struct usb_serial *serial); -static void empeg_shutdown (struct usb_serial *serial); -static void empeg_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios); -static void empeg_write_bulk_callback (struct urb *urb); -static void empeg_read_bulk_callback (struct urb *urb); +static int empeg_open (struct tty_struct *tty,struct usb_serial_port *port, +struct file *filp); +static void empeg_close (struct tty_struct *tty,struct usb_serial_port *port, +struct file *filp); +static int empeg_write (struct tty_struct *tty,struct usb_serial_port *port, +const unsigned char *buf, +int count); +static int empeg_write_room (struct tty_struct *tty); +static int empeg_chars_in_buffer (struct tty_struct *tty); +static void empeg_throttle (struct tty_struct *tty); +static void empeg_unthrottle (struct tty_struct *tty); +static int empeg_startup (struct usb_serial *serial); +static void empeg_shutdown (struct usb_serial *serial); +static void empeg_set_termios (struct tty_struct *tty, +struct usb_serial_port *port,struct ktermios *old_termios); +static void empeg_write_bulk_callback (struct urb *urb); +static void empeg_read_bulk_callback (struct urb *urb);static struct usb_device_id id_table [] = { {USB_DEVICE (EMPEG_VENDOR_ID ,EMPEG_PRODUCT_ID ) }, { }/* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table); +MODULE_DEVICE_TABLE (usb, id_table);static struct usb_driver empeg_driver = { .name ="empeg" ,
@@ -149,7 +155,7 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port,dbg ("%s - port %d" , __func__, port->number);/* Force default termio settings */ -empeg_set_termios (tty, port,NULL ) ; +empeg_set_termios (tty, port,NULL ) ; bytes_in =0 ; bytes_out =0 ;
@@ -157,7 +163,7 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port,/* Start reading from the device */ usb_fill_bulk_urb( port->read_urb, - serial->dev, + serial->dev, usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer,
@@ -168,14 +174,16 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port, result =usb_submit_urb (port->read_urb,GFP_KERNEL );if (result) -dev_err (&port->dev,"%s - failed submitting read urb, error %d\n" , __func__, result); +dev_err (&port->dev, +"%s - failed submitting read urb, error %d\n" , + __func__, result);return result; }static void empeg_close (struct tty_struct *tty,struct usb_serial_port *port, -struct file * filp) +struct file *filp) {dbg ("%s - port %d" , __func__, port->number);
@@ -186,7 +194,8 @@ static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port, } -static int empeg_write (struct tty_struct *tty,struct usb_serial_port *port,const unsigned char *buf,int count) +static int empeg_write (struct tty_struct *tty,struct usb_serial_port *port, +const unsigned char *buf,int count) {struct usb_serial *serial = port->serial;struct urb *urb;
@@ -203,7 +212,7 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con/* try to find a free urb in our list of them */ urb =NULL ; -spin_lock_irqsave (&write_urb_pool_lock, flags); +spin_lock_irqsave (&write_urb_pool_lock, flags);for (i =0 ; i <NUM_URBS ; ++i) {if (write_urb_pool[i]->status != -EINPROGRESS ) {
@@ -212,7 +221,7 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con } } -spin_unlock_irqrestore (&write_urb_pool_lock, flags); +spin_unlock_irqrestore (&write_urb_pool_lock, flags);if (urb ==NULL ) {dbg ("%s - no more free urbs" , __func__);
@@ -220,25 +229,27 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con }if (urb->transfer_buffer ==NULL ) { - urb->transfer_buffer =kmalloc (URB_TRANSFER_BUFFER_SIZE ,GFP_ATOMIC ); + urb->transfer_buffer =kmalloc (URB_TRANSFER_BUFFER_SIZE ,GFP_ATOMIC );if (urb->transfer_buffer ==NULL ) { -dev_err (&port->dev,"%s no more kernel memory...\n" , __func__); +dev_err (&port->dev, +"%s no more kernel memory...\n" , + __func__); goto exit; } } - transfer_size =min (count,URB_TRANSFER_BUFFER_SIZE ); + transfer_size =min (count,URB_TRANSFER_BUFFER_SIZE ); -memcpy (urb->transfer_buffer, current_position, transfer_size); +memcpy (urb->transfer_buffer, current_position, transfer_size);usb_serial_debug_data (debug, &port->dev, __func__, transfer_size, urb->transfer_buffer);/* build up our urb */ - usb_fill_bulk_urb ( + usb_fill_bulk_urb( urb, serial->dev, usb_sndbulkpipe(serial->dev, - port->bulk_out_endpointAddress), + port->bulk_out_endpointAddress), urb->transfer_buffer, transfer_size, empeg_write_bulk_callback,
@@ -260,7 +271,7 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con } exit:return bytes_sent; -} +}static int empeg_write_room (struct tty_struct *tty)
@@ -272,14 +283,13 @@ static int empeg_write_room(struct tty_struct *tty)dbg ("%s - port %d" , __func__, port->number); -spin_lock_irqsave (&write_urb_pool_lock, flags); +spin_lock_irqsave (&write_urb_pool_lock, flags);/* tally up the number of bytes available */ for (i =0 ; i <NUM_URBS ; ++i) { -if (write_urb_pool[i]->status != -EINPROGRESS ) { +if (write_urb_pool[i]->status != -EINPROGRESS ) room +=URB_TRANSFER_BUFFER_SIZE ; - } - } -spin_unlock_irqrestore (&write_urb_pool_lock, flags); + } +spin_unlock_irqrestore (&write_urb_pool_lock, flags);dbg ("%s - returns %d" , __func__, room);return room;
@@ -295,25 +305,21 @@ static int empeg_chars_in_buffer(struct tty_struct *tty)dbg ("%s - port %d" , __func__, port->number); -spin_lock_irqsave (&write_urb_pool_lock, flags); +spin_lock_irqsave (&write_urb_pool_lock, flags);/* tally up the number of bytes waiting */ for (i =0 ; i <NUM_URBS ; ++i) { -if (write_urb_pool[i]->status == -EINPROGRESS ) { +if (write_urb_pool[i]->status == -EINPROGRESS ) chars +=URB_TRANSFER_BUFFER_SIZE ; - } } -spin_unlock_irqrestore (&write_urb_pool_lock, flags); - +spin_unlock_irqrestore (&write_urb_pool_lock, flags);dbg ("%s - returns %d" , __func__, chars); - -return (chars); - +return chars; } -static void empeg_write_bulk_callback (struct urb *urb) +static void empeg_write_bulk_callback (struct urb *urb) {struct usb_serial_port *port = urb->context;int status = urb->status;
@@ -330,7 +336,7 @@ static void empeg_write_bulk_callback (struct urb *urb) } -static void empeg_read_bulk_callback (struct urb *urb) +static void empeg_read_bulk_callback (struct urb *urb) {struct usb_serial_port *port = urb->context;struct tty_struct *tty;
@@ -346,8 +352,8 @@ static void empeg_read_bulk_callback (struct urb *urb)return ; } -usb_serial_debug_data (debug, &port->dev, __func__, urb->actual_length, data); - +usb_serial_debug_data (debug, &port->dev, __func__, + urb->actual_length, data); tty = port->port.tty;if (urb->actual_length) {
@@ -360,7 +366,7 @@ static void empeg_read_bulk_callback (struct urb *urb)/* Continue trying to always read */ usb_fill_bulk_urb( port->read_urb, - port->serial->dev, + port->serial->dev, usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer,
@@ -371,7 +377,9 @@ static void empeg_read_bulk_callback (struct urb *urb) result =usb_submit_urb (port->read_urb,GFP_ATOMIC );if (result) -dev_err (&urb->dev->dev,"%s - failed resubmitting read urb, error %d\n" , __func__, result); +dev_err (&urb->dev->dev, +"%s - failed resubmitting read urb, error %d\n" , + __func__, result);return ;
@@ -395,11 +403,13 @@ static void empeg_unthrottle(struct tty_struct *tty) port->read_urb->dev = port->serial->dev; result =usb_submit_urb (port->read_urb,GFP_ATOMIC );if (result) -dev_err (&port->dev,"%s - failed submitting read urb, error %d\n" , __func__, result); +dev_err (&port->dev, +"%s - failed submitting read urb, error %d\n" , + __func__, result); } -static int empeg_startup (struct usb_serial *serial) +static int empeg_startup (struct usb_serial *serial) {int r;
@@ -411,7 +421,7 @@ static int empeg_startup (struct usb_serial *serial)return -ENODEV ; }dbg ("%s - reset config" , __func__); - r =usb_reset_configuration (serial->dev); + r =usb_reset_configuration (serial->dev);/* continue on with initialization */ return r;
@@ -419,9 +429,9 @@ static int empeg_startup (struct usb_serial *serial) } -static void empeg_shutdown (struct usb_serial *serial) +static void empeg_shutdown (struct usb_serial *serial) { -dbg ("%s" , __func__); +dbg ("%s" , __func__); }
@@ -432,14 +442,14 @@ static void empeg_set_termios(struct tty_struct *tty,dbg ("%s - port %d" , __func__, port->number);/* -* The empeg-car player wants these particular tty settings. -* You could, for example, change the baud rate, however the -* player only supports 115200 (currently), so there is really -* no point in support for changes to the tty settings. -* (at least for now) -* -* The default requirements for this device are: -*/ +* The empeg-car player wants these particular tty settings. +* You could, for example, change the baud rate, however the +* player only supports 115200 (currently), so there is really +* no point in support for changes to the tty settings. +* (at least for now) +* +* The default requirements for this device are: +*/ termios->c_iflag &= ~(IGNBRK /* disable ignore break */ | BRKINT /* disable break causes interrupt */
@@ -478,13 +488,13 @@ static void empeg_set_termios(struct tty_struct *tty, } -static int __init empeg_init (void ) +static int __init empeg_init (void ) {struct urb *urb;int i, retval; -/* create our write urb pool and transfer buffers */ -spin_lock_init (&write_urb_pool_lock); +/* create our write urb pool and transfer buffers */ +spin_lock_init (&write_urb_pool_lock);for (i =0 ; i <NUM_URBS ; ++i) { urb =usb_alloc_urb (0 ,GFP_KERNEL ); write_urb_pool[i] = urb;
@@ -493,9 +503,10 @@ static int __init empeg_init (void)continue ; } - urb->transfer_buffer =kmalloc (URB_TRANSFER_BUFFER_SIZE ,GFP_KERNEL ); + urb->transfer_buffer =kmalloc (URB_TRANSFER_BUFFER_SIZE , +GFP_KERNEL );if (!urb->transfer_buffer) { -err ("%s - out of memory for urb buffers." , +err ("%s - out of memory for urb buffers." , __func__);continue ; }
@@ -524,36 +535,36 @@ failed_usb_serial_register: } -static void __exit empeg_exit (void) +static void __exit empeg_exit(void) {int i;unsigned long flags;usb_deregister (&empeg_driver); -usb_serial_deregister (&empeg_device); +usb_serial_deregister (&empeg_device); -spin_lock_irqsave (&write_urb_pool_lock, flags); +spin_lock_irqsave (&write_urb_pool_lock, flags);for (i =0 ; i <NUM_URBS ; ++i) {if (write_urb_pool[i]) { -/* FIXME - uncomment the following usb_kill_urb call when -* the host controllers get fixed to set urb->dev = NULL after -* the urb is finished. Otherwise this call oopses. */ +/* FIXME - uncomment the following usb_kill_urb call +* when the host controllers get fixed to set urb->dev +* = NULL after the urb is finished. Otherwise this +* call oopses. */ /* usb_kill_urb(write_urb_pool[i]); */ kfree (write_urb_pool[i]->transfer_buffer); -usb_free_urb (write_urb_pool[i]); +usb_free_urb (write_urb_pool[i]); } } - -spin_unlock_irqrestore (&write_urb_pool_lock, flags); +spin_unlock_irqrestore (&write_urb_pool_lock, flags); }module_init (empeg_init);module_exit (empeg_exit); -MODULE_AUTHOR (DRIVER_AUTHOR ); -MODULE_DESCRIPTION (DRIVER_DESC ); +MODULE_AUTHOR (DRIVER_AUTHOR ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );module_param (debug, bool,S_IRUGO |S_IWUSR );
PATCH 36/70 ftdi_sio: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/ftdi_sio.c | 1078 ++++++++++++++++++++++------------------- drivers/usb/serial/ftdi_sio.h | 126 ++--- 2 files changed, 635 insertions(+), 569 deletions(-)
drivers/usb/serial/ftdi_sio.c +572 -506
@@ -12,7 +12,8 @@* the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * -* See Documentation/usb/usb-serial.txt for more information on using this driver +* See Documentation/usb/usb-serial.txt for more information on using this +* driver * * See http://ftdi-usb-sio.sourceforge.net for upto date testing info * and extra documentation
@@ -25,7 +26,8 @@/* Bill Ryder - [email protected] - wrote the FTDI_SIO implementation */ /* Thanx to FTDI for so kindly providing details of the protocol required */ /* to talk to the device */ -/* Thanx to gkh and the rest of the usb dev group for all code I have assimilated :-) */ +/* Thanx to gkh and the rest of the usb dev group for all code I have +assimilated :-) */ #include <linux/kernel.h> #include <linux/errno.h>
@@ -36,7 +38,7 @@#include <linux/tty_flip.h> #include <linux/module.h> #include <linux/spinlock.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/serial.h> #include <linux/usb/serial.h>
@@ -55,17 +57,22 @@ static __u16 product;struct ftdi_private {ftdi_chip_type_t chip_type; -/* type of the device, either SIO or FT8U232AM */ +/* type of device, either SIO or FT8U232AM */ int baud_base;/* baud base clock for divisor setting */ -int custom_divisor;/* custom_divisor kludge, this is for baud_base (different from what goes to the chip!) */ +int custom_divisor;/* custom_divisor kludge, this is for +baud_base (different from what goes to the +chip!) */ __u16 last_set_data_urb_value ; -/* the last data state set - needed for doing a break */ -int write_offset;/* This is the offset in the usb data block to write the serial data - -* it is different between devices +/* the last data state set - needed for doing +* a break +*/ +int write_offset;/* This is the offset in the usb data block to +* write the serial data - it varies between +* devices */ int flags;/* some ASYNC_xxxx flags are supported */ unsigned long last_dtr_rts;/* saved modem control outputs */ -wait_queue_head_t delta_msr_wait;/* Used for TIOCMIWAIT */ +wait_queue_head_t delta_msr_wait;/* Used for TIOCMIWAIT */ char prev_status, diff_status;/* Used for TIOCMIWAIT */ __u8 rx_flags;/* receive state flags (throttling) */ spinlock_t rx_lock;/* spinlock for receive state */
@@ -76,8 +83,10 @@ struct ftdi_private {__u16 interface;/* FT2232C port interface (0 for FT232/245) */ -speed_t force_baud;/* if non-zero, force the baud rate to this value */ -int force_rtscts;/* if non-zero, force RTS-CTS to always be enabled */ +speed_t force_baud;/* if non-zero, force the baud rate to +this value */ +int force_rtscts;/* if non-zero, force RTS-CTS to always +be enabled */ spinlock_t tx_lock;/* spinlock for transmit state */ unsigned long tx_bytes;
@@ -88,13 +97,14 @@ struct ftdi_private {/* struct ftdi_sio_quirk is used by devices requiring special attention. */ struct ftdi_sio_quirk {int (*probe)(struct usb_serial *); -void (*port_probe)(struct ftdi_private *);/* Special settings for probed ports. */ +/* Special settings for probed ports. */ +void (*port_probe)(struct ftdi_private *); }; -static int ftdi_jtag_probe (struct usb_serial *serial); -static int ftdi_mtxorb_hack_setup (struct usb_serial *serial); -static void ftdi_USB_UIRT_setup (struct ftdi_private *priv); -static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv); +static int ftdi_jtag_probe (struct usb_serial *serial); +static int ftdi_mtxorb_hack_setup (struct usb_serial *serial); +static void ftdi_USB_UIRT_setup (struct ftdi_private *priv); +static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv);static struct ftdi_sio_quirk ftdi_jtag_quirk = { .probe = ftdi_jtag_probe,
@@ -174,270 +184,270 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(FTDI_VID, FTDI_MTXORB_4_PID) }, { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) }, { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0100_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0101_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0102_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0103_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0104_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0105_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0106_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0107_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0108_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0109_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0110_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0111_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0112_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0113_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0114_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0115_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0116_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0117_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0118_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0119_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0120_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0121_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0122_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0123_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0124_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0125_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0126_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0127_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0100_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0101_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0102_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0103_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0104_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0105_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0106_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0107_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0108_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0109_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0110_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0111_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0112_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0113_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0114_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0115_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0116_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0117_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0118_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0119_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0120_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0121_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0122_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0123_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0124_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0125_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0126_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0127_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0128_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0129_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012C_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0128_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0129_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012C_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0130_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0131_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0132_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0133_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0134_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0135_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0136_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0137_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0138_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0139_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0140_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0141_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0142_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0143_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0144_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0145_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0146_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0147_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0148_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0149_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0150_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0151_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0152_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0153_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0130_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0131_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0132_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0133_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0134_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0135_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0136_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0137_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0138_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0139_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0140_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0141_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0142_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0143_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0144_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0145_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0146_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0147_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0148_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0149_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0150_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0151_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0152_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0153_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0154_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0154_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0155_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0155_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0156_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0156_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0157_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0157_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0158_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0158_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0159_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0160_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0161_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0162_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0163_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0164_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0165_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0166_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0167_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0168_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0169_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0170_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0171_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0172_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0173_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0174_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0175_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0176_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0177_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0178_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0179_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0180_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0181_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0182_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0183_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0184_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0185_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0186_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0187_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0188_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0189_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0190_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0191_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0192_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0193_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0194_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0195_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0196_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0197_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0198_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0199_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A0_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A1_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A2_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A3_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A4_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A5_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A6_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A7_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A8_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A9_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AA_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AB_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AC_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AD_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AE_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AF_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B0_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B1_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B2_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B3_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B4_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B5_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B6_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B7_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B8_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B9_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BA_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BB_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BC_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BD_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BE_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BF_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C0_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C1_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C2_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C3_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C4_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C5_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C6_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C7_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C8_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C9_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CA_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CB_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CC_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CD_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CE_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CF_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D0_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D1_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D2_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D3_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D4_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D5_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D6_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D7_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D8_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D9_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DA_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DB_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DC_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DD_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DE_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DF_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E0_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E1_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E2_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E3_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E4_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E5_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E6_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E7_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E8_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E9_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EA_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EB_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EC_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01ED_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EE_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EF_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F0_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F1_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F2_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F3_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F4_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F5_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F6_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F7_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F8_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F9_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FA_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FB_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FC_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FD_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FE_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FF_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0159_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0160_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0161_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0162_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0163_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0164_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0165_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0166_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0167_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0168_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0169_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0170_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0171_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0172_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0173_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0174_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0175_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0176_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0177_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0178_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0179_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0180_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0181_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0182_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0183_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0184_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0185_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0186_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0187_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0188_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0189_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0190_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0191_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0192_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0193_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0194_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0195_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0196_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0197_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0198_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0199_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A0_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A1_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A2_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A3_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A4_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A5_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A6_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A7_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A8_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A9_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AA_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AB_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AC_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AD_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AE_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AF_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B0_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B1_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B2_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B3_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B4_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B5_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B6_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B7_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B8_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B9_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BA_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BB_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BC_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BD_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BE_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BF_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C0_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C1_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C2_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C3_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C4_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C5_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C6_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C7_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C8_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C9_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CA_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CB_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CC_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CD_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CE_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CF_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D0_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D1_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D2_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D3_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D4_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D5_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D6_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D7_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D8_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D9_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DA_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DB_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DC_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DD_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DE_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DF_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E0_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E1_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E2_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E3_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E4_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E5_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E6_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E7_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E8_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E9_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EA_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EB_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EC_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01ED_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EE_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EF_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F0_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F1_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F2_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F3_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F4_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F5_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F6_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F7_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F8_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F9_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FA_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FB_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FC_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FD_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FE_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FF_PID) }, { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) }, { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) }, { USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) },
@@ -641,7 +651,7 @@ static struct usb_device_id id_table_combined [] = { { }/* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE (usb, id_table_combined);static struct usb_driver ftdi_driver = { .name ="ftdi_sio" ,
@@ -677,30 +687,37 @@ static const char *ftdi_chip_name[] = { | ASYNC_SPD_CUST | ASYNC_SPD_SHI | ASYNC_SPD_WARP)/* function prototypes for a FTDI serial converter */ -static int ftdi_sio_probe (struct usb_serial *serial,const struct usb_device_id *id); -static void ftdi_shutdown (struct usb_serial *serial); -static int ftdi_sio_port_probe (struct usb_serial_port *port); -static int ftdi_sio_port_remove (struct usb_serial_port *port); -static int ftdi_open (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp); -static void ftdi_close (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp); -static int ftdi_write (struct tty_struct *tty,struct usb_serial_port *port,const unsigned char *buf,int count); -static int ftdi_write_room (struct tty_struct *tty); -static int ftdi_chars_in_buffer (struct tty_struct *tty); -static void ftdi_write_bulk_callback (struct urb *urb); -static void ftdi_read_bulk_callback (struct urb *urb); -static void ftdi_process_read (struct work_struct *work); -static void ftdi_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios * old); -static int ftdi_tiocmget (struct tty_struct *tty,struct file *file); -static int ftdi_tiocmset (struct tty_struct *tty,struct file * file,unsigned int set,unsigned int clear); -static int ftdi_ioctl (struct tty_struct *tty,struct file * file,unsigned int cmd,unsigned long arg); -static void ftdi_break_ctl (struct tty_struct *tty,int break_state ); -static void ftdi_throttle (struct tty_struct *tty); -static void ftdi_unthrottle (struct tty_struct *tty); - -static unsigned short int ftdi_232am_baud_base_to_divisor (int baud,int base); -static unsigned short int ftdi_232am_baud_to_divisor (int baud); -static __u32 ftdi_232bm_baud_base_to_divisor (int baud,int base); -static __u32 ftdi_232bm_baud_to_divisor (int baud); +static int ftdi_sio_probe (struct usb_serial *serial, +const struct usb_device_id *id); +static void ftdi_shutdown (struct usb_serial *serial); +static int ftdi_sio_port_probe (struct usb_serial_port *port); +static int ftdi_sio_port_remove (struct usb_serial_port *port); +static int ftdi_open (struct tty_struct *tty, +struct usb_serial_port *port,struct file *filp); +static void ftdi_close (struct tty_struct *tty, +struct usb_serial_port *port,struct file *filp); +static int ftdi_write (struct tty_struct *tty,struct usb_serial_port *port, +const unsigned char *buf,int count); +static int ftdi_write_room (struct tty_struct *tty); +static int ftdi_chars_in_buffer (struct tty_struct *tty); +static void ftdi_write_bulk_callback (struct urb *urb); +static void ftdi_read_bulk_callback (struct urb *urb); +static void ftdi_process_read (struct work_struct *work); +static void ftdi_set_termios (struct tty_struct *tty, +struct usb_serial_port *port,struct ktermios *old); +static int ftdi_tiocmget (struct tty_struct *tty,struct file *file); +static int ftdi_tiocmset (struct tty_struct *tty,struct file *file, +unsigned int set,unsigned int clear); +static int ftdi_ioctl (struct tty_struct *tty,struct file *file, +unsigned int cmd,unsigned long arg); +static void ftdi_break_ctl (struct tty_struct *tty,int break_state); +static void ftdi_throttle (struct tty_struct *tty); +static void ftdi_unthrottle (struct tty_struct *tty); + +static unsigned short int ftdi_232am_baud_base_to_divisor (int baud,int base); +static unsigned short int ftdi_232am_baud_to_divisor (int baud); +static __u32 ftdi_232bm_baud_base_to_divisor (int baud,int base); +static __u32 ftdi_232bm_baud_to_divisor (int baud);static struct usb_serial_driver ftdi_sio_device = { .driver = {
@@ -751,44 +768,54 @@ static struct usb_serial_driver ftdi_sio_device = {static unsigned short int ftdi_232am_baud_base_to_divisor (int baud,int base) {unsigned short int divisor; -int divisor3 = base /2 / baud;// divisor shifted 3 bits to the left -if ((divisor3 &0x7 ) ==7 ) divisor3 ++;// round x.7/8 up to x+1 +/* divisor shifted 3 bits to the left */ +int divisor3 = base /2 / baud; +if ((divisor3 &0x7 ) ==7 ) + divisor3++;/* round x.7/8 up to x+1 */ divisor = divisor3 >>3 ; divisor3 &=0x7 ; -if (divisor3 ==1 ) divisor |=0xc000 ;else // 0.125 -if (divisor3 >=4 ) divisor |=0x4000 ;else // 0.5 -if (divisor3 !=0 ) divisor |=0x8000 ;// 0.25 -if (divisor ==1 ) divisor =0 ;/* special case for maximum baud rate */ +if (divisor3 ==1 ) + divisor |=0xc000 ; +else if (divisor3 >=4 ) + divisor |=0x4000 ; +else if (divisor3 !=0 ) + divisor |=0x8000 ; +else if (divisor ==1 ) + divisor =0 ;/* special case for maximum baud rate */ return divisor; }static unsigned short int ftdi_232am_baud_to_divisor (int baud) { -return (ftdi_232am_baud_base_to_divisor (baud,48000000 )); +return ftdi_232am_baud_base_to_divisor (baud,48000000 ); }static __u32 ftdi_232bm_baud_base_to_divisor (int baud,int base) {static const unsigned char divfrac[8 ] = {0 ,3 ,2 ,4 ,1 ,5 ,6 ,7 };__u32 divisor; -int divisor3 = base /2 / baud;// divisor shifted 3 bits to the left +/* divisor shifted 3 bits to the left */ +int divisor3 = base /2 / baud; divisor = divisor3 >>3 ; divisor |= (__u32 )divfrac[divisor3 &0x7 ] <<14 ;/* Deal with special cases for highest baud rates. */ -if (divisor ==1 ) divisor =0 ;else // 1.0 -if (divisor ==0x4001 ) divisor =1 ;// 1.5 +if (divisor ==1 ) + divisor =0 ; +else if (divisor ==0x4001 ) + divisor =1 ;return divisor; }static __u32 ftdi_232bm_baud_to_divisor (int baud) { -return (ftdi_232bm_baud_base_to_divisor (baud,48000000 )); +return ftdi_232bm_baud_base_to_divisor (baud,48000000 ); }#define set_mctrl (port, set) update_mctrl((port), (set), 0)#define clear_mctrl (port, clear) update_mctrl((port), 0, (clear)) -static int update_mctrl (struct usb_serial_port *port,unsigned int set,unsigned int clear) +static int update_mctrl (struct usb_serial_port *port,unsigned int set, +unsigned int clear) {struct ftdi_private *priv =usb_get_serial_port_data (port);char *buf;
@@ -842,7 +869,8 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned } -static __u32 get_ftdi_divisor (struct tty_struct *tty,struct usb_serial_port *port) +static __u32 get_ftdi_divisor (struct tty_struct *tty, +struct usb_serial_port *port) {/* get_ftdi_divisor */ struct ftdi_private *priv =usb_get_serial_port_data (port);__u32 div_value =0 ;
@@ -850,48 +878,56 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *point baud;/* -* The logic involved in setting the baudrate can be cleanly split in 3 steps. -* Obtaining the actual baud rate is a little tricky since unix traditionally -* somehow ignored the possibility to set non-standard baud rates. +* The logic involved in setting the baudrate can be cleanly split into +* 3 steps. * 1. Standard baud rates are set in tty->termios->c_cflag -* 2. If these are not enough, you can set any speed using alt_speed as follows: +* 2. If these are not enough, you can set any speed using alt_speed as +* follows: * - set tty->termios->c_cflag speed to B38400 * - set your real speed in tty->alt_speed; it gets ignored when * alt_speed==0, (or) -* - call TIOCSSERIAL ioctl with (struct serial_struct) set as follows: -* flags & ASYNC_SPD_MASK == ASYNC_SPD_[HI, VHI, SHI, WARP], this just -* sets alt_speed to (HI: 57600, VHI: 115200, SHI: 230400, WARP: 460800) +* - call TIOCSSERIAL ioctl with (struct serial_struct) set as +* follows: +* flags & ASYNC_SPD_MASK == ASYNC_SPD_[HI, VHI, SHI, WARP], +* this just sets alt_speed to (HI: 57600, VHI: 115200, +* SHI: 230400, WARP: 460800) * ** Steps 1, 2 are done courtesy of tty_get_baud_rate * 3. You can also set baud rate by setting custom divisor as follows * - set tty->termios->c_cflag speed to B38400 -* - call TIOCSSERIAL ioctl with (struct serial_struct) set as follows: +* - call TIOCSSERIAL ioctl with (struct serial_struct) set as +* follows: * o flags & ASYNC_SPD_MASK == ASYNC_SPD_CUST * o custom_divisor set to baud_base / your_new_baudrate -* ** Step 3 is done courtesy of code borrowed from serial.c - I should really -* spend some time and separate+move this common code to serial.c, it is -* replicated in nearly every serial driver you see. +* ** Step 3 is done courtesy of code borrowed from serial.c +* I should really spend some time and separate + move this common +* code to serial.c, it is replicated in nearly every serial driver +* you see. */ -/* 1. Get the baud rate from the tty settings, this observes alt_speed hack */ +/* 1. Get the baud rate from the tty settings, this observes +alt_speed hack */ baud =tty_get_baud_rate (tty);dbg ("%s - tty_get_baud_rate reports speed %d" , __func__, baud); -/* 2. Observe async-compatible custom_divisor hack, update baudrate if needed */ +/* 2. Observe async-compatible custom_divisor hack, update baudrate +if needed */ if (baud ==38400 && ((priv->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST ) && (priv->custom_divisor)) { baud = priv->baud_base / priv->custom_divisor; -dbg ("%s - custom divisor %d sets baud rate to %d" , __func__, priv->custom_divisor, baud); +dbg ("%s - custom divisor %d sets baud rate to %d" , + __func__, priv->custom_divisor, baud); }/* 3. Convert baudrate to device-specific divisor */ -if (!baud) baud =9600 ; -switch (priv->chip_type) { +if (!baud) + baud =9600 ; +switch (priv->chip_type) {case SIO :/* SIO chip */ -switch (baud) { +switch (baud) {case 300 : div_value = ftdi_sio_b300;break ;case 600 : div_value = ftdi_sio_b600;break ;case 1200 : div_value = ftdi_sio_b1200;break ;
@@ -904,7 +940,8 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *pocase 115200 : div_value = ftdi_sio_b115200;break ; }/* baud */ if (div_value ==0 ) { -dbg ("%s - Baudrate (%d) requested is not supported" , __func__, baud); +dbg ("%s - Baudrate (%d) requested is not supported" , + __func__, baud); div_value = ftdi_sio_b9600; baud =9600 ; div_okay =0 ;
@@ -914,7 +951,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *poif (baud <=3000000 ) { div_value =ftdi_232am_baud_to_divisor (baud); }else { -dbg ("%s - Baud rate too high!" , __func__); +dbg ("%s - Baud rate too high!" , __func__); baud =9600 ; div_value =ftdi_232am_baud_to_divisor (9600 ); div_okay =0 ;
@@ -926,7 +963,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *poif (baud <=3000000 ) { div_value =ftdi_232bm_baud_to_divisor (baud); }else { -dbg ("%s - Baud rate too high!" , __func__); +dbg ("%s - Baud rate too high!" , __func__); div_value =ftdi_232bm_baud_to_divisor (9600 ); div_okay =0 ; baud =9600 ;
@@ -941,14 +978,14 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po }tty_encode_baud_rate (tty, baud, baud); -return (div_value); +return div_value; }static int change_speed (struct tty_struct *tty,struct usb_serial_port *port) {struct ftdi_private *priv =usb_get_serial_port_data (port);char *buf; -__u16 urb_value; +__u16 urb_value;__u16 urb_index;__u32 urb_index_value;int rv;
@@ -977,7 +1014,8 @@ static int change_speed(struct tty_struct *tty, struct usb_serial_port *port) -static int get_serial_info (struct usb_serial_port * port,struct serial_struct __user * retinfo) +static int get_serial_info (struct usb_serial_port *port, +struct serial_struct __user *retinfo) {struct ftdi_private *priv =usb_get_serial_port_data (port);struct serial_struct tmp;
@@ -995,7 +1033,7 @@ static int get_serial_info(struct usb_serial_port * port, struct serial_struct _static int set_serial_info (struct tty_struct *tty, -struct usb_serial_port * port,struct serial_struct __user * newinfo) +struct usb_serial_port *port,struct serial_struct __user *newinfo) {/* set_serial_info */ struct ftdi_private *priv =usb_get_serial_port_data (port);struct serial_struct new_serial;
@@ -1003,7 +1041,7 @@ static int set_serial_info(struct tty_struct *tty,if (copy_from_user (&new_serial, newinfo,sizeof (new_serial)))return -EFAULT ; - old_priv = * priv; + old_priv = *priv;/* Do error checking and permission checking */
@@ -1024,7 +1062,7 @@ static int set_serial_info(struct tty_struct *tty,/* Make the changes - these are privileged changes! */ priv->flags = ((priv->flags & ~ASYNC_FLAGS ) | - (new_serial.flags &ASYNC_FLAGS )); + (new_serial.flags &ASYNC_FLAGS )); priv->custom_divisor = new_serial.custom_divisor; tty->low_latency = (priv->flags &ASYNC_LOW_LATENCY ) ?1 :0 ;
@@ -1078,11 +1116,10 @@ static void ftdi_determine_type(struct usb_serial_port *port) priv->chip_type =FT2232C ;/* Determine interface code. */ inter = serial->interface->altsetting->desc.bInterfaceNumber; -if (inter ==0 ) { +if (inter ==0 ) priv->interface =PIT_SIOA ; - }else { +else priv->interface =PIT_SIOB ; - }/* BM-type devices have a bug where bcdDevice gets set * to 0x200 when iSerialNumber is 0. */ if (version <0x500 ) {
@@ -1116,7 +1153,8 @@ static void ftdi_determine_type(struct usb_serial_port *port)* *************************************************************************** */ -static ssize_t show_latency_timer (struct device *dev,struct device_attribute *attr,char *buf) +static ssize_t show_latency_timer (struct device *dev, +struct device_attribute *attr,char *buf) {struct usb_serial_port *port =to_usb_serial_port (dev);struct ftdi_private *priv =usb_get_serial_port_data (port);
@@ -1125,14 +1163,14 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *aint rv =0 ; -dbg ("%s" ,__func__); +dbg ("%s" , __func__); rv =usb_control_msg (udev,usb_rcvctrlpipe (udev,0 ),FTDI_SIO_GET_LATENCY_TIMER_REQUEST ,FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE ,0 , priv->interface, - (char *) &latency,1 ,WDR_TIMEOUT ); + (char *) &latency,1 ,WDR_TIMEOUT );if (rv <0 ) {dev_err (dev,"Unable to read latency timer: %i\n" , rv);
@@ -1142,8 +1180,9 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *a }/* Write a new value of the latency timer, in units of milliseconds. */ -static ssize_t store_latency_timer (struct device *dev,struct device_attribute *attr,const char *valbuf, -size_t count) +static ssize_t store_latency_timer (struct device *dev, +struct device_attribute *attr,const char *valbuf, +size_t count) {struct usb_serial_port *port =to_usb_serial_port (dev);struct ftdi_private *priv =usb_get_serial_port_data (port);
@@ -1171,8 +1210,8 @@ static ssize_t store_latency_timer(struct device *dev, struct device_attribute */* Write an event character directly to the FTDI register. The ASCII value is in the low 8 bits, with the enable bit in the 9th bit. */ -static ssize_t store_event_char (struct device *dev,struct device_attribute *attr,const char *valbuf, -size_t count) +static ssize_t store_event_char (struct device *dev, +struct device_attribute *attr,const char *valbuf,size_t count) {struct usb_serial_port *port =to_usb_serial_port (dev);struct ftdi_private *priv =usb_get_serial_port_data (port);
@@ -1198,7 +1237,8 @@ static ssize_t store_event_char(struct device *dev, struct device_attribute *attreturn count; } -static DEVICE_ATTR(latency_timer, S_IWUSR | S_IRUGO, show_latency_timer, store_latency_timer); +static DEVICE_ATTR(latency_timer, S_IWUSR | S_IRUGO, show_latency_timer, + store_latency_timer); static DEVICE_ATTR(event_char, S_IWUSR, NULL, store_event_char);static int create_sysfs_attrs (struct usb_serial_port *port)
@@ -1206,7 +1246,7 @@ static int create_sysfs_attrs(struct usb_serial_port *port)struct ftdi_private *priv =usb_get_serial_port_data (port);int retval =0 ; -dbg ("%s" ,__func__); +dbg ("%s" , __func__);/* XXX I've no idea if the original SIO supports the event_char * sysfs parameter, so I'm playing it safe. */
@@ -1228,7 +1268,7 @@ static void remove_sysfs_attrs(struct usb_serial_port *port) {struct ftdi_private *priv =usb_get_serial_port_data (port); -dbg ("%s" ,__func__); +dbg ("%s" , __func__);/* XXX see create_sysfs_attrs */ if (priv->chip_type !=SIO ) {
@@ -1249,9 +1289,11 @@ static void remove_sysfs_attrs(struct usb_serial_port *port)*/ /* Probe function to check for special devices */ -static int ftdi_sio_probe (struct usb_serial *serial,const struct usb_device_id *id) +static int ftdi_sio_probe (struct usb_serial *serial, +const struct usb_device_id *id) { -struct ftdi_sio_quirk *quirk = (struct ftdi_sio_quirk *)id->driver_info; +struct ftdi_sio_quirk *quirk = + (struct ftdi_sio_quirk *)id->driver_info;if (quirk && quirk->probe) {int ret = quirk->probe (serial);
@@ -1270,17 +1312,18 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)struct ftdi_sio_quirk *quirk =usb_get_serial_data (port->serial); -dbg ("%s" ,__func__); +dbg ("%s" , __func__); priv =kzalloc (sizeof (struct ftdi_private ),GFP_KERNEL ); -if (!priv){ -err ("%s- kmalloc(%Zd) failed." , __func__,sizeof (struct ftdi_private )); +if (!priv) { +err ("%s- kmalloc(%Zd) failed." , __func__, +sizeof (struct ftdi_private ));return -ENOMEM ; }spin_lock_init (&priv->rx_lock);spin_lock_init (&priv->tx_lock); -init_waitqueue_head (&priv->delta_msr_wait); +init_waitqueue_head (&priv->delta_msr_wait);/* This will push the characters through immediately rather than queue a task to deliver them */ priv->flags =ASYNC_LOW_LATENCY ;
@@ -1290,9 +1333,9 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)/* Increase the size of read buffers */ kfree (port->bulk_in_buffer); - port->bulk_in_buffer =kmalloc (BUFSZ ,GFP_KERNEL ); + port->bulk_in_buffer =kmalloc (BUFSZ ,GFP_KERNEL );if (!port->bulk_in_buffer) { -kfree (priv); +kfree (priv);return -ENOMEM ; }if (port->read_urb) {
@@ -1305,7 +1348,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)/* Free port's existing write urb and transfer buffer. */ if (port->write_urb) { -usb_free_urb (port->write_urb); +usb_free_urb (port->write_urb); port->write_urb =NULL ; }kfree (port->bulk_out_buffer);
@@ -1313,7 +1356,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)usb_set_serial_port_data (port, priv); -ftdi_determine_type (port); +ftdi_determine_type (port);create_sysfs_attrs (port);return 0 ; }
@@ -1321,9 +1364,9 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)/* Setup for the USB-UIRT device, which requires hardwired * baudrate (38400 gets mapped to 312500) */ /* Called from usbserial:serial_probe */ -static void ftdi_USB_UIRT_setup (struct ftdi_private *priv) +static void ftdi_USB_UIRT_setup (struct ftdi_private *priv) { -dbg ("%s" ,__func__); +dbg ("%s" , __func__); priv->flags |=ASYNC_SPD_CUST ; priv->custom_divisor =77 ;
@@ -1332,9 +1375,10 @@ static void ftdi_USB_UIRT_setup (struct ftdi_private *priv)/* Setup for the HE-TIRA1 device, which requires hardwired * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */ -static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv) + +static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv) { -dbg ("%s" ,__func__); +dbg ("%s" , __func__); priv->flags |=ASYNC_SPD_CUST ; priv->custom_divisor =240 ;
@@ -1352,7 +1396,7 @@ static int ftdi_jtag_probe(struct usb_serial *serial)struct usb_device *udev = serial->dev;struct usb_interface *interface = serial->interface; -dbg ("%s" ,__func__); +dbg ("%s" , __func__);if (interface == udev->actconfig->interface[0 ]) {info ("Ignoring serial port reserved for JTAG" );
@@ -1386,7 +1430,7 @@ static int ftdi_mtxorb_hack_setup(struct usb_serial *serial)* calls __serial_close for each open of the port * shutdown is called then (ie ftdi_shutdown) */ -static void ftdi_shutdown (struct usb_serial *serial) +static void ftdi_shutdown (struct usb_serial *serial) {dbg ("%s" , __func__); }
@@ -1400,7 +1444,7 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)remove_sysfs_attrs (port);/* all open ports are closed at this point -* (by usbserial.c:__serial_close, which calls ftdi_close) +* (by usbserial.c:__serial_close, which calls ftdi_close) */ if (priv) {
@@ -1461,12 +1505,14 @@ static int ftdi_open(struct tty_struct *tty,/* Start reading from the device */ priv->rx_processed =0 ;usb_fill_bulk_urb (port->read_urb, dev, -usb_rcvbulkpipe (dev, port->bulk_in_endpointAddress), - port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, - ftdi_read_bulk_callback, port); +usb_rcvbulkpipe (dev, port->bulk_in_endpointAddress), + port->read_urb->transfer_buffer, + port->read_urb->transfer_buffer_length, + ftdi_read_bulk_callback, port); result =usb_submit_urb (port->read_urb,GFP_KERNEL );if (result) -err ("%s - failed submitting read urb, error %d" , __func__, result); +err ("%s - failed submitting read urb, error %d" , + __func__, result);return result;
@@ -1492,7 +1538,7 @@ static void ftdi_close(struct tty_struct *tty,dbg ("%s" , __func__);mutex_lock (&port->serial->disc_mutex); -if (c_cflag &HUPCL && !port->serial->disconnected){ +if (c_cflag &HUPCL && !port->serial->disconnected) {/* Disable flow control */ if (usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
@@ -1552,7 +1598,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,spin_unlock_irqrestore (&priv->tx_lock, flags); data_offset = priv->write_offset; -dbg ("data_offset set to %d" ,data_offset); +dbg ("data_offset set to %d" , data_offset);/* Determine total transfer size */ transfer_size = count;
@@ -1563,7 +1609,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, (PKTSZ - data_offset))); } - buffer =kmalloc (transfer_size,GFP_ATOMIC ); + buffer =kmalloc (transfer_size,GFP_ATOMIC );if (!buffer) {err ("%s ran out of kernel memory for urb ..." , __func__); count = -ENOMEM ;
@@ -1579,20 +1625,20 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,/* Copy data */ if (data_offset >0 ) { -/* Original sio requires control byte at start of each packet. */ +/* Original sio requires control byte at start of +each packet. */ int user_pktsz =PKTSZ - data_offset;int todo = count;unsigned char *first_byte = buffer;const unsigned char *current_position = buf;while (todo >0 ) { -if (user_pktsz > todo) { +if (user_pktsz > todo) user_pktsz = todo; - }/* Write the control byte at the front of the packet*/ *first_byte =1 | ((user_pktsz) <<2 );/* Copy data for packet */ -memcpy (first_byte + data_offset, +memcpy (first_byte + data_offset, current_position, user_pktsz); first_byte += user_pktsz + data_offset; current_position += user_pktsz;
@@ -1601,20 +1647,23 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, }else {/* No control byte required. */ /* Copy in the data to send */ -memcpy (buffer, buf, count); +memcpy (buffer, buf, count); } -usb_serial_debug_data (debug, &port->dev, __func__, transfer_size, buffer); +usb_serial_debug_data (debug, &port->dev, __func__, + transfer_size, buffer);/* fill the buffer and send it */ usb_fill_bulk_urb (urb, port->serial->dev, -usb_sndbulkpipe (port->serial->dev, port->bulk_out_endpointAddress), - buffer, transfer_size, - ftdi_write_bulk_callback, port); +usb_sndbulkpipe (port->serial->dev, + port->bulk_out_endpointAddress), + buffer, transfer_size, + ftdi_write_bulk_callback, port); status =usb_submit_urb (urb,GFP_ATOMIC );if (status) { -err ("%s - failed submitting write urb, error %d" , __func__, status); +err ("%s - failed submitting write urb, error %d" , + __func__, status); count = status; goto error; }else {
@@ -1633,7 +1682,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, error:usb_free_urb (urb); error_no_urb: -kfree (buffer); +kfree (buffer); error_no_buffer:spin_lock_irqsave (&priv->tx_lock, flags); priv->tx_outstanding_urbs--;
@@ -1644,7 +1693,7 @@ error_no_buffer:/* This function may get called when the device is closed */ -static void ftdi_write_bulk_callback (struct urb *urb) +static void ftdi_write_bulk_callback (struct urb *urb) {unsigned long flags;struct usb_serial_port *port = urb->context;
@@ -1654,7 +1703,7 @@ static void ftdi_write_bulk_callback (struct urb *urb)int status = urb->status;/* free up the transfer buffer, as usb_free_urb() does not do this */ -kfree (urb->transfer_buffer); +kfree (urb->transfer_buffer);dbg ("%s - port %d" , __func__, port->number);
@@ -1737,9 +1786,11 @@ static void ftdi_read_bulk_callback(struct urb *urb)int status = urb->status;if (urb->number_of_packets >0 ) { -err ("%s transfer_buffer_length %d actual_length %d number of packets %d" ,__func__, - urb->transfer_buffer_length, urb->actual_length, urb->number_of_packets ); -err ("%s transfer_flags %x " , __func__,urb->transfer_flags ); +err ("%s transfer_buffer_length %d actual_length %d number of packets %d" , + __func__, + urb->transfer_buffer_length, + urb->actual_length, urb->number_of_packets); +err ("%s transfer_flags %x " , __func__, urb->transfer_flags); }dbg ("%s - port %d" , __func__, port->number);
@@ -1749,7 +1800,7 @@ static void ftdi_read_bulk_callback(struct urb *urb) tty = port->port.tty;if (!tty) { -dbg ("%s - bad tty pointer - exiting" ,__func__); +dbg ("%s - bad tty pointer - exiting" , __func__);return ; }
@@ -1759,14 +1810,13 @@ static void ftdi_read_bulk_callback(struct urb *urb)return ; } -if (urb != port->read_urb) { +if (urb != port->read_urb)err ("%s - Not my urb!" , __func__); - }if (status) { -/* This will happen at close every time so it is a dbg not an err */ -dbg ("(this is ok on close) nonzero read bulk status received: " -"%d" , status); +/* This will happen at close every time so it is a dbg not an +err */ +dbg ("(this is ok on close) nonzero read bulk status received: %d" , status);return ; }
@@ -1782,7 +1832,7 @@ static void ftdi_read_bulk_callback(struct urb *urb) }/* ftdi_read_bulk_callback */ -static void ftdi_process_read (struct work_struct *work) +static void ftdi_process_read (struct work_struct *work) {/* ftdi_process_read */ struct ftdi_private *priv = container_of(work, struct ftdi_private, rx_work.work);
@@ -1805,7 +1855,7 @@ static void ftdi_process_read (struct work_struct *work) tty = port->port.tty;if (!tty) { -dbg ("%s - bad tty pointer - exiting" ,__func__); +dbg ("%s - bad tty pointer - exiting" , __func__);return ; }
@@ -1829,11 +1879,11 @@ static void ftdi_process_read (struct work_struct *work) urb->actual_length - priv->rx_processed); }else {/* The first two bytes of every read packet are status */ -if (urb->actual_length >2 ) { -usb_serial_debug_data (debug, &port->dev, __func__, urb->actual_length, data); - }else { -dbg ("Status only: %03oo %03oo" ,data[0 ],data[1 ]); - } +if (urb->actual_length >2 ) +usb_serial_debug_data (debug, &port->dev, __func__, + urb->actual_length, data); +else +dbg ("Status only: %03oo %03oo" , data[0 ], data[1 ]); }
@@ -1843,16 +1893,19 @@ static void ftdi_process_read (struct work_struct *work)/* if CD is dropped and the line is not CLOCAL then we should hangup */ need_flip =0 ; -for (packet_offset = priv->rx_processed; packet_offset < urb->actual_length; packet_offset +=PKTSZ ) { +for (packet_offset = priv->rx_processed; + packet_offset < urb->actual_length; packet_offset +=PKTSZ ) {int length; -/* Compare new line status to the old one, signal if different */ -/* N.B. packet may be processed more than once, but differences -* are only processed once. */ +/* Compare new line status to the old one, signal if different/ +N.B. packet may be processed more than once, but differences +are only processed once. */ if (priv !=NULL ) { -char new_status = data[packet_offset+0 ] &FTDI_STATUS_B0_MASK ; +char new_status = data[packet_offset +0 ] & +FTDI_STATUS_B0_MASK ;if (new_status != priv->prev_status) { - priv->diff_status |= new_status ^ priv->prev_status; + priv->diff_status |= + new_status ^ priv->prev_status;wake_up_interruptible (&priv->delta_msr_wait); priv->prev_status = new_status; }
@@ -1869,30 +1922,31 @@ static void ftdi_process_read (struct work_struct *work)break ; }if (tty_buffer_request_room (tty, length) < length) { -/* break out & wait for throttling/unthrottling to happen */ +/* break out & wait for throttling/unthrottling to +happen */ dbg ("%s - receive room low" , __func__);break ; }/* Handle errors and break */ error_flag =TTY_NORMAL ; -/* Although the device uses a bitmask and hence can have multiple */ -/* errors on a packet - the order here sets the priority the */ -/* error is returned to the tty layer */ +/* Although the device uses a bitmask and hence can have +multiple errors on a packet - the order here sets the +priority the error is returned to the tty layer */ -if ( data[packet_offset+1 ] &FTDI_RS_OE ) { +if (data[packet_offset+1 ] &FTDI_RS_OE ) { error_flag =TTY_OVERRUN ;dbg ("OVERRRUN error" ); } -if ( data[packet_offset+1 ] &FTDI_RS_BI ) { +if (data[packet_offset+1 ] &FTDI_RS_BI ) { error_flag =TTY_BREAK ;dbg ("BREAK received" ); } -if ( data[packet_offset+1 ] &FTDI_RS_PE ) { +if (data[packet_offset+1 ] &FTDI_RS_PE ) { error_flag =TTY_PARITY ;dbg ("PARITY error" ); } -if ( data[packet_offset+1 ] &FTDI_RS_FE ) { +if (data[packet_offset+1 ] &FTDI_RS_FE ) { error_flag =TTY_FRAME ;dbg ("FRAMING error" ); }
@@ -1901,7 +1955,8 @@ static void ftdi_process_read (struct work_struct *work)/* Note that the error flag is duplicated for every character received since we don't know which character it applied to */ -tty_insert_flip_char (tty, data[packet_offset+i], error_flag); +tty_insert_flip_char (tty, + data[packet_offset + i], error_flag); } need_flip =1 ; }
@@ -1909,19 +1964,19 @@ static void ftdi_process_read (struct work_struct *work)#ifdef NOT_CORRECT_BUT_KEEPING_IT_FOR_NOW /* if a parity error is detected you get status packets forever until a character is sent without a parity error. -This doesn't work well since the application receives a never -ending stream of bad data - even though new data hasn't been sent. -Therefore I (bill) have taken this out. +This doesn't work well since the application receives a +never ending stream of bad data - even though new data +hasn't been sent. Therefore I (bill) have taken this out. However - this might make sense for framing errors and so on so I am leaving the code in for now. */ else { -if (error_flag !=TTY_NORMAL ){ +if (error_flag !=TTY_NORMAL ) {dbg ("error_flag is not normal" ); -/* In this case it is just status - if that is an error send a bad character */ -if (tty->flip.count >=TTY_FLIPBUF_SIZE ) { +/* In this case it is just status - if that is +an error send a bad character */ +if (tty->flip.count >=TTY_FLIPBUF_SIZE )tty_flip_buffer_push (tty); - }tty_insert_flip_char (tty,0xff , error_flag); need_flip =1 ; }
@@ -1930,9 +1985,8 @@ static void ftdi_process_read (struct work_struct *work) }/* "for(packet_offset=0..." */ /* Low latency */ -if (need_flip) { +if (need_flip)tty_flip_buffer_push (tty); - }if (packet_offset < urb->actual_length) {/* not completely processed - record progress */
@@ -1951,12 +2005,11 @@ static void ftdi_process_read (struct work_struct *work) }spin_unlock_irqrestore (&priv->rx_lock, flags);/* if the port is closed stop trying to read */ -if (port->port.count >0 ){ +if (port->port.count >0 )/* delay processing of remainder */ schedule_delayed_work (&priv->rx_work,1 ); - }else { +else dbg ("%s - port is closed" , __func__); - }return ; }
@@ -1964,19 +2017,20 @@ static void ftdi_process_read (struct work_struct *work) priv->rx_processed =0 ;/* if the port is closed stop trying to read */ -if (port->port.count >0 ){ +if (port->port.count >0 ) {/* Continue trying to always read */ usb_fill_bulk_urb (port->read_urb, port->serial->dev, -usb_rcvbulkpipe (port->serial->dev, port->bulk_in_endpointAddress), - port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, - ftdi_read_bulk_callback, port); +usb_rcvbulkpipe (port->serial->dev, + port->bulk_in_endpointAddress), + port->read_urb->transfer_buffer, + port->read_urb->transfer_buffer_length, + ftdi_read_bulk_callback, port); result =usb_submit_urb (port->read_urb,GFP_ATOMIC );if (result) -err ("%s - failed resubmitting read urb, error %d" , __func__, result); +err ("%s - failed resubmitting read urb, error %d" , + __func__, result); } - -return ; }/* ftdi_process_read */
@@ -1991,22 +2045,23 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state)/* see drivers/char/tty_io.c to see it used */ /* last_set_data_urb_value NEVER has the break bit set in it */ -if (break_state) { +if (break_state) urb_value = priv->last_set_data_urb_value |FTDI_SIO_SET_BREAK ; - }else { +else urb_value = priv->last_set_data_urb_value; - } - -if (usb_control_msg (port->serial->dev,usb_sndctrlpipe (port->serial->dev,0 ), -FTDI_SIO_SET_DATA_REQUEST , -FTDI_SIO_SET_DATA_REQUEST_TYPE , - urb_value , priv->interface, - buf,0 ,WDR_TIMEOUT ) <0 ) { -err ("%s FAILED to enable/disable break state (state was %d)" , __func__,break_state); +if (usb_control_msg (port->serial->dev, +usb_sndctrlpipe (port->serial->dev,0 ), +FTDI_SIO_SET_DATA_REQUEST , +FTDI_SIO_SET_DATA_REQUEST_TYPE , + urb_value , priv->interface, + buf,0 ,WDR_TIMEOUT ) <0 ) { +err ("%s FAILED to enable/disable break state (state was %d)" , + __func__, break_state); } -dbg ("%s break state is %d - urb is %d" , __func__,break_state, urb_value); +dbg ("%s break state is %d - urb is %d" , __func__, + break_state, urb_value); }
@@ -2026,14 +2081,15 @@ static void ftdi_set_termios(struct tty_struct *tty,__u16 urb_value;/* will hold the new flags */ char buf[1 ];/* Perhaps I should dynamically alloc this? */ -// Added for xon/xoff support +/* Added for xon/xoff support */ unsigned int iflag = termios->c_iflag;unsigned char vstop;unsigned char vstart;dbg ("%s" , __func__); -/* Force baud rate if this device requires it, unless it is set to B0. */ +/* Force baud rate if this device requires it, unless it is set to +B0. */ if (priv->force_baud && ((termios->c_cflag &CBAUD ) !=B0 )) {dbg ("%s: forcing baud rate for this device" , __func__); tty_encode_baud_rate(tty, priv->force_baud,
@@ -2052,8 +2108,8 @@ static void ftdi_set_termios(struct tty_struct *tty,not - so just do the change regardless - should be able to compare old_termios and tty->termios */ /* NOTE These routines can get interrupted by -ftdi_sio_read_bulk_callback - need to examine what this -means - don't see any problems yet */ +ftdi_sio_read_bulk_callback - need to examine what this means - +don't see any problems yet */ /* Set number of data bits, parity, stop bits */
@@ -2077,8 +2133,8 @@ static void ftdi_set_termios(struct tty_struct *tty, } } -/* This is needed by the break command since it uses the same command - but is -* or'ed with this value */ +/* This is needed by the break command since it uses the same command +- but is or'ed with this value */ priv->last_set_data_urb_value = urb_value; if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
@@ -2090,7 +2146,7 @@ static void ftdi_set_termios(struct tty_struct *tty, }/* Now do the baudrate */ -if ((cflag &CBAUD ) ==B0 ) { +if ((cflag &CBAUD ) ==B0 ) {/* Disable flow control */ if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), FTDI_SIO_SET_FLOW_CTRL_REQUEST,
@@ -2103,13 +2159,11 @@ static void ftdi_set_termios(struct tty_struct *tty,clear_mctrl (port,TIOCM_DTR |TIOCM_RTS ); }else {/* set the baudrate determined before */ -if (change_speed (tty, port)) { +if (change_speed (tty, port))err ("%s urb failed to set baudrate" , __func__); - }/* Ensure RTS and DTR are raised when baudrate changed from 0 */ -if (!old_termios || (old_termios->c_cflag &CBAUD ) ==B0 ) { +if (!old_termios || (old_termios->c_cflag &CBAUD ) ==B0 )set_mctrl (port,TIOCM_DTR |TIOCM_RTS ); - } }/* Set flow control */
@@ -2129,18 +2183,22 @@ static void ftdi_set_termios(struct tty_struct *tty,/* * Xon/Xoff code * -* Check the IXOFF status in the iflag component of the termios structure -* if IXOFF is not set, the pre-xon/xoff code is executed. -*/ +* Check the IXOFF status in the iflag component of the +* termios structure. If IXOFF is not set, the pre-xon/xoff +* code is executed. +*/ if (iflag &IXOFF ) { -dbg ("%s request to enable xonxoff iflag=%04x" ,__func__,iflag); -// Try to enable the XON/XOFF on the ftdi_sio -// Set the vstart and vstop -- could have been done up above where -// a lot of other dereferencing is done but that would be very -// inefficient as vstart and vstop are not always needed +dbg ("%s request to enable xonxoff iflag=%04x" , + __func__, iflag); +/* Try to enable the XON/XOFF on the ftdi_sio +* Set the vstart and vstop -- could have been done up +* above where a lot of other dereferencing is done but +* that would be very inefficient as vstart and vstop +* are not always needed. +*/ vstart = termios->c_cc[VSTART ]; vstop = termios->c_cc[VSTOP ]; - urb_value=(vstop <<8 ) | (vstart); + urb_value = (vstop <<8 ) | (vstart); if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
@@ -2152,8 +2210,9 @@ static void ftdi_set_termios(struct tty_struct *tty,err ("urb failed to set to xon/xoff flow control" ); } }else { -/* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */ -/* CHECKME Assuming XON/XOFF handled by tty stack - not by device */ +/* else clause to only run if cflag ! CRTSCTS and iflag +* ! XOFF. CHECKME Assuming XON/XOFF handled by tty +* stack - not by device */ dbg ("%s Turning off hardware flow control" , __func__); if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
@@ -2180,32 +2239,35 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)switch (priv->chip_type) {case SIO :/* Request the status from the device */ -if ((ret =usb_control_msg (port->serial->dev, -usb_rcvctrlpipe (port->serial->dev,0 ), -FTDI_SIO_GET_MODEM_STATUS_REQUEST , -FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE , -0 ,0 , - buf,1 ,WDR_TIMEOUT )) <0 ) { + ret =usb_control_msg (port->serial->dev, +usb_rcvctrlpipe (port->serial->dev,0 ), +FTDI_SIO_GET_MODEM_STATUS_REQUEST , +FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE , +0 ,0 , + buf,1 ,WDR_TIMEOUT ); +if (ret <0 ) {err ("%s Could not get modem status of device - err: %d" , __func__, ret); -return (ret); +return ret; }break ;case FT8U232AM :case FT232BM :case FT2232C :case FT232RL : -/* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same -format as the data returned from the in point */ -if ((ret =usb_control_msg (port->serial->dev, -usb_rcvctrlpipe (port->serial->dev,0 ), -FTDI_SIO_GET_MODEM_STATUS_REQUEST , -FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE , -0 , priv->interface, - buf,2 ,WDR_TIMEOUT )) <0 ) { +/* the 8U232AM returns a two byte value (the sio is a 1 byte +value) - in the same format as the data returned from the in +point */ + ret =usb_control_msg (port->serial->dev, +usb_rcvctrlpipe (port->serial->dev,0 ), +FTDI_SIO_GET_MODEM_STATUS_REQUEST , +FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE , +0 , priv->interface, + buf,2 ,WDR_TIMEOUT ); +if (ret <0 ) {err ("%s Could not get modem status of device - err: %d" , __func__, ret); -return (ret); +return ret; }break ;default :
@@ -2220,7 +2282,7 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file) priv->last_dtr_rts; } -static int ftdi_tiocmset (struct tty_struct *tty,struct file * file, +static int ftdi_tiocmset (struct tty_struct *tty,struct file *file,unsigned int set,unsigned int clear) {struct usb_serial_port *port = tty->driver_data;
@@ -2229,7 +2291,8 @@ static int ftdi_tiocmset(struct tty_struct *tty, struct file * file, } -static int ftdi_ioctl (struct tty_struct *tty,struct file * file,unsigned int cmd,unsigned long arg) +static int ftdi_ioctl (struct tty_struct *tty,struct file *file, +unsigned int cmd,unsigned long arg) {struct usb_serial_port *port = tty->driver_data;struct ftdi_private *priv =usb_get_serial_port_data (port);
@@ -2240,10 +2303,12 @@ static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int cswitch (cmd) {case TIOCGSERIAL :/* gets serial port data */ -return get_serial_info (port, (struct serial_struct __user *) arg); +return get_serial_info (port, + (struct serial_struct __user *) arg);case TIOCSSERIAL :/* sets serial port data */ -return set_serial_info (tty, port, (struct serial_struct __user *) arg); +return set_serial_info (tty, port, + (struct serial_struct __user *) arg);/* * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
@@ -2262,23 +2327,24 @@ static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int celse {char diff = priv->diff_status; -if (diff ==0 ) { +if (diff ==0 )return -EIO ;/* no change => error */ - }/* Consume all events */ priv->diff_status =0 ; -/* Return 0 if caller wanted to know about these bits */ -if ( ((arg &TIOCM_RNG ) && (diff &FTDI_RS0_RI )) || - ((arg &TIOCM_DSR ) && (diff &FTDI_RS0_DSR )) || - ((arg &TIOCM_CD ) && (diff &FTDI_RS0_RLSD )) || - ((arg &TIOCM_CTS ) && (diff &FTDI_RS0_CTS )) ) { +/* Return 0 if caller wanted to know about +these bits */ +if (((arg &TIOCM_RNG ) && (diff &FTDI_RS0_RI )) || + ((arg &TIOCM_DSR ) && (diff &FTDI_RS0_DSR )) || + ((arg &TIOCM_CD ) && (diff &FTDI_RS0_RLSD )) || + ((arg &TIOCM_CTS ) && (diff &FTDI_RS0_CTS ))) {return 0 ; }/* -* Otherwise caller can't care less about what happened, -* and so we continue to wait for more events. +* Otherwise caller can't care less about what +* happened,and so we continue to wait for more +* events. */ } }
@@ -2286,8 +2352,8 @@ static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int cdefault :break ; } -/* This is not necessarily an error - turns out the higher layers will do -* some ioctls itself (see comment above) +/* This is not necessarily an error - turns out the higher layers +* will do some ioctls themselves (see comment above) */ dbg ("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h" , __func__, cmd);return -ENOIOCTLCMD ;
@@ -2325,7 +2391,7 @@ static void ftdi_unthrottle(struct tty_struct *tty)schedule_delayed_work (&priv->rx_work,0 ); } -static int __init ftdi_init (void ) +static int __init ftdi_init (void ) {int retval;
@@ -2355,13 +2421,13 @@ failed_sio_register: } -static void __exit ftdi_exit (void) +static void __exit ftdi_exit(void) {dbg ("%s" , __func__); -usb_deregister (&ftdi_driver); -usb_serial_deregister (&ftdi_sio_device); +usb_deregister (&ftdi_driver); +usb_serial_deregister (&ftdi_sio_device); }
@@ -2369,8 +2435,8 @@ static void __exit ftdi_exit (void)module_init (ftdi_init);module_exit (ftdi_exit); -MODULE_AUTHOR (DRIVER_AUTHOR ); -MODULE_DESCRIPTION (DRIVER_DESC ); +MODULE_AUTHOR (DRIVER_AUTHOR ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );module_param (debug, bool,S_IRUGO |S_IWUSR );
drivers/usb/serial/ftdi_sio.h +63 -63
343 lines not on this page · raw message
PATCH 37/70 funsoft: Switch to linux/uaccess
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/funsoft.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/serial/funsoft.c +1 -1
@@ -14,7 +14,7 @@#include <linux/module.h> #include <linux/usb.h> #include <linux/usb/serial.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> static int debug;
PATCH 38/70 garmin_gps: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/garmin_gps.c | 354 +++++++++++++++++++-------------------- 1 files changed, 176 insertions(+), 178 deletions(-)
drivers/usb/serial/garmin_gps.c +176 -178
@@ -33,7 +33,7 @@#include <linux/tty_flip.h> #include <linux/module.h> #include <linux/spinlock.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <asm/atomic.h> #include <linux/usb.h> #include <linux/usb/serial.h>
@@ -44,7 +44,7 @@static int initial_mode =1 ;/* debug flag */ -static int debug =0 ; +static int debug;#define GARMIN_VENDOR_ID 0x091E
@@ -56,7 +56,7 @@ static int debug = 0;#define VERSION_MINOR 31#define _STR (s) #s -#define _DRIVER_VERSION (a,b) "v" _STR(a) "." _STR(b) +#define _DRIVER_VERSION (a, b) "v" _STR(a) "." _STR(b)#define DRIVER_VERSION _DRIVER_VERSION(VERSION_MAJOR, VERSION_MINOR)#define DRIVER_AUTHOR "hermann kneissel"#define DRIVER_DESC "garmin gps driver"
@@ -65,37 +65,37 @@ static int debug = 0;#define EINVPKT 1000/* invalid packet structure */ -// size of the header of a packet using the usb protocol +/* size of the header of a packet using the usb protocol */ #define GARMIN_PKTHDR_LENGTH 12 -// max. possible size of a packet using the serial protocol -#define MAX_SERIAL_PKT_SIZ (3+255+3) +/* max. possible size of a packet using the serial protocol */ +#define MAX_SERIAL_PKT_SIZ (3 + 255 + 3) -// max. possible size of a packet with worst case stuffing -#define MAX_SERIAL_PKT_SIZ_STUFFED MAX_SERIAL_PKT_SIZ+256 +/* max. possible size of a packet with worst case stuffing */ +#define MAX_SERIAL_PKT_SIZ_STUFFED (MAX_SERIAL_PKT_SIZ + 256) -// size of a buffer able to hold a complete (no stuffing) packet -// (the document protocol does not contain packets with a larger -// size, but in theory a packet may be 64k+12 bytes - if in -// later protocol versions larger packet sizes occur, this value -// should be increased accordingly, so the input buffer is always -// large enough the store a complete packet inclusive header) -#define GPS_IN_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ) +/* size of a buffer able to hold a complete (no stuffing) packet +* (the document protocol does not contain packets with a larger +* size, but in theory a packet may be 64k+12 bytes - if in +* later protocol versions larger packet sizes occur, this value +* should be increased accordingly, so the input buffer is always +* large enough the store a complete packet inclusive header) */ +#define GPS_IN_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ) -// size of a buffer able to hold a complete (incl. stuffing) packet -#define GPS_OUT_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ_STUFFED) +/* size of a buffer able to hold a complete (incl. stuffing) packet */ +#define GPS_OUT_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ_STUFFED) -// where to place the packet id of a serial packet, so we can -// prepend the usb-packet header without the need to move the -// packets data +/* where to place the packet id of a serial packet, so we can +* prepend the usb-packet header without the need to move the +* packets data */ #define GSP_INITIAL_OFFSET (GARMIN_PKTHDR_LENGTH-2) -// max. size of incoming private packets (header+1 param) +/* max. size of incoming private packets (header+1 param) */ #define PRIVPKTSIZ (GARMIN_PKTHDR_LENGTH+4)#define GARMIN_LAYERID_TRANSPORT 0#define GARMIN_LAYERID_APPL 20 -// our own layer-id to use for some control mechanisms +/* our own layer-id to use for some control mechanisms */ #define GARMIN_LAYERID_PRIVATE 0x01106E4B#define GARMIN_PKTID_PVT_DATA 51
@@ -103,7 +103,7 @@ static int debug = 0;#define CMND_ABORT_TRANSFER 0 -// packet ids used in private layer +/* packet ids used in private layer */ #define PRIV_PKTID_SET_DEBUG 1#define PRIV_PKTID_SET_MODE 2#define PRIV_PKTID_INFO_REQ 3
@@ -121,7 +121,8 @@ static int debug = 0;struct garmin_packet {struct list_head list;int seq; -int size;// the real size of the data array, always > 0 +/* the real size of the data array, always > 0 */ +int size;__u8 data[1 ]; };
@@ -164,7 +165,7 @@ struct garmin_data {#define MODE_NATIVE 0#define MODE_GARMIN_SERIAL 1 -// Flags used in garmin_data.flags: +/* Flags used in garmin_data.flags: */ #define FLAGS_SESSION_REPLY_MASK 0x00C0#define FLAGS_SESSION_REPLY1_SEEN 0x0080#define FLAGS_SESSION_REPLY2_SEEN 0x0040
@@ -185,7 +186,7 @@ struct garmin_data {/* function prototypes */ -static void gsp_next_packet (struct garmin_data * garmin_data_p); +static void gsp_next_packet (struct garmin_data *garmin_data_p);static int garmin_write_bulk (struct usb_serial_port *port,const unsigned char *buf,int count,int dismiss_ack);
@@ -217,12 +218,13 @@ static unsigned char const PRIVATE_REQ[]static struct usb_device_id id_table [] = { -/* the same device id seems to be used by all usb enabled gps devices */ - {USB_DEVICE (GARMIN_VENDOR_ID ,3 ) }, +/* the same device id seems to be used by all +usb enabled GPS devices */ + {USB_DEVICE (GARMIN_VENDOR_ID ,3 ) }, { }/* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table); +MODULE_DEVICE_TABLE (usb, id_table);static struct usb_driver garmin_driver = { .name ="garmin_gps" ,
@@ -233,9 +235,10 @@ static struct usb_driver garmin_driver = { }; -static inline int noResponseFromAppLayer (struct garmin_data * garmin_data_p) +static inline int noResponseFromAppLayer (struct garmin_data *garmin_data_p) { -return atomic_read (&garmin_data_p->req_count) ==atomic_read (&garmin_data_p->resp_count); +return atomic_read (&garmin_data_p->req_count) == +atomic_read (&garmin_data_p->resp_count); }
@@ -261,10 +264,10 @@ static inline int getDataLength(const __u8 *usbPacket)*/ static inline int isAbortTrfCmnd (const unsigned char *buf) { -if (0 ==memcmp (buf,GARMIN_STOP_TRANSFER_REQ , -sizeof (GARMIN_STOP_TRANSFER_REQ )) || -0 ==memcmp (buf,GARMIN_STOP_TRANSFER_REQ_V2 , -sizeof (GARMIN_STOP_TRANSFER_REQ_V2 ))) +if (0 ==memcmp (buf,GARMIN_STOP_TRANSFER_REQ , +sizeof (GARMIN_STOP_TRANSFER_REQ )) || +0 ==memcmp (buf,GARMIN_STOP_TRANSFER_REQ_V2 , +sizeof (GARMIN_STOP_TRANSFER_REQ_V2 )))return 1 ;else return 0 ;
@@ -279,7 +282,7 @@ static void send_to_tty(struct usb_serial_port *port,if (tty && actual_length) { -usb_serial_debug_data (debug, &port->dev, +usb_serial_debug_data (debug, &port->dev, __func__, actual_length, data);tty_buffer_request_room (tty, actual_length);
@@ -296,7 +299,7 @@ static void send_to_tty(struct usb_serial_port *port,/* * queue a received (usb-)packet for later processing */ -static int pkt_add (struct garmin_data * garmin_data_p, +static int pkt_add (struct garmin_data *garmin_data_p,unsigned char *data,unsigned int data_length) {int state =0 ;
@@ -307,7 +310,7 @@ static int pkt_add(struct garmin_data * garmin_data_p,/* process only packets containg data ... */ if (data_length) { pkt =kmalloc (sizeof (struct garmin_packet )+data_length, -GFP_ATOMIC ); +GFP_ATOMIC );if (pkt ==NULL ) {dev_err (&garmin_data_p->port->dev,"out of memory\n" );return 0 ;
@@ -325,16 +328,15 @@ static int pkt_add(struct garmin_data * garmin_data_p,/* in serial mode, if someone is waiting for data from the device, iconvert and send the next packet to tty. */ -if (result && (state ==STATE_GSP_WAIT_DATA )) { +if (result && (state ==STATE_GSP_WAIT_DATA ))gsp_next_packet (garmin_data_p); - } }return result; }/* get the next pending packet */ -static struct garmin_packet *pkt_pop (struct garmin_data * garmin_data_p) +static struct garmin_packet *pkt_pop (struct garmin_data *garmin_data_p) {unsigned long flags;struct garmin_packet *result =NULL ;
@@ -350,7 +352,7 @@ static struct garmin_packet *pkt_pop(struct garmin_data * garmin_data_p)/* free up all queued data */ -static void pkt_clear (struct garmin_data * garmin_data_p) +static void pkt_clear (struct garmin_data *garmin_data_p) {unsigned long flags;struct garmin_packet *result =NULL ;
@@ -372,7 +374,7 @@ static void pkt_clear(struct garmin_data * garmin_data_p)******************************************************************************/ /* send an ack packet back to the tty */ -static int gsp_send_ack (struct garmin_data * garmin_data_p,__u8 pkt_id) +static int gsp_send_ack (struct garmin_data *garmin_data_p,__u8 pkt_id) {__u8 pkt[10 ];__u8 cksum =0 ;
@@ -391,9 +393,8 @@ static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id) *ptr++ = pkt_id; cksum += pkt_id; -if (pkt_id ==DLE ) { +if (pkt_id ==DLE ) *ptr++ =DLE ; - } *ptr++ =0 ; *ptr++ =0xFF & (-cksum);
@@ -415,12 +416,12 @@ static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id)* at GSP_INITIAL_OFFSET. * * count - number of bytes in the input buffer including space reserved for -* the usb header: GSP_INITIAL_OFFSET + number of bytes in packet +* the usb header: GSP_INITIAL_OFFSET + number of bytes in packet * (including pkt-id, data-length a. cksum) */ -static int gsp_rec_packet (struct garmin_data * garmin_data_p,int count) +static int gsp_rec_packet (struct garmin_data *garmin_data_p,int count) { -const __u8 * recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET ; +const __u8 *recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET ;__le32 *usbdata = (__le32 *) garmin_data_p->inbuffer;int cksum =0 ;
@@ -440,8 +441,8 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count) cksum += *recpkt++; cksum += *recpkt++; -// sanity check, remove after test ... -if ((__u8 *)&(usbdata[3 ]) != recpkt) { +/* sanity check, remove after test ... */ +if ((__u8 *)&(usbdata[3 ]) != recpkt) {dbg ("%s - ptr mismatch %p - %p" , __func__, &(usbdata[4 ]), recpkt);return -EINVPKT ;
@@ -462,7 +463,7 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count) usbdata[1 ] =__cpu_to_le32 (pktid); usbdata[2 ] =__cpu_to_le32 (size); -garmin_write_bulk (garmin_data_p->port, garmin_data_p->inbuffer, +garmin_write_bulk (garmin_data_p->port, garmin_data_p->inbuffer,GARMIN_PKTHDR_LENGTH +size,0 );/* if this was an abort-transfer command, flush all
@@ -495,7 +496,7 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)* if the input is an abort command, drop all queued data. */ -static int gsp_receive (struct garmin_data * garmin_data_p, +static int gsp_receive (struct garmin_data *garmin_data_p,const unsigned char *buf,int count) {unsigned long flags;
@@ -504,10 +505,11 @@ static int gsp_receive(struct garmin_data * garmin_data_p,int i =0 ;__u8 *dest;int size; -// dleSeen: set if last byte read was a DLE +/* dleSeen: set if last byte read was a DLE */ int dleSeen; -// skip: if set, skip incoming data until possible start of -// new packet +/* skip: if set, skip incoming data until possible start of +* new packet +*/ int skip;__u8 data;
@@ -521,14 +523,13 @@ static int gsp_receive(struct garmin_data * garmin_data_p,dbg ("%s - dle=%d skip=%d size=%d count=%d" , __func__, dleSeen, skip, size, count); -if (size ==0 ) { +if (size ==0 ) size =GSP_INITIAL_OFFSET ; - }while (offs < count) { data = *(buf+offs); - offs ++; + offs++;if (data ==DLE ) {if (skip) {/* start of a new pkt */
@@ -554,9 +555,8 @@ static int gsp_receive(struct garmin_data * garmin_data_p, ack_or_nak_seen =NAK ;dbg ("NAK packet complete." ); }else { -dbg ("packet complete " -"- id=0x%X." , -0xFF & data); +dbg ("packet complete - id=0x%X." , +0xFF & data);gsp_rec_packet (garmin_data_p, size); }
@@ -589,7 +589,7 @@ static int gsp_receive(struct garmin_data * garmin_data_p, garmin_data_p->insize = size; -// copy flags back to structure +/* copy flags back to structure */ if (skip) garmin_data_p->flags |=FLAGS_GSP_SKIP ;else
@@ -600,16 +600,13 @@ static int gsp_receive(struct garmin_data * garmin_data_p,else garmin_data_p->flags &= ~FLAGS_GSP_DLESEEN ; -if (ack_or_nak_seen) { +if (ack_or_nak_seen) garmin_data_p->state =STATE_GSP_WAIT_DATA ; - }spin_unlock_irqrestore (&garmin_data_p->lock, flags); -if (ack_or_nak_seen) { +if (ack_or_nak_seen)gsp_next_packet (garmin_data_p); - } -return count; }
@@ -623,7 +620,7 @@ static int gsp_receive(struct garmin_data * garmin_data_p,* * return <0 on error, 0 if packet is incomplete or > 0 if packet was sent */ -static int gsp_send (struct garmin_data * garmin_data_p, +static int gsp_send (struct garmin_data *garmin_data_p,const unsigned char *buf,int count) {const unsigned char *src;
@@ -631,11 +628,11 @@ static int gsp_send(struct garmin_data * garmin_data_p,int pktid =0 ;int datalen =0 ;int cksum =0 ; -int i=0 ; +int i =0 ;int k;dbg ("%s - state %d - %d bytes." , __func__, - garmin_data_p->state, count); + garmin_data_p->state, count); k = garmin_data_p->outsize;if ((k+count) >GPS_OUT_BUFSIZ ) {
@@ -650,7 +647,7 @@ static int gsp_send(struct garmin_data * garmin_data_p,if (k >=GARMIN_PKTHDR_LENGTH ) { pktid =getPacketId (garmin_data_p->outbuffer); - datalen=getDataLength (garmin_data_p->outbuffer); + datalen =getDataLength (garmin_data_p->outbuffer); i =GARMIN_PKTHDR_LENGTH + datalen;if (k < i)return 0 ;
@@ -658,19 +655,18 @@ static int gsp_send(struct garmin_data * garmin_data_p,return 0 ; } -dbg ("%s - %d bytes in buffer, %d bytes in pkt." , __func__, - k, i); +dbg ("%s - %d bytes in buffer, %d bytes in pkt." , __func__, k, i);/* garmin_data_p->outbuffer now contains a complete packet */ usb_serial_debug_data (debug, &garmin_data_p->port->dev, - __func__, k, garmin_data_p->outbuffer); + __func__, k, garmin_data_p->outbuffer); garmin_data_p->outsize =0 ;if (GARMIN_LAYERID_APPL !=getLayerId (garmin_data_p->outbuffer)) { -dbg ("not an application packet (%d)" , -getLayerId (garmin_data_p->outbuffer)); +dbg ("not an application packet (%d)" , +getLayerId (garmin_data_p->outbuffer));return -1 ; }
@@ -688,14 +684,14 @@ static int gsp_send(struct garmin_data * garmin_data_p, k =0 ; src = garmin_data_p->outbuffer+GARMIN_PKTHDR_LENGTH ; -for (i=0 ; i<datalen; i++) { +for (i =0 ; i < datalen; i++) {if (*src++ ==DLE ) k++; } src = garmin_data_p->outbuffer+GARMIN_PKTHDR_LENGTH ;if (k > (GARMIN_PKTHDR_LENGTH -2 )) { -/* can't add stuffing DLEs in place, move data to end +/* can't add stuffing DLEs in place, move data to end of buffer ... */ dst = garmin_data_p->outbuffer+GPS_OUT_BUFSIZ -datalen;memcpy (dst, src, datalen);
@@ -712,14 +708,14 @@ static int gsp_send(struct garmin_data * garmin_data_p,if (datalen ==DLE ) *dst++ =DLE ; -for (i=0 ; i<datalen; i++) { +for (i =0 ; i < datalen; i++) {__u8 c = *src++; *dst++ = c; cksum += c;if (c ==DLE ) *dst++ =DLE ; } - + cksum =0xFF & -cksum; *dst++ = cksum;if (cksum ==DLE )
@@ -744,7 +740,7 @@ static int gsp_send(struct garmin_data * garmin_data_p,/* * Process the next pending data packet - if there is one */ -static void gsp_next_packet (struct garmin_data * garmin_data_p) +static void gsp_next_packet (struct garmin_data *garmin_data_p) {struct garmin_packet *pkt =NULL ;
@@ -774,17 +770,17 @@ static void gsp_next_packet(struct garmin_data * garmin_data_p)* buf contains the data read, it may span more than one packet * or even incomplete packets */ -static int nat_receive (struct garmin_data * garmin_data_p, +static int nat_receive (struct garmin_data *garmin_data_p,const unsigned char *buf,int count) {unsigned long flags; -__u8 * dest; +__u8 *dest;int offs =0 ;int result = count;int len;while (offs < count) { -// if buffer contains header, copy rest of data +/* if buffer contains header, copy rest of data */ if (garmin_data_p->insize >=GARMIN_PKTHDR_LENGTH ) len =GARMIN_PKTHDR_LENGTH +getDataLength (garmin_data_p->inbuffer);
@@ -792,9 +788,9 @@ static int nat_receive(struct garmin_data * garmin_data_p, len =GARMIN_PKTHDR_LENGTH ;if (len >=GPS_IN_BUFSIZ ) { -/* seem to be an invalid packet, ignore rest of input */ -dbg ("%s - packet size too large: %d" , - __func__, len); +/* seems to be an invalid packet, ignore rest +of input */ +dbg ("%s - packet size too large: %d" , __func__, len); garmin_data_p->insize =0 ; count =0 ; result = -EINVPKT ;
@@ -804,7 +800,7 @@ static int nat_receive(struct garmin_data * garmin_data_p, len = (count-offs);if (len >0 ) { dest = garmin_data_p->inbuffer - +garmin_data_p->insize; + + garmin_data_p->insize;memcpy (dest, buf+offs, len); garmin_data_p->insize += len; offs += len;
@@ -816,17 +812,19 @@ static int nat_receive(struct garmin_data * garmin_data_p, len =GARMIN_PKTHDR_LENGTH +getDataLength (garmin_data_p->inbuffer);if (garmin_data_p->insize >= len) { -garmin_write_bulk (garmin_data_p->port, - garmin_data_p->inbuffer, - len,0 ); +garmin_write_bulk (garmin_data_p->port, + garmin_data_p->inbuffer, + len,0 ); garmin_data_p->insize =0 ;/* if this was an abort-transfer command, flush all queued data. */ if (isAbortTrfCmnd (garmin_data_p->inbuffer)) { -spin_lock_irqsave (&garmin_data_p->lock, flags); +spin_lock_irqsave (&garmin_data_p->lock, + flags); garmin_data_p->flags |=FLAGS_DROP_DATA ; -spin_unlock_irqrestore (&garmin_data_p->lock, flags); +spin_unlock_irqrestore ( + &garmin_data_p->lock, flags);pkt_clear (garmin_data_p); } }
@@ -842,7 +840,7 @@ static int nat_receive(struct garmin_data * garmin_data_p,static void priv_status_resp (struct usb_serial_port *port) { -struct garmin_data * garmin_data_p =usb_get_serial_port_data (port); +struct garmin_data *garmin_data_p =usb_get_serial_port_data (port);__le32 *pkt = (__le32 *)garmin_data_p->privpkt; pkt[0 ] =__cpu_to_le32 (GARMIN_LAYERID_PRIVATE );
@@ -852,7 +850,7 @@ static void priv_status_resp(struct usb_serial_port *port) pkt[4 ] =__cpu_to_le32 (garmin_data_p->mode); pkt[5 ] =__cpu_to_le32 (garmin_data_p->serial_num); -send_to_tty (port, (__u8 *)pkt,6 *4 ); +send_to_tty (port, (__u8 *)pkt,6 *4 ); }
@@ -864,7 +862,7 @@ static int process_resetdev_request(struct usb_serial_port *port) {unsigned long flags;int status; -struct garmin_data * garmin_data_p =usb_get_serial_port_data (port); +struct garmin_data *garmin_data_p =usb_get_serial_port_data (port);spin_lock_irqsave (&garmin_data_p->lock, flags); garmin_data_p->flags &= ~(CLEAR_HALT_REQUIRED );
@@ -872,8 +870,8 @@ static int process_resetdev_request(struct usb_serial_port *port) garmin_data_p->serial_num =0 ;spin_unlock_irqrestore (&garmin_data_p->lock, flags); -usb_kill_urb (port->interrupt_in_urb); -dbg ("%s - usb_reset_device" , __func__ ); +usb_kill_urb (port->interrupt_in_urb); +dbg ("%s - usb_reset_device" , __func__); status =usb_reset_device (port->serial->dev);if (status) dbg("%s - usb_reset_device failed: %d",
@@ -886,7 +884,7 @@ static int process_resetdev_request(struct usb_serial_port *port)/* * clear all cached data */ -static int garmin_clear (struct garmin_data * garmin_data_p) +static int garmin_clear (struct garmin_data *garmin_data_p) {unsigned long flags;int status =0 ;
@@ -896,8 +894,7 @@ static int garmin_clear(struct garmin_data * garmin_data_p)if (port !=NULL &&atomic_read (&garmin_data_p->resp_count)) {/* send a terminate command */ status =garmin_write_bulk (port,GARMIN_STOP_TRANSFER_REQ , -sizeof (GARMIN_STOP_TRANSFER_REQ ), -1 ); +sizeof (GARMIN_STOP_TRANSFER_REQ ),1 ); }/* flush all queued data */
@@ -920,28 +917,26 @@ static int garmin_init_session(struct usb_serial_port *port) {unsigned long flags;struct usb_serial *serial = port->serial; -struct garmin_data * garmin_data_p =usb_get_serial_port_data (port); +struct garmin_data *garmin_data_p =usb_get_serial_port_data (port);int status =0 ;if (status ==0 ) { -usb_kill_urb (port->interrupt_in_urb); +usb_kill_urb (port->interrupt_in_urb);dbg ("%s - adding interrupt input" , __func__); port->interrupt_in_urb->dev = serial->dev; status =usb_submit_urb (port->interrupt_in_urb,GFP_KERNEL );if (status)dev_err (&serial->dev->dev, -"%s - failed submitting interrupt urb," -" error %d\n" , - __func__, status); +"%s - failed submitting interrupt urb, error %d\n" , + __func__, status); }if (status ==0 ) {dbg ("%s - starting session ..." , __func__); garmin_data_p->state =STATE_ACTIVE ; status =garmin_write_bulk (port,GARMIN_START_SESSION_REQ , -sizeof (GARMIN_START_SESSION_REQ ), -0 ); +sizeof (GARMIN_START_SESSION_REQ ),0 );if (status >=0 ) {
@@ -951,14 +946,14 @@ static int garmin_init_session(struct usb_serial_port *port)/* not needed, but the win32 driver does it too ... */ status =garmin_write_bulk (port, -GARMIN_START_SESSION_REQ2 , -sizeof (GARMIN_START_SESSION_REQ2 ), -0 ); +GARMIN_START_SESSION_REQ2 , +sizeof (GARMIN_START_SESSION_REQ2 ),0 );if (status >=0 ) { status =0 ;spin_lock_irqsave (&garmin_data_p->lock, flags); garmin_data_p->ignorePkts++; -spin_unlock_irqrestore (&garmin_data_p->lock, flags); +spin_unlock_irqrestore (&garmin_data_p->lock, + flags); } } }
@@ -970,12 +965,12 @@ static int garmin_init_session(struct usb_serial_port *port) -static int garmin_open (struct tty_struct *tty, +static int garmin_open (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp) {unsigned long flags;int status =0 ; -struct garmin_data * garmin_data_p =usb_get_serial_port_data (port); +struct garmin_data *garmin_data_p =usb_get_serial_port_data (port);dbg ("%s - port %d" , __func__, port->number);
@@ -996,8 +991,8 @@ static int garmin_open (struct tty_struct *tty,spin_unlock_irqrestore (&garmin_data_p->lock, flags);/* shutdown any bulk reads that might be going on */ -usb_kill_urb (port->write_urb); -usb_kill_urb (port->read_urb); +usb_kill_urb (port->write_urb); +usb_kill_urb (port->read_urb);if (garmin_data_p->state ==STATE_RESET ) status =garmin_init_session (port);
@@ -1008,10 +1003,10 @@ static int garmin_open (struct tty_struct *tty,static void garmin_close (struct tty_struct *tty, -struct usb_serial_port *port,struct file * filp) +struct usb_serial_port *port,struct file *filp) {struct usb_serial *serial = port->serial; -struct garmin_data * garmin_data_p =usb_get_serial_port_data (port); +struct garmin_data *garmin_data_p =usb_get_serial_port_data (port); dbg("%s - port %d - mode=%d state=%d flags=0x%X", __func__, port->number, garmin_data_p->mode,
@@ -1025,8 +1020,8 @@ static void garmin_close(struct tty_struct *tty,garmin_clear (garmin_data_p);/* shutdown our urbs */ -usb_kill_urb (port->read_urb); -usb_kill_urb (port->write_urb); +usb_kill_urb (port->read_urb); +usb_kill_urb (port->write_urb);if (!port->serial->disconnected) { if (noResponseFromAppLayer(garmin_data_p) ||
@@ -1042,20 +1037,22 @@ static void garmin_close(struct tty_struct *tty,mutex_unlock (&port->serial->disc_mutex); } -static void garmin_write_bulk_callback (struct urb *urb) +static void garmin_write_bulk_callback (struct urb *urb) {unsigned long flags;struct usb_serial_port *port = urb->context;int status = urb->status;if (port) { -struct garmin_data * garmin_data_p =usb_get_serial_port_data (port); +struct garmin_data *garmin_data_p = +usb_get_serial_port_data (port);dbg ("%s - port %d" , __func__, port->number);if (GARMIN_LAYERID_APPL ==getLayerId (urb->transfer_buffer) && (garmin_data_p->mode ==MODE_GARMIN_SERIAL )) { -gsp_send_ack (garmin_data_p, ((__u8 *)urb->transfer_buffer)[4 ]); +gsp_send_ack (garmin_data_p, + ((__u8 *)urb->transfer_buffer)[4 ]); }if (status) {
@@ -1069,20 +1066,21 @@ static void garmin_write_bulk_callback (struct urb *urb)usb_serial_port_softint (port); } -/* Ignore errors that resulted from garmin_write_bulk with dismiss_ack=1 */ +/* Ignore errors that resulted from garmin_write_bulk with +dismiss_ack = 1 */ /* free up the transfer buffer, as usb_free_urb() does not do this */ -kfree (urb->transfer_buffer); +kfree (urb->transfer_buffer); } -static int garmin_write_bulk (struct usb_serial_port *port, +static int garmin_write_bulk (struct usb_serial_port *port,const unsigned char *buf,int count,int dismiss_ack) {unsigned long flags;struct usb_serial *serial = port->serial; -struct garmin_data * garmin_data_p =usb_get_serial_port_data (port); +struct garmin_data *garmin_data_p =usb_get_serial_port_data (port);struct urb *urb;unsigned char *buffer;int status;
@@ -1094,7 +1092,7 @@ static int garmin_write_bulk (struct usb_serial_port *port, garmin_data_p->flags &= ~FLAGS_DROP_DATA ;spin_unlock_irqrestore (&garmin_data_p->lock, flags); - buffer =kmalloc (count,GFP_ATOMIC ); + buffer =kmalloc (count,GFP_ATOMIC );if (!buffer) {dev_err (&port->dev,"out of memory\n" );return -ENOMEM ;
@@ -1103,17 +1101,17 @@ static int garmin_write_bulk (struct usb_serial_port *port, urb =usb_alloc_urb (0 ,GFP_ATOMIC );if (!urb) {dev_err (&port->dev,"no more free urbs\n" ); -kfree (buffer); +kfree (buffer);return -ENOMEM ; } -memcpy (buffer, buf, count); +memcpy (buffer, buf, count);usb_serial_debug_data (debug, &port->dev, __func__, count, buffer); -usb_fill_bulk_urb (urb, serial->dev, -usb_sndbulkpipe (serial->dev, - port->bulk_out_endpointAddress), +usb_fill_bulk_urb (urb, serial->dev, +usb_sndbulkpipe (serial->dev, + port->bulk_out_endpointAddress), buffer, count, garmin_write_bulk_callback, dismiss_ack ?NULL : port);
@@ -1131,24 +1129,23 @@ static int garmin_write_bulk (struct usb_serial_port *port, status =usb_submit_urb (urb,GFP_ATOMIC );if (status) {dev_err (&port->dev, -"%s - usb_submit_urb(write bulk) " -"failed with status = %d\n" , +"%s - usb_submit_urb(write bulk) failed with status = %d\n" , __func__, status); count = status; }/* we are done with this urb, so let the host driver * really free it when it is finished with it */ -usb_free_urb (urb); +usb_free_urb (urb);return count; } -static int garmin_write (struct tty_struct *tty,struct usb_serial_port *port, +static int garmin_write (struct tty_struct *tty,struct usb_serial_port *port,const unsigned char *buf,int count) {int pktid, pktsiz, len; -struct garmin_data * garmin_data_p =usb_get_serial_port_data (port); +struct garmin_data *garmin_data_p =usb_get_serial_port_data (port);__le32 *privpkt = (__le32 *)garmin_data_p->privpkt;usb_serial_debug_data (debug, &port->dev, __func__, count, buf);
@@ -1165,15 +1162,16 @@ static int garmin_write (struct tty_struct *tty, struct usb_serial_port *port, pktid =getPacketId (garmin_data_p->privpkt);if (count == (GARMIN_PKTHDR_LENGTH +pktsiz) - &&GARMIN_LAYERID_PRIVATE ==getLayerId (garmin_data_p->privpkt)) { + &&GARMIN_LAYERID_PRIVATE == +getLayerId (garmin_data_p->privpkt)) {dbg ("%s - processing private request %d" , __func__, pktid); -// drop all unfinished transfers +/* drop all unfinished transfers */ garmin_clear (garmin_data_p); -switch (pktid) { +switch (pktid) {case PRIV_PKTID_SET_DEBUG :if (pktsiz !=4 )
@@ -1228,25 +1226,25 @@ static int garmin_write_room(struct tty_struct *tty)/* * Report back the bytes currently available in the output buffer. */ -struct garmin_data * garmin_data_p =usb_get_serial_port_data (port); +struct garmin_data *garmin_data_p =usb_get_serial_port_data (port);return GPS_OUT_BUFSIZ -garmin_data_p->outsize; } -static void garmin_read_process (struct garmin_data * garmin_data_p, +static void garmin_read_process (struct garmin_data *garmin_data_p,unsigned char *data,unsigned data_length) {if (garmin_data_p->flags &FLAGS_DROP_DATA ) {/* abort-transfer cmd is actice */ dbg ("%s - pkt dropped" , __func__); }else if (garmin_data_p->state !=STATE_DISCONNECTED && - garmin_data_p->state !=STATE_RESET ) { + garmin_data_p->state !=STATE_RESET ) {/* remember any appl.layer packets, so we know if a reset is required or not when closing the device */ if (0 ==memcmp (data,GARMIN_APP_LAYER_REPLY , -sizeof (GARMIN_APP_LAYER_REPLY ))) { +sizeof (GARMIN_APP_LAYER_REPLY ))) {atomic_inc (&garmin_data_p->resp_count); }
@@ -1256,9 +1254,8 @@ static void garmin_read_process(struct garmin_data * garmin_data_p,if (garmin_data_p->flags &FLAGS_QUEUING ) {pkt_add (garmin_data_p, data, data_length); }else if (garmin_data_p->mode ==MODE_GARMIN_SERIAL ) { -if (getLayerId (data) ==GARMIN_LAYERID_APPL ) { +if (getLayerId (data) ==GARMIN_LAYERID_APPL )pkt_add (garmin_data_p, data, data_length); - } }else {send_to_tty (garmin_data_p->port, data, data_length); }
@@ -1266,12 +1263,12 @@ static void garmin_read_process(struct garmin_data * garmin_data_p, } -static void garmin_read_bulk_callback (struct urb *urb) +static void garmin_read_bulk_callback (struct urb *urb) {unsigned long flags;struct usb_serial_port *port = urb->context;struct usb_serial *serial = port->serial; -struct garmin_data * garmin_data_p =usb_get_serial_port_data (port); +struct garmin_data *garmin_data_p =usb_get_serial_port_data (port);unsigned char *data = urb->transfer_buffer;int status = urb->status;int retval;
@@ -1289,7 +1286,7 @@ static void garmin_read_bulk_callback (struct urb *urb)return ; } -usb_serial_debug_data (debug, &port->dev, +usb_serial_debug_data (debug, &port->dev, __func__, urb->actual_length, data);garmin_read_process (garmin_data_p, data, urb->actual_length);
@@ -1323,13 +1320,13 @@ static void garmin_read_bulk_callback (struct urb *urb) } -static void garmin_read_int_callback (struct urb *urb) +static void garmin_read_int_callback (struct urb *urb) {unsigned long flags;int retval;struct usb_serial_port *port = urb->context;struct usb_serial *serial = port->serial; -struct garmin_data * garmin_data_p =usb_get_serial_port_data (port); +struct garmin_data *garmin_data_p =usb_get_serial_port_data (port);unsigned char *data = urb->transfer_buffer;int status = urb->status;
@@ -1355,30 +1352,31 @@ static void garmin_read_int_callback (struct urb *urb)if (urb->actual_length ==sizeof (GARMIN_BULK_IN_AVAIL_REPLY ) &&0 ==memcmp (data,GARMIN_BULK_IN_AVAIL_REPLY , -sizeof (GARMIN_BULK_IN_AVAIL_REPLY ))) { +sizeof (GARMIN_BULK_IN_AVAIL_REPLY ))) {dbg ("%s - bulk data available." , __func__);if (0 == (garmin_data_p->flags &FLAGS_BULK_IN_ACTIVE )) {/* bulk data available */ -usb_fill_bulk_urb (port->read_urb, serial->dev, -usb_rcvbulkpipe (serial->dev, - port->bulk_in_endpointAddress), +usb_fill_bulk_urb (port->read_urb, serial->dev, +usb_rcvbulkpipe (serial->dev, + port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, garmin_read_bulk_callback, port); retval =usb_submit_urb (port->read_urb,GFP_ATOMIC );if (retval) {dev_err (&port->dev, -"%s - failed submitting read urb, error %d\n" , - __func__, retval); +"%s - failed submitting read urb, error %d\n" , + __func__, retval); }else {spin_lock_irqsave (&garmin_data_p->lock, flags); garmin_data_p->flags |=FLAGS_BULK_IN_ACTIVE ;/* do not send this packet to the user */ garmin_data_p->ignorePkts =1 ; -spin_unlock_irqrestore (&garmin_data_p->lock, flags); +spin_unlock_irqrestore (&garmin_data_p->lock, + flags); } }else {/* bulk-in transfer still active */
@@ -1389,15 +1387,15 @@ static void garmin_read_int_callback (struct urb *urb) }else if (urb->actual_length == (4 +sizeof (GARMIN_START_SESSION_REPLY )) &&0 ==memcmp (data,GARMIN_START_SESSION_REPLY , -sizeof (GARMIN_START_SESSION_REPLY ))) { +sizeof (GARMIN_START_SESSION_REPLY ))) {spin_lock_irqsave (&garmin_data_p->lock, flags); garmin_data_p->flags |=FLAGS_SESSION_REPLY1_SEEN ;spin_unlock_irqrestore (&garmin_data_p->lock, flags);/* save the serial number */ - garmin_data_p->serial_num - =__le32_to_cpup ((__le32 *)(data+GARMIN_PKTHDR_LENGTH )); + garmin_data_p->serial_num =__le32_to_cpup ( + (__le32 *)(data+GARMIN_PKTHDR_LENGTH ));dbg ("%s - start-of-session reply seen - serial %u." , __func__, garmin_data_p->serial_num);
@@ -1416,7 +1414,7 @@ static void garmin_read_int_callback (struct urb *urb) } port->interrupt_in_urb->dev = port->serial->dev; - retval =usb_submit_urb (urb,GFP_ATOMIC ); + retval =usb_submit_urb (urb,GFP_ATOMIC );if (retval) dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n",
@@ -1429,7 +1427,7 @@ static void garmin_read_int_callback (struct urb *urb)* and then sets a timer to call itself again until all queued data * is sent. */ -static int garmin_flush_queue (struct garmin_data * garmin_data_p) +static int garmin_flush_queue (struct garmin_data *garmin_data_p) {unsigned long flags;struct garmin_packet *pkt;
@@ -1454,7 +1452,7 @@ static int garmin_flush_queue(struct garmin_data * garmin_data_p)static void garmin_throttle (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data; -struct garmin_data * garmin_data_p =usb_get_serial_port_data (port); +struct garmin_data *garmin_data_p =usb_get_serial_port_data (port);unsigned long flags;dbg ("%s - port %d" , __func__, port->number);
@@ -1466,10 +1464,10 @@ static void garmin_throttle(struct tty_struct *tty) } -static void garmin_unthrottle (struct tty_struct *tty) +static void garmin_unthrottle (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data; -struct garmin_data * garmin_data_p =usb_get_serial_port_data (port); +struct garmin_data *garmin_data_p =usb_get_serial_port_data (port);unsigned long flags;int status;
@@ -1513,7 +1511,7 @@ static int garmin_attach(struct usb_serial *serial) {int status =0 ;struct usb_serial_port *port = serial->port[0 ]; -struct garmin_data * garmin_data_p =NULL ; +struct garmin_data *garmin_data_p =NULL ;dbg ("%s" , __func__);
@@ -1525,7 +1523,7 @@ static int garmin_attach(struct usb_serial *serial)init_timer (&garmin_data_p->timer);spin_lock_init (&garmin_data_p->lock);INIT_LIST_HEAD (&garmin_data_p->pktlist); -//garmin_data_p->timer.expires = jiffies + session_timeout; +/* garmin_data_p->timer.expires = jiffies + session_timeout; */ garmin_data_p->timer.data = (unsigned long )garmin_data_p; garmin_data_p->timer.function = timeout_handler; garmin_data_p->port = port;
@@ -1542,13 +1540,13 @@ static int garmin_attach(struct usb_serial *serial)static void garmin_shutdown (struct usb_serial *serial) {struct usb_serial_port *port = serial->port[0 ]; -struct garmin_data * garmin_data_p =usb_get_serial_port_data (port); +struct garmin_data *garmin_data_p =usb_get_serial_port_data (port);dbg ("%s" , __func__); -usb_kill_urb (port->interrupt_in_urb); +usb_kill_urb (port->interrupt_in_urb);del_timer_sync (&garmin_data_p->timer); -kfree (garmin_data_p); +kfree (garmin_data_p);usb_set_serial_port_data (port,NULL ); }
@@ -1578,7 +1576,7 @@ static struct usb_serial_driver garmin_device = { -static int __init garmin_init (void ) +static int __init garmin_init (void ) {int retval;
@@ -1598,10 +1596,10 @@ failed_garmin_register: } -static void __exit garmin_exit (void) +static void __exit garmin_exit(void) { -usb_deregister (&garmin_driver); -usb_serial_deregister (&garmin_device); +usb_deregister (&garmin_driver); +usb_serial_deregister (&garmin_device); }
@@ -1610,8 +1608,8 @@ static void __exit garmin_exit (void)module_init (garmin_init);module_exit (garmin_exit); -MODULE_AUTHOR (DRIVER_AUTHOR ); -MODULE_DESCRIPTION (DRIVER_DESC ); +MODULE_AUTHOR (DRIVER_AUTHOR ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );module_param (debug, bool,S_IWUSR |S_IRUGO );
PATCH 39/70 tty-usb-generic: Code cleanup
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/generic.c | 87 ++++++++++++++++++++++++------------------ 1 files changed, 49 insertions(+), 38 deletions(-)
drivers/usb/serial/generic.c +49 -38
@@ -18,7 +18,7 @@#include <linux/moduleparam.h> #include <linux/usb.h> #include <linux/usb/serial.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> static int debug;
@@ -81,7 +81,7 @@ static int generic_probe(struct usb_interface *interface, }#endif -int usb_serial_generic_register (int _debug) +int usb_serial_generic_register (int _debug) {int retval =0 ;
@@ -89,10 +89,11 @@ int usb_serial_generic_register (int _debug)#ifdef CONFIG_USB_SERIAL_GENERIC generic_device_ids[0 ].idVendor = vendor; generic_device_ids[0 ].idProduct = product; - generic_device_ids[0 ].match_flags =USB_DEVICE_ID_MATCH_VENDOR |USB_DEVICE_ID_MATCH_PRODUCT ; + generic_device_ids[0 ].match_flags = +USB_DEVICE_ID_MATCH_VENDOR |USB_DEVICE_ID_MATCH_PRODUCT ;/* register our generic driver with ourselves */ - retval =usb_serial_register (&usb_serial_generic_device); + retval =usb_serial_register (&usb_serial_generic_device);if (retval) goto exit; retval =usb_register (&generic_driver);
@@ -103,12 +104,12 @@ exit:return retval; } -void usb_serial_generic_deregister (void ) +void usb_serial_generic_deregister (void ) {#ifdef CONFIG_USB_SERIAL_GENERIC /* remove our generic driver */ usb_deregister (&generic_driver); -usb_serial_deregister (&usb_serial_generic_device); +usb_serial_deregister (&usb_serial_generic_device);#endif }
@@ -121,9 +122,9 @@ int usb_serial_generic_open(struct tty_struct *tty,dbg ("%s - port %d" , __func__, port->number); -/* force low_latency on so that our tty_push actually forces the data through, -otherwise it is scheduled, and with high data rates (like with OHCI) data -can get lost. */ +/* force low_latency on so that our tty_push actually forces the data +through, otherwise it is scheduled, and with high data rates (like +with OHCI) data can get lost. */ if (tty) tty->low_latency =1 ;
@@ -136,8 +137,9 @@ int usb_serial_generic_open(struct tty_struct *tty,/* if we have a bulk endpoint, start reading from it */ if (serial->num_bulk_in) {/* Start reading from the device */ - usb_fill_bulk_urb (port->read_urb, serial->dev, - usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), + usb_fill_bulk_urb(port->read_urb, serial->dev, + usb_rcvbulkpipe(serial->dev, + port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, ((serial->type->read_bulk_callback) ?
@@ -146,7 +148,9 @@ int usb_serial_generic_open(struct tty_struct *tty, port); result =usb_submit_urb (port->read_urb,GFP_KERNEL );if (result) -dev_err (&port->dev,"%s - failed resubmitting read urb, error %d\n" , __func__, result); +dev_err (&port->dev, +"%s - failed resubmitting read urb, error %d\n" , + __func__, result); }return result;
@@ -194,10 +198,10 @@ int usb_serial_generic_resume(struct usb_serial *serial) }void usb_serial_generic_close (struct tty_struct *tty, -struct usb_serial_port *port,struct file * filp) +struct usb_serial_port *port,struct file *filp) {dbg ("%s - port %d" , __func__, port->number); -generic_cleanup (port); +generic_cleanup (port); } int usb_serial_generic_write(struct tty_struct *tty,
@@ -211,7 +215,7 @@ int usb_serial_generic_write(struct tty_struct *tty,if (count ==0 ) {dbg ("%s - write request of 0 bytes" , __func__); -return (0 ); +return 0 ; }/* only do something if we have a bulk out endpoint */
@@ -226,27 +230,32 @@ int usb_serial_generic_write(struct tty_struct *tty, port->write_urb_busy =1 ;spin_unlock_irqrestore (&port->lock, flags); - count = (count > port->bulk_out_size) ? port->bulk_out_size : count; + count = (count > port->bulk_out_size) ? + port->bulk_out_size : count; -memcpy (port->write_urb->transfer_buffer, buf, count); +memcpy (port->write_urb->transfer_buffer, buf, count); data = port->write_urb->transfer_buffer;usb_serial_debug_data (debug, &port->dev, __func__, count, data);/* set up our urb */ -usb_fill_bulk_urb (port->write_urb, serial->dev, -usb_sndbulkpipe (serial->dev, - port->bulk_out_endpointAddress), +usb_fill_bulk_urb (port->write_urb, serial->dev, +usb_sndbulkpipe (serial->dev, + port->bulk_out_endpointAddress), port->write_urb->transfer_buffer, count, - ((serial->type->write_bulk_callback) ? + ((serial->type->write_bulk_callback) ? serial->type->write_bulk_callback : - usb_serial_generic_write_bulk_callback), port); + usb_serial_generic_write_bulk_callback), + port);/* send the data out the bulk port */ port->write_urb_busy =1 ; result =usb_submit_urb (port->write_urb,GFP_ATOMIC );if (result) { -dev_err (&port->dev,"%s - failed submitting write urb, error %d\n" , __func__, result); -/* don't have to grab the lock here, as we will retry if != 0 */ +dev_err (&port->dev, +"%s - failed submitting write urb, error %d\n" , + __func__, result); +/* don't have to grab the lock here, as we will +retry if != 0 */ port->write_urb_busy =0 ; }else result = count;
@@ -258,7 +267,7 @@ int usb_serial_generic_write(struct tty_struct *tty,return 0 ; } -int usb_serial_generic_write_room (struct tty_struct *tty) +int usb_serial_generic_write_room (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;struct usb_serial *serial = port->serial;
@@ -302,17 +311,19 @@ static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags)int result;/* Continue reading from device */ -usb_fill_bulk_urb (urb, serial->dev, -usb_rcvbulkpipe (serial->dev, - port->bulk_in_endpointAddress), +usb_fill_bulk_urb (urb, serial->dev, +usb_rcvbulkpipe (serial->dev, + port->bulk_in_endpointAddress), urb->transfer_buffer, urb->transfer_buffer_length, - ((serial->type->read_bulk_callback) ? - serial->type->read_bulk_callback : + ((serial->type->read_bulk_callback) ? + serial->type->read_bulk_callback : usb_serial_generic_read_bulk_callback), port); result =usb_submit_urb (urb, mem_flags);if (result) -dev_err (&port->dev,"%s - failed resubmitting read urb, error %d\n" , __func__, result); +dev_err (&port->dev, +"%s - failed resubmitting read urb, error %d\n" , + __func__, result); }/* Push data to tty layer and resubmit the bulk read URB */
@@ -349,16 +360,17 @@ void usb_serial_generic_read_bulk_callback(struct urb *urb)return ; } -usb_serial_debug_data (debug, &port->dev, __func__, urb->actual_length, data); +usb_serial_debug_data (debug, &port->dev, __func__, + urb->actual_length, data);/* Throttle the device if requested by tty */ spin_lock_irqsave (&port->lock, flags); -if (!(port->throttled = port->throttle_req)) { + port->throttled = port->throttle_req; +if (!port->throttled) {spin_unlock_irqrestore (&port->lock, flags);flush_and_resubmit_read_urb (port); - }else { + }else spin_unlock_irqrestore (&port->lock, flags); - } }EXPORT_SYMBOL_GPL (usb_serial_generic_read_bulk_callback);
@@ -413,15 +425,14 @@ void usb_serial_generic_unthrottle(struct tty_struct *tty) } } -void usb_serial_generic_shutdown (struct usb_serial *serial) +void usb_serial_generic_shutdown (struct usb_serial *serial) {int i;dbg ("%s" , __func__);/* stop reads and writes on all ports */ -for (i=0 ; i < serial->num_ports; ++i) { +for (i =0 ; i < serial->num_ports; ++i)generic_cleanup (serial->port[i]); - } }
PATCH 40/70 tty-usb-hp4x: Fix overlong line
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/hp4x.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/usb/serial/hp4x.c +2 -1
@@ -9,7 +9,8 @@* the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * -* See Documentation/usb/usb-serial.txt for more information on using this driver +* See Documentation/usb/usb-serial.txt for more information on using this +* driver */ #include <linux/kernel.h>
PATCH 41/70 tty-usb-visor: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/visor.c | 340 +++++++++++++++++++++++++------------------- 1 files changed, 191 insertions(+), 149 deletions(-)
drivers/usb/serial/visor.c +191 -149
@@ -9,7 +9,8 @@* modify it under the terms of the GNU General Public License version * 2 as published by the Free Software Foundation. * -* See Documentation/usb/usb-serial.txt for more information on using this driver +* See Documentation/usb/usb-serial.txt for more information on using this +* driver * */
@@ -23,7 +24,7 @@#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/spinlock.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/usb/serial.h> #include "visor.h"
@@ -35,23 +36,29 @@#define DRIVER_DESC "USB HandSpring Visor / Palm OS driver"/* function prototypes for a handspring visor */ -static int visor_open (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp); -static void visor_close (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp); -static int visor_write (struct tty_struct *tty,struct usb_serial_port *port,const unsigned char *buf,int count); -static int visor_write_room (struct tty_struct *tty); -static void visor_throttle (struct tty_struct *tty); -static void visor_unthrottle (struct tty_struct *tty); -static int visor_probe (struct usb_serial *serial,const struct usb_device_id *id); +static int visor_open (struct tty_struct *tty,struct usb_serial_port *port, +struct file *filp); +static void visor_close (struct tty_struct *tty,struct usb_serial_port *port, +struct file *filp); +static int visor_write (struct tty_struct *tty,struct usb_serial_port *port, +const unsigned char *buf,int count); +static int visor_write_room (struct tty_struct *tty); +static void visor_throttle (struct tty_struct *tty); +static void visor_unthrottle (struct tty_struct *tty); +static int visor_probe (struct usb_serial *serial, +const struct usb_device_id *id);static int visor_calc_num_ports (struct usb_serial *serial); -static void visor_shutdown (struct usb_serial *serial); -static void visor_write_bulk_callback (struct urb *urb); -static void visor_read_bulk_callback (struct urb *urb); -static void visor_read_int_callback (struct urb *urb); -static int clie_3_5_startup (struct usb_serial *serial); -static int treo_attach (struct usb_serial *serial); -static int clie_5_attach (struct usb_serial *serial); -static int palm_os_3_probe (struct usb_serial *serial,const struct usb_device_id *id); -static int palm_os_4_probe (struct usb_serial *serial,const struct usb_device_id *id); +static void visor_shutdown (struct usb_serial *serial); +static void visor_write_bulk_callback (struct urb *urb); +static void visor_read_bulk_callback (struct urb *urb); +static void visor_read_int_callback (struct urb *urb); +static int clie_3_5_startup (struct usb_serial *serial); +static int treo_attach (struct usb_serial *serial); +static int clie_5_attach (struct usb_serial *serial); +static int palm_os_3_probe (struct usb_serial *serial, +const struct usb_device_id *id); +static int palm_os_4_probe (struct usb_serial *serial, +const struct usb_device_id *id);/* Parameters that may be passed into the module. */ static int debug;
@@ -103,13 +110,13 @@ static struct usb_device_id id_table [] = { .driver_info = (kernel_ulong_t)&palm_os_4_probe }, { USB_DEVICE(ACER_VENDOR_ID, ACER_S10_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe }, - { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID), + { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe }, - { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID), + { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe }, { USB_DEVICE(TAPWAVE_VENDOR_ID, TAPWAVE_ZODIAC_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe }, - { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID), + { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe }, { USB_DEVICE(ACEECA_VENDOR_ID, ACEECA_MEZ1000_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe },
@@ -168,7 +175,7 @@ static struct usb_device_id id_table_combined [] = { { }/* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE (usb, id_table_combined);static struct usb_driver visor_driver = { .name ="visor" ,
@@ -178,7 +185,8 @@ static struct usb_driver visor_driver = { .no_dynamic_id = 1, }; -/* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */ +/* All of the device info needed for the Handspring Visor, +and Palm 4.0 devices */ static struct usb_serial_driver handspring_device = { .driver = { .owner =THIS_MODULE ,
@@ -266,7 +274,8 @@ static int stats;/****************************************************************************** * Handspring Visor specific driver functions ******************************************************************************/ -static int visor_open (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp) +static int visor_open (struct tty_struct *tty,struct usb_serial_port *port, +struct file *filp) {struct usb_serial *serial = port->serial;struct visor_private *priv =usb_get_serial_port_data (port);
@@ -296,39 +305,41 @@ static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, str tty->low_latency =1 ;/* Start reading from the device */ -usb_fill_bulk_urb (port->read_urb, serial->dev, -usb_rcvbulkpipe (serial->dev, +usb_fill_bulk_urb (port->read_urb, serial->dev, +usb_rcvbulkpipe (serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, visor_read_bulk_callback, port); result =usb_submit_urb (port->read_urb,GFP_KERNEL );if (result) { -dev_err (&port->dev,"%s - failed submitting read urb, error %d\n" , - __func__, result); +dev_err (&port->dev, +"%s - failed submitting read urb, error %d\n" , + __func__, result); goto exit; } - +if (port->interrupt_in_urb) {dbg ("%s - adding interrupt input for treo" , __func__); result =usb_submit_urb (port->interrupt_in_urb,GFP_KERNEL );if (result) -dev_err (&port->dev,"%s - failed submitting interrupt urb, error %d\n" , - __func__, result); +dev_err (&port->dev, +"%s - failed submitting interrupt urb, error %d\n" , + __func__, result); } -exit: +exit:return result; }static void visor_close (struct tty_struct *tty, -struct usb_serial_port *port,struct file * filp) +struct usb_serial_port *port,struct file *filp) {struct visor_private *priv =usb_get_serial_port_data (port);unsigned char *transfer_buffer;dbg ("%s - port %d" , __func__, port->number); - +/* shutdown our urbs */ usb_kill_urb (port->read_urb);usb_kill_urb (port->interrupt_in_urb);
@@ -336,14 +347,14 @@ static void visor_close(struct tty_struct *tty,mutex_lock (&port->serial->disc_mutex);if (!port->serial->disconnected) {/* Try to send shutdown message, unless the device is gone */ - transfer_buffer =kmalloc (0x12 ,GFP_KERNEL ); + transfer_buffer =kmalloc (0x12 ,GFP_KERNEL );if (transfer_buffer) { -usb_control_msg (port->serial->dev, +usb_control_msg (port->serial->dev,usb_rcvctrlpipe (port->serial->dev,0 ),VISOR_CLOSE_NOTIFICATION ,0xc2 ,0x0000 ,0x0000 , transfer_buffer,0x12 ,300 ); -kfree (transfer_buffer); +kfree (transfer_buffer); } }mutex_unlock (&port->serial->disc_mutex);
@@ -375,7 +386,7 @@ static int visor_write(struct tty_struct *tty, struct usb_serial_port *port, priv->outstanding_urbs++;spin_unlock_irqrestore (&priv->lock, flags); - buffer =kmalloc (count,GFP_ATOMIC ); + buffer =kmalloc (count,GFP_ATOMIC );if (!buffer) {dev_err (&port->dev,"out of memory\n" ); count = -ENOMEM ;
@@ -389,21 +400,22 @@ static int visor_write(struct tty_struct *tty, struct usb_serial_port *port, goto error_no_urb; } -memcpy (buffer, buf, count); +memcpy (buffer, buf, count);usb_serial_debug_data (debug, &port->dev, __func__, count, buffer); -usb_fill_bulk_urb (urb, serial->dev, -usb_sndbulkpipe (serial->dev, +usb_fill_bulk_urb (urb, serial->dev, +usb_sndbulkpipe (serial->dev, port->bulk_out_endpointAddress), - buffer, count, + buffer, count, visor_write_bulk_callback, port);/* send it down the pipe */ status =usb_submit_urb (urb,GFP_ATOMIC );if (status) { -dev_err (&port->dev,"%s - usb_submit_urb(write bulk) failed with status = %d\n" , - __func__, status); +dev_err (&port->dev, +"%s - usb_submit_urb(write bulk) failed with status = %d\n" , + __func__, status); count = status; goto error; }else {
@@ -429,7 +441,7 @@ error_no_buffer: } -static int visor_write_room (struct tty_struct *tty) +static int visor_write_room (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;struct visor_private *priv =usb_get_serial_port_data (port);
@@ -455,7 +467,7 @@ static int visor_write_room (struct tty_struct *tty) } -static void visor_write_bulk_callback (struct urb *urb) +static void visor_write_bulk_callback (struct urb *urb) {struct usb_serial_port *port = urb->context;struct visor_private *priv =usb_get_serial_port_data (port);
@@ -463,7 +475,7 @@ static void visor_write_bulk_callback (struct urb *urb)unsigned long flags;/* free up the transfer buffer, as usb_free_urb() does not do this */ -kfree (urb->transfer_buffer); +kfree (urb->transfer_buffer);dbg ("%s - port %d" , __func__, port->number);
@@ -479,7 +491,7 @@ static void visor_write_bulk_callback (struct urb *urb) } -static void visor_read_bulk_callback (struct urb *urb) +static void visor_read_bulk_callback (struct urb *urb) {struct usb_serial_port *port = urb->context;struct visor_private *priv =usb_get_serial_port_data (port);
@@ -497,11 +509,13 @@ static void visor_read_bulk_callback (struct urb *urb)return ; } -usb_serial_debug_data (debug, &port->dev, __func__, urb->actual_length, data); +usb_serial_debug_data (debug, &port->dev, __func__, + urb->actual_length, data); tty = port->port.tty;if (tty && urb->actual_length) { - available_room =tty_buffer_request_room (tty, urb->actual_length); + available_room =tty_buffer_request_room (tty, + urb->actual_length);if (available_room) {tty_insert_flip_string (tty, data, available_room);tty_flip_buffer_push (tty);
@@ -515,22 +529,23 @@ static void visor_read_bulk_callback (struct urb *urb)/* Continue trying to always read if we should */ if (!priv->throttled) { -usb_fill_bulk_urb (port->read_urb, port->serial->dev, +usb_fill_bulk_urb (port->read_urb, port->serial->dev,usb_rcvbulkpipe (port->serial->dev, - port->bulk_in_endpointAddress), + port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, visor_read_bulk_callback, port); result =usb_submit_urb (port->read_urb,GFP_ATOMIC );if (result) -dev_err (&port->dev,"%s - failed resubmitting read urb, error %d\n" , __func__, result); - }else { +dev_err (&port->dev, +"%s - failed resubmitting read urb, error %d\n" , + __func__, result); + }else priv->actually_throttled =1 ; - }spin_unlock (&priv->lock); } -static void visor_read_int_callback (struct urb *urb) +static void visor_read_int_callback (struct urb *urb) {struct usb_serial_port *port = urb->context;int status = urb->status;
@@ -564,13 +579,14 @@ static void visor_read_int_callback (struct urb *urb) urb->actual_length, urb->transfer_buffer); exit: - result =usb_submit_urb (urb,GFP_ATOMIC ); + 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 (&urb->dev->dev, +"%s - Error %d submitting interrupt urb\n" , + __func__, result); } -static void visor_throttle (struct tty_struct *tty) +static void visor_throttle (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;struct visor_private *priv =usb_get_serial_port_data (port);
@@ -583,7 +599,7 @@ static void visor_throttle (struct tty_struct *tty) } -static void visor_unthrottle (struct tty_struct *tty) +static void visor_unthrottle (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;struct visor_private *priv =usb_get_serial_port_data (port);
@@ -599,10 +615,13 @@ static void visor_unthrottle (struct tty_struct *tty) port->read_urb->dev = port->serial->dev; result =usb_submit_urb (port->read_urb,GFP_ATOMIC );if (result) -dev_err (&port->dev,"%s - failed submitting read urb, error %d\n" , __func__, result); +dev_err (&port->dev, +"%s - failed submitting read urb, error %d\n" , + __func__, result); } -static int palm_os_3_probe (struct usb_serial *serial,const struct usb_device_id *id) +static int palm_os_3_probe (struct usb_serial *serial, +const struct usb_device_id *id) {struct device *dev = &serial->dev->dev;struct visor_connection_info *connection_info;
@@ -614,7 +633,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_idbg ("%s" , __func__); - transfer_buffer =kmalloc (sizeof (*connection_info),GFP_KERNEL ); + transfer_buffer =kmalloc (sizeof (*connection_info),GFP_KERNEL );if (!transfer_buffer) {dev_err (dev,"%s - kmalloc(%Zd) failed.\n" , __func__,sizeof (*connection_info));
@@ -622,7 +641,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i }/* send a get connection info request */ - retval = usb_control_msg (serial->dev, + retval = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), VISOR_GET_CONNECTION_INFORMATION, 0xc2, 0x0000, 0x0000, transfer_buffer,
@@ -634,29 +653,31 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i }if (retval ==sizeof (*connection_info)) { - connection_info = (struct visor_connection_info *)transfer_buffer; + connection_info = (struct visor_connection_info *) + transfer_buffer; num_ports =le16_to_cpu (connection_info->num_ports);for (i =0 ; i < num_ports; ++i) { -switch (connection_info->connections[i].port_function_id) { -case VISOR_FUNCTION_GENERIC : - string ="Generic" ; -break ; -case VISOR_FUNCTION_DEBUGGER : - string ="Debugger" ; -break ; -case VISOR_FUNCTION_HOTSYNC : - string ="HotSync" ; -break ; -case VISOR_FUNCTION_CONSOLE : - string ="Console" ; -break ; -case VISOR_FUNCTION_REMOTE_FILE_SYS : - string ="Remote File System" ; -break ; -default : - string ="unknown" ; -break ; +switch ( + connection_info->connections[i].port_function_id) { +case VISOR_FUNCTION_GENERIC : + string ="Generic" ; +break ; +case VISOR_FUNCTION_DEBUGGER : + string ="Debugger" ; +break ; +case VISOR_FUNCTION_HOTSYNC : + string ="HotSync" ; +break ; +case VISOR_FUNCTION_CONSOLE : + string ="Console" ; +break ; +case VISOR_FUNCTION_REMOTE_FILE_SYS : + string ="Remote File System" ; +break ; +default : + string ="unknown" ; +break ; } dev_info(dev, "%s: port %d, is for %s use\n", serial->type->description,
@@ -667,11 +688,11 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i* Handle devices that report invalid stuff here. */ if (num_ports ==0 || num_ports >2 ) { -dev_warn (dev,"%s: No valid connect info available\n" , +dev_warn (dev,"%s: No valid connect info available\n" , serial->type->description); num_ports =2 ; } - +dev_info (dev,"%s: Number of ports: %d\n" , serial->type->description, num_ports);
@@ -681,8 +702,9 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i*/ usb_set_serial_data (serial, (void *)(long )num_ports); -/* ask for the number of bytes available, but ignore the response as it is broken */ - retval = usb_control_msg (serial->dev, +/* ask for the number of bytes available, but ignore the +response as it is broken */ + retval = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), VISOR_REQUEST_BYTES_AVAILABLE, 0xc2, 0x0000, 0x0005, transfer_buffer,
@@ -693,12 +715,13 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i retval =0 ; exit: -kfree (transfer_buffer); +kfree (transfer_buffer);return retval; } -static int palm_os_4_probe (struct usb_serial *serial,const struct usb_device_id *id) +static int palm_os_4_probe (struct usb_serial *serial, +const struct usb_device_id *id) {struct device *dev = &serial->dev->dev;struct palm_ext_connection_info *connection_info;
@@ -707,18 +730,18 @@ static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_idbg ("%s" , __func__); - transfer_buffer =kmalloc (sizeof (*connection_info),GFP_KERNEL ); + transfer_buffer =kmalloc (sizeof (*connection_info),GFP_KERNEL );if (!transfer_buffer) {dev_err (dev,"%s - kmalloc(%Zd) failed.\n" , __func__,sizeof (*connection_info));return -ENOMEM ; } - retval =usb_control_msg (serial->dev, -usb_rcvctrlpipe (serial->dev,0 ), + retval =usb_control_msg (serial->dev, +usb_rcvctrlpipe (serial->dev,0 ),PALM_GET_EXT_CONNECTION_INFORMATION ,0xc2 ,0x0000 ,0x0000 , transfer_buffer, -sizeof (*connection_info),300 ); +sizeof (*connection_info),300 );if (retval <0 )dev_err (dev,"%s - error %d getting connection info\n" , __func__, retval);
@@ -726,15 +749,17 @@ static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_iusb_serial_debug_data (debug, &serial->dev->dev, __func__, retval, transfer_buffer); -kfree (transfer_buffer); +kfree (transfer_buffer);return 0 ; } -static int visor_probe (struct usb_serial *serial,const struct usb_device_id *id) +static int visor_probe (struct usb_serial *serial, +const struct usb_device_id *id) {int retval =0 ; -int (*startup) (struct usb_serial *serial,const struct usb_device_id *id); +int (*startup)(struct usb_serial *serial, +const struct usb_device_id *id);dbg ("%s" , __func__);
@@ -752,7 +777,7 @@ static int visor_probe (struct usb_serial *serial, const struct usb_device_id *ireturn retval; } -static int visor_calc_num_ports (struct usb_serial *serial) +static int visor_calc_num_ports (struct usb_serial *serial) {int num_ports = (int )(long )(usb_get_serial_data (serial));
@@ -769,7 +794,7 @@ static int generic_startup(struct usb_serial *serial)int i;for (i =0 ; i < serial->num_ports; ++i) { - priv =kzalloc (sizeof (*priv),GFP_KERNEL ); + priv =kzalloc (sizeof (*priv),GFP_KERNEL );if (!priv) {while (i-- !=0 ) { priv =usb_get_serial_port_data (ports[i]);
@@ -784,7 +809,7 @@ static int generic_startup(struct usb_serial *serial)return 0 ; } -static int clie_3_5_startup (struct usb_serial *serial) +static int clie_3_5_startup (struct usb_serial *serial) {struct device *dev = &serial->dev->dev;int result;
@@ -797,62 +822,72 @@ static int clie_3_5_startup (struct usb_serial *serial)*/ /* get the config number */ - result =usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev,0 ), + result =usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev,0 ),USB_REQ_GET_CONFIGURATION ,USB_DIR_IN ,0 ,0 , &data,1 ,3000 );if (result <0 ) { -dev_err (dev,"%s: get config number failed: %d\n" , __func__, result); +dev_err (dev,"%s: get config number failed: %d\n" , + __func__, result);return result; }if (result !=1 ) { -dev_err (dev,"%s: get config number bad return length: %d\n" , __func__, result); +dev_err (dev,"%s: get config number bad return length: %d\n" , + __func__, result);return -EIO ; }/* get the interface number */ - result =usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev,0 ), -USB_REQ_GET_INTERFACE , + result =usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev,0 ), +USB_REQ_GET_INTERFACE ,USB_DIR_IN |USB_RECIP_INTERFACE ,0 ,0 , &data,1 ,3000 );if (result <0 ) { -dev_err (dev,"%s: get interface number failed: %d\n" , __func__, result); +dev_err (dev,"%s: get interface number failed: %d\n" , + __func__, result);return result; }if (result !=1 ) { -dev_err (dev,"%s: get interface number bad return length: %d\n" , __func__, result); +dev_err (dev, +"%s: get interface number bad return length: %d\n" , + __func__, result);return -EIO ; }return generic_startup (serial); } - -static int treo_attach (struct usb_serial *serial) + +static int treo_attach (struct usb_serial *serial) {struct usb_serial_port *swap_port;/* Only do this endpoint hack for the Handspring devices with * interrupt in endpoints, which for now are the Treo devices. */ -if (!((le16_to_cpu (serial->dev->descriptor.idVendor) ==HANDSPRING_VENDOR_ID ) || - (le16_to_cpu (serial->dev->descriptor.idVendor) ==KYOCERA_VENDOR_ID )) || - (serial->num_interrupt_in ==0 )) +if (!((le16_to_cpu (serial->dev->descriptor.idVendor) + ==HANDSPRING_VENDOR_ID ) || + (le16_to_cpu (serial->dev->descriptor.idVendor) + ==KYOCERA_VENDOR_ID )) || + (serial->num_interrupt_in ==0 )) goto generic_startup;dbg ("%s" , __func__);/* -* It appears that Treos and Kyoceras want to use the -* 1st bulk in endpoint to communicate with the 2nd bulk out endpoint, -* so let's swap the 1st and 2nd bulk in and interrupt endpoints. -* Note that swapping the bulk out endpoints would break lots of +* It appears that Treos and Kyoceras want to use the +* 1st bulk in endpoint to communicate with the 2nd bulk out endpoint, +* so let's swap the 1st and 2nd bulk in and interrupt endpoints. +* Note that swapping the bulk out endpoints would break lots of * apps that want to communicate on the second port. */ #define COPY_PORT (dest, src) \ - dest->read_urb = src->read_urb; \ - dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress; \ - dest->bulk_in_buffer = src->bulk_in_buffer; \ - dest->interrupt_in_urb = src->interrupt_in_urb; \ - dest->interrupt_in_endpointAddress = src->interrupt_in_endpointAddress; \ - dest->interrupt_in_buffer = src->interrupt_in_buffer; + do { \ + dest->read_urb = src->read_urb; \ + dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress;\ + dest->bulk_in_buffer = src->bulk_in_buffer; \ + dest->interrupt_in_urb = src->interrupt_in_urb; \ + dest->interrupt_in_endpointAddress = \ + src->interrupt_in_endpointAddress;\ + dest->interrupt_in_buffer = src->interrupt_in_buffer; \ + } while (0); swap_port =kmalloc (sizeof (*swap_port),GFP_KERNEL );if (!swap_port)
@@ -866,28 +901,30 @@ generic_startup:return generic_startup (serial); } -static int clie_5_attach (struct usb_serial *serial) +static int clie_5_attach (struct usb_serial *serial) {dbg ("%s" , __func__); -/* TH55 registers 2 ports. -Communication in from the UX50/TH55 uses bulk_in_endpointAddress from port 0 -Communication out to the UX50/TH55 uses bulk_out_endpointAddress from port 1 -+ /* TH55 registers 2 ports. +Communication in from the UX50/TH55 uses bulk_in_endpointAddress +from port 0. Communication out to the UX50/TH55 uses +bulk_out_endpointAddress from port 1 +Lets do a quick and dirty mapping */ - +/* some sanity check */ if (serial->num_ports <2 )return -1 ; - +/* port 0 now uses the modified endpoint Address */ - serial->port[0 ]->bulk_out_endpointAddress = serial->port[1 ]->bulk_out_endpointAddress; + serial->port[0 ]->bulk_out_endpointAddress = + serial->port[1 ]->bulk_out_endpointAddress;return generic_startup (serial); } -static void visor_shutdown (struct usb_serial *serial) +static void visor_shutdown (struct usb_serial *serial) {struct visor_private *priv;int i;
@@ -903,30 +940,35 @@ static void visor_shutdown (struct usb_serial *serial) } } -static int __init visor_init (void ) +static int __init visor_init (void ) {int i, retval;/* Only if parameters were passed to us */ -if ((vendor>0 ) && (product>0 )) { -struct usb_device_id usb_dev_temp[]= - {{USB_DEVICE (vendor, product), - .driver_info = (kernel_ulong_t)&palm_os_4_probe }}; +if (vendor >0 && product >0 ) { +struct usb_device_id usb_dev_temp[] = { + { +USB_DEVICE (vendor, product), + .driver_info = + (kernel_ulong_t) &palm_os_4_probe + } + };/* Find the last entry in id_table */ -for (i=0 ; ; i++) { -if (id_table[i].idVendor==0 ) { +for (i =0 ;; i++) { +if (id_table[i].idVendor ==0 ) { id_table[i] = usb_dev_temp[0 ];break ; } }/* Find the last entry in id_table_combined */ -for (i=0 ; ; i++) { -if (id_table_combined[i].idVendor==0 ) { +for (i =0 ;; i++) { +if (id_table_combined[i].idVendor ==0 ) { id_table_combined[i] = usb_dev_temp[0 ];break ; } } -info ("Untested USB device specified at time of module insertion" ); +info ( +"Untested USB device specified at time of module insertion" );info ("Warning: This is not guaranteed to work" );info ("Using a newer kernel is preferred to this method" ); info("Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x",
@@ -942,7 +984,7 @@ static int __init visor_init (void)if (retval) goto failed_clie_5_register; retval =usb_register (&visor_driver); -if (retval) +if (retval) goto failed_usb_register;info (DRIVER_DESC );
@@ -960,18 +1002,18 @@ failed_handspring_register: static void __exit visor_exit (void) { -usb_deregister (&visor_driver); -usb_serial_deregister (&handspring_device); -usb_serial_deregister (&clie_3_5_device); -usb_serial_deregister (&clie_5_device); +usb_deregister (&visor_driver); +usb_serial_deregister (&handspring_device); +usb_serial_deregister (&clie_3_5_device); +usb_serial_deregister (&clie_5_device); }module_init (visor_init);module_exit (visor_exit); -MODULE_AUTHOR (DRIVER_AUTHOR ); -MODULE_DESCRIPTION (DRIVER_DESC ); +MODULE_AUTHOR (DRIVER_AUTHOR ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );module_param (debug, bool,S_IRUGO |S_IWUSR );
PATCH 42/70 tty-usb-io_edgeport: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/io_edgeport.c | 1965 +++++++++++++++++++++----------------- drivers/usb/serial/io_tables.h | 6 2 files changed, 1107 insertions(+), 864 deletions(-)
drivers/usb/serial/io_edgeport.c +1104 -861
@@ -42,7 +42,7 @@#include <linux/serial.h> #include <linux/ioctl.h> #include <linux/wait.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/usb/serial.h> #include "io_edgeport.h"
@@ -59,14 +59,17 @@/* First, the latest boot code - for first generation edgeports */ #define IMAGE_ARRAY_NAME BootCodeImage_GEN1#define IMAGE_VERSION_NAME BootCodeImageVersion_GEN1 -#include "io_fw_boot.h" /* the bootloader firmware to download to a device, if it needs it */ +#include "io_fw_boot.h" /* the bootloader firmware to download to +a device, if it needs it */ /* for second generation edgeports */ #define IMAGE_ARRAY_NAME BootCodeImage_GEN2#define IMAGE_VERSION_NAME BootCodeImageVersion_GEN2 -#include "io_fw_boot2.h" /* the bootloader firmware to download to a device, if it needs it */ +#include "io_fw_boot2.h" /* the bootloader firmware to download to +a device, if it needs it */ -/* Then finally the main run-time operational code - for first generation edgeports */ +/* Then finally the main run-time operational code - for first generation +edgeports */ #define IMAGE_ARRAY_NAME OperationalCodeImage_GEN1#define IMAGE_VERSION_NAME OperationalCodeImageVersion_GEN1#include "io_fw_down.h" /* Define array OperationalCodeImage[] */
@@ -84,16 +87,16 @@/* receive port state */ enum RXSTATE { -EXPECT_HDR1 =0 ,/* Expect header byte 1 */ -EXPECT_HDR2 =1 ,/* Expect header byte 2 */ -EXPECT_DATA =2 ,/* Expect 'RxBytesRemaining' data */ -EXPECT_HDR3 =3 ,/* Expect header byte 3 (for status hdrs only) */ +EXPECT_HDR1 =0 ,/* Expect header byte 1 */ +EXPECT_HDR2 =1 ,/* Expect header byte 2 */ +EXPECT_DATA =2 ,/* Expect 'RxBytesRemaining' data */ +EXPECT_HDR3 =3 ,/* Expect header byte 3 (for status hdrs only) */ }; -/* Transmit Fifo -* This Transmit queue is an extension of the edgeport Rx buffer. -* The maximum amount of data buffered in both the edgeport +/* Transmit Fifo +* This Transmit queue is an extension of the edgeport Rx buffer. +* The maximum amount of data buffered in both the edgeport * Rx buffer (maxTxCredits) and this buffer will never exceed maxTxCredits. */ struct TxFifo {
@@ -150,12 +153,12 @@ struct edgeport_serial {int is_epic;/* flag if EPiC device or not */ __u8 interrupt_in_endpoint;/* the interrupt endpoint handle */ -unsigned char * interrupt_in_buffer;/* the buffer we use for the interrupt endpoint */ -struct urb * interrupt_read_urb;/* our interrupt urb */ +unsigned char *interrupt_in_buffer;/* the buffer we use for the interrupt endpoint */ +struct urb *interrupt_read_urb;/* our interrupt urb */ __u8 bulk_in_endpoint;/* the bulk in endpoint handle */ -unsigned char * bulk_in_buffer;/* the buffer we use for the bulk in endpoint */ -struct urb * read_urb;/* our bulk read urb */ +unsigned char *bulk_in_buffer;/* the buffer we use for the bulk in endpoint */ +struct urb *read_urb;/* our bulk read urb */ bool read_in_progress;spinlock_t es_lock;
@@ -180,16 +183,17 @@ struct divisor_table_entry {__u16 Divisor; }; -// -// Define table of divisors for Rev A EdgePort/4 hardware -// These assume a 3.6864MHz crystal, the standard /16, and -// MCR.7 = 0. -// +/* +* Define table of divisors for Rev A EdgePort/4 hardware +* These assume a 3.6864MHz crystal, the standard /16, and +* MCR.7 = 0. +*/ +static const struct divisor_table_entry divisor_table[] = { - {50 ,4608 }, - {75 ,3072 }, - {110 ,2095 },/* 2094.545455 => 230450 => .0217 % over */ - {134 ,1713 },/* 1713.011152 => 230398.5 => .00065% under */ + {50 ,4608 }, + {75 ,3072 }, + {110 ,2095 },/* 2094.545455 => 230450 => .0217 % over */ + {134 ,1713 },/* 1713.011152 => 230398.5 => .00065% under */ {150 ,1536 }, {300 ,768 }, {600 ,384 },
@@ -212,65 +216,86 @@ static int debug;static int low_latency =1 ;/* tty low latency flag, on by default */ -static atomic_t CmdUrbs;/* Number of outstanding Command Write Urbs */ +static atomic_t CmdUrbs;/* Number of outstanding Command Write Urbs */ /* local function prototypes */ /* function prototypes for all URB callbacks */ -static void edge_interrupt_callback (struct urb *urb); -static void edge_bulk_in_callback (struct urb *urb); -static void edge_bulk_out_data_callback (struct urb *urb); -static void edge_bulk_out_cmd_callback (struct urb *urb); +static void edge_interrupt_callback (struct urb *urb); +static void edge_bulk_in_callback (struct urb *urb); +static void edge_bulk_out_data_callback (struct urb *urb); +static void edge_bulk_out_cmd_callback (struct urb *urb);/* function prototypes for the usbserial callbacks */ -static int edge_open (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp); -static void edge_close (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp); -static int edge_write (struct tty_struct *tty,struct usb_serial_port *port,const unsigned char *buf,int count); -static int edge_write_room (struct tty_struct *tty); -static int edge_chars_in_buffer (struct tty_struct *tty); -static void edge_throttle (struct tty_struct *tty); -static void edge_unthrottle (struct tty_struct *tty); -static void edge_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios); -static int edge_ioctl (struct tty_struct *tty,struct file *file,unsigned int cmd,unsigned long arg); -static void edge_break (struct tty_struct *tty,int break_state); -static int edge_tiocmget (struct tty_struct *tty,struct file *file); -static int edge_tiocmset (struct tty_struct *tty,struct file *file,unsigned int set,unsigned int clear); -static int edge_startup (struct usb_serial *serial); -static void edge_shutdown (struct usb_serial *serial); +static int edge_open (struct tty_struct *tty,struct usb_serial_port *port, +struct file *filp); +static void edge_close (struct tty_struct *tty,struct usb_serial_port *port, +struct file *filp); +static int edge_write (struct tty_struct *tty,struct usb_serial_port *port, +const unsigned char *buf,int count); +static int edge_write_room (struct tty_struct *tty); +static int edge_chars_in_buffer (struct tty_struct *tty); +static void edge_throttle (struct tty_struct *tty); +static void edge_unthrottle (struct tty_struct *tty); +static void edge_set_termios (struct tty_struct *tty, +struct usb_serial_port *port, +struct ktermios *old_termios); +static int edge_ioctl (struct tty_struct *tty,struct file *file, +unsigned int cmd,unsigned long arg); +static void edge_break (struct tty_struct *tty,int break_state); +static int edge_tiocmget (struct tty_struct *tty,struct file *file); +static int edge_tiocmset (struct tty_struct *tty,struct file *file, +unsigned int set,unsigned int clear); +static int edge_startup (struct usb_serial *serial); +static void edge_shutdown (struct usb_serial *serial);#include "io_tables.h" /* all of the devices that this driver supports */ /* function prototypes for all of our local functions */ -static void process_rcvd_data (struct edgeport_serial *edge_serial,unsigned char *buffer,__u16 bufferLength); -static void process_rcvd_status (struct edgeport_serial *edge_serial,__u8 byte2,__u8 byte3); -static void edge_tty_recv (struct device *dev,struct tty_struct *tty,unsigned char *data,int length); -static void handle_new_msr (struct edgeport_port *edge_port,__u8 newMsr); -static void handle_new_lsr (struct edgeport_port *edge_port,__u8 lsrData,__u8 lsr,__u8 data); -static int send_iosp_ext_cmd (struct edgeport_port *edge_port,__u8 command,__u8 param); -static int calc_baud_rate_divisor (int baud_rate,int *divisor); -static int send_cmd_write_baud_rate (struct edgeport_port *edge_port,int baudRate); -static void change_port_settings (struct tty_struct *tty,struct edgeport_port *edge_port, -struct ktermios *old_termios); -static int send_cmd_write_uart_register (struct edgeport_port *edge_port,__u8 regNum,__u8 regValue); -static int write_cmd_usb (struct edgeport_port *edge_port,unsigned char *buffer,int writeLength); -static void send_more_port_data (struct edgeport_serial *edge_serial,struct edgeport_port *edge_port); - -static int sram_write (struct usb_serial *serial,__u16 extAddr,__u16 addr,__u16 length,__u8 *data); -static int rom_read (struct usb_serial *serial,__u16 extAddr,__u16 addr,__u16 length,__u8 *data); -static int rom_write (struct usb_serial *serial,__u16 extAddr,__u16 addr,__u16 length,__u8 *data); -static void get_manufacturing_desc (struct edgeport_serial *edge_serial); -static void get_boot_desc (struct edgeport_serial *edge_serial); -static void load_application_firmware (struct edgeport_serial *edge_serial); - -static void unicode_to_ascii (char *string,int buflen,__le16 *unicode,int unicode_size); - - -// ************************************************************************ -// ************************************************************************ -// ************************************************************************ -// ************************************************************************ +static void process_rcvd_data (struct edgeport_serial *edge_serial, +unsigned char *buffer,__u16 bufferLength); +static void process_rcvd_status (struct edgeport_serial *edge_serial, +__u8 byte2,__u8 byte3); +static void edge_tty_recv (struct device *dev,struct tty_struct *tty, +unsigned char *data,int length); +static void handle_new_msr (struct edgeport_port *edge_port,__u8 newMsr); +static void handle_new_lsr (struct edgeport_port *edge_port,__u8 lsrData, +__u8 lsr,__u8 data); +static int send_iosp_ext_cmd (struct edgeport_port *edge_port,__u8 command, +__u8 param); +static int calc_baud_rate_divisor (int baud_rate,int *divisor); +static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, +int baudRate); +static void change_port_settings (struct tty_struct *tty, +struct edgeport_port *edge_port, +struct ktermios *old_termios); +static int send_cmd_write_uart_register (struct edgeport_port *edge_port, +__u8 regNum,__u8 regValue); +static int write_cmd_usb (struct edgeport_port *edge_port, +unsigned char *buffer,int writeLength); +static void send_more_port_data (struct edgeport_serial *edge_serial, +struct edgeport_port *edge_port); + +static int sram_write (struct usb_serial *serial,__u16 extAddr,__u16 addr, +__u16 length,__u8 *data); +static int rom_read (struct usb_serial *serial,__u16 extAddr,__u16 addr, +__u16 length,__u8 *data); +static int rom_write (struct usb_serial *serial,__u16 extAddr,__u16 addr, +__u16 length,__u8 *data); +static void get_manufacturing_desc (struct edgeport_serial *edge_serial); +static void get_boot_desc (struct edgeport_serial *edge_serial); +static void load_application_firmware (struct edgeport_serial *edge_serial); + +static void unicode_to_ascii (char *string,int buflen, +__le16 *unicode,int unicode_size); + + +/* ************************************************************************ */ +/* ************************************************************************ */ +/* ************************************************************************ */ +/* ************************************************************************ */ /************************************************************************ * *
@@ -280,42 +305,43 @@ static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unic* embedded in this driver * * * ************************************************************************/ -static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial) +static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial) {__u32 BootCurVer;__u32 BootNewVer; -__u8 BootMajorVersion; -__u8 BootMinorVersion; +__u8 BootMajorVersion; +__u8 BootMinorVersion;__le16 BootBuildNumber; -__u8 *BootImage; +__u8 *BootImage;__u32 BootSize;struct edge_firmware_image_record *record;unsigned char *firmware;int response; -switch (edge_serial->product_info.iDownloadFile) { -case EDGE_DOWNLOAD_FILE_I930 : - BootMajorVersion = BootCodeImageVersion_GEN1.MajorVersion; - BootMinorVersion = BootCodeImageVersion_GEN1.MinorVersion; - BootBuildNumber =cpu_to_le16 (BootCodeImageVersion_GEN1.BuildNumber); - BootImage = &BootCodeImage_GEN1[0 ]; - BootSize =sizeof ( BootCodeImage_GEN1 ); -break ; +case EDGE_DOWNLOAD_FILE_I930 : + BootMajorVersion = BootCodeImageVersion_GEN1.MajorVersion; + BootMinorVersion = BootCodeImageVersion_GEN1.MinorVersion; + BootBuildNumber = +cpu_to_le16 (BootCodeImageVersion_GEN1.BuildNumber); + BootImage = &BootCodeImage_GEN1[0 ]; + BootSize =sizeof (BootCodeImage_GEN1); +break ; -case EDGE_DOWNLOAD_FILE_80251 : - BootMajorVersion = BootCodeImageVersion_GEN2.MajorVersion; - BootMinorVersion = BootCodeImageVersion_GEN2.MinorVersion; - BootBuildNumber =cpu_to_le16 (BootCodeImageVersion_GEN2.BuildNumber); - BootImage = &BootCodeImage_GEN2[0 ]; - BootSize =sizeof ( BootCodeImage_GEN2 ); -break ; +case EDGE_DOWNLOAD_FILE_80251 : + BootMajorVersion = BootCodeImageVersion_GEN2.MajorVersion; + BootMinorVersion = BootCodeImageVersion_GEN2.MinorVersion; + BootBuildNumber = +cpu_to_le16 (BootCodeImageVersion_GEN2.BuildNumber); + BootImage = &BootCodeImage_GEN2[0 ]; + BootSize =sizeof (BootCodeImage_GEN2); +break ; -default : -return ; +default : +return ; } -// Check Boot Image Version +/* Check Boot Image Version */ BootCurVer = (edge_serial->boot_descriptor.MajorVersion <<24 ) + (edge_serial->boot_descriptor.MinorVersion <<16 ) +le16_to_cpu (edge_serial->boot_descriptor.BuildNumber);
@@ -346,19 +372,26 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial)for (;;) { record = (struct edge_firmware_image_record *)firmware; - response =rom_write (edge_serial->serial,le16_to_cpu (record->ExtAddr),le16_to_cpu (record->Addr),le16_to_cpu (record->Len), &record->Data[0 ]); + response =rom_write (edge_serial->serial, +le16_to_cpu (record->ExtAddr), +le16_to_cpu (record->Addr), +le16_to_cpu (record->Len), + &record->Data[0 ]);if (response <0 ) { -dev_err (&edge_serial->serial->dev->dev,"rom_write failed (%x, %x, %d)\n" ,le16_to_cpu (record->ExtAddr),le16_to_cpu (record->Addr),le16_to_cpu (record->Len)); +dev_err (&edge_serial->serial->dev->dev, +"rom_write failed (%x, %x, %d)\n" , +le16_to_cpu (record->ExtAddr), +le16_to_cpu (record->Addr), +le16_to_cpu (record->Len));break ; } - firmware +=sizeof (struct edge_firmware_image_record ) +le16_to_cpu (record->Len); -if (firmware >= &BootImage[BootSize]) { + firmware +=sizeof (struct edge_firmware_image_record ) + +le16_to_cpu (record->Len); +if (firmware >= &BootImage[BootSize])break ; - } } - }else { + }else dbg ("Boot Image -- already up to date" ); - } }
@@ -367,29 +400,29 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial)* Get string descriptor from device * * * ************************************************************************/ -static int get_string (struct usb_device *dev,int Id,char *string,int buflen) +static int get_string (struct usb_device *dev,int Id,char *string,int buflen) {struct usb_string_descriptor StringDesc;struct usb_string_descriptor *pStringDesc; -dbg ("%s - USB String ID = %d" , __func__, Id ); +dbg ("%s - USB String ID = %d" , __func__, Id); -if (!usb_get_descriptor (dev,USB_DT_STRING , Id, &StringDesc,sizeof (StringDesc))) { +if (!usb_get_descriptor (dev,USB_DT_STRING , Id, + &StringDesc,sizeof (StringDesc)))return 0 ; - } - - pStringDesc =kmalloc (StringDesc.bLength,GFP_KERNEL ); -if (!pStringDesc) { + pStringDesc =kmalloc (StringDesc.bLength,GFP_KERNEL ); +if (!pStringDesc)return 0 ; - } -if (!usb_get_descriptor (dev,USB_DT_STRING , Id, pStringDesc, StringDesc.bLength )) { +if (!usb_get_descriptor (dev,USB_DT_STRING , Id, + pStringDesc, StringDesc.bLength)) {kfree (pStringDesc);return 0 ; } -unicode_to_ascii (string, buflen, pStringDesc->wData, pStringDesc->bLength/2 ); +unicode_to_ascii (string, buflen, + pStringDesc->wData, pStringDesc->bLength/2 );kfree (pStringDesc);dbg ("%s - USB String %s" , __func__, string);
@@ -403,24 +436,24 @@ static int get_string (struct usb_device *dev, int Id, char *string, int buflen)* Get string descriptor from device * ************************************************************************/ -static int get_string_desc (struct usb_device *dev,int Id,struct usb_string_descriptor **pRetDesc) +static int get_string_desc (struct usb_device *dev,int Id, +struct usb_string_descriptor **pRetDesc) {struct usb_string_descriptor StringDesc;struct usb_string_descriptor *pStringDesc; -dbg ("%s - USB String ID = %d" , __func__, Id ); +dbg ("%s - USB String ID = %d" , __func__, Id); -if (!usb_get_descriptor (dev,USB_DT_STRING , Id, &StringDesc,sizeof (StringDesc))) { +if (!usb_get_descriptor (dev,USB_DT_STRING , Id, &StringDesc, +sizeof (StringDesc)))return 0 ; - } - - pStringDesc =kmalloc (StringDesc.bLength,GFP_KERNEL ); -if (!pStringDesc) { + pStringDesc =kmalloc (StringDesc.bLength,GFP_KERNEL ); +if (!pStringDesc)return -1 ; - } -if (!usb_get_descriptor (dev,USB_DT_STRING , Id, pStringDesc, StringDesc.bLength )) { +if (!usb_get_descriptor (dev,USB_DT_STRING , Id, pStringDesc, + StringDesc.bLength)) {kfree (pStringDesc);return -1 ; }
@@ -432,28 +465,30 @@ static int get_string_desc (struct usb_device *dev, int Id, struct usb_string_destatic void dump_product_info (struct edgeport_product_info *product_info) { -// Dump Product Info structure +/* Dump Product Info structure */ dbg ("**Product Information:" ); -dbg (" ProductId %x" , product_info->ProductId ); -dbg (" NumPorts %d" , product_info->NumPorts ); -dbg (" ProdInfoVer %d" , product_info->ProdInfoVer ); +dbg (" ProductId %x" , product_info->ProductId); +dbg (" NumPorts %d" , product_info->NumPorts); +dbg (" ProdInfoVer %d" , product_info->ProdInfoVer);dbg (" IsServer %d" , product_info->IsServer); -dbg (" IsRS232 %d" , product_info->IsRS232 ); -dbg (" IsRS422 %d" , product_info->IsRS422 ); -dbg (" IsRS485 %d" , product_info->IsRS485 ); -dbg (" RomSize %d" , product_info->RomSize ); -dbg (" RamSize %d" , product_info->RamSize ); -dbg (" CpuRev %x" , product_info->CpuRev ); +dbg (" IsRS232 %d" , product_info->IsRS232); +dbg (" IsRS422 %d" , product_info->IsRS422); +dbg (" IsRS485 %d" , product_info->IsRS485); +dbg (" RomSize %d" , product_info->RomSize); +dbg (" RamSize %d" , product_info->RamSize); +dbg (" CpuRev %x" , product_info->CpuRev);dbg (" BoardRev %x" , product_info->BoardRev);dbg (" BootMajorVersion %d.%d.%d" , product_info->BootMajorVersion, product_info->BootMinorVersion,le16_to_cpu (product_info->BootBuildNumber)); -dbg (" FirmwareMajorVersion %d.%d.%d" , product_info->FirmwareMajorVersion, - product_info->FirmwareMinorVersion, -le16_to_cpu (product_info->FirmwareBuildNumber)); -dbg (" ManufactureDescDate %d/%d/%d" , product_info->ManufactureDescDate[0 ], - product_info->ManufactureDescDate[1 ], - product_info->ManufactureDescDate[2 ]+1900 ); +dbg (" FirmwareMajorVersion %d.%d.%d" , + product_info->FirmwareMajorVersion, + product_info->FirmwareMinorVersion, +le16_to_cpu (product_info->FirmwareBuildNumber)); +dbg (" ManufactureDescDate %d/%d/%d" , + product_info->ManufactureDescDate[0 ], + product_info->ManufactureDescDate[1 ], + product_info->ManufactureDescDate[2 ]+1900 );dbg (" iDownloadFile 0x%x" , product_info->iDownloadFile);dbg (" EpicVer %d" , product_info->EpicVer); }
@@ -462,61 +497,73 @@ static void get_product_info(struct edgeport_serial *edge_serial) {struct edgeport_product_info *product_info = &edge_serial->product_info; -memset (product_info,0 ,sizeof (struct edgeport_product_info )); - - product_info->ProductId = (__u16)(le16_to_cpu (edge_serial->serial->dev->descriptor.idProduct) & ~ION_DEVICE_ID_80251_NETCHIP ); - product_info->NumPorts = edge_serial->manuf_descriptor.NumPorts; - product_info->ProdInfoVer =0 ; - - product_info->RomSize = edge_serial->manuf_descriptor.RomSize; - product_info->RamSize = edge_serial->manuf_descriptor.RamSize; - product_info->CpuRev = edge_serial->manuf_descriptor.CpuRev; - product_info->BoardRev = edge_serial->manuf_descriptor.BoardRev; - - product_info->BootMajorVersion = edge_serial->boot_descriptor.MajorVersion; - product_info->BootMinorVersion = edge_serial->boot_descriptor.MinorVersion; - product_info->BootBuildNumber = edge_serial->boot_descriptor.BuildNumber; - -memcpy (product_info->ManufactureDescDate, edge_serial->manuf_descriptor.DescDate,sizeof (edge_serial->manuf_descriptor.DescDate)); - -// check if this is 2nd generation hardware -if (le16_to_cpu (edge_serial->serial->dev->descriptor.idProduct) &ION_DEVICE_ID_80251_NETCHIP ) { - product_info->FirmwareMajorVersion = OperationalCodeImageVersion_GEN2.MajorVersion; - product_info->FirmwareMinorVersion = OperationalCodeImageVersion_GEN2.MinorVersion; - product_info->FirmwareBuildNumber =cpu_to_le16 (OperationalCodeImageVersion_GEN2.BuildNumber); - product_info->iDownloadFile =EDGE_DOWNLOAD_FILE_80251 ; +memset (product_info,0 ,sizeof (struct edgeport_product_info )); + + product_info->ProductId = (__u16)(le16_to_cpu (edge_serial->serial->dev->descriptor.idProduct) & ~ION_DEVICE_ID_80251_NETCHIP ); + product_info->NumPorts = edge_serial->manuf_descriptor.NumPorts; + product_info->ProdInfoVer =0 ; + + product_info->RomSize = edge_serial->manuf_descriptor.RomSize; + product_info->RamSize = edge_serial->manuf_descriptor.RamSize; + product_info->CpuRev = edge_serial->manuf_descriptor.CpuRev; + product_info->BoardRev = edge_serial->manuf_descriptor.BoardRev; + + product_info->BootMajorVersion = + edge_serial->boot_descriptor.MajorVersion; + product_info->BootMinorVersion = + edge_serial->boot_descriptor.MinorVersion; + product_info->BootBuildNumber = + edge_serial->boot_descriptor.BuildNumber; + +memcpy (product_info->ManufactureDescDate, + edge_serial->manuf_descriptor.DescDate, +sizeof (edge_serial->manuf_descriptor.DescDate)); + +/* check if this is 2nd generation hardware */ +if (le16_to_cpu (edge_serial->serial->dev->descriptor.idProduct) + &ION_DEVICE_ID_80251_NETCHIP ) { + product_info->FirmwareMajorVersion = + OperationalCodeImageVersion_GEN2.MajorVersion; + product_info->FirmwareMinorVersion = + OperationalCodeImageVersion_GEN2.MinorVersion; + product_info->FirmwareBuildNumber = +cpu_to_le16 (OperationalCodeImageVersion_GEN2.BuildNumber); + product_info->iDownloadFile =EDGE_DOWNLOAD_FILE_80251 ; }else { - product_info->FirmwareMajorVersion = OperationalCodeImageVersion_GEN1.MajorVersion; - product_info->FirmwareMinorVersion = OperationalCodeImageVersion_GEN1.MinorVersion; - product_info->FirmwareBuildNumber =cpu_to_le16 (OperationalCodeImageVersion_GEN1.BuildNumber); - product_info->iDownloadFile =EDGE_DOWNLOAD_FILE_I930 ; + product_info->FirmwareMajorVersion = + OperationalCodeImageVersion_GEN1.MajorVersion; + product_info->FirmwareMinorVersion = + OperationalCodeImageVersion_GEN1.MinorVersion; + product_info->FirmwareBuildNumber = +cpu_to_le16 (OperationalCodeImageVersion_GEN1.BuildNumber); + product_info->iDownloadFile =EDGE_DOWNLOAD_FILE_I930 ; } -// Determine Product type and set appropriate flags +/* Determine Product type and set appropriate flags */ switch (DEVICE_ID_FROM_USB_PRODUCT_ID (product_info->ProductId)) { -case ION_DEVICE_ID_EDGEPORT_COMPATIBLE : -case ION_DEVICE_ID_EDGEPORT_4T : -case ION_DEVICE_ID_EDGEPORT_4 : -case ION_DEVICE_ID_EDGEPORT_2 : -case ION_DEVICE_ID_EDGEPORT_8_DUAL_CPU : -case ION_DEVICE_ID_EDGEPORT_8 : -case ION_DEVICE_ID_EDGEPORT_421 : -case ION_DEVICE_ID_EDGEPORT_21 : -case ION_DEVICE_ID_EDGEPORT_2_DIN : -case ION_DEVICE_ID_EDGEPORT_4_DIN : -case ION_DEVICE_ID_EDGEPORT_16_DUAL_CPU : - product_info->IsRS232 =1 ; -break ; +case ION_DEVICE_ID_EDGEPORT_COMPATIBLE : +case ION_DEVICE_ID_EDGEPORT_4T : +case ION_DEVICE_ID_EDGEPORT_4 : +case ION_DEVICE_ID_EDGEPORT_2 : +case ION_DEVICE_ID_EDGEPORT_8_DUAL_CPU : +case ION_DEVICE_ID_EDGEPORT_8 : +case ION_DEVICE_ID_EDGEPORT_421 : +case ION_DEVICE_ID_EDGEPORT_21 : +case ION_DEVICE_ID_EDGEPORT_2_DIN : +case ION_DEVICE_ID_EDGEPORT_4_DIN : +case ION_DEVICE_ID_EDGEPORT_16_DUAL_CPU : + product_info->IsRS232 =1 ; +break ; -case ION_DEVICE_ID_EDGEPORT_2I :// Edgeport/2 RS422/RS485 - product_info->IsRS422 =1 ; - product_info->IsRS485 =1 ; -break ; +case ION_DEVICE_ID_EDGEPORT_2I :/* Edgeport/2 RS422/RS485 */ + product_info->IsRS422 =1 ; + product_info->IsRS485 =1 ; +break ; -case ION_DEVICE_ID_EDGEPORT_8I :// Edgeport/4 RS422 -case ION_DEVICE_ID_EDGEPORT_4I :// Edgeport/4 RS422 - product_info->IsRS422 =1 ; -break ; +case ION_DEVICE_ID_EDGEPORT_8I :/* Edgeport/4 RS422 */ +case ION_DEVICE_ID_EDGEPORT_4I :/* Edgeport/4 RS422 */ + product_info->IsRS422 =1 ; +break ; }dump_product_info (product_info);
@@ -544,32 +591,32 @@ static int get_epic_descriptor(struct edgeport_serial *ep) ep->is_epic =1 ;memset (product_info,0 ,sizeof (struct edgeport_product_info )); - product_info->NumPorts = epic->NumPorts; - product_info->ProdInfoVer =0 ; - product_info->FirmwareMajorVersion = epic->MajorVersion; - product_info->FirmwareMinorVersion = epic->MinorVersion; - product_info->FirmwareBuildNumber = epic->BuildNumber; - product_info->iDownloadFile = epic->iDownloadFile; - product_info->EpicVer = epic->EpicVer; - product_info->Epic = epic->Supports; - product_info->ProductId =ION_DEVICE_ID_EDGEPORT_COMPATIBLE ; + product_info->NumPorts = epic->NumPorts; + product_info->ProdInfoVer =0 ; + product_info->FirmwareMajorVersion = epic->MajorVersion; + product_info->FirmwareMinorVersion = epic->MinorVersion; + product_info->FirmwareBuildNumber = epic->BuildNumber; + product_info->iDownloadFile = epic->iDownloadFile; + product_info->EpicVer = epic->EpicVer; + product_info->Epic = epic->Supports; + product_info->ProductId =ION_DEVICE_ID_EDGEPORT_COMPATIBLE ;dump_product_info (product_info); bits = &ep->epic_descriptor.Supports;dbg ("**EPIC descriptor:" );dbg (" VendEnableSuspend: %s" , bits->VendEnableSuspend ?"TRUE" :"FALSE" ); -dbg (" IOSPOpen : %s" , bits->IOSPOpen ?"TRUE" :"FALSE" ); -dbg (" IOSPClose : %s" , bits->IOSPClose ?"TRUE" :"FALSE" ); -dbg (" IOSPChase : %s" , bits->IOSPChase ?"TRUE" :"FALSE" ); -dbg (" IOSPSetRxFlow : %s" , bits->IOSPSetRxFlow ?"TRUE" :"FALSE" ); -dbg (" IOSPSetTxFlow : %s" , bits->IOSPSetTxFlow ?"TRUE" :"FALSE" ); -dbg (" IOSPSetXChar : %s" , bits->IOSPSetXChar ?"TRUE" :"FALSE" ); -dbg (" IOSPRxCheck : %s" , bits->IOSPRxCheck ?"TRUE" :"FALSE" ); -dbg (" IOSPSetClrBreak : %s" , bits->IOSPSetClrBreak ?"TRUE" :"FALSE" ); -dbg (" IOSPWriteMCR : %s" , bits->IOSPWriteMCR ?"TRUE" :"FALSE" ); -dbg (" IOSPWriteLCR : %s" , bits->IOSPWriteLCR ?"TRUE" :"FALSE" ); -dbg (" IOSPSetBaudRate : %s" , bits->IOSPSetBaudRate ?"TRUE" :"FALSE" ); -dbg (" TrueEdgeport : %s" , bits->TrueEdgeport ?"TRUE" :"FALSE" ); +dbg (" IOSPOpen : %s" , bits->IOSPOpen ?"TRUE" :"FALSE" ); +dbg (" IOSPClose : %s" , bits->IOSPClose ?"TRUE" :"FALSE" ); +dbg (" IOSPChase : %s" , bits->IOSPChase ?"TRUE" :"FALSE" ); +dbg (" IOSPSetRxFlow : %s" , bits->IOSPSetRxFlow ?"TRUE" :"FALSE" ); +dbg (" IOSPSetTxFlow : %s" , bits->IOSPSetTxFlow ?"TRUE" :"FALSE" ); +dbg (" IOSPSetXChar : %s" , bits->IOSPSetXChar ?"TRUE" :"FALSE" ); +dbg (" IOSPRxCheck : %s" , bits->IOSPRxCheck ?"TRUE" :"FALSE" ); +dbg (" IOSPSetClrBreak : %s" , bits->IOSPSetClrBreak ?"TRUE" :"FALSE" ); +dbg (" IOSPWriteMCR : %s" , bits->IOSPWriteMCR ?"TRUE" :"FALSE" ); +dbg (" IOSPWriteLCR : %s" , bits->IOSPWriteLCR ?"TRUE" :"FALSE" ); +dbg (" IOSPSetBaudRate : %s" , bits->IOSPSetBaudRate ?"TRUE" :"FALSE" ); +dbg (" TrueEdgeport : %s" , bits->TrueEdgeport ?"TRUE" :"FALSE" ); }return result;
@@ -585,10 +632,10 @@ static int get_epic_descriptor(struct edgeport_serial *ep)/***************************************************************************** * edge_interrupt_callback -* this is the callback function for when we have received data on the +* this is the callback function for when we have received data on the * interrupt endpoint. *****************************************************************************/ -static void edge_interrupt_callback (struct urb *urb) +static void edge_interrupt_callback (struct urb *urb) {struct edgeport_serial *edge_serial = urb->context;struct edgeport_port *edge_port;
@@ -613,17 +660,17 @@ static void edge_interrupt_callback (struct urb *urb)case -ESHUTDOWN :/* this urb is terminated, clean up */ dbg ("%s - urb shutting down with status: %d" , - __func__, status); + __func__, status);return ;default : -dbg ("%s - nonzero urb status received: %d" , - __func__, status); +dbg ("%s - nonzero urb status received: %d" , __func__, status); goto exit; } -// process this interrupt-read even if there are no ports open +/* process this interrupt-read even if there are no ports open */ if (length) { -usb_serial_debug_data (debug, &edge_serial->serial->dev->dev, __func__, length, data); +usb_serial_debug_data (debug, &edge_serial->serial->dev->dev, + __func__, length, data);if (length >1 ) { bytes_avail = data[0 ] | (data[1 ] <<8 );
@@ -637,7 +684,8 @@ static void edge_interrupt_callback (struct urb *urb)dbg ("%s - posting a read" , __func__); edge_serial->read_in_progress = true; -/* we have pending bytes on the bulk in pipe, send a request */ +/* we have pending bytes on the +bulk in pipe, send a request */ edge_serial->read_urb->dev = edge_serial->serial->dev; result =usb_submit_urb (edge_serial->read_urb,GFP_ATOMIC );if (result) {
@@ -651,7 +699,8 @@ static void edge_interrupt_callback (struct urb *urb)/* grab the txcredits for the ports if available */ position =2 ; portNumber =0 ; -while ((position < length) && (portNumber < edge_serial->serial->num_ports)) { +while ((position < length) && + (portNumber < edge_serial->serial->num_ports)) { txCredits = data[position] | (data[position+1 ] <<8 );if (txCredits) { port = edge_serial->serial->port[portNumber];
@@ -660,14 +709,19 @@ static void edge_interrupt_callback (struct urb *urb)spin_lock (&edge_port->ep_lock); edge_port->txCredits += txCredits;spin_unlock (&edge_port->ep_lock); -dbg ("%s - txcredits for port%d = %d" , __func__, portNumber, edge_port->txCredits); +dbg ("%s - txcredits for port%d = %d" , + __func__, portNumber, + edge_port->txCredits); -/* tell the tty driver that something has changed */ +/* tell the tty driver that something +has changed */ if (edge_port->port->port.tty)tty_wakeup (edge_port->port->port.tty); -// Since we have more credit, check if more data can be sent -send_more_port_data (edge_serial, edge_port); +/* Since we have more credit, check +if more data can be sent */ +send_more_port_data (edge_serial, + edge_port); } } position +=2 ;
@@ -676,19 +730,20 @@ static void edge_interrupt_callback (struct urb *urb) } exit: - result =usb_submit_urb (urb,GFP_ATOMIC ); -if (result) { -dev_err (&urb->dev->dev,"%s - Error %d submitting control urb\n" , __func__, result); - } + result =usb_submit_urb (urb,GFP_ATOMIC ); +if (result) +dev_err (&urb->dev->dev, +"%s - Error %d submitting control urb\n" , + __func__, result); }/***************************************************************************** * edge_bulk_in_callback -* this is the callback function for when we have received data on the +* this is the callback function for when we have received data on the * bulk in endpoint. *****************************************************************************/ -static void edge_bulk_in_callback (struct urb *urb) +static void edge_bulk_in_callback (struct urb *urb) {struct edgeport_serial *edge_serial = urb->context;unsigned char *data = urb->transfer_buffer;
@@ -713,16 +768,18 @@ static void edge_bulk_in_callback (struct urb *urb) raw_data_length = urb->actual_length; -usb_serial_debug_data (debug, &edge_serial->serial->dev->dev, __func__, raw_data_length, data); +usb_serial_debug_data (debug, &edge_serial->serial->dev->dev, + __func__, raw_data_length, data);spin_lock (&edge_serial->es_lock);/* decrement our rxBytes available by the number that we just got */ edge_serial->rxBytesAvail -= raw_data_length; -dbg ("%s - Received = %d, rxBytesAvail %d" , __func__, raw_data_length, edge_serial->rxBytesAvail); +dbg ("%s - Received = %d, rxBytesAvail %d" , __func__, + raw_data_length, edge_serial->rxBytesAvail); -process_rcvd_data (edge_serial, data, urb->actual_length); +process_rcvd_data (edge_serial, data, urb->actual_length);/* check to see if there's any more data for us to read */ if (edge_serial->rxBytesAvail >0 ) {
@@ -745,10 +802,10 @@ static void edge_bulk_in_callback (struct urb *urb)/***************************************************************************** * edge_bulk_out_data_callback -* this is the callback function for when we have finished sending serial data -* on the bulk out endpoint. +* this is the callback function for when we have finished sending +* serial data on the bulk out endpoint. *****************************************************************************/ -static void edge_bulk_out_data_callback (struct urb *urb) +static void edge_bulk_out_data_callback (struct urb *urb) {struct edgeport_port *edge_port = urb->context;struct tty_struct *tty;
@@ -764,24 +821,26 @@ static void edge_bulk_out_data_callback (struct urb *urb) tty = edge_port->port->port.tty;if (tty && edge_port->open) { -/* let the tty driver wakeup if it has a special write_wakeup function */ +/* let the tty driver wakeup if it has a special +write_wakeup function */ tty_wakeup (tty); } -// Release the Write URB +/* Release the Write URB */ edge_port->write_in_progress = false; -// Check if more data needs to be sent -send_more_port_data ((struct edgeport_serial *)(usb_get_serial_data (edge_port->port->serial)), edge_port); +/* Check if more data needs to be sent */ +send_more_port_data ((struct edgeport_serial *) + (usb_get_serial_data (edge_port->port->serial)), edge_port); }/***************************************************************************** * BulkOutCmdCallback -* this is the callback function for when we have finished sending a command -* on the bulk out endpoint. +* this is the callback function for when we have finished sending a +* command on the bulk out endpoint. *****************************************************************************/ -static void edge_bulk_out_cmd_callback (struct urb *urb) +static void edge_bulk_out_cmd_callback (struct urb *urb) {struct edgeport_port *edge_port = urb->context;struct tty_struct *tty;
@@ -790,17 +849,19 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)dbg ("%s" , __func__);atomic_dec (&CmdUrbs); -dbg ("%s - FREE URB %p (outstanding %d)" , __func__, urb,atomic_read (&CmdUrbs)); +dbg ("%s - FREE URB %p (outstanding %d)" , __func__, + urb,atomic_read (&CmdUrbs));/* clean up the transfer buffer */ kfree (urb->transfer_buffer);/* Free the command urb */ -usb_free_urb (urb); +usb_free_urb (urb);if (status) { -dbg ("%s - nonzero write bulk status received: %d" , __func__, status); +dbg ("%s - nonzero write bulk status received: %d" , + __func__, status);return ; }
@@ -828,7 +889,7 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)* Otherwise we return a negative error number. *****************************************************************************/ static int edge_open (struct tty_struct *tty, -struct usb_serial_port *port,struct file * filp) +struct usb_serial_port *port,struct file *filp) {struct edgeport_port *edge_port =usb_get_serial_port_data (port);struct usb_serial *serial;
@@ -843,51 +904,59 @@ static int edge_open(struct tty_struct *tty,if (tty) tty->low_latency = low_latency; -/* see if we've set up our endpoint info yet (can't set it up in edge_startup -as the structures were not set up at that time.) */ +/* see if we've set up our endpoint info yet (can't set it up +in edge_startup as the structures were not set up at that time.) */ serial = port->serial; edge_serial =usb_get_serial_data (serial);if (edge_serial ==NULL )return -ENODEV ;if (edge_serial->interrupt_in_buffer ==NULL ) {struct usb_serial_port *port0 = serial->port[0 ]; - +/* not set up yet, so do it now */ - edge_serial->interrupt_in_buffer = port0->interrupt_in_buffer; - edge_serial->interrupt_in_endpoint = port0->interrupt_in_endpointAddress; + edge_serial->interrupt_in_buffer = + port0->interrupt_in_buffer; + edge_serial->interrupt_in_endpoint = + port0->interrupt_in_endpointAddress; edge_serial->interrupt_read_urb = port0->interrupt_in_urb; edge_serial->bulk_in_buffer = port0->bulk_in_buffer; - edge_serial->bulk_in_endpoint = port0->bulk_in_endpointAddress; + edge_serial->bulk_in_endpoint = + port0->bulk_in_endpointAddress; edge_serial->read_urb = port0->read_urb; - edge_serial->bulk_out_endpoint = port0->bulk_out_endpointAddress; - + edge_serial->bulk_out_endpoint = + port0->bulk_out_endpointAddress; +/* set up our interrupt urb */ usb_fill_int_urb (edge_serial->interrupt_read_urb, - serial->dev, -usb_rcvintpipe (serial->dev, - port0->interrupt_in_endpointAddress), - port0->interrupt_in_buffer, - edge_serial->interrupt_read_urb->transfer_buffer_length, - edge_interrupt_callback, edge_serial, - edge_serial->interrupt_read_urb->interval); - + serial->dev, +usb_rcvintpipe (serial->dev, + port0->interrupt_in_endpointAddress), + port0->interrupt_in_buffer, + edge_serial->interrupt_read_urb->transfer_buffer_length, + edge_interrupt_callback, edge_serial, + edge_serial->interrupt_read_urb->interval); +/* set up our bulk in urb */ usb_fill_bulk_urb (edge_serial->read_urb, serial->dev, -usb_rcvbulkpipe (serial->dev, - port0->bulk_in_endpointAddress), - port0->bulk_in_buffer, - edge_serial->read_urb->transfer_buffer_length, - edge_bulk_in_callback, edge_serial); +usb_rcvbulkpipe (serial->dev, + port0->bulk_in_endpointAddress), + port0->bulk_in_buffer, + edge_serial->read_urb->transfer_buffer_length, + edge_bulk_in_callback, edge_serial); edge_serial->read_in_progress = false;/* start interrupt read for this edgeport -* this interrupt will continue as long as the edgeport is connected */ - response =usb_submit_urb (edge_serial->interrupt_read_urb,GFP_KERNEL ); +* this interrupt will continue as long +* as the edgeport is connected */ + response =usb_submit_urb (edge_serial->interrupt_read_urb, +GFP_KERNEL );if (response) { -dev_err (&port->dev,"%s - Error %d submitting control urb\n" , __func__, response); +dev_err (&port->dev, +"%s - Error %d submitting control urb\n" , + __func__, response); } } - +/* initialize our wait queues */ init_waitqueue_head (&edge_port->wait_open);init_waitqueue_head (&edge_port->wait_chase);
@@ -895,26 +964,29 @@ static int edge_open(struct tty_struct *tty,init_waitqueue_head (&edge_port->wait_command);/* initialize our icount structure */ -memset (&(edge_port->icount),0x00 ,sizeof (edge_port->icount)); +memset (&(edge_port->icount),0x00 ,sizeof (edge_port->icount));/* initialize our port settings */ - edge_port->txCredits =0 ;/* Can't send any data yet */ - edge_port->shadowMCR =MCR_MASTER_IE ;/* Must always set this bit to enable ints! */ + edge_port->txCredits =0 ;/* Can't send any data yet */ +/* Must always set this bit to enable ints! */ + edge_port->shadowMCR =MCR_MASTER_IE ; edge_port->chaseResponsePending = false;/* send a open port command */ edge_port->openPending = true; edge_port->open = false; - response =send_iosp_ext_cmd (edge_port,IOSP_CMD_OPEN_PORT ,0 ); + response =send_iosp_ext_cmd (edge_port,IOSP_CMD_OPEN_PORT ,0 );if (response <0 ) { -dev_err (&port->dev,"%s - error sending open port command\n" , __func__); +dev_err (&port->dev,"%s - error sending open port command\n" , + __func__); edge_port->openPending = false;return -ENODEV ; }/* now wait for the port to be completely opened */ -wait_event_timeout (edge_port->wait_open, !edge_port->openPending,OPEN_TIMEOUT ); +wait_event_timeout (edge_port->wait_open, !edge_port->openPending, +OPEN_TIMEOUT );if (!edge_port->open) {/* open timed out */
@@ -928,25 +1000,26 @@ static int edge_open(struct tty_struct *tty, edge_port->txfifo.tail =0 ; edge_port->txfifo.count =0 ; edge_port->txfifo.size = edge_port->maxTxCredits; - edge_port->txfifo.fifo =kmalloc (edge_port->maxTxCredits,GFP_KERNEL ); + edge_port->txfifo.fifo =kmalloc (edge_port->maxTxCredits,GFP_KERNEL );if (!edge_port->txfifo.fifo) {dbg ("%s - no memory" , __func__); -edge_close (tty, port, filp); +edge_close (tty, port, filp);return -ENOMEM ; }/* Allocate a URB for the write */ - edge_port->write_urb =usb_alloc_urb (0 ,GFP_KERNEL ); + edge_port->write_urb =usb_alloc_urb (0 ,GFP_KERNEL ); edge_port->write_in_progress = false;if (!edge_port->write_urb) {dbg ("%s - no memory" , __func__); -edge_close (tty, port, filp); +edge_close (tty, port, filp);return -ENOMEM ; } -dbg ("%s(%d) - Initialize TX fifo to %d bytes" , __func__, port->number, edge_port->maxTxCredits); +dbg ("%s(%d) - Initialize TX fifo to %d bytes" , + __func__, port->number, edge_port->maxTxCredits);dbg ("%s exited" , __func__);
@@ -972,27 +1045,28 @@ static void block_until_chase_response(struct edgeport_port *edge_port)int loop =10 ;while (1 ) { -// Save Last credits +/* Save Last credits */ lastCredits = edge_port->txCredits; -// Did we get our Chase response +/* Did we get our Chase response */ if (!edge_port->chaseResponsePending) {dbg ("%s - Got Chase Response" , __func__); -// did we get all of our credit back? -if (edge_port->txCredits == edge_port->maxTxCredits ) { +/* did we get all of our credit back? */ +if (edge_port->txCredits == edge_port->maxTxCredits) {dbg ("%s - Got all credits" , __func__);return ; } } -// Block the thread for a while -prepare_to_wait (&edge_port->wait_chase, &wait,TASK_UNINTERRUPTIBLE ); +/* Block the thread for a while */ +prepare_to_wait (&edge_port->wait_chase, &wait, +TASK_UNINTERRUPTIBLE );schedule_timeout (timeout);finish_wait (&edge_port->wait_chase, &wait);if (lastCredits == edge_port->txCredits) { -// No activity.. count down. +/* No activity.. count down. */ loop--;if (loop ==0 ) { edge_port->chaseResponsePending = false;
@@ -1000,8 +1074,9 @@ static void block_until_chase_response(struct edgeport_port *edge_port)return ; } }else { -// Reset timeout value back to 10 seconds -dbg ("%s - Last %d, Current %d" , __func__, lastCredits, edge_port->txCredits); +/* Reset timeout value back to 10 seconds */ +dbg ("%s - Last %d, Current %d" , __func__, + lastCredits, edge_port->txCredits); loop =10 ; } }
@@ -1018,7 +1093,7 @@ static void block_until_chase_response(struct edgeport_port *edge_port)* 3. A timeout of 3 seconds without activity has expired * ************************************************************************/ -static void block_until_tx_empty (struct edgeport_port *edge_port) +static void block_until_tx_empty (struct edgeport_port *edge_port) {DEFINE_WAIT (wait);struct TxFifo *fifo = &edge_port->txfifo;
@@ -1027,31 +1102,32 @@ static void block_until_tx_empty (struct edgeport_port *edge_port)int loop =30 ;while (1 ) { -// Save Last count +/* Save Last count */ lastCount = fifo->count; -// Is the Edgeport Buffer empty? +/* Is the Edgeport Buffer empty? */ if (lastCount ==0 ) {dbg ("%s - TX Buffer Empty" , __func__);return ; } -// Block the thread for a while -prepare_to_wait (&edge_port->wait_chase, &wait,TASK_UNINTERRUPTIBLE ); +/* Block the thread for a while */ +prepare_to_wait (&edge_port->wait_chase, &wait, +TASK_UNINTERRUPTIBLE );schedule_timeout (timeout);finish_wait (&edge_port->wait_chase, &wait);dbg ("%s wait" , __func__);if (lastCount == fifo->count) { -// No activity.. count down. +/* No activity.. count down. */ loop--;if (loop ==0 ) {dbg ("%s - TIMEOUT" , __func__);return ; } }else { -// Reset timeout value back to seconds +/* Reset timeout value back to seconds */ loop =30 ; } }
@@ -1063,20 +1139,20 @@ static void block_until_tx_empty (struct edgeport_port *edge_port)* this function is called by the tty driver when a port is closed *****************************************************************************/ static void edge_close (struct tty_struct *tty, -struct usb_serial_port *port,struct file * filp) +struct usb_serial_port *port,struct file *filp) {struct edgeport_serial *edge_serial;struct edgeport_port *edge_port;int status;dbg ("%s - port %d" , __func__, port->number); - + edge_serial =usb_get_serial_data (port->serial); edge_port =usb_get_serial_port_data (port); -if ((edge_serial ==NULL ) || (edge_port ==NULL )) +if (edge_serial ==NULL || edge_port ==NULL )return ; - -// block until tx is empty + +/* block until tx is empty */ block_until_tx_empty (edge_port); edge_port->closePending = true;
@@ -1088,13 +1164,12 @@ static void edge_close(struct tty_struct *tty, edge_port->chaseResponsePending = true;dbg ("%s - Sending IOSP_CMD_CHASE_PORT" , __func__); - status =send_iosp_ext_cmd (edge_port,IOSP_CMD_CHASE_PORT ,0 ); -if (status ==0 ) { -// block until chase finished + status =send_iosp_ext_cmd (edge_port,IOSP_CMD_CHASE_PORT ,0 ); +if (status ==0 ) +/* block until chase finished */ block_until_chase_response (edge_port); - }else { +else edge_port->chaseResponsePending = false; - } } if ((!edge_serial->is_epic) ||
@@ -1102,10 +1177,10 @@ static void edge_close(struct tty_struct *tty, (edge_serial->epic_descriptor.Supports.IOSPClose))) {/* close the port */ dbg ("%s - Sending IOSP_CMD_CLOSE_PORT" , __func__); -send_iosp_ext_cmd (edge_port,IOSP_CMD_CLOSE_PORT ,0 ); +send_iosp_ext_cmd (edge_port,IOSP_CMD_CLOSE_PORT ,0 ); } -//port->close = true; +/* port->close = true; */ edge_port->closePending = false; edge_port->open = false; edge_port->openPending = false;
@@ -1113,7 +1188,8 @@ static void edge_close(struct tty_struct *tty,usb_kill_urb (edge_port->write_urb);if (edge_port->write_urb) { -/* if this urb had a transfer buffer already (old transfer) free it */ +/* if this urb had a transfer buffer already +(old transfer) free it */ kfree (edge_port->write_urb->transfer_buffer);usb_free_urb (edge_port->write_urb); edge_port->write_urb =NULL ;
@@ -1122,14 +1198,14 @@ static void edge_close(struct tty_struct *tty, edge_port->txfifo.fifo =NULL ;dbg ("%s exited" , __func__); -} +}/***************************************************************************** * SerialWrite -* this function is called by the tty driver when data should be written to -* the port. -* If successful, we return the number of bytes written, otherwise we return -* a negative error number. +* this function is called by the tty driver when data should be written +* to the port. +* If successful, we return the number of bytes written, otherwise we +* return a negative error number. *****************************************************************************/ static int edge_write (struct tty_struct *tty,struct usb_serial_port *port,const unsigned char *data,int count)
@@ -1147,66 +1223,76 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,if (edge_port ==NULL )return -ENODEV ; -// get a pointer to the Tx fifo +/* get a pointer to the Tx fifo */ fifo = &edge_port->txfifo;spin_lock_irqsave (&edge_port->ep_lock, flags); -// calculate number of bytes to put in fifo - copySize =min ((unsigned int )count, (edge_port->txCredits - fifo->count)); +/* calculate number of bytes to put in fifo */ + copySize =min ((unsigned int )count, + (edge_port->txCredits - fifo->count)); -dbg ("%s(%d) of %d byte(s) Fifo room %d -- will copy %d bytes" , __func__, - port->number, count, edge_port->txCredits - fifo->count, copySize); +dbg ("%s(%d) of %d byte(s) Fifo room %d -- will copy %d bytes" , + __func__, port->number, count, + edge_port->txCredits - fifo->count, copySize); -/* catch writes of 0 bytes which the tty driver likes to give us, and when txCredits is empty */ +/* catch writes of 0 bytes which the tty driver likes to give us, +and when txCredits is empty */ if (copySize ==0 ) {dbg ("%s - copySize = Zero" , __func__); goto finish_write; } -// queue the data -// since we can never overflow the buffer we do not have to check for full condition - -// the copy is done is two parts -- first fill to the end of the buffer -// then copy the reset from the start of the buffer - +/* queue the data +* since we can never overflow the buffer we do not have to check for a +* full condition +* +* the copy is done is two parts -- first fill to the end of the buffer +* then copy the reset from the start of the buffer +*/ bytesleft = fifo->size - fifo->head; - firsthalf =min (bytesleft, copySize); -dbg ("%s - copy %d bytes of %d into fifo " , __func__, firsthalf, bytesleft); + firsthalf =min (bytesleft, copySize); +dbg ("%s - copy %d bytes of %d into fifo " , __func__, + firsthalf, bytesleft);/* now copy our data */ memcpy (&fifo->fifo[fifo->head], data, firsthalf); -usb_serial_debug_data (debug, &port->dev, __func__, firsthalf, &fifo->fifo[fifo->head]); +usb_serial_debug_data (debug, &port->dev, __func__, + firsthalf, &fifo->fifo[fifo->head]); -// update the index and size +/* update the index and size */ fifo->head += firsthalf; fifo->count += firsthalf; -// wrap the index -if (fifo->head == fifo->size) { +/* wrap the index */ +if (fifo->head == fifo->size) fifo->head =0 ; - } secondhalf = copySize-firsthalf;if (secondhalf) {dbg ("%s - copy rest of data %d" , __func__, secondhalf);memcpy (&fifo->fifo[fifo->head], &data[firsthalf], secondhalf); -usb_serial_debug_data (debug, &port->dev, __func__, secondhalf, &fifo->fifo[fifo->head]); -// update the index and size +usb_serial_debug_data (debug, &port->dev, __func__, + secondhalf, &fifo->fifo[fifo->head]); +/* update the index and size */ fifo->count += secondhalf; fifo->head += secondhalf; -// No need to check for wrap since we can not get to end of fifo in this part +/* No need to check for wrap since we can not get to end of +* the fifo in this part +*/ } finish_write:spin_unlock_irqrestore (&edge_port->ep_lock, flags); -send_more_port_data ((struct edgeport_serial *)usb_get_serial_data (port->serial), edge_port); +send_more_port_data ((struct edgeport_serial *) +usb_get_serial_data (port->serial), edge_port); -dbg ("%s wrote %d byte(s) TxCredits %d, Fifo %d" , __func__, copySize, edge_port->txCredits, fifo->count); +dbg ("%s wrote %d byte(s) TxCredits %d, Fifo %d" , __func__, + copySize, edge_port->txCredits, fifo->count); -return copySize; +return copySize; }
@@ -1223,7 +1309,8 @@ finish_write:* can transmit more. * ************************************************************************/ -static void send_more_port_data (struct edgeport_serial *edge_serial,struct edgeport_port *edge_port) +static void send_more_port_data (struct edgeport_serial *edge_serial, +struct edgeport_port *edge_port) {struct TxFifo *fifo = &edge_port->txfifo;struct urb *urb;
@@ -1242,67 +1329,78 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edgeif (edge_port->write_in_progress || !edge_port->open || (fifo->count ==0 )) { -dbg ("%s(%d) EXIT - fifo %d, PendingWrite = %d" , __func__, edge_port->port->number, fifo->count, edge_port->write_in_progress); +dbg ("%s(%d) EXIT - fifo %d, PendingWrite = %d" , + __func__, edge_port->port->number, + fifo->count, edge_port->write_in_progress); goto exit_send; } -// since the amount of data in the fifo will always fit into the -// edgeport buffer we do not need to check the write length - -// Do we have enough credits for this port to make it worthwhile -// to bother queueing a write. If it's too small, say a few bytes, -// it's better to wait for more credits so we can do a larger -// write. -if (edge_port->txCredits <EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD (edge_port->maxTxCredits,EDGE_FW_BULK_MAX_PACKET_SIZE )) { -dbg ("%s(%d) Not enough credit - fifo %d TxCredit %d" , __func__, edge_port->port->number, fifo->count, edge_port->txCredits ); +/* since the amount of data in the fifo will always fit into the +* edgeport buffer we do not need to check the write length +* +* Do we have enough credits for this port to make it worthwhile +* to bother queueing a write. If it's too small, say a few bytes, +* it's better to wait for more credits so we can do a larger write. +*/ +if (edge_port->txCredits <EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD (edge_port->maxTxCredits,EDGE_FW_BULK_MAX_PACKET_SIZE )) { +dbg ("%s(%d) Not enough credit - fifo %d TxCredit %d" , + __func__, edge_port->port->number, fifo->count, + edge_port->txCredits); goto exit_send; } -// lock this write +/* lock this write */ edge_port->write_in_progress = true; -// get a pointer to the write_urb +/* get a pointer to the write_urb */ urb = edge_port->write_urb;/* make sure transfer buffer is freed */ kfree (urb->transfer_buffer); urb->transfer_buffer =NULL ; -/* build the data header for the buffer and port that we are about to send out */ +/* build the data header for the buffer and port that we are about +to send out */ count = fifo->count; - buffer =kmalloc (count+2 ,GFP_ATOMIC ); + buffer =kmalloc (count+2 ,GFP_ATOMIC );if (buffer ==NULL ) { -dev_err (&edge_port->port->dev,"%s - no more kernel memory...\n" , __func__); +dev_err (&edge_port->port->dev, +"%s - no more kernel memory...\n" , __func__); edge_port->write_in_progress = false; goto exit_send; } - buffer[0 ] =IOSP_BUILD_DATA_HDR1 (edge_port->port->number - edge_port->port->serial->minor, count); - buffer[1 ] =IOSP_BUILD_DATA_HDR2 (edge_port->port->number - edge_port->port->serial->minor, count); + buffer[0 ] =IOSP_BUILD_DATA_HDR1 (edge_port->port->number + - edge_port->port->serial->minor, count); + buffer[1 ] =IOSP_BUILD_DATA_HDR2 (edge_port->port->number + - edge_port->port->serial->minor, count);/* now copy our data */ bytesleft = fifo->size - fifo->tail; - firsthalf =min (bytesleft, count); + firsthalf =min (bytesleft, count);memcpy (&buffer[2 ], &fifo->fifo[fifo->tail], firsthalf); fifo->tail += firsthalf; fifo->count -= firsthalf; -if (fifo->tail == fifo->size) { +if (fifo->tail == fifo->size) fifo->tail =0 ; - } secondhalf = count-firsthalf;if (secondhalf) { -memcpy (&buffer[2 +firsthalf], &fifo->fifo[fifo->tail], secondhalf); +memcpy (&buffer[2 +firsthalf], &fifo->fifo[fifo->tail], + secondhalf); fifo->tail += secondhalf; fifo->count -= secondhalf; }if (count) -usb_serial_debug_data (debug, &edge_port->port->dev, __func__, count, &buffer[2 ]); +usb_serial_debug_data (debug, &edge_port->port->dev, + __func__, count, &buffer[2 ]);/* fill up the urb with all of our data and submit it */ -usb_fill_bulk_urb (urb, edge_serial->serial->dev, -usb_sndbulkpipe (edge_serial->serial->dev, edge_serial->bulk_out_endpoint), - buffer, count+2 , edge_bulk_out_data_callback, edge_port); +usb_fill_bulk_urb (urb, edge_serial->serial->dev, +usb_sndbulkpipe (edge_serial->serial->dev, + edge_serial->bulk_out_endpoint), + buffer, count+2 , + edge_bulk_out_data_callback, edge_port);/* decrement the number of credits we have by the number we just sent */ edge_port->txCredits -= count;
@@ -1312,14 +1410,17 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge status =usb_submit_urb (urb,GFP_ATOMIC );if (status) {/* something went wrong */ -dev_err (&edge_port->port->dev,"%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n" , __func__, status); +dev_err (&edge_port->port->dev, +"%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n" , + __func__, status); edge_port->write_in_progress = false;/* revert the credits as something bad happened. */ edge_port->txCredits += count; edge_port->icount.tx -= count; } -dbg ("%s wrote %d byte(s) TxCredit %d, Fifo %d" , __func__, count, edge_port->txCredits, fifo->count); +dbg ("%s wrote %d byte(s) TxCredit %d, Fifo %d" , + __func__, count, edge_port->txCredits, fifo->count); exit_send:spin_unlock_irqrestore (&edge_port->ep_lock, flags);
@@ -1328,11 +1429,10 @@ exit_send:/***************************************************************************** * edge_write_room -* this function is called by the tty driver when it wants to know how many -* bytes of data we can accept for a specific port. -* If successful, we return the amount of room that we have for this port -* (the txCredits), -* Otherwise we return a negative error number. +* this function is called by the tty driver when it wants to know how +* many bytes of data we can accept for a specific port. If successful, +* we return the amount of room that we have for this port (the txCredits) +* otherwise we return a negative error number. *****************************************************************************/ static int edge_write_room (struct tty_struct *tty) {
@@ -1355,7 +1455,7 @@ static int edge_write_room(struct tty_struct *tty)return -EINVAL ; } -// total of both buffers is still txCredit +/* total of both buffers is still txCredit */ spin_lock_irqsave (&edge_port->ep_lock, flags); room = edge_port->txCredits - edge_port->txfifo.count;spin_unlock_irqrestore (&edge_port->ep_lock, flags);
@@ -1367,11 +1467,11 @@ static int edge_write_room(struct tty_struct *tty)/***************************************************************************** * edge_chars_in_buffer -* this function is called by the tty driver when it wants to know how many -* bytes of data we currently have outstanding in the port (data that has -* been written, but hasn't made it out the port yet) -* If successful, we return the number of bytes left to be written in the -* system, +* this function is called by the tty driver when it wants to know how +* many bytes of data we currently have outstanding in the port (data that +* has been written, but hasn't made it out the port yet) +* If successful, we return the number of bytes left to be written in the +* system, * Otherwise we return a negative error number. *****************************************************************************/ static int edge_chars_in_buffer (struct tty_struct *tty)
@@ -1394,10 +1494,12 @@ static int edge_chars_in_buffer(struct tty_struct *tty) }spin_lock_irqsave (&edge_port->ep_lock, flags); - num_chars = edge_port->maxTxCredits - edge_port->txCredits + edge_port->txfifo.count; + num_chars = edge_port->maxTxCredits - edge_port->txCredits + + edge_port->txfifo.count;spin_unlock_irqrestore (&edge_port->ep_lock, flags);if (num_chars) { -dbg ("%s(port %d) - returns %d" , __func__, port->number, num_chars); +dbg ("%s(port %d) - returns %d" , __func__, + port->number, num_chars); }return num_chars;
@@ -1428,19 +1530,18 @@ static void edge_throttle(struct tty_struct *tty)/* if we are implementing XON/XOFF, send the stop character */ if (I_IXOFF (tty)) {unsigned char stop_char =STOP_CHAR (tty); - status =edge_write (tty, port, &stop_char,1 ); -if (status <=0 ) { + status =edge_write (tty, port, &stop_char,1 ); +if (status <=0 )return ; - } }/* if we are implementing RTS/CTS, toggle that line */ if (tty->termios->c_cflag &CRTSCTS ) { edge_port->shadowMCR &= ~MCR_RTS ; - status =send_cmd_write_uart_register (edge_port,MCR , edge_port->shadowMCR); -if (status !=0 ) { + status =send_cmd_write_uart_register (edge_port,MCR , + edge_port->shadowMCR); +if (status !=0 )return ; - } }return ;
@@ -1449,8 +1550,8 @@ static void edge_throttle(struct tty_struct *tty)/***************************************************************************** * edge_unthrottle -* this function is called by the tty driver when it wants to resume the data -* being read from the port (called after SerialThrottle is called) +* this function is called by the tty driver when it wants to resume the +* data being read from the port (called after SerialThrottle is called) *****************************************************************************/ static void edge_unthrottle (struct tty_struct *tty) {
@@ -1478,14 +1579,16 @@ static void edge_unthrottle(struct tty_struct *tty)/* if we are implementing RTS/CTS, toggle that line */ if (tty->termios->c_cflag &CRTSCTS ) { edge_port->shadowMCR |=MCR_RTS ; -send_cmd_write_uart_register (edge_port,MCR , edge_port->shadowMCR); +send_cmd_write_uart_register (edge_port,MCR , + edge_port->shadowMCR); } }/***************************************************************************** * SerialSetTermios -* this function is called by the tty driver when it wants to change the termios structure +* this function is called by the tty driver when it wants to change +* the termios structure *****************************************************************************/ static void edge_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios)
@@ -1522,9 +1625,10 @@ static void edge_set_termios(struct tty_struct *tty,* release the bus after transmitting. This must be done when * the transmit shift register is empty, not be done when the * transmit holding register is empty. This functionality -* allows an RS485 driver to be written in user space. +* allows an RS485 driver to be written in user space. *****************************************************************************/ -static int get_lsr_info (struct edgeport_port *edge_port,unsigned int __user *value) +static int get_lsr_info (struct edgeport_port *edge_port, +unsigned int __user *value) {unsigned int result =0 ;unsigned long flags;
@@ -1542,7 +1646,8 @@ static int get_lsr_info(struct edgeport_port *edge_port, unsigned int __user *vareturn 0 ; } -static int edge_tiocmset (struct tty_struct *tty,struct file *file,unsigned int set,unsigned int clear) +static int edge_tiocmset (struct tty_struct *tty,struct file *file, +unsigned int set,unsigned int clear) {struct usb_serial_port *port = tty->driver_data;struct edgeport_port *edge_port =usb_get_serial_port_data (port);
@@ -1597,7 +1702,8 @@ static int edge_tiocmget(struct tty_struct *tty, struct file *file)return result; } -static int get_serial_info (struct edgeport_port *edge_port,struct serial_struct __user *retinfo) +static int get_serial_info (struct edgeport_port *edge_port, +struct serial_struct __user *retinfo) {struct serial_struct tmp;
@@ -1640,60 +1746,61 @@ static int edge_ioctl(struct tty_struct *tty, struct file *file,dbg ("%s - port %d, cmd = 0x%x" , __func__, port->number, cmd);switch (cmd) { -case TIOCSERGETLSR : -dbg ("%s (%d) TIOCSERGETLSR" , __func__, port->number); -return get_lsr_info (edge_port, (unsigned int __user *) arg); - -case TIOCGSERIAL : -dbg ("%s (%d) TIOCGSERIAL" , __func__, port->number); -return get_serial_info (edge_port, (struct serial_struct __user *) arg); - -case TIOCMIWAIT : -dbg ("%s (%d) TIOCMIWAIT" , __func__, port->number); - cprev = edge_port->icount; -while (1 ) { -prepare_to_wait (&edge_port->delta_msr_wait, &wait,TASK_INTERRUPTIBLE ); -schedule (); -finish_wait (&edge_port->delta_msr_wait, &wait); -/* see if a signal did it */ -if (signal_pending (current)) -return -ERESTARTSYS ; - cnow = edge_port->icount; -if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && - cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) -return -EIO ;/* no change => error */ -if (((arg &TIOCM_RNG ) && (cnow.rng != cprev.rng)) || - ((arg &TIOCM_DSR ) && (cnow.dsr != cprev.dsr)) || - ((arg &TIOCM_CD ) && (cnow.dcd != cprev.dcd)) || - ((arg &TIOCM_CTS ) && (cnow.cts != cprev.cts)) ) { -return 0 ; - } - cprev = cnow; +case TIOCSERGETLSR : +dbg ("%s (%d) TIOCSERGETLSR" , __func__, port->number); +return get_lsr_info (edge_port, (unsigned int __user *) arg); + +case TIOCGSERIAL : +dbg ("%s (%d) TIOCGSERIAL" , __func__, port->number); +return get_serial_info (edge_port, (struct serial_struct __user *) arg); + +case TIOCMIWAIT : +dbg ("%s (%d) TIOCMIWAIT" , __func__, port->number); + cprev = edge_port->icount; +while (1 ) { +prepare_to_wait (&edge_port->delta_msr_wait, + &wait,TASK_INTERRUPTIBLE ); +schedule (); +finish_wait (&edge_port->delta_msr_wait, &wait); +/* see if a signal did it */ +if (signal_pending (current)) +return -ERESTARTSYS ; + cnow = edge_port->icount; +if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && + cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) +return -EIO ;/* no change => error */ +if (((arg &TIOCM_RNG ) && (cnow.rng != cprev.rng)) || + ((arg &TIOCM_DSR ) && (cnow.dsr != cprev.dsr)) || + ((arg &TIOCM_CD ) && (cnow.dcd != cprev.dcd)) || + ((arg &TIOCM_CTS ) && (cnow.cts != cprev.cts))) { +return 0 ; } -/* NOTREACHED */ -break ; + cprev = cnow; + } +/* NOTREACHED */ +break ; -case TIOCGICOUNT : - cnow = edge_port->icount; -memset (&icount,0 ,sizeof (icount)); - icount.cts = cnow.cts; - icount.dsr = cnow.dsr; - icount.rng = cnow.rng; - icount.dcd = cnow.dcd; - icount.rx = cnow.rx; - icount.tx = cnow.tx; - icount.frame = cnow.frame; - icount.overrun = cnow.overrun; - icount.parity = cnow.parity; - icount.brk = cnow.brk; - icount.buf_overrun = cnow.buf_overrun; - -dbg ("%s (%d) TIOCGICOUNT RX=%d, TX=%d" , __func__, port->number, icount.rx, icount.tx ); -if (copy_to_user ((void __user *)arg, &icount,sizeof (icount))) -return -EFAULT ; -return 0 ; +case TIOCGICOUNT : + cnow = edge_port->icount; +memset (&icount,0 ,sizeof (icount)); + icount.cts = cnow.cts; + icount.dsr = cnow.dsr; + icount.rng = cnow.rng; + icount.dcd = cnow.dcd; + icount.rx = cnow.rx; + icount.tx = cnow.tx; + icount.frame = cnow.frame; + icount.overrun = cnow.overrun; + icount.parity = cnow.parity; + icount.brk = cnow.brk; + icount.buf_overrun = cnow.buf_overrun; + +dbg ("%s (%d) TIOCGICOUNT RX=%d, TX=%d" , + __func__, port->number, icount.rx, icount.tx); +if (copy_to_user ((void __user *)arg, &icount,sizeof (icount))) +return -EFAULT ; +return 0 ; } -return -ENOIOCTLCMD ; }
@@ -1702,7 +1809,7 @@ static int edge_ioctl(struct tty_struct *tty, struct file *file,* SerialBreak * this function sends a break to the port *****************************************************************************/ -static void edge_break (struct tty_struct *tty,int break_state) +static void edge_break (struct tty_struct *tty,int break_state) {struct usb_serial_port *port = tty->driver_data;struct edgeport_port *edge_port =usb_get_serial_port_data (port);
@@ -1716,9 +1823,9 @@ static void edge_break (struct tty_struct *tty, int break_state) edge_port->chaseResponsePending = true;dbg ("%s - Sending IOSP_CMD_CHASE_PORT" , __func__); - status =send_iosp_ext_cmd (edge_port,IOSP_CMD_CHASE_PORT ,0 ); + status =send_iosp_ext_cmd (edge_port,IOSP_CMD_CHASE_PORT ,0 );if (status ==0 ) { -// block until chase finished +/* block until chase finished */ block_until_chase_response (edge_port); }else { edge_port->chaseResponsePending = false;
@@ -1730,14 +1837,16 @@ static void edge_break (struct tty_struct *tty, int break_state) (edge_serial->epic_descriptor.Supports.IOSPSetClrBreak))) {if (break_state ==-1 ) {dbg ("%s - Sending IOSP_CMD_SET_BREAK" , __func__); - status =send_iosp_ext_cmd (edge_port,IOSP_CMD_SET_BREAK ,0 ); + status =send_iosp_ext_cmd (edge_port, +IOSP_CMD_SET_BREAK ,0 ); }else {dbg ("%s - Sending IOSP_CMD_CLEAR_BREAK" , __func__); - status =send_iosp_ext_cmd (edge_port,IOSP_CMD_CLEAR_BREAK ,0 ); - } -if (status) { -dbg ("%s - error sending break set/clear command." , __func__); + status =send_iosp_ext_cmd (edge_port, +IOSP_CMD_CLEAR_BREAK ,0 ); } +if (status) +dbg ("%s - error sending break set/clear command." , + __func__); }return ;
@@ -1748,7 +1857,8 @@ static void edge_break (struct tty_struct *tty, int break_state)* process_rcvd_data * this function handles the data received on the bulk in pipe. *****************************************************************************/ -static void process_rcvd_data (struct edgeport_serial *edge_serial,unsigned char * buffer,__u16 bufferLength) +static void process_rcvd_data (struct edgeport_serial *edge_serial, +unsigned char *buffer,__u16 bufferLength) {struct usb_serial_port *port;struct edgeport_port *edge_port;
@@ -1769,105 +1879,123 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha lastBufferLength = bufferLength;switch (edge_serial->rxState) { -case EXPECT_HDR1 : - edge_serial->rxHeader1 = *buffer; - ++buffer; - --bufferLength; +case EXPECT_HDR1 : + edge_serial->rxHeader1 = *buffer; + ++buffer; + --bufferLength; -if (bufferLength ==0 ) { - edge_serial->rxState =EXPECT_HDR2 ; +if (bufferLength ==0 ) { + edge_serial->rxState =EXPECT_HDR2 ; +break ; + } +/* otherwise, drop on through */ +case EXPECT_HDR2 : + edge_serial->rxHeader2 = *buffer; + ++buffer; + --bufferLength; + +dbg ("%s - Hdr1=%02X Hdr2=%02X" , __func__, + edge_serial->rxHeader1, edge_serial->rxHeader2); +/* Process depending on whether this header is +* data or status */ + +if (IS_CMD_STAT_HDR (edge_serial->rxHeader1)) { +/* Decode this status header and go to +* EXPECT_HDR1 (if we can process the status +* with only 2 bytes), or go to EXPECT_HDR3 to +* get the third byte. */ + edge_serial->rxPort = +IOSP_GET_HDR_PORT (edge_serial->rxHeader1); + edge_serial->rxStatusCode = +IOSP_GET_STATUS_CODE ( + edge_serial->rxHeader1); + +if (!IOSP_STATUS_IS_2BYTE ( + edge_serial->rxStatusCode)) { +/* This status needs additional bytes. +* Save what we have and then wait for +* more data. +*/ + edge_serial->rxStatusParam + = edge_serial->rxHeader2; + edge_serial->rxState =EXPECT_HDR3 ;break ; } -/* otherwise, drop on through */ - -case EXPECT_HDR2 : - edge_serial->rxHeader2 = *buffer; - ++buffer; - --bufferLength; - -dbg ("%s - Hdr1=%02X Hdr2=%02X" , __func__, edge_serial->rxHeader1, edge_serial->rxHeader2); - -// Process depending on whether this header is -// data or status - -if (IS_CMD_STAT_HDR (edge_serial->rxHeader1)) { -// Decode this status header and goto EXPECT_HDR1 (if we -// can process the status with only 2 bytes), or goto -// EXPECT_HDR3 to get the third byte. - - edge_serial->rxPort =IOSP_GET_HDR_PORT (edge_serial->rxHeader1); - edge_serial->rxStatusCode =IOSP_GET_STATUS_CODE (edge_serial->rxHeader1); - -if (!IOSP_STATUS_IS_2BYTE (edge_serial->rxStatusCode)) { -// This status needs additional bytes. Save what we have -// and then wait for more data. - edge_serial->rxStatusParam = edge_serial->rxHeader2; - - edge_serial->rxState =EXPECT_HDR3 ; -break ; - } +/* We have all the header bytes, process the +status now */ +process_rcvd_status (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); +dbg ("%s - Data for Port %u Len %u" , + __func__, + edge_serial->rxPort, + edge_serial->rxBytesRemaining); + +/* ASSERT(DevExt->RxPort < DevExt->NumPorts); +* ASSERT(DevExt->RxBytesRemaining < +* IOSP_MAX_DATA_LENGTH); +*/ -// We have all the header bytes, process the status now -process_rcvd_status (edge_serial, edge_serial->rxHeader2,0 ); - edge_serial->rxState =EXPECT_HDR1 ; +if (bufferLength ==0 ) { + edge_serial->rxState =EXPECT_DATA ;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); - -dbg ("%s - Data for Port %u Len %u" , __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 } +/* Else, drop through */ + } +case EXPECT_DATA :/* Expect data */ +if (bufferLength < edge_serial->rxBytesRemaining) { + rxLen = bufferLength; +/* Expect data to start next buffer */ + edge_serial->rxState =EXPECT_DATA ; + }else { +/* BufLen >= RxBytesRemaining */ + rxLen = edge_serial->rxBytesRemaining; +/* Start another header next time */ + edge_serial->rxState =EXPECT_HDR1 ; + } -case EXPECT_DATA :// Expect data - -if (bufferLength < edge_serial->rxBytesRemaining) { - rxLen = bufferLength; - edge_serial->rxState =EXPECT_DATA ;// Expect data to start next buffer - }else { -// BufLen >= RxBytesRemaining - rxLen = edge_serial->rxBytesRemaining; - edge_serial->rxState =EXPECT_HDR1 ;// Start another header next time - } + bufferLength -= rxLen; + edge_serial->rxBytesRemaining -= rxLen; - bufferLength -= rxLen; - edge_serial->rxBytesRemaining -= rxLen; - -/* spit this data back into the tty driver if this port is open */ -if (rxLen) { - port = edge_serial->serial->port[edge_serial->rxPort]; - edge_port =usb_get_serial_port_data (port); -if (edge_port->open) { - tty = edge_port->port->port.tty; -if (tty) { -dbg ("%s - Sending %d bytes to TTY for port %d" , __func__, rxLen, edge_serial->rxPort); -edge_tty_recv (&edge_serial->serial->dev->dev, tty, buffer, rxLen); - } - edge_port->icount.rx += rxLen; +/* spit this data back into the tty driver if this +port is open */ +if (rxLen) { + port = edge_serial->serial->port[ + edge_serial->rxPort]; + edge_port =usb_get_serial_port_data (port); +if (edge_port->open) { + tty = edge_port->port->port.tty; +if (tty) { +dbg ("%s - Sending %d bytes to TTY for port %d" , + __func__, rxLen, edge_serial->rxPort); +edge_tty_recv (&edge_serial->serial->dev->dev, tty, buffer, rxLen); } - buffer += rxLen; + edge_port->icount.rx += rxLen; } + buffer += rxLen; + } +break ; -break ; - -case EXPECT_HDR3 :// Expect 3rd byte of status header - edge_serial->rxHeader3 = *buffer; - ++buffer; - --bufferLength; - -// We have all the header bytes, process the status now -process_rcvd_status (edge_serial, edge_serial->rxStatusParam, edge_serial->rxHeader3); - edge_serial->rxState =EXPECT_HDR1 ; -break ; - +case EXPECT_HDR3 :/* Expect 3rd byte of status header */ + edge_serial->rxHeader3 = *buffer; + ++buffer; + --bufferLength; + +/* We have all the header bytes, process the +status now */ +process_rcvd_status (edge_serial, + edge_serial->rxStatusParam, + edge_serial->rxHeader3); + edge_serial->rxState =EXPECT_HDR1 ; +break ; } } }
@@ -1875,9 +2003,11 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha/***************************************************************************** * process_rcvd_status -* this function handles the any status messages received on the bulk in pipe. +* this function handles the any status messages received on the +* bulk in pipe. *****************************************************************************/ -static void process_rcvd_status (struct edgeport_serial *edge_serial,__u8 byte2,__u8 byte3) +static void process_rcvd_status (struct edgeport_serial *edge_serial, +__u8 byte2,__u8 byte3) {struct usb_serial_port *port;struct edgeport_port *edge_port;
@@ -1887,7 +2017,9 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2 port = edge_serial->serial->port[edge_serial->rxPort]; edge_port =usb_get_serial_port_data (port);if (edge_port ==NULL ) { -dev_err (&edge_serial->serial->dev->dev,"%s - edge_port == NULL for port %d\n" , __func__, edge_serial->rxPort); +dev_err (&edge_serial->serial->dev->dev, +"%s - edge_port == NULL for port %d\n" , + __func__, edge_serial->rxPort);return ; }
@@ -1895,22 +2027,28 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2if (code ==IOSP_EXT_STATUS ) {switch (byte2) { -case IOSP_EXT_STATUS_CHASE_RSP : -// we want to do EXT status regardless of port open/closed -dbg ("%s - Port %u EXT CHASE_RSP Data = %02x" , __func__, edge_serial->rxPort, byte3 ); -// Currently, the only EXT_STATUS is Chase, so process here instead of one more call -// to one more subroutine. If/when more EXT_STATUS, there'll be more work to do. -// Also, we currently clear flag and close the port regardless of content of above's Byte3. -// We could choose to do something else when Byte3 says Timeout on Chase from Edgeport, -// like wait longer in block_until_chase_response, but for now we don't. - edge_port->chaseResponsePending = false; -wake_up (&edge_port->wait_chase); -return ; +case IOSP_EXT_STATUS_CHASE_RSP : +/* we want to do EXT status regardless of port +* open/closed */ +dbg ("%s - Port %u EXT CHASE_RSP Data = %02x" , + __func__, edge_serial->rxPort, byte3); +/* Currently, the only EXT_STATUS is Chase, so process +* here instead of one more call to one more subroutine +* If/when more EXT_STATUS, there'll be more work to do +* Also, we currently clear flag and close the port +* regardless of content of above's Byte3. +* We could choose to do something else when Byte3 says +* Timeout on Chase from Edgeport, like wait longer in +* block_until_chase_response, but for now we don't. +*/ + edge_port->chaseResponsePending = false; +wake_up (&edge_port->wait_chase); +return ; -case IOSP_EXT_STATUS_RX_CHECK_RSP : -dbg ("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n" , __func__, edge_serial->rxPort, byte3 ); -//Port->RxCheckRsp = true; -return ; +case IOSP_EXT_STATUS_RX_CHECK_RSP : +dbg ("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n" , __func__, edge_serial->rxPort, byte3); +/* Port->RxCheckRsp = true; */ +return ; } }
@@ -1918,12 +2056,14 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2 edge_port->txCredits =GET_TX_BUFFER_SIZE (byte3); edge_port->maxTxCredits = edge_port->txCredits;dbg ("%s - Port %u Open Response Inital MSR = %02x TxBufferSize = %d" , __func__, edge_serial->rxPort, byte2, edge_port->txCredits); -handle_new_msr (edge_port, byte2); +handle_new_msr (edge_port, byte2); -/* send the current line settings to the port so we are in sync with any further termios calls */ +/* send the current line settings to the port so we are +in sync with any further termios calls */ /* FIXME: locking on tty */ if (edge_port->port->port.tty) -change_port_settings (edge_port->port->port.tty, edge_port, edge_port->port->port.tty->termios); +change_port_settings (edge_port->port->port.tty, + edge_port, edge_port->port->port.tty->termios);/* we have completed the open */ edge_port->openPending = false;
@@ -1932,45 +2072,49 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2return ; } -// If port is closed, silently discard all rcvd status. We can -// have cases where buffered status is received AFTER the close -// port command is sent to the Edgeport. -if (!edge_port->open || edge_port->closePending) { +/* If port is closed, silently discard all rcvd status. We can +* have cases where buffered status is received AFTER the close +* port command is sent to the Edgeport. +*/ +if (!edge_port->open || edge_port->closePending)return ; - }switch (code) { -// Not currently sent by Edgeport -case IOSP_STATUS_LSR : -dbg ("%s - Port %u LSR Status = %02x" , __func__, edge_serial->rxPort, byte2); -handle_new_lsr (edge_port, false, byte2,0 ); -break ; +/* Not currently sent by Edgeport */ +case IOSP_STATUS_LSR : +dbg ("%s - Port %u LSR Status = %02x" , + __func__, edge_serial->rxPort, byte2); +handle_new_lsr (edge_port, false, byte2,0 ); +break ; -case IOSP_STATUS_LSR_DATA : -dbg ("%s - Port %u LSR Status = %02x, Data = %02x" , __func__, edge_serial->rxPort, byte2, byte3); -// byte2 is LSR Register -// byte3 is broken data byte -handle_new_lsr (edge_port, true, byte2, byte3); -break ; -// -// case IOSP_EXT_4_STATUS: -// dbg("%s - Port %u LSR Status = %02x Data = %02x", __func__, edge_serial->rxPort, byte2, byte3); -// break; -// -case IOSP_STATUS_MSR : -dbg ("%s - Port %u MSR Status = %02x" , __func__, edge_serial->rxPort, byte2); - -// Process this new modem status and generate appropriate -// events, etc, based on the new status. This routine -// also saves the MSR in Port->ShadowMsr. -handle_new_msr (edge_port, byte2); -break ; +case IOSP_STATUS_LSR_DATA : +dbg ("%s - Port %u LSR Status = %02x, Data = %02x" , + __func__, edge_serial->rxPort, byte2, byte3); +/* byte2 is LSR Register */ +/* byte3 is broken data byte */ +handle_new_lsr (edge_port, true, byte2, byte3); +break ; +/* +* case IOSP_EXT_4_STATUS: +* dbg("%s - Port %u LSR Status = %02x Data = %02x", +* __func__, edge_serial->rxPort, byte2, byte3); +* break; +*/ +case IOSP_STATUS_MSR : +dbg ("%s - Port %u MSR Status = %02x" , + __func__, edge_serial->rxPort, byte2); +/* +* Process this new modem status and generate appropriate +* events, etc, based on the new status. This routine +* also saves the MSR in Port->ShadowMsr. +*/ +handle_new_msr (edge_port, byte2); +break ; -default : -dbg ("%s - Unrecognized IOSP status code %u\n" , __func__, code); -break ; +default : +dbg ("%s - Unrecognized IOSP status code %u\n" , __func__, code); +break ; } -return ; }
@@ -1979,7 +2123,8 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2* edge_tty_recv * this function passes data on to the tty flip buffer *****************************************************************************/ -static void edge_tty_recv (struct device *dev,struct tty_struct *tty,unsigned char *data,int length) +static void edge_tty_recv (struct device *dev,struct tty_struct *tty, +unsigned char *data,int length) {int cnt;
@@ -1988,7 +2133,7 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned cif (cnt < length) {dev_err (dev,"%s - dropping data, %d bytes lost\n" , __func__, length - cnt); -if (cnt ==0 ) +if (cnt ==0 )break ; }tty_insert_flip_string (tty, data, cnt);
@@ -2010,22 +2155,19 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr)dbg ("%s %02x" , __func__, newMsr); -if (newMsr & (EDGEPORT_MSR_DELTA_CTS |EDGEPORT_MSR_DELTA_DSR |EDGEPORT_MSR_DELTA_RI |EDGEPORT_MSR_DELTA_CD )) { +if (newMsr & (EDGEPORT_MSR_DELTA_CTS |EDGEPORT_MSR_DELTA_DSR | +EDGEPORT_MSR_DELTA_RI |EDGEPORT_MSR_DELTA_CD )) { icount = &edge_port->icount;/* update input line counters */ -if (newMsr &EDGEPORT_MSR_DELTA_CTS ) { +if (newMsr &EDGEPORT_MSR_DELTA_CTS ) icount->cts++; - } -if (newMsr &EDGEPORT_MSR_DELTA_DSR ) { +if (newMsr &EDGEPORT_MSR_DELTA_DSR ) icount->dsr++; - } -if (newMsr &EDGEPORT_MSR_DELTA_CD ) { +if (newMsr &EDGEPORT_MSR_DELTA_CD ) icount->dcd++; - } -if (newMsr &EDGEPORT_MSR_DELTA_RI ) { +if (newMsr &EDGEPORT_MSR_DELTA_RI ) icount->rng++; - }wake_up_interruptible (&edge_port->delta_msr_wait); }
@@ -2040,42 +2182,41 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr)* handle_new_lsr * this function handles any change to the lsr register for a port. *****************************************************************************/ -static void handle_new_lsr (struct edgeport_port *edge_port,__u8 lsrData,__u8 lsr,__u8 data) +static void handle_new_lsr (struct edgeport_port *edge_port,__u8 lsrData, +__u8 lsr,__u8 data) { -__u8 newLsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR |LSR_PAR_ERR |LSR_FRM_ERR |LSR_BREAK )); -struct async_icount *icount; +__u8 newLsr = (__u8) (lsr & (__u8) + (LSR_OVER_ERR |LSR_PAR_ERR |LSR_FRM_ERR |LSR_BREAK )); +struct async_icount *icount;dbg ("%s - %02x" , __func__, newLsr); edge_port->shadowLSR = lsr;if (newLsr &LSR_BREAK ) { -// -// Parity and Framing errors only count if they -// occur exclusive of a break being -// received. -// +/* +* Parity and Framing errors only count if they +* occur exclusive of a break being +* received. +*/ newLsr &= (__u8)(LSR_OVER_ERR |LSR_BREAK ); }/* Place LSR data byte into Rx buffer */ if (lsrData && edge_port->port->port.tty) -edge_tty_recv (&edge_port->port->dev, edge_port->port->port.tty, &data,1 ); +edge_tty_recv (&edge_port->port->dev, + edge_port->port->port.tty, &data,1 );/* update input line counters */ icount = &edge_port->icount; -if (newLsr &LSR_BREAK ) { +if (newLsr &LSR_BREAK ) icount->brk++; - } -if (newLsr &LSR_OVER_ERR ) { +if (newLsr &LSR_OVER_ERR ) icount->overrun++; - } -if (newLsr &LSR_PAR_ERR ) { +if (newLsr &LSR_PAR_ERR ) icount->parity++; - } -if (newLsr &LSR_FRM_ERR ) { +if (newLsr &LSR_FRM_ERR ) icount->frame++; - }return ; }
@@ -2083,12 +2224,13 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, __u8 l/**************************************************************************** * sram_write -* writes a number of bytes to the Edgeport device's sram starting at the +* writes a number of bytes to the Edgeport device's sram starting at the * given address. * If successful returns the number of bytes written, otherwise it returns * a negative error number of the problem. ****************************************************************************/ -static int sram_write (struct usb_serial *serial,__u16 extAddr,__u16 addr,__u16 length,__u8 *data) +static int sram_write (struct usb_serial *serial,__u16 extAddr,__u16 addr, +__u16 length,__u8 *data) {int result;__u16 current_length;
@@ -2096,32 +2238,37 @@ static int sram_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __udbg ("%s - %x, %x, %d" , __func__, extAddr, addr, length); - transfer_buffer =kmalloc (64 ,GFP_KERNEL ); + transfer_buffer =kmalloc (64 ,GFP_KERNEL );if (!transfer_buffer) { -dev_err (&serial->dev->dev,"%s - kmalloc(%d) failed.\n" , __func__,64 ); +dev_err (&serial->dev->dev,"%s - kmalloc(%d) failed.\n" , + __func__,64 );return -ENOMEM ; }/* need to split these writes up into 64 byte chunks */ result =0 ;while (length >0 ) { -if (length >64 ) { +if (length >64 ) current_length =64 ; - }else { +else current_length = length; - } -// dbg("%s - writing %x, %x, %d", __func__, extAddr, addr, current_length); -memcpy (transfer_buffer, data, current_length); - result =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ),USB_REQUEST_ION_WRITE_RAM , -0x40 , addr, extAddr, transfer_buffer, current_length,300 ); + +/* dbg("%s - writing %x, %x, %d", __func__, +extAddr, addr, current_length); */ +memcpy (transfer_buffer, data, current_length); + result =usb_control_msg (serial->dev, +usb_sndctrlpipe (serial->dev,0 ), +USB_REQUEST_ION_WRITE_RAM , +0x40 , addr, extAddr, transfer_buffer, + current_length,300 );if (result <0 )break ; length -= current_length; addr += current_length; data += current_length; - } + } -kfree (transfer_buffer); +kfree (transfer_buffer);return result; }
@@ -2133,40 +2280,46 @@ static int sram_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u* If successful returns the number of bytes written, otherwise it returns * a negative error number of the problem. ****************************************************************************/ -static int rom_write (struct usb_serial *serial,__u16 extAddr,__u16 addr,__u16 length,__u8 *data) +static int rom_write (struct usb_serial *serial,__u16 extAddr,__u16 addr, +__u16 length,__u8 *data) {int result;__u16 current_length;unsigned char *transfer_buffer; -// dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); +/* dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); */ - transfer_buffer =kmalloc (64 ,GFP_KERNEL ); + transfer_buffer =kmalloc (64 ,GFP_KERNEL );if (!transfer_buffer) { -dev_err (&serial->dev->dev,"%s - kmalloc(%d) failed.\n" , __func__,64 ); +dev_err (&serial->dev->dev,"%s - kmalloc(%d) failed.\n" , + __func__,64 );return -ENOMEM ; }/* need to split these writes up into 64 byte chunks */ result =0 ;while (length >0 ) { -if (length >64 ) { +if (length >64 ) current_length =64 ; - }else { +else current_length = length; - } -// dbg("%s - writing %x, %x, %d", __func__, extAddr, addr, current_length); -memcpy (transfer_buffer, data, current_length); - result =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ),USB_REQUEST_ION_WRITE_ROM , -0x40 , addr, extAddr, transfer_buffer, current_length,300 ); + +/* dbg("%s - writing %x, %x, %d", __func__, +extAddr, addr, current_length); */ +memcpy (transfer_buffer, data, current_length); + result =usb_control_msg (serial->dev, +usb_sndctrlpipe (serial->dev,0 ), +USB_REQUEST_ION_WRITE_ROM ,0x40 , + addr, extAddr, + transfer_buffer, current_length,300 );if (result <0 )break ; length -= current_length; addr += current_length; data += current_length; - } + } -kfree (transfer_buffer); +kfree (transfer_buffer);return result; }
@@ -2178,7 +2331,8 @@ static int rom_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u1* If successful returns the number of bytes read, otherwise it returns * a negative error number of the problem. ****************************************************************************/ -static int rom_read (struct usb_serial *serial,__u16 extAddr,__u16 addr,__u16 length,__u8 *data) +static int rom_read (struct usb_serial *serial,__u16 extAddr, +__u16 addr,__u16 length,__u8 *data) {int result;__u16 current_length;
@@ -2186,32 +2340,36 @@ static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16dbg ("%s - %x, %x, %d" , __func__, extAddr, addr, length); - transfer_buffer =kmalloc (64 ,GFP_KERNEL ); + transfer_buffer =kmalloc (64 ,GFP_KERNEL );if (!transfer_buffer) { -dev_err (&serial->dev->dev,"%s - kmalloc(%d) failed.\n" , __func__,64 ); +dev_err (&serial->dev->dev, +"%s - kmalloc(%d) failed.\n" , __func__,64 );return -ENOMEM ; }/* need to split these reads up into 64 byte chunks */ result =0 ;while (length >0 ) { -if (length >64 ) { +if (length >64 ) current_length =64 ; - }else { +else current_length = length; - } -// dbg("%s - %x, %x, %d", __func__, extAddr, addr, current_length); - result =usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev,0 ),USB_REQUEST_ION_READ_ROM , -0xC0 , addr, extAddr, transfer_buffer, current_length,300 ); +/* dbg("%s - %x, %x, %d", __func__, +extAddr, addr, current_length); */ + result =usb_control_msg (serial->dev, +usb_rcvctrlpipe (serial->dev,0 ), +USB_REQUEST_ION_READ_ROM , +0xC0 , addr, extAddr, transfer_buffer, + current_length,300 );if (result <0 )break ; -memcpy (data, transfer_buffer, current_length); +memcpy (data, transfer_buffer, current_length); length -= current_length; addr += current_length; data += current_length; - } + } -kfree (transfer_buffer); +kfree (transfer_buffer);return result; }
@@ -2220,7 +2378,8 @@ static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16* send_iosp_ext_cmd * Is used to send a IOSP message to the Edgeport device ****************************************************************************/ -static int send_iosp_ext_cmd (struct edgeport_port *edge_port,__u8 command,__u8 param) +static int send_iosp_ext_cmd (struct edgeport_port *edge_port, +__u8 command,__u8 param) {unsigned char *buffer;unsigned char *currentCommand;
@@ -2229,19 +2388,20 @@ static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __udbg ("%s - %d, %d" , __func__, command, param); - buffer =kmalloc (10 ,GFP_ATOMIC ); + buffer =kmalloc (10 ,GFP_ATOMIC );if (!buffer) { -dev_err (&edge_port->port->dev,"%s - kmalloc(%d) failed.\n" , __func__,10 ); +dev_err (&edge_port->port->dev, +"%s - kmalloc(%d) failed.\n" , __func__,10 );return -ENOMEM ; } currentCommand = buffer; -MAKE_CMD_EXT_CMD (¤tCommand, &length, - edge_port->port->number - edge_port->port->serial->minor, - command, param); +MAKE_CMD_EXT_CMD (¤tCommand, &length, + edge_port->port->number - edge_port->port->serial->minor, + command, param); - status =write_cmd_usb (edge_port, buffer, length); + status =write_cmd_usb (edge_port, buffer, length);if (status) {/* something bad happened, let's free up the memory */ kfree (buffer);
@@ -2255,43 +2415,50 @@ static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u* write_cmd_usb * this function writes the given buffer out to the bulk write endpoint. *****************************************************************************/ -static int write_cmd_usb (struct edgeport_port *edge_port,unsigned char *buffer,int length) +static int write_cmd_usb (struct edgeport_port *edge_port, +unsigned char *buffer,int length) { -struct edgeport_serial *edge_serial =usb_get_serial_data (edge_port->port->serial); +struct edgeport_serial *edge_serial = +usb_get_serial_data (edge_port->port->serial);int status =0 ;struct urb *urb;int timeout; -usb_serial_debug_data (debug, &edge_port->port->dev, __func__, length, buffer); +usb_serial_debug_data (debug, &edge_port->port->dev, + __func__, length, buffer);/* Allocate our next urb */ - urb =usb_alloc_urb (0 ,GFP_ATOMIC ); + urb =usb_alloc_urb (0 ,GFP_ATOMIC );if (!urb)return -ENOMEM ;atomic_inc (&CmdUrbs); -dbg ("%s - ALLOCATE URB %p (outstanding %d)" , __func__, urb,atomic_read (&CmdUrbs)); +dbg ("%s - ALLOCATE URB %p (outstanding %d)" , + __func__, urb,atomic_read (&CmdUrbs)); -usb_fill_bulk_urb (urb, edge_serial->serial->dev, -usb_sndbulkpipe (edge_serial->serial->dev, edge_serial->bulk_out_endpoint), - buffer, length, edge_bulk_out_cmd_callback, edge_port); +usb_fill_bulk_urb (urb, edge_serial->serial->dev, +usb_sndbulkpipe (edge_serial->serial->dev, + edge_serial->bulk_out_endpoint), + buffer, length, edge_bulk_out_cmd_callback, edge_port); edge_port->commandPending = true; status =usb_submit_urb (urb,GFP_ATOMIC );if (status) {/* something went wrong */ -dev_err (&edge_port->port->dev,"%s - usb_submit_urb(write command) failed, status = %d\n" , __func__, status); +dev_err (&edge_port->port->dev, +"%s - usb_submit_urb(write command) failed, status = %d\n" , + __func__, status);usb_kill_urb (urb);usb_free_urb (urb);atomic_dec (&CmdUrbs);return status; } -// wait for command to finish +/* wait for command to finish */ timeout =COMMAND_TIMEOUT ;#if 0 -wait_event (&edge_port->wait_command, !edge_port->commandPending); +wait_event (&edge_port->wait_command, !edge_port->commandPending);if (edge_port->commandPending) {/* command timed out */
@@ -2308,15 +2475,18 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer* this function sends the proper command to change the baud rate of the * specified port. *****************************************************************************/ -static int send_cmd_write_baud_rate (struct edgeport_port *edge_port,int baudRate) +static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, +int baudRate) { -struct edgeport_serial *edge_serial =usb_get_serial_data (edge_port->port->serial); +struct edgeport_serial *edge_serial = +usb_get_serial_data (edge_port->port->serial);unsigned char *cmdBuffer;unsigned char *currCmd;int cmdLen =0 ;int divisor;int status; -unsigned char number = edge_port->port->number - edge_port->port->serial->minor; +unsigned char number = + edge_port->port->number - edge_port->port->serial->minor;if (edge_serial->is_epic && !edge_serial->epic_descriptor.Supports.IOSPSetBaudRate) {
@@ -2325,36 +2495,40 @@ static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRareturn 0 ; } -dbg ("%s - port = %d, baud = %d" , __func__, edge_port->port->number, baudRate); +dbg ("%s - port = %d, baud = %d" , __func__, + edge_port->port->number, baudRate); - status =calc_baud_rate_divisor (baudRate, &divisor); + status =calc_baud_rate_divisor (baudRate, &divisor);if (status) { -dev_err (&edge_port->port->dev,"%s - bad baud rate\n" , __func__); +dev_err (&edge_port->port->dev,"%s - bad baud rate\n" , + __func__);return status; } -// Alloc memory for the string of commands. - cmdBuffer =kmalloc (0x100 ,GFP_ATOMIC ); +/* Alloc memory for the string of commands. */ + cmdBuffer =kmalloc (0x100 ,GFP_ATOMIC );if (!cmdBuffer) { -dev_err (&edge_port->port->dev,"%s - kmalloc(%d) failed.\n" , __func__,0x100 ); +dev_err (&edge_port->port->dev, +"%s - kmalloc(%d) failed.\n" , __func__,0x100 );return -ENOMEM ; } currCmd = cmdBuffer; -// Enable access to divisor latch -MAKE_CMD_WRITE_REG ( &currCmd, &cmdLen, number,LCR ,LCR_DL_ENABLE ); +/* Enable access to divisor latch */ +MAKE_CMD_WRITE_REG (&currCmd, &cmdLen, number,LCR ,LCR_DL_ENABLE ); -// Write the divisor itself -MAKE_CMD_WRITE_REG ( &currCmd, &cmdLen, number,DLL ,LOW8 (divisor) ); -MAKE_CMD_WRITE_REG ( &currCmd, &cmdLen, number,DLM ,HIGH8 (divisor) ); +/* Write the divisor itself */ +MAKE_CMD_WRITE_REG (&currCmd, &cmdLen, number,DLL ,LOW8 (divisor)); +MAKE_CMD_WRITE_REG (&currCmd, &cmdLen, number,DLM ,HIGH8 (divisor)); -// Restore original value to disable access to divisor latch -MAKE_CMD_WRITE_REG ( &currCmd, &cmdLen, number,LCR , edge_port->shadowLCR); +/* Restore original value to disable access to divisor latch */ +MAKE_CMD_WRITE_REG (&currCmd, &cmdLen, number,LCR , + edge_port->shadowLCR); - status =write_cmd_usb (edge_port, cmdBuffer, cmdLen ); + status =write_cmd_usb (edge_port, cmdBuffer, cmdLen);if (status) {/* something bad happened, let's free up the memory */ -kfree (cmdBuffer); +kfree (cmdBuffer); }return status;
@@ -2366,7 +2540,7 @@ static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRa* this function calculates the proper baud rate divisor for the specified * baud rate. *****************************************************************************/ -static int calc_baud_rate_divisor (int baudrate,int *divisor) +static int calc_baud_rate_divisor (int baudrate,int *divisor) {int i;__u16 custom;
@@ -2375,17 +2549,17 @@ static int calc_baud_rate_divisor (int baudrate, int *divisor)dbg ("%s - %d" , __func__, baudrate);for (i =0 ; i <ARRAY_SIZE (divisor_table); i++) { -if ( divisor_table[i].BaudRate == baudrate ) { +if (divisor_table[i].BaudRate == baudrate) { *divisor = divisor_table[i].Divisor;return 0 ; } } -// We have tried all of the standard baud rates -// lets try to calculate the divisor for this baud rate -// Make sure the baud rate is reasonable +/* We have tried all of the standard baud rates +* lets try to calculate the divisor for this baud rate +* Make sure the baud rate is reasonable */ if (baudrate >50 && baudrate <230400 ) { -// get divisor +/* get divisor */ custom = (__u16)((230400L + baudrate/2 ) / baudrate); *divisor = custom;
@@ -2400,17 +2574,20 @@ static int calc_baud_rate_divisor (int baudrate, int *divisor)/***************************************************************************** * send_cmd_write_uart_register -* this function builds up a uart register message and sends to to the device. +* this function builds up a uart register message and sends to to the device. *****************************************************************************/ -static int send_cmd_write_uart_register (struct edgeport_port *edge_port,__u8 regNum,__u8 regValue) +static int send_cmd_write_uart_register (struct edgeport_port *edge_port, +__u8 regNum,__u8 regValue) { -struct edgeport_serial *edge_serial =usb_get_serial_data (edge_port->port->serial); +struct edgeport_serial *edge_serial = +usb_get_serial_data (edge_port->port->serial);unsigned char *cmdBuffer;unsigned char *currCmd;unsigned long cmdLen =0 ;int status; -dbg ("%s - write to %s register 0x%02x" , (regNum ==MCR ) ?"MCR" :"LCR" , __func__, regValue); +dbg ("%s - write to %s register 0x%02x" , + (regNum ==MCR ) ?"MCR" :"LCR" , __func__, regValue); if (edge_serial->is_epic && !edge_serial->epic_descriptor.Supports.IOSPWriteMCR &&
@@ -2422,27 +2599,26 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 rif (edge_serial->is_epic && !edge_serial->epic_descriptor.Supports.IOSPWriteLCR && regNum ==LCR ) { -dbg ("SendCmdWriteUartReg - Not writing to LCR Register" ); +dbg ("SendCmdWriteUartReg - Not writing to LCR Register" );return 0 ; } -// Alloc memory for the string of commands. - cmdBuffer =kmalloc (0x10 ,GFP_ATOMIC ); -if (cmdBuffer ==NULL ) { +/* Alloc memory for the string of commands. */ + cmdBuffer =kmalloc (0x10 ,GFP_ATOMIC ); +if (cmdBuffer ==NULL )return -ENOMEM ; - } currCmd = cmdBuffer; -// Build a cmd in the buffer to write the given register -MAKE_CMD_WRITE_REG (&currCmd, &cmdLen, - edge_port->port->number - edge_port->port->serial->minor, - regNum, regValue); +/* Build a cmd in the buffer to write the given register */ +MAKE_CMD_WRITE_REG (&currCmd, &cmdLen, + edge_port->port->number - edge_port->port->serial->minor, + regNum, regValue); status =write_cmd_usb (edge_port, cmdBuffer, cmdLen);if (status) {/* something bad happened, let's free up the memory */ -kfree (cmdBuffer); +kfree (cmdBuffer); }return status;
@@ -2451,14 +2627,15 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r/***************************************************************************** * change_port_settings -* This routine is called to set the UART on the device to match the specified -* new settings. +* This routine is called to set the UART on the device to match the +* specified new settings. *****************************************************************************/ static void change_port_settings (struct tty_struct *tty,struct edgeport_port *edge_port,struct ktermios *old_termios) { -struct edgeport_serial *edge_serial =usb_get_serial_data (edge_port->port->serial); +struct edgeport_serial *edge_serial = +usb_get_serial_data (edge_port->port->serial);int baud;unsigned cflag;__u8 mask =0xff ;
@@ -2480,11 +2657,23 @@ static void change_port_settings(struct tty_struct *tty, cflag = tty->termios->c_cflag;switch (cflag &CSIZE ) { -case CS5 : lData =LCR_BITS_5 ; mask =0x1f ;dbg ("%s - data bits = 5" , __func__);break ; -case CS6 : lData =LCR_BITS_6 ; mask =0x3f ;dbg ("%s - data bits = 6" , __func__);break ; -case CS7 : lData =LCR_BITS_7 ; mask =0x7f ;dbg ("%s - data bits = 7" , __func__);break ; -default : -case CS8 : lData =LCR_BITS_8 ;dbg ("%s - data bits = 8" , __func__);break ; +case CS5 : + lData =LCR_BITS_5 ; mask =0x1f ; +dbg ("%s - data bits = 5" , __func__); +break ; +case CS6 : + lData =LCR_BITS_6 ; mask =0x3f ; +dbg ("%s - data bits = 6" , __func__); +break ; +case CS7 : + lData =LCR_BITS_7 ; mask =0x7f ; +dbg ("%s - data bits = 7" , __func__); +break ; +default : +case CS8 : + lData =LCR_BITS_8 ; +dbg ("%s - data bits = 8" , __func__); +break ; } lParity =LCR_PAR_NONE ;
@@ -2526,7 +2715,8 @@ static void change_port_settings(struct tty_struct *tty,dbg ("%s - RTS/CTS is disabled" , __func__); } -/* if we are implementing XON/XOFF, set the start and stop character in the device */ +/* if we are implementing XON/XOFF, set the start and stop character +in the device */ if (I_IXOFF (tty) ||I_IXON (tty)) {unsigned char stop_char =STOP_CHAR (tty);unsigned char start_char =START_CHAR (tty);
@@ -2534,14 +2724,17 @@ static void change_port_settings(struct tty_struct *tty,if ((!edge_serial->is_epic) || ((edge_serial->is_epic) && (edge_serial->epic_descriptor.Supports.IOSPSetXChar))) { -send_iosp_ext_cmd (edge_port,IOSP_CMD_SET_XON_CHAR , start_char); -send_iosp_ext_cmd (edge_port,IOSP_CMD_SET_XOFF_CHAR , stop_char); +send_iosp_ext_cmd (edge_port, +IOSP_CMD_SET_XON_CHAR , start_char); +send_iosp_ext_cmd (edge_port, +IOSP_CMD_SET_XOFF_CHAR , stop_char); }/* if we are implementing INBOUND XON/XOFF */ if (I_IXOFF (tty)) { rxFlow |=IOSP_RX_FLOW_XON_XOFF ; -dbg ("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x" , __func__, start_char, stop_char); +dbg ("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x" , + __func__, start_char, stop_char); }else {dbg ("%s - INBOUND XON/XOFF is disabled" , __func__); }
@@ -2549,7 +2742,8 @@ static void change_port_settings(struct tty_struct *tty,/* if we are implementing OUTBOUND XON/XOFF */ if (I_IXON (tty)) { txFlow |=IOSP_TX_FLOW_XON_XOFF ; -dbg ("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x" , __func__, start_char, stop_char); +dbg ("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x" , + __func__, start_char, stop_char); }else {dbg ("%s - OUTBOUND XON/XOFF is disabled" , __func__); }
@@ -2572,20 +2766,20 @@ static void change_port_settings(struct tty_struct *tty, edge_port->validDataMask = mask;/* Send the updated LCR value to the EdgePort */ - status =send_cmd_write_uart_register (edge_port,LCR , edge_port->shadowLCR); -if (status !=0 ) { + status =send_cmd_write_uart_register (edge_port,LCR , + edge_port->shadowLCR); +if (status !=0 )return ; - }/* set up the MCR register and send it to the EdgePort */ edge_port->shadowMCR =MCR_MASTER_IE ; -if (cflag &CBAUD ) { +if (cflag &CBAUD ) edge_port->shadowMCR |= (MCR_DTR |MCR_RTS ); - } - status =send_cmd_write_uart_register (edge_port,MCR , edge_port->shadowMCR); -if (status !=0 ) { + + status =send_cmd_write_uart_register (edge_port,MCR , + edge_port->shadowMCR); +if (status !=0 )return ; - }/* Determine divisor based on baud rate */ baud =tty_get_baud_rate (tty);
@@ -2595,7 +2789,7 @@ static void change_port_settings(struct tty_struct *tty, }dbg ("%s - baud rate = %d" , __func__, baud); - status =send_cmd_write_baud_rate (edge_port, baud); + status =send_cmd_write_baud_rate (edge_port, baud);if (status ==-1 ) {/* Speed change was not possible - put back the old speed */ baud =tty_termios_baud_rate (old_termios);
@@ -2612,7 +2806,8 @@ static void change_port_settings(struct tty_struct *tty,* ASCII range, but it's only for debugging... * NOTE: expects the unicode in LE format ****************************************************************************/ -static void unicode_to_ascii (char *string,int buflen,__le16 *unicode,int unicode_size) +static void unicode_to_ascii (char *string,int buflen, +__le16 *unicode,int unicode_size) {int i;
@@ -2631,75 +2826,99 @@ static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unic/**************************************************************************** * get_manufacturing_desc -* reads in the manufacturing descriptor and stores it into the serial +* reads in the manufacturing descriptor and stores it into the serial * structure. ****************************************************************************/ -static void get_manufacturing_desc (struct edgeport_serial *edge_serial) +static void get_manufacturing_desc (struct edgeport_serial *edge_serial) {int response;dbg ("getting manufacturer descriptor" ); - response =rom_read (edge_serial->serial, (EDGE_MANUF_DESC_ADDR &0xffff0000 ) >>16 , - (__u16)(EDGE_MANUF_DESC_ADDR &0x0000ffff ),EDGE_MANUF_DESC_LEN , - (__u8 *)(&edge_serial->manuf_descriptor)); + response =rom_read (edge_serial->serial, + (EDGE_MANUF_DESC_ADDR &0xffff0000 ) >>16 , + (__u16)(EDGE_MANUF_DESC_ADDR &0x0000ffff ), +EDGE_MANUF_DESC_LEN , + (__u8 *)(&edge_serial->manuf_descriptor)); -if (response <1 ) { -dev_err (&edge_serial->serial->dev->dev,"error in getting manufacturer descriptor\n" ); - }else { +if (response <1 ) +dev_err (&edge_serial->serial->dev->dev, +"error in getting manufacturer descriptor\n" ); +else {char string[30 ];dbg ("**Manufacturer Descriptor" ); -dbg (" RomSize: %dK" , edge_serial->manuf_descriptor.RomSize); -dbg (" RamSize: %dK" , edge_serial->manuf_descriptor.RamSize); -dbg (" CpuRev: %d" , edge_serial->manuf_descriptor.CpuRev); -dbg (" BoardRev: %d" , edge_serial->manuf_descriptor.BoardRev); -dbg (" NumPorts: %d" , edge_serial->manuf_descriptor.NumPorts); -dbg (" DescDate: %d/%d/%d" , edge_serial->manuf_descriptor.DescDate[0 ], edge_serial->manuf_descriptor.DescDate[1 ], edge_serial->manuf_descriptor.DescDate[2 ]+1900 ); +dbg (" RomSize: %dK" , + edge_serial->manuf_descriptor.RomSize); +dbg (" RamSize: %dK" , + edge_serial->manuf_descriptor.RamSize); +dbg (" CpuRev: %d" , + edge_serial->manuf_descriptor.CpuRev); +dbg (" BoardRev: %d" , + edge_serial->manuf_descriptor.BoardRev); +dbg (" NumPorts: %d" , + edge_serial->manuf_descriptor.NumPorts); +dbg (" DescDate: %d/%d/%d" , + edge_serial->manuf_descriptor.DescDate[0 ], + edge_serial->manuf_descriptor.DescDate[1 ], + edge_serial->manuf_descriptor.DescDate[2 ]+1900 );unicode_to_ascii (string,sizeof (string), - edge_serial->manuf_descriptor.SerialNumber, - edge_serial->manuf_descriptor.SerNumLength/2 ); + edge_serial->manuf_descriptor.SerialNumber, + edge_serial->manuf_descriptor.SerNumLength/2 );dbg (" SerialNumber: %s" , string);unicode_to_ascii (string,sizeof (string), - edge_serial->manuf_descriptor.AssemblyNumber, - edge_serial->manuf_descriptor.AssemblyNumLength/2 ); + edge_serial->manuf_descriptor.AssemblyNumber, + edge_serial->manuf_descriptor.AssemblyNumLength/2 );dbg (" AssemblyNumber: %s" , string);unicode_to_ascii (string,sizeof (string), edge_serial->manuf_descriptor.OemAssyNumber, edge_serial->manuf_descriptor.OemAssyNumLength/2 );dbg (" OemAssyNumber: %s" , string); -dbg (" UartType: %d" , edge_serial->manuf_descriptor.UartType); -dbg (" IonPid: %d" , edge_serial->manuf_descriptor.IonPid); -dbg (" IonConfig: %d" , edge_serial->manuf_descriptor.IonConfig); +dbg (" UartType: %d" , + edge_serial->manuf_descriptor.UartType); +dbg (" IonPid: %d" , + edge_serial->manuf_descriptor.IonPid); +dbg (" IonConfig: %d" , + edge_serial->manuf_descriptor.IonConfig); } }/**************************************************************************** * get_boot_desc -* reads in the bootloader descriptor and stores it into the serial +* reads in the bootloader descriptor and stores it into the serial * structure. ****************************************************************************/ -static void get_boot_desc (struct edgeport_serial *edge_serial) +static void get_boot_desc (struct edgeport_serial *edge_serial) {int response;dbg ("getting boot descriptor" ); - response =rom_read (edge_serial->serial, (EDGE_BOOT_DESC_ADDR &0xffff0000 ) >>16 , - (__u16)(EDGE_BOOT_DESC_ADDR &0x0000ffff ),EDGE_BOOT_DESC_LEN , - (__u8 *)(&edge_serial->boot_descriptor)); + response =rom_read (edge_serial->serial, + (EDGE_BOOT_DESC_ADDR &0xffff0000 ) >>16 , + (__u16)(EDGE_BOOT_DESC_ADDR &0x0000ffff ), +EDGE_BOOT_DESC_LEN , + (__u8 *)(&edge_serial->boot_descriptor)); -if (response <1 ) { -dev_err (&edge_serial->serial->dev->dev,"error in getting boot descriptor\n" ); - }else { +if (response <1 ) +dev_err (&edge_serial->serial->dev->dev, +"error in getting boot descriptor\n" ); +else {dbg ("**Boot Descriptor:" ); -dbg (" BootCodeLength: %d" ,le16_to_cpu (edge_serial->boot_descriptor.BootCodeLength)); -dbg (" MajorVersion: %d" , edge_serial->boot_descriptor.MajorVersion); -dbg (" MinorVersion: %d" , edge_serial->boot_descriptor.MinorVersion); -dbg (" BuildNumber: %d" ,le16_to_cpu (edge_serial->boot_descriptor.BuildNumber)); -dbg (" Capabilities: 0x%x" ,le16_to_cpu (edge_serial->boot_descriptor.Capabilities)); -dbg (" UConfig0: %d" , edge_serial->boot_descriptor.UConfig0); -dbg (" UConfig1: %d" , edge_serial->boot_descriptor.UConfig1); +dbg (" BootCodeLength: %d" , +le16_to_cpu (edge_serial->boot_descriptor.BootCodeLength)); +dbg (" MajorVersion: %d" , + edge_serial->boot_descriptor.MajorVersion); +dbg (" MinorVersion: %d" , + edge_serial->boot_descriptor.MinorVersion); +dbg (" BuildNumber: %d" , +le16_to_cpu (edge_serial->boot_descriptor.BuildNumber)); +dbg (" Capabilities: 0x%x" , +le16_to_cpu (edge_serial->boot_descriptor.Capabilities)); +dbg (" UConfig0: %d" , + edge_serial->boot_descriptor.UConfig0); +dbg (" UConfig1: %d" , + edge_serial->boot_descriptor.UConfig1); } }
@@ -2708,7 +2927,7 @@ static void get_boot_desc (struct edgeport_serial *edge_serial)* load_application_firmware * This is called to load the application firmware to the device ****************************************************************************/ -static void load_application_firmware (struct edgeport_serial *edge_serial) +static void load_application_firmware (struct edgeport_serial *edge_serial) {struct edge_firmware_image_record *record;unsigned char *firmware;
@@ -2718,53 +2937,60 @@ static void load_application_firmware (struct edgeport_serial *edge_serial)switch (edge_serial->product_info.iDownloadFile) { -case EDGE_DOWNLOAD_FILE_I930 : -dbg ("downloading firmware version (930) %d.%d.%d" , - OperationalCodeImageVersion_GEN1.MajorVersion, - OperationalCodeImageVersion_GEN1.MinorVersion, - OperationalCodeImageVersion_GEN1.BuildNumber); - firmware = &OperationalCodeImage_GEN1[0 ]; - FirmwareImage = &OperationalCodeImage_GEN1[0 ]; - ImageSize =sizeof (OperationalCodeImage_GEN1); -break ; +case EDGE_DOWNLOAD_FILE_I930 : +dbg ("downloading firmware version (930) %d.%d.%d" , + OperationalCodeImageVersion_GEN1.MajorVersion, + OperationalCodeImageVersion_GEN1.MinorVersion, + OperationalCodeImageVersion_GEN1.BuildNumber); + firmware = &OperationalCodeImage_GEN1[0 ]; + FirmwareImage = &OperationalCodeImage_GEN1[0 ]; + ImageSize =sizeof (OperationalCodeImage_GEN1); +break ; -case EDGE_DOWNLOAD_FILE_80251 : -dbg ("downloading firmware version (80251) %d.%d.%d" , - OperationalCodeImageVersion_GEN2.MajorVersion, - OperationalCodeImageVersion_GEN2.MinorVersion, - OperationalCodeImageVersion_GEN2.BuildNumber); - firmware = &OperationalCodeImage_GEN2[0 ]; - FirmwareImage = &OperationalCodeImage_GEN2[0 ]; - ImageSize =sizeof (OperationalCodeImage_GEN2); -break ; +case EDGE_DOWNLOAD_FILE_80251 : +dbg ("downloading firmware version (80251) %d.%d.%d" , + OperationalCodeImageVersion_GEN2.MajorVersion, + OperationalCodeImageVersion_GEN2.MinorVersion, + OperationalCodeImageVersion_GEN2.BuildNumber); + firmware = &OperationalCodeImage_GEN2[0 ]; + FirmwareImage = &OperationalCodeImage_GEN2[0 ]; + ImageSize =sizeof (OperationalCodeImage_GEN2); +break ; -case EDGE_DOWNLOAD_FILE_NONE : -dbg ("No download file specified, skipping download\n" ); -return ; +case EDGE_DOWNLOAD_FILE_NONE : +dbg ("No download file specified, skipping download\n" ); +return ; -default : -return ; +default : +return ; } -for (;;) { record = (struct edge_firmware_image_record *)firmware; - response =sram_write (edge_serial->serial,le16_to_cpu (record->ExtAddr),le16_to_cpu (record->Addr),le16_to_cpu (record->Len), &record->Data[0 ]); + response =sram_write (edge_serial->serial, +le16_to_cpu (record->ExtAddr), +le16_to_cpu (record->Addr), +le16_to_cpu (record->Len), + &record->Data[0 ]);if (response <0 ) { -dev_err (&edge_serial->serial->dev->dev,"sram_write failed (%x, %x, %d)\n" ,le16_to_cpu (record->ExtAddr),le16_to_cpu (record->Addr),le16_to_cpu (record->Len)); +dev_err (&edge_serial->serial->dev->dev, +"sram_write failed (%x, %x, %d)\n" , +le16_to_cpu (record->ExtAddr), +le16_to_cpu (record->Addr), +le16_to_cpu (record->Len));break ; } - firmware +=sizeof (struct edge_firmware_image_record ) +le16_to_cpu (record->Len); -if (firmware >= &FirmwareImage[ImageSize]) { + firmware +=sizeof (struct edge_firmware_image_record ) + +le16_to_cpu (record->Len); +if (firmware >= &FirmwareImage[ImageSize])break ; - } }dbg ("sending exec_dl_code" ); - response =usb_control_msg (edge_serial->serial->dev, -usb_sndctrlpipe (edge_serial->serial->dev,0 ), -USB_REQUEST_ION_EXEC_DL_CODE , -0x40 ,0x4000 ,0x0001 ,NULL ,0 ,3000 ); + response =usb_control_msg (edge_serial->serial->dev, +usb_sndctrlpipe (edge_serial->serial->dev,0 ), +USB_REQUEST_ION_EXEC_DL_CODE , +0x40 ,0x4000 ,0x0001 ,NULL ,0 ,3000 );return ; }
@@ -2773,7 +2999,7 @@ static void load_application_firmware (struct edgeport_serial *edge_serial)/**************************************************************************** * edge_startup ****************************************************************************/ -static int edge_startup (struct usb_serial *serial) +static int edge_startup (struct usb_serial *serial) {struct edgeport_serial *edge_serial;struct edgeport_port *edge_port;
@@ -2815,10 +3041,10 @@ static int edge_startup (struct usb_serial *serial) sizeof(struct edge_compatibility_bits));/* get the manufacturing descriptor for this device */ -get_manufacturing_desc (edge_serial); +get_manufacturing_desc (edge_serial);/* get the boot descriptor */ -get_boot_desc (edge_serial); +get_boot_desc (edge_serial);get_product_info (edge_serial); }
@@ -2839,37 +3065,40 @@ static int edge_startup (struct usb_serial *serial)/* If not an EPiC device */ if (!edge_serial->is_epic) {/* now load the application firmware into this device */ -load_application_firmware (edge_serial); +load_application_firmware (edge_serial);dbg ("%s - time 2 %ld" , __func__, jiffies);/* Check current Edgeport EEPROM and update if necessary */ -update_edgeport_E2PROM (edge_serial); +update_edgeport_E2PROM (edge_serial);dbg ("%s - time 3 %ld" , __func__, jiffies);/* set the configuration to use #1 */ -// dbg("set_configuration 1"); -// usb_set_configuration (dev, 1); +/* dbg("set_configuration 1"); */ +/* usb_set_configuration (dev, 1); */ } -/* we set up the pointers to the endpoints in the edge_open function, +/* we set up the pointers to the endpoints in the edge_open function, * as the structures aren't created yet. */ /* set up our port private structures */ for (i =0 ; i < serial->num_ports; ++i) { - edge_port =kmalloc (sizeof (struct edgeport_port ),GFP_KERNEL ); + edge_port =kmalloc (sizeof (struct edgeport_port ),GFP_KERNEL );
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
PATCH 43/70 io_edgeport: Fix various bogus returns to the tty layer
In reply to Alan CoxFrom: Alan Cox <[email protected]>
The edgeport reports negative error codes to functions that do not expect them. This can cause ports to jam forever
---
drivers/usb/serial/io_edgeport.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/usb/serial/io_edgeport.c +6 -6
@@ -1444,15 +1444,15 @@ static int edge_write_room(struct tty_struct *tty)dbg ("%s" , __func__);if (edge_port ==NULL ) -return -ENODEV ; +return 0 ;if (edge_port->closePending) -return -ENODEV ; +return 0 ;dbg ("%s - port %d" , __func__, port->number);if (!edge_port->open) {dbg ("%s - port not opened" , __func__); -return -EINVAL ; +return 0 ; }/* total of both buffers is still txCredit */
@@ -1484,13 +1484,13 @@ static int edge_chars_in_buffer(struct tty_struct *tty)dbg ("%s" , __func__);if (edge_port ==NULL ) -return -ENODEV ; +return 0 ;if (edge_port->closePending) -return -ENODEV ; +return 0 ;if (!edge_port->open) {dbg ("%s - port not opened" , __func__); -return -EINVAL ; +return 0 ; }spin_lock_irqsave (&edge_port->ep_lock, flags);
PATCH 44/70 usb-serial: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/usb-serial.c | 311 +++++++++++++++++++++------------------ 1 files changed, 168 insertions(+), 143 deletions(-)
drivers/usb/serial/usb-serial.c +168 -143
@@ -12,7 +12,8 @@* This driver was originally based on the ACM driver by Armin Fuerst (which was * based on a driver by Brad Keryan) * -* See Documentation/usb/usb-serial.txt for more information on using this driver +* See Documentation/usb/usb-serial.txt for more information on using this +* driver * */
@@ -28,7 +29,7 @@#include <linux/spinlock.h> #include <linux/mutex.h> #include <linux/list.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/usb/serial.h> #include "pl2303.h"
@@ -59,7 +60,8 @@ static struct usb_driver usb_serial_driver = {*/ static int debug; -static struct usb_serial *serial_table[SERIAL_TTY_MINORS ];/* initially all NULL */ +/* initially all NULL */ +static struct usb_serial *serial_table[SERIAL_TTY_MINORS ];static DEFINE_MUTEX (table_lock);static LIST_HEAD (usb_serial_driver_list);
@@ -76,7 +78,8 @@ struct usb_serial *usb_serial_get_by_index(unsigned index)return serial; } -static struct usb_serial *get_free_serial (struct usb_serial *serial,int num_ports,unsigned int *minor) +static struct usb_serial *get_free_serial (struct usb_serial *serial, +int num_ports,unsigned int *minor) {unsigned int i, j;int good_spot;
@@ -122,9 +125,8 @@ static void return_serial(struct usb_serial *serial)if (serial ==NULL )return ; -for (i =0 ; i < serial->num_ports; ++i) { +for (i =0 ; i < serial->num_ports; ++i) serial_table[serial->minor + i] =NULL ; - } }static void destroy_serial (struct kref *kref)
@@ -156,7 +158,8 @@ static void destroy_serial(struct kref *kref)* not get cleaned up in port_release() as it was never registered with * the driver core */ if (serial->num_ports < serial->num_port_pointers) { -for (i = serial->num_ports; i < serial->num_port_pointers; ++i) { +for (i = serial->num_ports; + i < serial->num_port_pointers; ++i) { port = serial->port[i];if (!port)continue ;
@@ -167,7 +170,7 @@ static void destroy_serial(struct kref *kref)usb_put_dev (serial->dev);/* free up any memory that we allocated */ -kfree (serial); +kfree (serial); }void usb_serial_put (struct usb_serial *serial)
@@ -180,13 +183,13 @@ void usb_serial_put(struct usb_serial *serial)/***************************************************************************** * Driver tty interface functions *****************************************************************************/ -static int serial_open (struct tty_struct *tty,struct file * filp) +static int serial_open (struct tty_struct *tty,struct file *filp) {struct usb_serial *serial;struct usb_serial_port *port;unsigned int portNumber;int retval; - +dbg ("%s" , __func__);/* get the serial object associated with this tty pointer */
@@ -207,7 +210,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp) retval = -ERESTARTSYS ; goto bailout_kref_put; } - + ++port->port.count;/* set up our port structure making the tty driver
@@ -228,7 +231,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp) retval =usb_autopm_get_interface (serial->interface);if (retval) goto bailout_module_put; -/* only call the device specific open if this +/* only call the device specific open if this * is the first time the port is opened */ retval = serial->type->open (tty, port, filp);if (retval)
@@ -252,7 +255,7 @@ bailout_kref_put:return retval; } -static void serial_close (struct tty_struct *tty,struct file * filp) +static void serial_close (struct tty_struct *tty,struct file *filp) {struct usb_serial_port *port = tty->driver_data;
@@ -270,7 +273,7 @@ static void serial_close(struct tty_struct *tty, struct file * filp) --port->port.count;if (port->port.count ==0 ) -/* only call the device specific close if this +/* only call the device specific close if this * port is being closed by the last owner */ port->serial->type->close (tty, port, filp);
@@ -291,7 +294,8 @@ static void serial_close(struct tty_struct *tty, struct file * filp)usb_serial_put (port->serial); } -static int serial_write (struct tty_struct * tty,const unsigned char *buf,int count) +static int serial_write (struct tty_struct *tty,const unsigned char *buf, +int count) {struct usb_serial_port *port = tty->driver_data;int retval = -ENODEV ;
@@ -302,7 +306,7 @@ static int serial_write (struct tty_struct * tty, const unsigned char *buf, intdbg ("%s - port %d, %d byte(s)" , __func__, port->number, count);/* count is managed under the mutex lock for the tty so cannot -drop to zero until after the last close completes */ +drop to zero until after the last close completes */ WARN_ON (!port->port.count);/* pass on to the driver specific version of this function */
@@ -312,7 +316,7 @@ exit:return retval; } -static int serial_write_room (struct tty_struct *tty) +static int serial_write_room (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;dbg ("%s - port %d" , __func__, port->number);
@@ -321,7 +325,7 @@ static int serial_write_room (struct tty_struct *tty)return port->serial->type->write_room (tty); } -static int serial_chars_in_buffer (struct tty_struct *tty) +static int serial_chars_in_buffer (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;dbg ("%s = port %d" , __func__, port->number);
@@ -331,7 +335,7 @@ static int serial_chars_in_buffer (struct tty_struct *tty)return port->serial->type->chars_in_buffer (tty); } -static void serial_throttle (struct tty_struct * tty) +static void serial_throttle (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;dbg ("%s - port %d" , __func__, port->number);
@@ -342,7 +346,7 @@ static void serial_throttle (struct tty_struct * tty) port->serial->type->throttle (tty); } -static void serial_unthrottle (struct tty_struct * tty) +static void serial_unthrottle (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;dbg ("%s - port %d" , __func__, port->number);
@@ -353,7 +357,8 @@ static void serial_unthrottle (struct tty_struct * tty) port->serial->type->unthrottle (tty); } -static int serial_ioctl (struct tty_struct *tty,struct file * file,unsigned int cmd,unsigned long arg) +static int serial_ioctl (struct tty_struct *tty,struct file *file, +unsigned int cmd,unsigned long arg) {struct usb_serial_port *port = tty->driver_data;int retval = -ENODEV ;
@@ -362,38 +367,40 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned inWARN_ON (!port->port.count); -/* pass on to the driver specific version of this function if it is available */ +/* pass on to the driver specific version of this function +if it is available */ if (port->serial->type->ioctl) {lock_kernel (); retval = port->serial->type->ioctl (tty, file, cmd, arg);unlock_kernel (); - } -else + }else retval = -ENOIOCTLCMD ;return retval; } -static void serial_set_termios (struct tty_struct *tty,struct ktermios * old) +static void serial_set_termios (struct tty_struct *tty,struct ktermios *old) {struct usb_serial_port *port = tty->driver_data;dbg ("%s - port %d" , __func__, port->number);WARN_ON (!port->port.count); -/* pass on to the driver specific version of this function if it is available */ +/* pass on to the driver specific version of this function +if it is available */ if (port->serial->type->set_termios) port->serial->type->set_termios (tty, port, old);else tty_termios_copy_hw (tty->termios, old); } -static void serial_break (struct tty_struct *tty,int break_state) +static void serial_break (struct tty_struct *tty,int break_state) {struct usb_serial_port *port = tty->driver_data;dbg ("%s - port %d" , __func__, port->number);WARN_ON (!port->port.count); -/* pass on to the driver specific version of this function if it is available */ +/* pass on to the driver specific version of this function +if it is available */ if (port->serial->type->break_ctl) {lock_kernel (); port->serial->type->break_ctl (tty, break_state);
@@ -401,7 +408,8 @@ static void serial_break (struct tty_struct *tty, int break_state) } } -static int serial_read_proc (char *page,char **start,off_t off,int count,int *eof,void *data) +static int serial_read_proc (char *page,char **start,off_t off,int count, +int *eof,void *data) {struct usb_serial *serial;int length =0 ;
@@ -410,26 +418,29 @@ static int serial_read_proc (char *page, char **start, off_t off, int count, intchar tmp[40 ];dbg ("%s" , __func__); - length +=sprintf (page,"usbserinfo:1.0 driver:2.0\n" ); + length +=sprintf (page,"usbserinfo:1.0 driver:2.0\n" );for (i =0 ; i <SERIAL_TTY_MINORS && length <PAGE_SIZE ; ++i) { serial =usb_serial_get_by_index (i);if (serial ==NULL )continue ; - length +=sprintf (page+length,"%d:" , i); + length +=sprintf (page+length,"%d:" , i);if (serial->type->driver.owner) - length +=sprintf (page+length," module:%s" ,module_name (serial->type->driver.owner)); - length +=sprintf (page+length," name:\"%s\"" , serial->type->description); - length +=sprintf (page+length," vendor:%04x product:%04x" , -le16_to_cpu (serial->dev->descriptor.idVendor), -le16_to_cpu (serial->dev->descriptor.idProduct)); - length +=sprintf (page+length," num_ports:%d" , serial->num_ports); - length +=sprintf (page+length," port:%d" , i - serial->minor +1 ); - + length +=sprintf (page+length," module:%s" , +module_name (serial->type->driver.owner)); + length +=sprintf (page+length," name:\"%s\"" , + serial->type->description); + length +=sprintf (page+length," vendor:%04x product:%04x" , +le16_to_cpu (serial->dev->descriptor.idVendor), +le16_to_cpu (serial->dev->descriptor.idProduct)); + length +=sprintf (page+length," num_ports:%d" , + serial->num_ports); + length +=sprintf (page+length," port:%d" , + i - serial->minor +1 );usb_make_path (serial->dev, tmp,sizeof (tmp)); - length +=sprintf (page+length," path:%s" , tmp); - - length +=sprintf (page+length,"\n" ); + length +=sprintf (page+length," path:%s" , tmp); + + length +=sprintf (page+length,"\n" );if ((length + begin) > (off + count)) {usb_serial_put (serial); goto done;
@@ -445,10 +456,10 @@ done:if (off >= (length + begin))return 0 ; *start = page + (off-begin); -return ((count < begin+length-off) ? count : begin+length-off); +return (count < begin+length-off) ? count : begin+length-off; } -static int serial_tiocmget (struct tty_struct *tty,struct file *file) +static int serial_tiocmget (struct tty_struct *tty,struct file *file) {struct usb_serial_port *port = tty->driver_data;
@@ -460,7 +471,7 @@ static int serial_tiocmget (struct tty_struct *tty, struct file *file)return -EINVAL ; } -static int serial_tiocmset (struct tty_struct *tty,struct file *file, +static int serial_tiocmset (struct tty_struct *tty,struct file *file,unsigned int set,unsigned int clear) {struct usb_serial_port *port = tty->driver_data;
@@ -482,6 +493,7 @@ void usb_serial_port_softint(struct usb_serial_port *port) {schedule_work (&port->work); } +EXPORT_SYMBOL_GPL (usb_serial_port_softint);static void usb_serial_port_work (struct work_struct *work) {
@@ -490,7 +502,7 @@ static void usb_serial_port_work(struct work_struct *work)struct tty_struct *tty;dbg ("%s - port %d" , __func__, port->number); - +if (!port)return ;
@@ -505,7 +517,7 @@ static void port_release(struct device *dev) {struct usb_serial_port *port =to_usb_serial_port (dev); -dbg ("%s - %s" , __func__, dev->bus_id); +dbg ("%s - %s" , __func__, dev->bus_id);port_free (port); }
@@ -543,9 +555,9 @@ static void port_free(struct usb_serial_port *port)kfree (port); } -static struct usb_serial *create_serial (struct usb_device *dev, -struct usb_interface *interface, -struct usb_serial_driver *driver) +static struct usb_serial *create_serial (struct usb_device *dev, +struct usb_interface *interface, +struct usb_serial_driver *driver) {struct usb_serial *serial;
@@ -564,7 +576,7 @@ static struct usb_serial * create_serial (struct usb_device *dev, }static const struct usb_device_id *match_dynamic_id (struct usb_interface *intf, -struct usb_serial_driver *drv) +struct usb_serial_driver *drv) {struct usb_dynid *dynid;
@@ -596,7 +608,8 @@ exit:return id; } -static struct usb_serial_driver *search_serial_device (struct usb_interface *iface) +static struct usb_serial_driver *search_serial_device ( +struct usb_interface *iface) {const struct usb_device_id *id;struct usb_serial_driver *drv;
@@ -614,7 +627,7 @@ static struct usb_serial_driver *search_serial_device(struct usb_interface *ifacint usb_serial_probe (struct usb_interface *interface,const struct usb_device_id *id) { -struct usb_device *dev =interface_to_usbdev (interface); +struct usb_device *dev =interface_to_usbdev (interface);struct usb_serial *serial =NULL ;struct usb_serial_port *port;struct usb_host_interface *iface_desc;
@@ -643,7 +656,7 @@ int usb_serial_probe(struct usb_interface *interface,return -ENODEV ; } - serial =create_serial (dev, interface, type); + serial =create_serial (dev, interface, type);if (!serial) {unlock_kernel ();dev_err (&interface->dev,"%s - out of memory\n" , __func__);
@@ -656,8 +669,9 @@ int usb_serial_probe(struct usb_interface *interface,if (!try_module_get (type->driver.owner)) {unlock_kernel (); -dev_err (&interface->dev,"module get failed, exiting\n" ); -kfree (serial); +dev_err (&interface->dev, +"module get failed, exiting\n" ); +kfree (serial);return -EIO ; }
@@ -667,8 +681,8 @@ int usb_serial_probe(struct usb_interface *interface,if (retval) {unlock_kernel (); -dbg ("sub driver rejected device" ); -kfree (serial); +dbg ("sub driver rejected device" ); +kfree (serial);return retval; } }
@@ -709,7 +723,7 @@ int usb_serial_probe(struct usb_interface *interface, }#if defined(CONFIG_USB_SERIAL_PL2303 ) || defined(CONFIG_USB_SERIAL_PL2303_MODULE ) -/* BEGIN HORRIBLE HACK FOR PL2303 */ +/* BEGIN HORRIBLE HACK FOR PL2303 */ /* this is needed due to the looney way its endpoints are set up */ if (((le16_to_cpu(dev->descriptor.idVendor) == PL2303_VENDOR_ID) && (le16_to_cpu(dev->descriptor.idProduct) == PL2303_PRODUCT_ID)) ||
@@ -738,7 +752,7 @@ int usb_serial_probe(struct usb_interface *interface,if (num_bulk_in ==0 || num_bulk_out ==0 ) {unlock_kernel ();dev_info (&interface->dev,"PL-2303 hack: descriptors matched but endpoints did not\n" ); -kfree (serial); +kfree (serial);return -ENODEV ; } }
@@ -750,8 +764,9 @@ int usb_serial_probe(struct usb_interface *interface, num_ports = num_bulk_out;if (num_ports ==0 ) {unlock_kernel (); -dev_err (&interface->dev,"Generic device with no bulk out, not allowed.\n" ); -kfree (serial); +dev_err (&interface->dev, +"Generic device with no bulk out, not allowed.\n" ); +kfree (serial);return -EIO ; } }
@@ -761,11 +776,12 @@ int usb_serial_probe(struct usb_interface *interface,if (type->calc_num_ports) {if (!try_module_get (type->driver.owner)) {unlock_kernel (); -dev_err (&interface->dev,"module get failed, exiting\n" ); -kfree (serial); +dev_err (&interface->dev, +"module get failed, exiting\n" ); +kfree (serial);return -EIO ; } - num_ports = type->calc_num_ports (serial); + num_ports = type->calc_num_ports (serial);module_put (type->driver.owner); }if (!num_ports)
@@ -783,7 +799,8 @@ int usb_serial_probe(struct usb_interface *interface, type->description);/* create our ports, we need as many as the max endpoints */ -/* we don't use num_ports here cauz some devices have more endpoint pairs than ports */ +/* we don't use num_ports here because some devices have more +endpoint pairs than ports */ max_endpoints =max (num_bulk_in, num_bulk_out); max_endpoints =max (max_endpoints, num_interrupt_in); max_endpoints =max (max_endpoints, num_interrupt_out);
@@ -791,7 +808,8 @@ int usb_serial_probe(struct usb_interface *interface, serial->num_port_pointers = max_endpoints;unlock_kernel (); -dbg ("%s - setting up %d port structures for this device" , __func__, max_endpoints); +dbg ("%s - setting up %d port structures for this device" , + __func__, max_endpoints);for (i =0 ; i < max_endpoints; ++i) { port =kzalloc (sizeof (struct usb_serial_port ),GFP_KERNEL );if (!port)
@@ -807,7 +825,7 @@ int usb_serial_probe(struct usb_interface *interface,for (i =0 ; i < num_bulk_in; ++i) { endpoint = bulk_in_endpoint[i]; port = serial->port[i]; - port->read_urb =usb_alloc_urb (0 ,GFP_KERNEL ); + port->read_urb =usb_alloc_urb (0 ,GFP_KERNEL );if (!port->read_urb) {dev_err (&interface->dev,"No free urbs available\n" ); goto probe_error;
@@ -815,17 +833,17 @@ int usb_serial_probe(struct usb_interface *interface, buffer_size =le16_to_cpu (endpoint->wMaxPacketSize); port->bulk_in_size = buffer_size; port->bulk_in_endpointAddress = endpoint->bEndpointAddress; - port->bulk_in_buffer =kmalloc (buffer_size,GFP_KERNEL ); + port->bulk_in_buffer =kmalloc (buffer_size,GFP_KERNEL );if (!port->bulk_in_buffer) { -dev_err (&interface->dev,"Couldn't allocate bulk_in_buffer\n" ); +dev_err (&interface->dev, +"Couldn't allocate bulk_in_buffer\n" ); goto probe_error; } -usb_fill_bulk_urb (port->read_urb, dev, -usb_rcvbulkpipe (dev, - endpoint->bEndpointAddress), - port->bulk_in_buffer, buffer_size, - serial->type->read_bulk_callback, - port); +usb_fill_bulk_urb (port->read_urb, dev, +usb_rcvbulkpipe (dev, + endpoint->bEndpointAddress), + port->bulk_in_buffer, buffer_size, + serial->type->read_bulk_callback, port); }for (i =0 ; i < num_bulk_out; ++i) {
@@ -839,17 +857,17 @@ int usb_serial_probe(struct usb_interface *interface, buffer_size =le16_to_cpu (endpoint->wMaxPacketSize); port->bulk_out_size = buffer_size; port->bulk_out_endpointAddress = endpoint->bEndpointAddress; - port->bulk_out_buffer =kmalloc (buffer_size,GFP_KERNEL ); + port->bulk_out_buffer =kmalloc (buffer_size,GFP_KERNEL );if (!port->bulk_out_buffer) { -dev_err (&interface->dev,"Couldn't allocate bulk_out_buffer\n" ); +dev_err (&interface->dev, +"Couldn't allocate bulk_out_buffer\n" ); goto probe_error; } -usb_fill_bulk_urb (port->write_urb, dev, -usb_sndbulkpipe (dev, - endpoint->bEndpointAddress), - port->bulk_out_buffer, buffer_size, - serial->type->write_bulk_callback, - port); +usb_fill_bulk_urb (port->write_urb, dev, +usb_sndbulkpipe (dev, + endpoint->bEndpointAddress), + port->bulk_out_buffer, buffer_size, + serial->type->write_bulk_callback, port); }if (serial->type->read_int_callback) {
@@ -858,73 +876,82 @@ int usb_serial_probe(struct usb_interface *interface, port = serial->port[i]; port->interrupt_in_urb =usb_alloc_urb (0 ,GFP_KERNEL );if (!port->interrupt_in_urb) { -dev_err (&interface->dev,"No free urbs available\n" ); +dev_err (&interface->dev, +"No free urbs available\n" ); goto probe_error; } buffer_size =le16_to_cpu (endpoint->wMaxPacketSize); - port->interrupt_in_endpointAddress = endpoint->bEndpointAddress; - port->interrupt_in_buffer =kmalloc (buffer_size,GFP_KERNEL ); + port->interrupt_in_endpointAddress = + endpoint->bEndpointAddress; + port->interrupt_in_buffer =kmalloc (buffer_size, +GFP_KERNEL );if (!port->interrupt_in_buffer) { -dev_err (&interface->dev,"Couldn't allocate interrupt_in_buffer\n" ); +dev_err (&interface->dev, +"Couldn't allocate interrupt_in_buffer\n" ); goto probe_error; } -usb_fill_int_urb (port->interrupt_in_urb, dev, -usb_rcvintpipe (dev, - endpoint->bEndpointAddress), - port->interrupt_in_buffer, buffer_size, - serial->type->read_int_callback, port, - endpoint->bInterval); +usb_fill_int_urb (port->interrupt_in_urb, dev, +usb_rcvintpipe (dev, + endpoint->bEndpointAddress), + port->interrupt_in_buffer, buffer_size, + serial->type->read_int_callback, port, + endpoint->bInterval); } }else if (num_interrupt_in) {dbg ("the device claims to support interrupt in transfers, but read_int_callback is not defined" ); } - +if (serial->type->write_int_callback) {for (i =0 ; i < num_interrupt_out; ++i) { endpoint = interrupt_out_endpoint[i]; port = serial->port[i]; port->interrupt_out_urb =usb_alloc_urb (0 ,GFP_KERNEL );if (!port->interrupt_out_urb) { -dev_err (&interface->dev,"No free urbs available\n" ); +dev_err (&interface->dev, +"No free urbs available\n" ); goto probe_error; } buffer_size =le16_to_cpu (endpoint->wMaxPacketSize); port->interrupt_out_size = buffer_size; - port->interrupt_out_endpointAddress = endpoint->bEndpointAddress; - port->interrupt_out_buffer =kmalloc (buffer_size,GFP_KERNEL ); + port->interrupt_out_endpointAddress = + endpoint->bEndpointAddress; + port->interrupt_out_buffer =kmalloc (buffer_size, +GFP_KERNEL );if (!port->interrupt_out_buffer) { -dev_err (&interface->dev,"Couldn't allocate interrupt_out_buffer\n" ); +dev_err (&interface->dev, +"Couldn't allocate interrupt_out_buffer\n" ); goto probe_error; } -usb_fill_int_urb (port->interrupt_out_urb, dev, -usb_sndintpipe (dev, - endpoint->bEndpointAddress), - port->interrupt_out_buffer, buffer_size, - serial->type->write_int_callback, port, - endpoint->bInterval); +usb_fill_int_urb (port->interrupt_out_urb, dev, +usb_sndintpipe (dev, + endpoint->bEndpointAddress), + port->interrupt_out_buffer, buffer_size, + serial->type->write_int_callback, port, + endpoint->bInterval); } }else if (num_interrupt_out) {dbg ("the device claims to support interrupt out transfers, but write_int_callback is not defined" ); } - +/* if this device type has an attach function, call it */ if (type->attach) {if (!try_module_get (type->driver.owner)) { -dev_err (&interface->dev,"module get failed, exiting\n" ); +dev_err (&interface->dev, +"module get failed, exiting\n" ); goto probe_error; } - retval = type->attach (serial); + retval = type->attach (serial);module_put (type->driver.owner);if (retval <0 ) goto probe_error;if (retval >0 ) { -/* quietly accept this device, but don't bind to a serial port -* as it's about to disappear */ +/* quietly accept this device, but don't bind to a +serial port as it's about to disappear */ goto exit; } } -if (get_free_serial (serial, num_ports, &minor) ==NULL ) { +if (get_free_serial (serial, num_ports, &minor) ==NULL ) {dev_err (&interface->dev,"No more free serial devices\n" ); goto probe_error; }
@@ -938,19 +965,20 @@ int usb_serial_probe(struct usb_interface *interface, port->dev.bus = &usb_serial_bus_type; port->dev.release = &port_release; -snprintf (&port->dev.bus_id[0 ],sizeof (port->dev.bus_id),"ttyUSB%d" , port->number); -dbg ("%s - registering %s" , __func__, port->dev.bus_id); +snprintf (&port->dev.bus_id[0 ],sizeof (port->dev.bus_id), +"ttyUSB%d" , port->number); +dbg ("%s - registering %s" , __func__, port->dev.bus_id); retval =device_register (&port->dev);if (retval)dev_err (&port->dev,"Error registering port device, " "continuing\n" ); } -usb_serial_console_init (debug, minor); +usb_serial_console_init (debug, minor); exit:/* success */ -usb_set_intfdata (interface, serial); +usb_set_intfdata (interface, serial);return 0 ; probe_error:
@@ -986,22 +1014,23 @@ probe_error:/* free up any memory that we allocated */ for (i =0 ; i < serial->num_port_pointers; ++i)kfree (serial->port[i]); -kfree (serial); +kfree (serial);return -EIO ; } +EXPORT_SYMBOL_GPL (usb_serial_probe);void usb_serial_disconnect (struct usb_interface *interface) {int i; -struct usb_serial *serial =usb_get_intfdata (interface); +struct usb_serial *serial =usb_get_intfdata (interface);struct device *dev = &interface->dev;struct usb_serial_port *port;usb_serial_console_disconnect (serial); -dbg ("%s" , __func__); +dbg ("%s" , __func__);mutex_lock (&serial->disc_mutex); -usb_set_intfdata (interface,NULL ); +usb_set_intfdata (interface,NULL );/* must set a flag, to signal subdrivers */ serial->disconnected =1 ;for (i =0 ; i < serial->num_ports; ++i) {
@@ -1018,6 +1047,7 @@ void usb_serial_disconnect(struct usb_interface *interface)usb_serial_put (serial);dev_info (dev,"device disconnected\n" ); } +EXPORT_SYMBOL_GPL (usb_serial_disconnect);int usb_serial_suspend (struct usb_interface *intf,pm_message_t message) {
@@ -1076,9 +1106,8 @@ static int __init usb_serial_init(void)return -ENOMEM ;/* Initialize our global data */ -for (i =0 ; i <SERIAL_TTY_MINORS ; ++i) { +for (i =0 ; i <SERIAL_TTY_MINORS ; ++i) serial_table[i] =NULL ; - } result =bus_register (&usb_serial_bus_type);if (result) {
@@ -1093,9 +1122,11 @@ static int __init usb_serial_init(void) usb_serial_tty_driver->minor_start =0 ; usb_serial_tty_driver->type =TTY_DRIVER_TYPE_SERIAL ; usb_serial_tty_driver->subtype =SERIAL_TYPE_NORMAL ; - usb_serial_tty_driver->flags =TTY_DRIVER_REAL_RAW |TTY_DRIVER_DYNAMIC_DEV ; + usb_serial_tty_driver->flags =TTY_DRIVER_REAL_RAW | +TTY_DRIVER_DYNAMIC_DEV ; usb_serial_tty_driver->init_termios = tty_std_termios; - usb_serial_tty_driver->init_termios.c_cflag =B9600 |CS8 |CREAD |HUPCL |CLOCAL ; + usb_serial_tty_driver->init_termios.c_cflag =B9600 |CS8 |CREAD + |HUPCL |CLOCAL ; usb_serial_tty_driver->init_termios.c_ispeed =9600 ; usb_serial_tty_driver->init_termios.c_ospeed =9600 ;tty_set_operations (usb_serial_tty_driver, &serial_ops);
@@ -1133,7 +1164,7 @@ exit_reg_driver:bus_unregister (&usb_serial_bus_type); exit_bus: -err ("%s - returning with error %d" , __func__, result); +err ("%s - returning with error %d" , __func__, result);put_tty_driver (usb_serial_tty_driver);return result; }
@@ -1160,7 +1191,7 @@ module_exit(usb_serial_exit);if (!type->function) { \ type->function = usb_serial_generic_##function; \ dbg("Had to override the " #function \ - " usb serial operation with the generic one.");\ + " usb serial operation with the generic one.");\ } \ } while (0)
@@ -1177,8 +1208,9 @@ static void fixup_generic(struct usb_serial_driver *device)set_to_generic_if_null (device, resume); } -int usb_serial_register (struct usb_serial_driver *driver)/* must be called with BKL held */ +int usb_serial_register (struct usb_serial_driver *driver) { +/* must be called with BKL held */ int retval;fixup_generic (driver);
@@ -1191,37 +1223,30 @@ int usb_serial_register(struct usb_serial_driver *driver) /* must be called with retval =usb_serial_bus_register (driver);if (retval) { -err ("problem %d when registering driver %s" , retval, driver->description); +err ("problem %d when registering driver %s" , + retval, driver->description);list_del (&driver->driver_list); - } -else -info ("USB Serial support registered for %s" , driver->description); + }else +info ("USB Serial support registered for %s" , + driver->description);return retval; } +EXPORT_SYMBOL_GPL (usb_serial_register); -void usb_serial_deregister (struct usb_serial_driver *device)/* must be called with BKL held */ +void usb_serial_deregister (struct usb_serial_driver *device) { +/* must be called with BKL held */ info ("USB Serial deregistering driver %s" , device->description);list_del (&device->driver_list);usb_serial_bus_deregister (device); } - - - -/* If the usb-serial core is built into the core, the usb-serial drivers -need these symbols to load properly as modules. */ -EXPORT_SYMBOL_GPL (usb_serial_register);EXPORT_SYMBOL_GPL (usb_serial_deregister); -EXPORT_SYMBOL_GPL (usb_serial_probe); -EXPORT_SYMBOL_GPL (usb_serial_disconnect); -EXPORT_SYMBOL_GPL (usb_serial_port_softint); -/* Module information */ -MODULE_AUTHOR (DRIVER_AUTHOR ); -MODULE_DESCRIPTION (DRIVER_DESC ); +MODULE_AUTHOR (DRIVER_AUTHOR ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );module_param (debug, bool,S_IRUGO |S_IWUSR );
PATCH 45/70 io_ti: Minor coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/io_ti.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/usb/serial/io_ti.c +3 -3
@@ -2402,7 +2402,7 @@ static void change_port_settings(struct tty_struct *tty,return ; } -static void edge_set_termios (struct tty_struct *tty, +static void edge_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios) {struct edgeport_port *edge_port =usb_get_serial_port_data (port);
@@ -2771,7 +2771,7 @@ static unsigned int edge_buf_data_avail(struct edge_buf *eb) {if (eb ==NULL )return 0 ; -return ((eb->buf_size + eb->buf_put - eb->buf_get) % eb->buf_size); +return (eb->buf_size + eb->buf_put - eb->buf_get) % eb->buf_size; }
@@ -2786,7 +2786,7 @@ static unsigned int edge_buf_space_avail(struct edge_buf *eb) {if (eb ==NULL )return 0 ; -return ((eb->buf_size + eb->buf_get - eb->buf_put -1 ) % eb->buf_size); +return (eb->buf_size + eb->buf_get - eb->buf_put -1 ) % eb->buf_size; }
PATCH 46/70 ipaq: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/ipaq.c | 97 ++++++++++++++++++++++++--------------------- 1 files changed, 52 insertions(+), 45 deletions(-)
drivers/usb/serial/ipaq.c +52 -45
@@ -53,7 +53,7 @@#include <linux/tty_flip.h> #include <linux/module.h> #include <linux/spinlock.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/usb/serial.h> #include "ipaq.h"
@@ -82,10 +82,10 @@ static int ipaq_startup(struct usb_serial *serial);static void ipaq_shutdown (struct usb_serial *serial);static int ipaq_write (struct tty_struct *tty,struct usb_serial_port *port,const unsigned char *buf,int count); -static int ipaq_write_bulk (struct usb_serial_port *port,const unsigned char *buf, -int count); +static int ipaq_write_bulk (struct usb_serial_port *port, +const unsigned char *buf,int count);static void ipaq_write_gather (struct usb_serial_port *port); -static void ipaq_read_bulk_callback (struct urb *urb); +static void ipaq_read_bulk_callback (struct urb *urb);static void ipaq_write_bulk_callback (struct urb *urb);static int ipaq_write_room (struct tty_struct *tty);static int ipaq_chars_in_buffer (struct tty_struct *tty);
@@ -552,7 +552,7 @@ static struct usb_device_id ipaq_id_table [] = { { }/* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, ipaq_id_table); +MODULE_DEVICE_TABLE (usb, ipaq_id_table);static struct usb_driver ipaq_driver = { .name ="ipaq" ,
@@ -615,9 +615,9 @@ static int ipaq_open(struct tty_struct *tty,for (i =0 ; i <URBDATA_QUEUE_MAX /PACKET_SIZE ; i++) { pkt =kmalloc (sizeof (struct ipaq_packet ),GFP_KERNEL ); -if (pkt ==NULL ) { +if (pkt ==NULL ) goto enomem; - } + pkt->data =kmalloc (PACKET_SIZE ,GFP_KERNEL );if (pkt->data ==NULL ) {kfree (pkt);
@@ -661,8 +661,9 @@ static int ipaq_open(struct tty_struct *tty, port->read_urb->transfer_buffer = port->bulk_in_buffer; port->write_urb->transfer_buffer = port->bulk_out_buffer; port->read_urb->transfer_buffer_length =URBDATA_SIZE ; - port->bulk_out_size = port->write_urb->transfer_buffer_length =URBDATA_SIZE ; - + port->bulk_out_size = port->write_urb->transfer_buffer_length + =URBDATA_SIZE ; +msleep (1000 *initial_wait);/*
@@ -691,13 +692,15 @@ static int ipaq_open(struct tty_struct *tty,/* Start reading from the device */ usb_fill_bulk_urb (port->read_urb, serial->dev, -usb_rcvbulkpipe (serial->dev, port->bulk_in_endpointAddress), - port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, - ipaq_read_bulk_callback, port); +usb_rcvbulkpipe (serial->dev, port->bulk_in_endpointAddress), + port->read_urb->transfer_buffer, + port->read_urb->transfer_buffer_length, + ipaq_read_bulk_callback, port); result =usb_submit_urb (port->read_urb,GFP_KERNEL );if (result) { -err ("%s - failed submitting read urb, error %d" , __func__, result); +err ("%s - failed submitting read urb, error %d" , + __func__, result); goto error; }
@@ -719,7 +722,7 @@ static void ipaq_close(struct tty_struct *tty,struct ipaq_private *priv =usb_get_serial_port_data (port);dbg ("%s - port %d" , __func__, port->number); - +/* * shut down bulk read and write */
@@ -729,7 +732,8 @@ static void ipaq_close(struct tty_struct *tty,kfree (priv);usb_set_serial_port_data (port,NULL ); -/* Uncomment the following line if you want to see some statistics in your syslog */ +/* Uncomment the following line if you want to see some statistics +* in your syslog */ /* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */ }
@@ -749,7 +753,8 @@ static void ipaq_read_bulk_callback(struct urb *urb)return ; } -usb_serial_debug_data (debug, &port->dev, __func__, urb->actual_length, data); +usb_serial_debug_data (debug, &port->dev, __func__, + urb->actual_length, data); tty = port->port.tty;if (tty && urb->actual_length) {
@@ -760,13 +765,15 @@ static void ipaq_read_bulk_callback(struct urb *urb) }/* Continue trying to always read */ -usb_fill_bulk_urb (port->read_urb, port->serial->dev, -usb_rcvbulkpipe (port->serial->dev, port->bulk_in_endpointAddress), - port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, - ipaq_read_bulk_callback, port); +usb_fill_bulk_urb (port->read_urb, port->serial->dev, +usb_rcvbulkpipe (port->serial->dev, port->bulk_in_endpointAddress), + port->read_urb->transfer_buffer, + port->read_urb->transfer_buffer_length, + ipaq_read_bulk_callback, port); result =usb_submit_urb (port->read_urb,GFP_ATOMIC );if (result) -err ("%s - failed resubmitting read urb, error %d" , __func__, result); +err ("%s - failed resubmitting read urb, error %d" , + __func__, result);return ; }
@@ -781,9 +788,8 @@ static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port,while (count >0 ) { transfer_size =min (count,PACKET_SIZE ); -if (ipaq_write_bulk (port, current_position, transfer_size)) { +if (ipaq_write_bulk (port, current_position, transfer_size))break ; - } current_position += transfer_size; bytes_sent += transfer_size; count -= transfer_size;
@@ -791,10 +797,10 @@ static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port, }return bytes_sent; -} +} -static int ipaq_write_bulk (struct usb_serial_port *port,const unsigned char *buf, -int count) +static int ipaq_write_bulk (struct usb_serial_port *port, +const unsigned char *buf,int count) {struct ipaq_private *priv =usb_get_serial_port_data (port);struct ipaq_packet *pkt =NULL ;
@@ -831,9 +837,9 @@ static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buipaq_write_gather (port);spin_unlock_irqrestore (&write_list_lock, flags); result =usb_submit_urb (port->write_urb,GFP_ATOMIC ); -if (result) { -err ("%s - failed submitting write urb, error %d" , __func__, result); - } +if (result) +err ("%s - failed submitting write urb, error %d" , + __func__, result); }else {spin_unlock_irqrestore (&write_list_lock, flags); }
@@ -860,16 +866,15 @@ static void ipaq_write_gather(struct usb_serial_port *port)list_move (&pkt->list, &priv->freelist); priv->free_len +=PACKET_SIZE ; } -if (room ==0 ) { +if (room ==0 )break ; - } } count =URBDATA_SIZE - room; -usb_fill_bulk_urb (port->write_urb, serial->dev, -usb_sndbulkpipe (serial->dev, port->bulk_out_endpointAddress), - port->write_urb->transfer_buffer, count, ipaq_write_bulk_callback, - port); +usb_fill_bulk_urb (port->write_urb, serial->dev, +usb_sndbulkpipe (serial->dev, port->bulk_out_endpointAddress), + port->write_urb->transfer_buffer, count, + ipaq_write_bulk_callback, port);return ; }
@@ -894,9 +899,9 @@ static void ipaq_write_bulk_callback(struct urb *urb)ipaq_write_gather (port);spin_unlock_irqrestore (&write_list_lock, flags); result =usb_submit_urb (port->write_urb,GFP_ATOMIC ); -if (result) { -err ("%s - failed submitting write urb, error %d" , __func__, result); - } +if (result) +err ("%s - failed submitting write urb, error %d" , + __func__, result); }else { priv->active =0 ;spin_unlock_irqrestore (&write_list_lock, flags);
@@ -947,7 +952,7 @@ static int ipaq_startup(struct usb_serial *serial) serial->dev->actconfig->desc.bConfigurationValue);return -ENODEV ; } -return usb_reset_configuration (serial->dev); +return usb_reset_configuration (serial->dev); }static void ipaq_shutdown (struct usb_serial *serial)
@@ -960,7 +965,7 @@ static int __init ipaq_init(void)int retval;spin_lock_init (&write_list_lock); retval =usb_serial_register (&ipaq_device); -if (retval) +if (retval) goto failed_usb_serial_register;info (DRIVER_DESC " " DRIVER_VERSION );if (vendor) {
@@ -970,7 +975,7 @@ static int __init ipaq_init(void) retval =usb_register (&ipaq_driver);if (retval) goto failed_usb_register; - +return 0 ; failed_usb_register:usb_serial_deregister (&ipaq_device);
@@ -989,8 +994,8 @@ static void __exit ipaq_exit(void)module_init (ipaq_init);module_exit (ipaq_exit); -MODULE_AUTHOR (DRIVER_AUTHOR ); -MODULE_DESCRIPTION (DRIVER_DESC ); +MODULE_AUTHOR (DRIVER_AUTHOR ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );module_param (debug, bool,S_IRUGO |S_IWUSR );
@@ -1003,7 +1008,9 @@ module_param(product, ushort, 0);MODULE_PARM_DESC (product,"User specified USB idProduct" );module_param (connect_retries, int,S_IRUGO |S_IWUSR ); -MODULE_PARM_DESC (connect_retries,"Maximum number of connect retries (one second each)" ); +MODULE_PARM_DESC (connect_retries, +"Maximum number of connect retries (one second each)" );module_param (initial_wait, int,S_IRUGO |S_IWUSR ); -MODULE_PARM_DESC (initial_wait,"Time to wait before attempting a connection (in seconds)" ); +MODULE_PARM_DESC (initial_wait, +"Time to wait before attempting a connection (in seconds)" );
PATCH 47/70 tty-usb-ipw: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/ipw.c | 279 ++++++++++++++++++++++++---------------------- 1 files changed, 144 insertions(+), 135 deletions(-)
drivers/usb/serial/ipw.c +144 -135
@@ -10,27 +10,27 @@* (at your option) any later version. * * All information about the device was acquired using SnoopyPro -* on MSFT's O/S, and examing the MSFT drivers' debug output +* on MSFT's O/S, and examing the MSFT drivers' debug output * (insanely left _on_ in the enduser version) * * It was written out of frustration with the IPWireless USB modem * supplied by Axity3G/Sentech South Africa not supporting * Linux whatsoever. * -* Nobody provided any proprietary information that was not already +* Nobody provided any proprietary information that was not already * available for this device. -* -* The modem adheres to the "3GPP TS 27.007 AT command set for 3G -* User Equipment (UE)" standard, available from +* +* The modem adheres to the "3GPP TS 27.007 AT command set for 3G +* User Equipment (UE)" standard, available from * http://www.3gpp.org/ftp/Specs/html-info/27007.htm * * The code was only tested the IPWireless handheld modem distributed * in South Africa by Sentech. -* +* * It may work for Woosh Inc in .nz too, as it appears they use the * same kit. * -* There is still some work to be done in terms of handling +* There is still some work to be done in terms of handling * DCD, DTR, RTS, CTS which are currently faked. * It's good enough for PPP at this point. It's based off all kinds of * code found in usb/serial and usb/class
@@ -47,7 +47,7 @@#include <linux/spinlock.h> #include <linux/usb.h> #include <linux/usb/serial.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> /* * Version Information
@@ -64,7 +64,7 @@/* Message sizes */ #define EVENT_BUFFER_SIZE 0xFF -#define CHAR2INT16 (c1,c0) (((u32)((c1) & 0xff) << 8) + (u32)((c0) & 0xff)) +#define CHAR2INT16 (c1, c0) (((u32)((c1) & 0xff) << 8) + (u32)((c0) & 0xff))#define NUM_BULK_URBS 24#define NUM_CONTROL_URBS 16
@@ -94,33 +94,34 @@ enum {/* data bits */ #define ipw_dtb_7 0x700 -#define ipw_dtb_8 0x810 // ok so the define is misleading, I know, but forces 8,n,1 -// I mean, is there a point to any other setting these days? :) +#define ipw_dtb_8 0x810/* ok so the define is misleading, I know, but forces 8,n,1 */ +/* I mean, is there a point to any other setting these days? :) */ /* usb control request types : */ -#define IPW_SIO_RXCTL 0x00 // control bulk rx channel transmissions, value=1/0 (on/off) -#define IPW_SIO_SET_BAUD 0x01 // set baud, value=requested ipw_sio_bxxxx -#define IPW_SIO_SET_LINE 0x03 // set databits, parity. value=ipw_dtb_x -#define IPW_SIO_SET_PIN 0x03 // set/clear dtr/rts value=ipw_pin_xxx -#define IPW_SIO_POLL 0x08 // get serial port status byte, call with value=0 -#define IPW_SIO_INIT 0x11 // initializes ? value=0 (appears as first thing todo on open) -#define IPW_SIO_PURGE 0x12 // purge all transmissions?, call with value=numchar_to_purge -#define IPW_SIO_HANDFLOW 0x13 // set xon/xoff limits value=0, and a buffer of 0x10 bytes -#define IPW_SIO_SETCHARS 0x13 // set the flowcontrol special chars, value=0, buf=6 bytes, -// last 2 bytes contain flowcontrol chars e.g. 00 00 00 00 11 13 +#define IPW_SIO_RXCTL 0x00/* control bulk rx channel transmissions, value=1/0 (on/off) */ +#define IPW_SIO_SET_BAUD 0x01/* set baud, value=requested ipw_sio_bxxxx */ +#define IPW_SIO_SET_LINE 0x03/* set databits, parity. value=ipw_dtb_x */ +#define IPW_SIO_SET_PIN 0x03/* set/clear dtr/rts value=ipw_pin_xxx */ +#define IPW_SIO_POLL 0x08/* get serial port status byte, call with value=0 */ +#define IPW_SIO_INIT 0x11/* initializes ? value=0 (appears as first thing todo on open) */ +#define IPW_SIO_PURGE 0x12/* purge all transmissions?, call with value=numchar_to_purge */ +#define IPW_SIO_HANDFLOW 0x13/* set xon/xoff limits value=0, and a buffer of 0x10 bytes */ +#define IPW_SIO_SETCHARS 0x13/* set the flowcontrol special chars, value=0, buf=6 bytes, */ +/* last 2 bytes contain flowcontrol chars e.g. 00 00 00 00 11 13 */ /* values used for request IPW_SIO_SET_PIN */ #define IPW_PIN_SETDTR 0x101#define IPW_PIN_SETRTS 0x202#define IPW_PIN_CLRDTR 0x100 -#define IPW_PIN_CLRRTS 0x200 // unconfirmed +#define IPW_PIN_CLRRTS 0x200/* unconfirmed */ /* values used for request IPW_SIO_RXCTL */ #define IPW_RXBULK_ON 1#define IPW_RXBULK_OFF 0/* various 16 byte hardcoded transferbuffers used by flow control */ -#define IPW_BYTES_FLOWINIT { 0x01, 0, 0, 0, 0x40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } +#define IPW_BYTES_FLOWINIT { 0x01, 0, 0, 0, 0x40, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0 }/* Interpretation of modem status lines */ /* These need sorting out by individually connecting pins and checking
@@ -132,17 +133,6 @@ enum {#define IPW_CTS ((1<<5) | (1<<4))#define IPW_WANTS_TO_SEND 0x30 -//#define IPW_DTR /* Data Terminal Ready */ -//#define IPW_CTS /* Clear To Send */ -//#define IPW_CD /* Carrier Detect */ -//#define IPW_DSR /* Data Set Ready */ -//#define IPW_RxD /* Receive pin */ - -//#define IPW_LE -//#define IPW_RTS -//#define IPW_ST -//#define IPW_SR -//#define IPW_RI /* Ring Indicator */ static struct usb_device_id usb_ipw_ids[] = { {USB_DEVICE (IPW_VID ,IPW_PID ) },
@@ -177,7 +167,8 @@ static void ipw_read_bulk_callback(struct urb *urb)return ; } -usb_serial_debug_data (debug, &port->dev, __func__, urb->actual_length, data); +usb_serial_debug_data (debug, &port->dev, __func__, + urb->actual_length, data); tty = port->port.tty;if (tty && urb->actual_length) {
@@ -187,15 +178,17 @@ static void ipw_read_bulk_callback(struct urb *urb) }/* Continue trying to always read */ -usb_fill_bulk_urb (port->read_urb, port->serial->dev, -usb_rcvbulkpipe (port->serial->dev, +usb_fill_bulk_urb (port->read_urb, port->serial->dev, +usb_rcvbulkpipe (port->serial->dev, port->bulk_in_endpointAddress), - port->read_urb->transfer_buffer, - port->read_urb->transfer_buffer_length, - ipw_read_bulk_callback, port); + port->read_urb->transfer_buffer, + port->read_urb->transfer_buffer_length, + ipw_read_bulk_callback, port); result =usb_submit_urb (port->read_urb,GFP_ATOMIC );if (result) -dev_err (&port->dev,"%s - failed resubmitting read urb, error %d\n" , __func__, result); +dev_err (&port->dev, +"%s - failed resubmitting read urb, error %d\n" , + __func__, result);return ; }
@@ -216,26 +209,30 @@ static int ipw_open(struct tty_struct *tty,if (tty) tty->low_latency =1 ; -/* --1: Tell the modem to initialize (we think) From sniffs this is always the -* first thing that gets sent to the modem during opening of the device */ -dbg ("%s: Sending SIO_INIT (we guess)" ,__func__); - result =usb_control_msg (dev,usb_sndctrlpipe (dev,0 ), -IPW_SIO_INIT , -USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , -0 , -0 ,/* index */ -NULL , -0 , -100000 ); +/* --1: Tell the modem to initialize (we think) From sniffs this is +* always the first thing that gets sent to the modem during +* opening of the device */ +dbg ("%s: Sending SIO_INIT (we guess)" , __func__); + result =usb_control_msg (dev,usb_sndctrlpipe (dev,0 ), +IPW_SIO_INIT , +USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , +0 , +0 ,/* index */ +NULL , +0 , +100000 );if (result <0 ) -dev_err (&port->dev,"Init of modem failed (error = %d)\n" , result); +dev_err (&port->dev, +"Init of modem failed (error = %d)\n" , result);/* reset the bulk pipes */ -usb_clear_halt (dev,usb_rcvbulkpipe (dev, port->bulk_in_endpointAddress)); -usb_clear_halt (dev,usb_sndbulkpipe (dev, port->bulk_out_endpointAddress)); +usb_clear_halt (dev, +usb_rcvbulkpipe (dev, port->bulk_in_endpointAddress)); +usb_clear_halt (dev, +usb_sndbulkpipe (dev, port->bulk_out_endpointAddress)); -/*--2: Start reading from the device */ -dbg ("%s: setting up bulk read callback" ,__func__); +/*--2: Start reading from the device */ +dbg ("%s: setting up bulk read callback" , __func__); usb_fill_bulk_urb(port->read_urb, dev, usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress), port->bulk_in_buffer,
@@ -243,67 +240,72 @@ static int ipw_open(struct tty_struct *tty, ipw_read_bulk_callback, port); result =usb_submit_urb (port->read_urb,GFP_KERNEL );if (result <0 ) -dbg ("%s - usb_submit_urb(read bulk) failed with status %d" , __func__, result); +dbg ("%s - usb_submit_urb(read bulk) failed with status %d" , + __func__, result);/*--3: Tell the modem to open the floodgates on the rx bulk channel */ -dbg ("%s:asking modem for RxRead (RXBULK_ON)" ,__func__); +dbg ("%s:asking modem for RxRead (RXBULK_ON)" , __func__); result =usb_control_msg (dev,usb_sndctrlpipe (dev,0 ), -IPW_SIO_RXCTL , -USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , -IPW_RXBULK_ON , -0 ,/* index */ -NULL , -0 , -100000 ); -if (result <0 ) -dev_err (&port->dev,"Enabling bulk RxRead failed (error = %d)\n" , result); +IPW_SIO_RXCTL , +USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , +IPW_RXBULK_ON , +0 ,/* index */ +NULL , +0 , +100000 ); +if (result <0 ) +dev_err (&port->dev, +"Enabling bulk RxRead failed (error = %d)\n" , result);/*--4: setup the initial flowcontrol */ -dbg ("%s:setting init flowcontrol (%s)" ,__func__,buf_flow_init); +dbg ("%s:setting init flowcontrol (%s)" , __func__, buf_flow_init); result =usb_control_msg (dev,usb_sndctrlpipe (dev,0 ), -IPW_SIO_HANDFLOW , -USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , -0 , -0 , - buf_flow_init, -0x10 , -200000 ); +IPW_SIO_HANDFLOW , +USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , +0 , +0 , + buf_flow_init, +0x10 , +200000 );if (result <0 ) -dev_err (&port->dev,"initial flowcontrol failed (error = %d)\n" , result); +dev_err (&port->dev, +"initial flowcontrol failed (error = %d)\n" , result);/*--5: raise the dtr */ -dbg ("%s:raising dtr" ,__func__); +dbg ("%s:raising dtr" , __func__); result =usb_control_msg (dev,usb_sndctrlpipe (dev,0 ), -IPW_SIO_SET_PIN , -USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , -IPW_PIN_SETDTR , -0 , -NULL , -0 , -200000 ); +IPW_SIO_SET_PIN , +USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , +IPW_PIN_SETDTR , +0 , +NULL , +0 , +200000 );if (result <0 ) -dev_err (&port->dev,"setting dtr failed (error = %d)\n" , result); +dev_err (&port->dev, +"setting dtr failed (error = %d)\n" , result);/*--6: raise the rts */ -dbg ("%s:raising rts" ,__func__); +dbg ("%s:raising rts" , __func__); result =usb_control_msg (dev,usb_sndctrlpipe (dev,0 ), -IPW_SIO_SET_PIN , -USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , -IPW_PIN_SETRTS , -0 , -NULL , -0 , -200000 ); +IPW_SIO_SET_PIN , +USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , +IPW_PIN_SETRTS , +0 , +NULL , +0 , +200000 );if (result <0 ) -dev_err (&port->dev,"setting dtr failed (error = %d)\n" , result); - +dev_err (&port->dev, +"setting dtr failed (error = %d)\n" , result); +kfree (buf_flow_init);return 0 ; }static void ipw_close (struct tty_struct *tty, -struct usb_serial_port *port,struct file * filp) +struct usb_serial_port *port,struct file *filp) {struct usb_device *dev = port->serial->dev;int result;
@@ -314,56 +316,62 @@ static void ipw_close(struct tty_struct *tty, }/*--1: drop the dtr */ -dbg ("%s:dropping dtr" ,__func__); +dbg ("%s:dropping dtr" , __func__); result =usb_control_msg (dev,usb_sndctrlpipe (dev,0 ), -IPW_SIO_SET_PIN , -USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , -IPW_PIN_CLRDTR , -0 , -NULL , -0 , -200000 ); +IPW_SIO_SET_PIN , +USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , +IPW_PIN_CLRDTR , +0 , +NULL , +0 , +200000 );if (result <0 ) -dev_err (&port->dev,"dropping dtr failed (error = %d)\n" , result); +dev_err (&port->dev,"dropping dtr failed (error = %d)\n" , + result);/*--2: drop the rts */ -dbg ("%s:dropping rts" ,__func__); +dbg ("%s:dropping rts" , __func__); result =usb_control_msg (dev,usb_sndctrlpipe (dev,0 ), -IPW_SIO_SET_PIN ,USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , -IPW_PIN_CLRRTS , -0 , -NULL , -0 , -200000 ); +IPW_SIO_SET_PIN ,USB_TYPE_VENDOR | +USB_RECIP_INTERFACE |USB_DIR_OUT , +IPW_PIN_CLRRTS , +0 , +NULL , +0 , +200000 );if (result <0 ) -dev_err (&port->dev,"dropping rts failed (error = %d)\n" , result); +dev_err (&port->dev, +"dropping rts failed (error = %d)\n" , result);/*--3: purge */ -dbg ("%s:sending purge" ,__func__); +dbg ("%s:sending purge" , __func__); result =usb_control_msg (dev,usb_sndctrlpipe (dev,0 ), -IPW_SIO_PURGE ,USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , -0x03 , -0 , -NULL , -0 , -200000 ); +IPW_SIO_PURGE ,USB_TYPE_VENDOR | +USB_RECIP_INTERFACE |USB_DIR_OUT , +0x03 , +0 , +NULL , +0 , +200000 );if (result <0 )dev_err (&port->dev,"purge failed (error = %d)\n" , result); -/* send RXBULK_off (tell modem to stop transmitting bulk data on rx chan) */ +/* send RXBULK_off (tell modem to stop transmitting bulk data on +rx chan) */ result =usb_control_msg (dev,usb_sndctrlpipe (dev,0 ), -IPW_SIO_RXCTL , -USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , -IPW_RXBULK_OFF , -0 ,/* index */ -NULL , -0 , -100000 ); +IPW_SIO_RXCTL , +USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , +IPW_RXBULK_OFF , +0 ,/* index */ +NULL , +0 , +100000 );if (result <0 ) -dev_err (&port->dev,"Disabling bulk RxRead failed (error = %d)\n" , result); +dev_err (&port->dev, +"Disabling bulk RxRead failed (error = %d)\n" , result);/* shutdown any in-flight urbs that we know about */ usb_kill_urb (port->read_urb);
@@ -393,7 +401,7 @@ static int ipw_write(struct tty_struct *tty, struct usb_serial_port *port,int ret;dbg ("%s: TOP: count=%d, in_interrupt=%ld" , __func__, - count,in_interrupt () ); + count,in_interrupt ());if (count ==0 ) {dbg ("%s - write request of 0 bytes" , __func__);
@@ -424,13 +432,14 @@ static int ipw_write(struct tty_struct *tty, struct usb_serial_port *port, ret =usb_submit_urb (port->write_urb,GFP_ATOMIC );if (ret !=0 ) { port->write_urb_busy =0 ; -dbg ("%s - usb_submit_urb(write bulk) failed with error = %d" , __func__, ret); +dbg ("%s - usb_submit_urb(write bulk) failed with error = %d" , + __func__, ret);return ret; }dbg ("%s returning %d" , __func__, count);return count; -} +}static int ipw_probe (struct usb_serial_port *port) {
@@ -489,8 +498,8 @@ module_init(usb_ipw_init);module_exit (usb_ipw_exit);/* Module information */ -MODULE_AUTHOR (DRIVER_AUTHOR ); -MODULE_DESCRIPTION (DRIVER_DESC ); +MODULE_AUTHOR (DRIVER_AUTHOR ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );module_param (debug, bool,S_IRUGO |S_IWUSR );
PATCH 48/70 tty-usb-ir-usb: Clean up to coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/ir-usb.c | 373 +++++++++++++++++++++++-------------------- 1 files changed, 201 insertions(+), 172 deletions(-)
drivers/usb/serial/ir-usb.c +201 -172
@@ -19,7 +19,8 @@* was written by Roman Weissgaerber <[email protected]>, Dag Brattli * <[email protected]>, and Jean Tourrilhes <[email protected]> * -* See Documentation/usb/usb-serial.txt for more information on using this driver +* See Documentation/usb/usb-serial.txt for more information on using this +* driver * * 2007_Jun_21 Alan Cox <[email protected]> * Minimal cleanups for some of the driver problens and tty layer abuse.
@@ -59,7 +60,7 @@#include <linux/tty_flip.h> #include <linux/module.h> #include <linux/spinlock.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/usb/serial.h>
@@ -105,28 +106,32 @@ static int buffer_size;/* if overridden by the user, then use the specified number of XBOFs */ static int xbof =-1 ; -static int ir_startup (struct usb_serial *serial); -static int ir_open (struct tty_struct *tty,struct usb_serial_port *port,struct file *filep); -static void ir_close (struct tty_struct *tty,struct usb_serial_port *port,struct file *filep); -static int ir_write (struct tty_struct *tty,struct usb_serial_port *port,const unsigned char *buf,int count); -static void ir_write_bulk_callback (struct urb *urb); -static void ir_read_bulk_callback (struct urb *urb); -static void ir_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios); +static int ir_startup (struct usb_serial *serial); +static int ir_open (struct tty_struct *tty,struct usb_serial_port *port, +struct file *filep); +static void ir_close (struct tty_struct *tty,struct usb_serial_port *port, +struct file *filep); +static int ir_write (struct tty_struct *tty,struct usb_serial_port *port, +const unsigned char *buf,int count); +static void ir_write_bulk_callback (struct urb *urb); +static void ir_read_bulk_callback (struct urb *urb); +static void ir_set_termios (struct tty_struct *tty, +struct usb_serial_port *port,struct ktermios *old_termios); -/* Not that this lot means you can only have one per system */ -static u8 ir_baud =0 ; -static u8 ir_xbof =0 ; -static u8 ir_add_bof =0 ; +/* FIXME: Note that this lot means you can only have one per system */ +static u8 ir_baud; +static u8 ir_xbof; +static u8 ir_add_bof;static struct usb_device_id id_table [] = { {USB_DEVICE (0x050f ,0x0180 ) },/* KC Technology, KC-180 */ {USB_DEVICE (0x08e9 ,0x0100 ) },/* XTNDAccess */ {USB_DEVICE (0x09c4 ,0x0011 ) },/* ACTiSys ACT-IR2000U */ - {USB_INTERFACE_INFO (USB_CLASS_APP_SPEC ,USB_CLASS_IRDA ,0 ) }, + {USB_INTERFACE_INFO (USB_CLASS_APP_SPEC ,USB_CLASS_IRDA ,0 ) }, { }/* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table); +MODULE_DEVICE_TABLE (usb, id_table);static struct usb_driver ir_driver = { .name ="ir-usb" ,
@@ -159,7 +164,7 @@ static inline void irda_usb_dump_class_desc(struct irda_class_desc *desc) {dbg ("bLength=%x" , desc->bLength);dbg ("bDescriptorType=%x" , desc->bDescriptorType); -dbg ("bcdSpecRevision=%x" , desc->bcdSpecRevision); +dbg ("bcdSpecRevision=%x" , desc->bcdSpecRevision);dbg ("bmDataSize=%x" , desc->bmDataSize);dbg ("bmWindowSize=%x" , desc->bmWindowSize);dbg ("bmMinTurnaroundTime=%d" , desc->bmMinTurnaroundTime);
@@ -181,25 +186,26 @@ static inline void irda_usb_dump_class_desc(struct irda_class_desc *desc)* * Based on the same function in drivers/net/irda/irda-usb.c */ -static struct irda_class_desc *irda_usb_find_class_desc (struct usb_device *dev,unsigned int ifnum) +static struct irda_class_desc *irda_usb_find_class_desc (struct usb_device *dev, +unsigned int ifnum) {struct irda_class_desc *desc;int ret; - - desc =kzalloc (sizeof (struct irda_class_desc ),GFP_KERNEL ); -if (desc ==NULL ) + + desc =kzalloc (sizeof (struct irda_class_desc ),GFP_KERNEL ); +if (desc ==NULL )return NULL ; - - ret =usb_control_msg (dev,usb_rcvctrlpipe (dev,0 ), + + ret =usb_control_msg (dev,usb_rcvctrlpipe (dev,0 ),IU_REQ_GET_CLASS_DESC ,USB_DIR_IN |USB_TYPE_CLASS |USB_RECIP_INTERFACE ,0 , ifnum, desc,sizeof (*desc),1000 ); - +dbg ("%s - ret=%d" , __func__, ret);if (ret <sizeof (*desc)) {dbg ("%s - class descriptor read %s (%d)" , __func__, - (ret<0 ) ?"failed" :"too short" , + (ret <0 ) ?"failed" :"too short" , ret); goto error; }
@@ -207,7 +213,7 @@ static struct irda_class_desc *irda_usb_find_class_desc(struct usb_device *dev,dbg ("%s - bad class descriptor type" , __func__); goto error; } - +irda_usb_dump_class_desc (desc);return desc; error:
@@ -220,34 +226,44 @@ static u8 ir_xbof_change(u8 xbof) {u8 result;/* reference irda-usb.c */ -switch (xbof) { -case 48 : result =0x10 ;break ; -case 28 : -case 24 : result =0x20 ;break ; -default : -case 12 : result =0x30 ;break ; -case 5 : -case 6 : result =0x40 ;break ; -case 3 : result =0x50 ;break ; -case 2 : result =0x60 ;break ; -case 1 : result =0x70 ;break ; -case 0 : result =0x80 ;break ; +switch (xbof) { +case 48 : + result =0x10 ; +break ; +case 28 : +case 24 :result =0x20 ; +break ; +default : +case 12 :result =0x30 ; +break ; +case 5 : +case 6 :result =0x40 ; +break ; +case 3 :result =0x50 ; +break ; +case 2 :result =0x60 ; +break ; +case 1 :result =0x70 ; +break ; +case 0 :result =0x80 ; +break ; } -return (result); +return result; } -static int ir_startup (struct usb_serial *serial) +static int ir_startup (struct usb_serial *serial) {struct irda_class_desc *irda_desc; - irda_desc =irda_usb_find_class_desc (serial->dev,0 ); + irda_desc =irda_usb_find_class_desc (serial->dev,0 );if (irda_desc ==NULL ) { -dev_err (&serial->dev->dev,"IRDA class descriptor not found, device not bound\n" ); +dev_err (&serial->dev->dev, +"IRDA class descriptor not found, device not bound\n" );return -ENODEV ; } - dbg ("%s - Baud rates supported:%s%s%s%s%s%s%s%s%s", + dbg("%s - Baud rates supported:%s%s%s%s%s%s%s%s%s", __func__, (irda_desc->wBaudRate & 0x0001) ? " 2400" : "", (irda_desc->wBaudRate & 0x0002) ? " 9600" : "",
@@ -259,21 +275,35 @@ static int ir_startup (struct usb_serial *serial) (irda_desc->wBaudRate &0x0080 ) ?" 1152000" :"" , (irda_desc->wBaudRate & 0x0100) ? " 4000000" : ""); -switch ( irda_desc->bmAdditionalBOFs ) { -case 0x01 : ir_add_bof =48 ;break ; -case 0x02 : ir_add_bof =24 ;break ; -case 0x04 : ir_add_bof =12 ;break ; -case 0x08 : ir_add_bof =6 ;break ; -case 0x10 : ir_add_bof =3 ;break ; -case 0x20 : ir_add_bof =2 ;break ; -case 0x40 : ir_add_bof =1 ;break ; -case 0x80 : ir_add_bof =0 ;break ; -default :; +switch (irda_desc->bmAdditionalBOFs) { +case 0x01 : + ir_add_bof =48 ; +break ; +case 0x02 : + ir_add_bof =24 ; +break ; +case 0x04 : + ir_add_bof =12 ; +break ; +case 0x08 : + ir_add_bof =6 ; +break ; +case 0x10 : + ir_add_bof =3 ; +break ; +case 0x20 : + ir_add_bof =2 ; +break ; +case 0x40 : + ir_add_bof =1 ; +break ; +case 0x80 : + ir_add_bof =0 ; +break ; +default :; } - -kfree (irda_desc); - -return 0 ; +kfree (irda_desc); +return 0 ; } static int ir_open(struct tty_struct *tty,
@@ -286,47 +316,48 @@ static int ir_open(struct tty_struct *tty,if (buffer_size) {/* override the default buffer sizes */ - buffer =kmalloc (buffer_size,GFP_KERNEL ); + buffer =kmalloc (buffer_size,GFP_KERNEL );if (!buffer) { -dev_err (&port->dev,"%s - out of memory.\n" , __func__); +dev_err (&port->dev,"%s - out of memory.\n" , __func__);return -ENOMEM ; } -kfree (port->read_urb->transfer_buffer); +kfree (port->read_urb->transfer_buffer); port->read_urb->transfer_buffer = buffer; port->read_urb->transfer_buffer_length = buffer_size; - buffer =kmalloc (buffer_size,GFP_KERNEL ); + buffer =kmalloc (buffer_size,GFP_KERNEL );if (!buffer) { -dev_err (&port->dev,"%s - out of memory.\n" , __func__); +dev_err (&port->dev,"%s - out of memory.\n" , + __func__);return -ENOMEM ; } -kfree (port->write_urb->transfer_buffer); +kfree (port->write_urb->transfer_buffer); port->write_urb->transfer_buffer = buffer; port->write_urb->transfer_buffer_length = buffer_size; port->bulk_out_size = buffer_size; }/* Start reading from the device */ -usb_fill_bulk_urb ( - port->read_urb, - port->serial->dev, -usb_rcvbulkpipe (port->serial->dev, port->bulk_in_endpointAddress), - port->read_urb->transfer_buffer, - port->read_urb->transfer_buffer_length, - ir_read_bulk_callback, - port); +usb_fill_bulk_urb (port->read_urb, port->serial->dev, +usb_rcvbulkpipe (port->serial->dev, + port->bulk_in_endpointAddress), + port->read_urb->transfer_buffer, + port->read_urb->transfer_buffer_length, + ir_read_bulk_callback, port); result =usb_submit_urb (port->read_urb,GFP_KERNEL );if (result) -dev_err (&port->dev,"%s - failed submitting read urb, error %d\n" , __func__, result); +dev_err (&port->dev, +"%s - failed submitting read urb, error %d\n" , + __func__, result);return result; }static void ir_close (struct tty_struct *tty, -struct usb_serial_port *port,struct file * filp) +struct usb_serial_port *port,struct file *filp) {dbg ("%s - port %d" , __func__, port->number); - +/* shutdown our bulk read */ usb_kill_urb (port->read_urb); }
@@ -365,31 +396,29 @@ static int ir_write(struct tty_struct *tty, struct usb_serial_port *port, *transfer_buffer = ir_xbof | ir_baud; ++transfer_buffer; -memcpy (transfer_buffer, buf, transfer_size); +memcpy (transfer_buffer, buf, transfer_size); -usb_fill_bulk_urb ( - port->write_urb, - port->serial->dev, -usb_sndbulkpipe (port->serial->dev, - port->bulk_out_endpointAddress), - port->write_urb->transfer_buffer, - transfer_size +1 , - ir_write_bulk_callback, - port); +usb_fill_bulk_urb (port->write_urb, port->serial->dev, +usb_sndbulkpipe (port->serial->dev, + port->bulk_out_endpointAddress), + port->write_urb->transfer_buffer, + transfer_size +1 , ir_write_bulk_callback, port); port->write_urb->transfer_flags =URB_ZERO_PACKET ; - result =usb_submit_urb (port->write_urb,GFP_ATOMIC ); + result =usb_submit_urb (port->write_urb,GFP_ATOMIC );if (result) { port->write_urb_busy =0 ; -dev_err (&port->dev,"%s - failed submitting write urb, error %d\n" , __func__, result); +dev_err (&port->dev, +"%s - failed submitting write urb, error %d\n" , + __func__, result); }else result = transfer_size;return result; } -static void ir_write_bulk_callback (struct urb *urb) +static void ir_write_bulk_callback (struct urb *urb) {struct usb_serial_port *port = urb->context;int status = urb->status;
@@ -403,17 +432,13 @@ static void ir_write_bulk_callback (struct urb *urb)return ; } -usb_serial_debug_data ( - debug, - &port->dev, - __func__, - urb->actual_length, - urb->transfer_buffer); +usb_serial_debug_data (debug, &port->dev, __func__, urb->actual_length, + urb->transfer_buffer);usb_serial_port_softint (port); } -static void ir_read_bulk_callback (struct urb *urb) +static void ir_read_bulk_callback (struct urb *urb) {struct usb_serial_port *port = urb->context;struct tty_struct *tty;
@@ -429,64 +454,52 @@ static void ir_read_bulk_callback (struct urb *urb) }switch (status) { -case 0 :/* Successful */ - -/* -* The first byte of the packet we get from the device -* contains a busy indicator and baud rate change. -* See section 5.4.1.2 of the USB IrDA spec. -*/ -if ((*data &0x0f ) >0 ) - ir_baud = *data &0x0f ; - -usb_serial_debug_data ( - debug, - &port->dev, - __func__, - urb->actual_length, - data); - - tty = port->port.tty; - -if (tty_buffer_request_room (tty, urb->actual_length -1 )) { -tty_insert_flip_string (tty, data+1 , urb->actual_length -1 ); -tty_flip_buffer_push (tty); - } - -/* -* No break here. -* We want to resubmit the urb so we can read -* again. -*/ +case 0 :/* Successful */ + +/* +* The first byte of the packet we get from the device +* contains a busy indicator and baud rate change. +* See section 5.4.1.2 of the USB IrDA spec. +*/ +if ((*data &0x0f ) >0 ) + ir_baud = *data &0x0f ; + +usb_serial_debug_data (debug, &port->dev, __func__, + urb->actual_length, data); + tty = port->port.tty; + +if (tty_buffer_request_room (tty, urb->actual_length -1 )) { +tty_insert_flip_string (tty, data +1 , + urb->actual_length -1 ); +tty_flip_buffer_push (tty); + } -case -EPROTO :/* taking inspiration from pl2303.c */ +/* +* No break here. +* We want to resubmit the urb so we can read +* again. +*/ -/* Continue trying to always read */ -usb_fill_bulk_urb ( - port->read_urb, - port->serial->dev, +case -EPROTO :/* taking inspiration from pl2303.c */ +/* Continue trying to always read */ +usb_fill_bulk_urb (port->read_urb, port->serial->dev,usb_rcvbulkpipe (port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, - ir_read_bulk_callback, - port); - - result =usb_submit_urb (port->read_urb,GFP_ATOMIC ); -if (result) -dev_err (&port->dev,"%s - failed resubmitting read urb, error %d\n" , - __func__, result); - -break ; - -default : -dbg ("%s - nonzero read bulk status received: %d" , - __func__, - status); -break ; - + ir_read_bulk_callback, port); + + result =usb_submit_urb (port->read_urb,GFP_ATOMIC ); +if (result) +dev_err (&port->dev, +"%s - failed resubmitting read urb, error %d\n" , + __func__, result); +break ; +default : +dbg ("%s - nonzero read bulk status received: %d" , + __func__, status); +break ; } -return ; }
@@ -509,19 +522,36 @@ static void ir_set_termios(struct tty_struct *tty,*/ switch (baud) { -case 2400 : ir_baud =SPEED_2400 ;break ; -case 9600 : ir_baud =SPEED_9600 ;break ; -case 19200 : ir_baud =SPEED_19200 ;break ; -case 38400 : ir_baud =SPEED_38400 ;break ; -case 57600 : ir_baud =SPEED_57600 ;break ; -case 115200 : ir_baud =SPEED_115200 ;break ; -case 576000 : ir_baud =SPEED_576000 ;break ; -case 1152000 : ir_baud =SPEED_1152000 ;break ; -case 4000000 : ir_baud =SPEED_4000000 ;break ; -break ; -default : - ir_baud =SPEED_9600 ; - baud =9600 ; +case 2400 : + ir_baud =SPEED_2400 ; +break ; +case 9600 : + ir_baud =SPEED_9600 ; +break ; +case 19200 : + ir_baud =SPEED_19200 ; +break ; +case 38400 : + ir_baud =SPEED_38400 ; +break ; +case 57600 : + ir_baud =SPEED_57600 ; +break ; +case 115200 : + ir_baud =SPEED_115200 ; +break ; +case 576000 : + ir_baud =SPEED_576000 ; +break ; +case 1152000 : + ir_baud =SPEED_1152000 ; +break ; +case 4000000 : + ir_baud =SPEED_4000000 ; +break ; +default : + ir_baud =SPEED_9600 ; + baud =9600 ; }if (xbof ==-1 )
@@ -537,20 +567,19 @@ static void ir_set_termios(struct tty_struct *tty, transfer_buffer = port->write_urb->transfer_buffer; *transfer_buffer = ir_xbof | ir_baud; -usb_fill_bulk_urb ( - port->write_urb, - port->serial->dev, -usb_sndbulkpipe (port->serial->dev, port->bulk_out_endpointAddress), - port->write_urb->transfer_buffer, -1 , - ir_write_bulk_callback, - port); +usb_fill_bulk_urb (port->write_urb, port->serial->dev, +usb_sndbulkpipe (port->serial->dev, + port->bulk_out_endpointAddress), + port->write_urb->transfer_buffer, +1 , ir_write_bulk_callback, port); port->write_urb->transfer_flags =URB_ZERO_PACKET ; - result =usb_submit_urb (port->write_urb,GFP_KERNEL ); + result =usb_submit_urb (port->write_urb,GFP_KERNEL );if (result) -dev_err (&port->dev,"%s - failed submitting write urb, error %d\n" , __func__, result); +dev_err (&port->dev, +"%s - failed submitting write urb, error %d\n" , + __func__, result);/* Only speed changes are supported */ tty_termios_copy_hw (tty->termios, old_termios);
@@ -558,14 +587,14 @@ static void ir_set_termios(struct tty_struct *tty, } -static int __init ir_init (void ) +static int __init ir_init (void ) {int retval; retval =usb_serial_register (&ir_device);if (retval) goto failed_usb_serial_register; retval =usb_register (&ir_driver); -if (retval) +if (retval) goto failed_usb_register;info (DRIVER_DESC " " DRIVER_VERSION );return 0 ;
@@ -576,10 +605,10 @@ failed_usb_serial_register: } -static void __exit ir_exit (void) +static void __exit ir_exit(void) { -usb_deregister (&ir_driver); -usb_serial_deregister (&ir_device); +usb_deregister (&ir_driver); +usb_serial_deregister (&ir_device); }
PATCH 49/70 tty-usb-iuu-phoenix: Clean up to coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/iuu_phoenix.c | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-)
drivers/usb/serial/iuu_phoenix.c +6 -9
@@ -318,11 +318,10 @@ static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count) port->bulk_out_endpointAddress), buf, count, &actual, HZ * 1); -if (status !=IUU_OPERATION_OK ) { +if (status !=IUU_OPERATION_OK )dbg ("%s - error = %2x" , __func__, status); - }else { +else dbg ("%s - write OK !" , __func__); - }return status; }
@@ -342,12 +341,10 @@ static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count) port->bulk_in_endpointAddress), buf, count, &actual, HZ * 1); -if (status !=IUU_OPERATION_OK ) { +if (status !=IUU_OPERATION_OK )dbg ("%s - error = %2x" , __func__, status); - }else { +else dbg ("%s - read OK !" , __func__); - } -return status; }
@@ -770,14 +767,14 @@ static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port,if (priv->writelen >0 ) {/* buffer already filled but not commited */ spin_unlock_irqrestore (&priv->lock, flags); -return (0 ); +return 0 ; }/* fill the buffer */ memcpy (priv->writebuf, buf, count); priv->writelen = count;spin_unlock_irqrestore (&priv->lock, flags); -return (count); +return count; }static void read_rxcmd_callback (struct urb *urb)
PATCH 50/70 tty-usb-keyspan: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/keyspan.c | 839 +++++++++++++++++++++--------------------- 1 files changed, 427 insertions(+), 412 deletions(-)
drivers/usb/serial/keyspan.c +427 -412
@@ -1,29 +1,29 @@/* Keyspan USB to Serial Converter driver -+ (C) Copyright (C) 2000-2001 Hugh Blemings <[email protected]> (C) Copyright (C) 2002 Greg Kroah-Hartman <[email protected]> -+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See http://misc.nu/hugh/keyspan.html for more information. -+ Code in this driver inspired by and in a number of places taken from Brian Warner's original Keyspan-PDA driver. This driver has been put together with the support of Innosys, Inc. and Keyspan, Inc the manufacturers of the Keyspan USB-serial products. Thanks Guys :) -+ Thanks to Paulus for miscellaneous tidy ups, some largish chunks of much nicer and/or completely new code and (perhaps most uniquely) having the patience to sit down and explain why and where he'd changed -stuff. -- Tip 'o the hat to IBM (and previously Linuxcare :) for supporting +stuff. + +Tip 'o the hat to IBM (and previously Linuxcare :) for supporting staff in their work on open source projects. Change History
@@ -70,21 +70,21 @@ Thu May 31 11:56:42 PDT 2001 gkh switched from using spinlock to a semaphore - + (04/08/2001) gb Identify version on module load. - + (11/01/2000) Adam J. Richter usb_device_id table support. - + Tue Oct 10 23:15:33 EST 2000 Hugh Merged Paul's changes with my USA-49W mods. Work in progress still... - + Wed Jul 19 14:00:42 EST 2000 gkh Added module_init and module_exit functions to handle the fact that this driver is a loadable module now. - + Tue Jul 18 16:14:52 EST 2000 Hugh Basic character input/output for USA-19 now mostly works, fixed at 9600 baud for the moment.
@@ -105,7 +105,7 @@#include <linux/tty_flip.h> #include <linux/module.h> #include <linux/spinlock.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/usb/serial.h> #include "keyspan.h"
@@ -130,15 +130,15 @@ struct keyspan_serial_private {struct urb *instat_urb;char instat_buf[INSTAT_BUFLEN ]; -/* added to support 49wg, where data from all 4 ports comes in on 1 EP */ -/* and high-speed supported */ +/* added to support 49wg, where data from all 4 ports comes in +on 1 EP and high-speed supported */ struct urb *indat_urb;char indat_buf[INDAT49W_BUFLEN ];/* XXX this one probably will need a lock */ struct urb *glocont_urb;char glocont_buf[GLOCONT_BUFLEN ]; -char ctrl_buf[8 ];// for EP0 control message +char ctrl_buf[8 ];/* for EP0 control message */ };struct keyspan_port_private {
@@ -184,19 +184,19 @@ struct keyspan_port_private {int resend_cont;/* need to resend control packet */ }; -/* Include Keyspan message headers. All current Keyspan Adapters make use of one of five message formats which are referred -to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and within this driver. */ +to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and +within this driver. */ #include "keyspan_usa26msg.h" #include "keyspan_usa28msg.h" #include "keyspan_usa49msg.h" #include "keyspan_usa90msg.h" #include "keyspan_usa67msg.h" - +/* Functions used by new usb-serial code. */ -static int __init keyspan_init (void ) +static int __init keyspan_init (void ) {int retval; retval =usb_serial_register (&keyspan_pre_device);
@@ -212,7 +212,7 @@ static int __init keyspan_init (void)if (retval) goto failed_4port_device_register; retval =usb_register (&keyspan_driver); -if (retval) +if (retval) goto failed_usb_register;info (DRIVER_VERSION ":" DRIVER_DESC );
@@ -230,13 +230,13 @@ failed_pre_device_register:return retval; } -static void __exit keyspan_exit (void) +static void __exit keyspan_exit(void) { -usb_deregister (&keyspan_driver); -usb_serial_deregister (&keyspan_pre_device); -usb_serial_deregister (&keyspan_1port_device); -usb_serial_deregister (&keyspan_2port_device); -usb_serial_deregister (&keyspan_4port_device); +usb_deregister (&keyspan_driver); +usb_serial_deregister (&keyspan_pre_device); +usb_serial_deregister (&keyspan_1port_device); +usb_serial_deregister (&keyspan_2port_device); +usb_serial_deregister (&keyspan_4port_device); }module_init (keyspan_init);
@@ -247,7 +247,7 @@ static void keyspan_break_ctl(struct tty_struct *tty, int break_state)struct usb_serial_port *port = tty->driver_data;struct keyspan_port_private *p_priv; -dbg ("%s" , __func__); +dbg ("%s" , __func__); p_priv =usb_get_serial_port_data (port);
@@ -260,7 +260,7 @@ static void keyspan_break_ctl(struct tty_struct *tty, int break_state) } -static void keyspan_set_termios (struct tty_struct *tty, +static void keyspan_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios) {int baud_rate, device_port;
@@ -278,7 +278,7 @@ static void keyspan_set_termios (struct tty_struct *tty,/* Baud rate calculation takes baud rate as an integer so other rates can be generated if desired. */ baud_rate =tty_get_baud_rate (tty); -/* If no match or invalid, don't change */ +/* If no match or invalid, don't change */ if (d_details->calculate_baud_rate (baud_rate, d_details->baudclk,NULL ,NULL ,NULL , device_port) ==KEYSPAN_BAUD_RATE_OK ) {/* FIXME - more to do here to ensure rate changes cleanly */
@@ -303,13 +303,13 @@ static int keyspan_tiocmget(struct tty_struct *tty, struct file *file)struct usb_serial_port *port = tty->driver_data;struct keyspan_port_private *p_priv =usb_get_serial_port_data (port);unsigned int value; - + value = ((p_priv->rts_state) ?TIOCM_RTS :0 ) | ((p_priv->dtr_state) ?TIOCM_DTR :0 ) | ((p_priv->cts_state) ?TIOCM_CTS :0 ) | ((p_priv->dsr_state) ?TIOCM_DSR :0 ) | ((p_priv->dcd_state) ?TIOCM_CAR :0 ) | - ((p_priv->ri_state) ?TIOCM_RNG :0 ); + ((p_priv->ri_state) ?TIOCM_RNG :0 );return value; }
@@ -319,7 +319,7 @@ static int keyspan_tiocmset(struct tty_struct *tty, struct file *file, {struct usb_serial_port *port = tty->driver_data;struct keyspan_port_private *p_priv =usb_get_serial_port_data (port); - +if (set &TIOCM_RTS ) p_priv->rts_state =1 ;if (set &TIOCM_DTR )
@@ -342,19 +342,19 @@ static int keyspan_write(struct tty_struct *tty,int flip;int left, todo;struct urb *this_urb; -int err, maxDataLen, dataOffset; +int err, maxDataLen, dataOffset; p_priv =usb_get_serial_port_data (port); d_details = p_priv->device_details;if (d_details->msg_format == msg_usa90) { - maxDataLen =64 ; + maxDataLen =64 ; dataOffset =0 ; }else { maxDataLen =63 ; dataOffset =1 ; } - +dbg ("%s - for port %d (%d chars), flip=%d" , __func__, port->number, count, p_priv->out_flip);
@@ -364,37 +364,40 @@ static int keyspan_write(struct tty_struct *tty, todo = maxDataLen; flip = p_priv->out_flip; - +/* Check we have a valid urb/endpoint before we use it... */ -if ((this_urb = p_priv->out_urbs[flip]) ==NULL ) { + this_urb = p_priv->out_urbs[flip]; +if (this_urb ==NULL ) {/* no bulk out, so return 0 bytes written */ dbg ("%s - no output urb :(" , __func__);return count; } -dbg ("%s - endpoint %d flip %d" , __func__,usb_pipeendpoint (this_urb->pipe), flip); +dbg ("%s - endpoint %d flip %d" , + __func__,usb_pipeendpoint (this_urb->pipe), flip);if (this_urb->status == -EINPROGRESS ) { -if (time_before (jiffies, p_priv->tx_start_time[flip] +10 *HZ )) +if (time_before (jiffies, + p_priv->tx_start_time[flip] +10 *HZ ))break ;usb_unlink_urb (this_urb);break ; } -/* First byte in buffer is "last flag" (except for usa19hx) - unused so -for now so set to zero */ +/* First byte in buffer is "last flag" (except for usa19hx) +- unused so for now so set to zero */ ((char *)this_urb->transfer_buffer)[0 ] =0 ; -memcpy (this_urb->transfer_buffer + dataOffset, buf, todo); +memcpy (this_urb->transfer_buffer + dataOffset, buf, todo); buf += todo;/* send the data out the bulk port */ this_urb->transfer_buffer_length = todo + dataOffset; this_urb->dev = port->serial->dev; -if ((err =usb_submit_urb (this_urb,GFP_ATOMIC )) !=0 ) { + err =usb_submit_urb (this_urb,GFP_ATOMIC ); +if (err !=0 )dbg ("usb_submit_urb(write bulk) failed (%d)" , err); - } p_priv->tx_start_time[flip] = jiffies;/* Flip for next time if usa26 or usa28 interface
@@ -414,7 +417,7 @@ static void usa26_indat_callback(struct urb *urb)unsigned char *data = urb->transfer_buffer;int status = urb->status; -dbg ("%s" , __func__); +dbg ("%s" , __func__); endpoint =usb_pipeendpoint (urb->pipe);
@@ -429,13 +432,14 @@ static void usa26_indat_callback(struct urb *urb)if (tty && urb->actual_length) {/* 0x80 bit is error flag */ if ((data[0 ] &0x80 ) ==0 ) { -/* no errors on individual bytes, only possible overrun err*/ +/* no errors on individual bytes, only +possible overrun err */ if (data[0 ] &RXERROR_OVERRUN ) - err =TTY_OVERRUN ; -else err =0 ; -for (i =1 ; i < urb->actual_length ; ++i) { + err =TTY_OVERRUN ; +else + err =0 ; +for (i =1 ; i < urb->actual_length ; ++i)tty_insert_flip_char (tty, data[i], err); - } }else {/* some bytes had errors, every byte has status */ dbg ("%s - RX error!!!!" , __func__);
@@ -453,17 +457,19 @@ static void usa26_indat_callback(struct urb *urb) }tty_flip_buffer_push (tty); } - -/* Resubmit urb so we continue receiving */ + +/* Resubmit urb so we continue receiving */ urb->dev = port->serial->dev; -if (port->port.count) -if ((err =usb_submit_urb (urb,GFP_ATOMIC )) !=0 ) { -dbg ("%s - resubmit read urb failed. (%d)" , __func__, err); - } +if (port->port.count) { + err =usb_submit_urb (urb,GFP_ATOMIC ); +if (err !=0 ) +dbg ("%s - resubmit read urb failed. (%d)" , + __func__, err); + }return ; } -/* Outdat handling is common for all devices */ +/* Outdat handling is common for all devices */ static void usa2x_outdat_callback (struct urb *urb) {struct usb_serial_port *port;
@@ -471,7 +477,7 @@ static void usa2x_outdat_callback(struct urb *urb) port = urb->context; p_priv =usb_get_serial_port_data (port); -dbg ("%s - urb %d" , __func__, urb == p_priv->out_urbs[1 ]); +dbg ("%s - urb %d" , __func__, urb == p_priv->out_urbs[1 ]);if (port->port.count)usb_serial_port_softint (port);
@@ -479,8 +485,8 @@ static void usa2x_outdat_callback(struct urb *urb)static void usa26_inack_callback (struct urb *urb) { -dbg ("%s" , __func__); - +dbg ("%s" , __func__); + }static void usa26_outcont_callback (struct urb *urb)
@@ -492,8 +498,9 @@ static void usa26_outcont_callback(struct urb *urb) p_priv =usb_get_serial_port_data (port);if (p_priv->resend_cont) { -dbg ("%s - sending setup" , __func__); -keyspan_usa26_send_setup (port->serial, port, p_priv->resend_cont -1 ); +dbg ("%s - sending setup" , __func__); +keyspan_usa26_send_setup (port->serial, port, + p_priv->resend_cont -1 ); } }
@@ -529,14 +536,14 @@ static void usa26_instat_callback(struct urb *urb)/* Now do something useful with the data */ -/* Check port number from message and retrieve private data */ +/* Check port number from message and retrieve private data */ if (msg->port >= serial->num_ports) { -dbg ("%s - Unexpected port number %d" , __func__, msg->port); +dbg ("%s - Unexpected port number %d" , __func__, msg->port); goto exit; } port = serial->port[msg->port]; p_priv =usb_get_serial_port_data (port); - +/* Update handshaking pin state information */ old_dcd_state = p_priv->dcd_state; p_priv->cts_state = ((msg->hskia_cts) ?1 :0 );
@@ -551,19 +558,18 @@ static void usa26_instat_callback(struct urb *urb)/* else */ /* wake_up_interruptible(&p_priv->open_wait); */ } - +/* Resubmit urb so we continue receiving */ urb->dev = serial->dev; -if ((err =usb_submit_urb (urb,GFP_ATOMIC )) !=0 ) { + err =usb_submit_urb (urb,GFP_ATOMIC ); +if (err !=0 )dbg ("%s - resubmit read urb failed. (%d)" , __func__, err); - } exit: ; }static void usa26_glocont_callback (struct urb *urb) { -dbg ("%s" , __func__); - +dbg ("%s" , __func__); }
@@ -576,7 +582,7 @@ static void usa28_indat_callback(struct urb *urb)struct keyspan_port_private *p_priv;int status = urb->status; -dbg ("%s" , __func__); +dbg ("%s" , __func__); port = urb->context; p_priv =usb_get_serial_port_data (port);
@@ -598,18 +604,19 @@ static void usa28_indat_callback(struct urb *urb) tty = port->port.tty;if (urb->actual_length) { -for (i =0 ; i < urb->actual_length ; ++i) { +for (i =0 ; i < urb->actual_length ; ++i)tty_insert_flip_char (tty, data[i],0 ); - }tty_flip_buffer_push (tty); }/* Resubmit urb so we continue receiving */ urb->dev = port->serial->dev; -if (port->port.count) -if ((err =usb_submit_urb (urb,GFP_ATOMIC )) !=0 ) { -dbg ("%s - resubmit read urb failed. (%d)" , __func__, err); - } +if (port->port.count) { + err =usb_submit_urb (urb,GFP_ATOMIC ); +if (err !=0 ) +dbg ("%s - resubmit read urb failed. (%d)" , + __func__, err); + } p_priv->in_flip ^=1 ; urb = p_priv->in_urbs[p_priv->in_flip];
@@ -618,7 +625,7 @@ static void usa28_indat_callback(struct urb *urb)static void usa28_inack_callback (struct urb *urb) { -dbg ("%s" , __func__); +dbg ("%s" , __func__); }static void usa28_outcont_callback (struct urb *urb)
@@ -630,8 +637,9 @@ static void usa28_outcont_callback(struct urb *urb) p_priv =usb_get_serial_port_data (port);if (p_priv->resend_cont) { -dbg ("%s - sending setup" , __func__); -keyspan_usa28_send_setup (port->serial, port, p_priv->resend_cont -1 ); +dbg ("%s - sending setup" , __func__); +keyspan_usa28_send_setup (port->serial, port, + p_priv->resend_cont -1 ); } }
@@ -661,19 +669,18 @@ static void usa28_instat_callback(struct urb *urb)/*dbg("%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__ data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11]);*/ - -/* Now do something useful with the data */ - msg = (struct keyspan_usa28_portStatusMessage *)data; +/* Now do something useful with the data */ + msg = (struct keyspan_usa28_portStatusMessage *)data; -/* Check port number from message and retrieve private data */ +/* Check port number from message and retrieve private data */ if (msg->port >= serial->num_ports) { -dbg ("%s - Unexpected port number %d" , __func__, msg->port); +dbg ("%s - Unexpected port number %d" , __func__, msg->port); goto exit; } port = serial->port[msg->port]; p_priv =usb_get_serial_port_data (port); - +/* Update handshaking pin state information */ old_dcd_state = p_priv->dcd_state; p_priv->cts_state = ((msg->cts) ?1 :0 );
@@ -691,15 +698,15 @@ static void usa28_instat_callback(struct urb *urb)/* Resubmit urb so we continue receiving */ urb->dev = serial->dev; -if ((err =usb_submit_urb (urb,GFP_ATOMIC )) !=0 ) { + err =usb_submit_urb (urb,GFP_ATOMIC ); +if (err !=0 )dbg ("%s - resubmit read urb failed. (%d)" , __func__, err); - } exit: ; }static void usa28_glocont_callback (struct urb *urb) { -dbg ("%s" , __func__); +dbg ("%s" , __func__); }
@@ -710,7 +717,7 @@ static void usa49_glocont_callback(struct urb *urb)struct keyspan_port_private *p_priv;int i; -dbg ("%s" , __func__); +dbg ("%s" , __func__); serial = urb->context;for (i =0 ; i < serial->num_ports; ++i) {
@@ -718,8 +725,9 @@ static void usa49_glocont_callback(struct urb *urb) p_priv =usb_get_serial_port_data (port);if (p_priv->resend_cont) { -dbg ("%s - sending setup" , __func__); -keyspan_usa49_send_setup (serial, port, p_priv->resend_cont -1 ); +dbg ("%s - sending setup" , __func__); +keyspan_usa49_send_setup (serial, port, + p_priv->resend_cont -1 );break ; } }
@@ -738,7 +746,7 @@ static void usa49_instat_callback(struct urb *urb)int old_dcd_state;int status = urb->status; -dbg ("%s" , __func__); +dbg ("%s" , __func__); serial = urb->context;
@@ -747,7 +755,8 @@ static void usa49_instat_callback(struct urb *urb)return ; } -if (urb->actual_length !=sizeof (struct keyspan_usa49_portStatusMessage )) { +if (urb->actual_length != +sizeof (struct keyspan_usa49_portStatusMessage )) {dbg ("%s - bad length %d" , __func__, urb->actual_length); goto exit; }
@@ -755,18 +764,19 @@ static void usa49_instat_callback(struct urb *urb)/*dbg(" %x %x %x %x %x %x %x %x %x %x %x", __func__, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10]);*/ - -/* Now do something useful with the data */ + +/* Now do something useful with the data */ msg = (struct keyspan_usa49_portStatusMessage *)data; -/* Check port number from message and retrieve private data */ +/* Check port number from message and retrieve private data */ if (msg->portNumber >= serial->num_ports) { -dbg ("%s - Unexpected port number %d" , __func__, msg->portNumber); +dbg ("%s - Unexpected port number %d" , + __func__, msg->portNumber); goto exit; } port = serial->port[msg->portNumber]; p_priv =usb_get_serial_port_data (port); - +/* Update handshaking pin state information */ old_dcd_state = p_priv->dcd_state; p_priv->cts_state = ((msg->cts) ?1 :0 );
@@ -782,18 +792,18 @@ static void usa49_instat_callback(struct urb *urb)/* wake_up_interruptible(&p_priv->open_wait); */ } -/* Resubmit urb so we continue receiving */ +/* Resubmit urb so we continue receiving */ urb->dev = serial->dev; -if ((err =usb_submit_urb (urb,GFP_ATOMIC )) !=0 ) { + err =usb_submit_urb (urb,GFP_ATOMIC ); +if (err !=0 )dbg ("%s - resubmit read urb failed. (%d)" , __func__, err); - } exit: ; }static void usa49_inack_callback (struct urb *urb) { -dbg ("%s" , __func__); +dbg ("%s" , __func__); }static void usa49_indat_callback (struct urb *urb)
@@ -805,7 +815,7 @@ static void usa49_indat_callback(struct urb *urb)unsigned char *data = urb->transfer_buffer;int status = urb->status; -dbg ("%s" , __func__); +dbg ("%s" , __func__); endpoint =usb_pipeendpoint (urb->pipe);
@@ -821,9 +831,8 @@ static void usa49_indat_callback(struct urb *urb)/* 0x80 bit is error flag */ if ((data[0 ] &0x80 ) ==0 ) {/* no error on any byte */ -for (i =1 ; i < urb->actual_length ; ++i) { +for (i =1 ; i < urb->actual_length ; ++i)tty_insert_flip_char (tty, data[i],0 ); - } }else {/* some bytes had errors, every byte has status */ for (i =0 ; i +1 < urb->actual_length; i +=2 ) {
@@ -840,13 +849,15 @@ static void usa49_indat_callback(struct urb *urb) }tty_flip_buffer_push (tty); } - -/* Resubmit urb so we continue receiving */ + +/* Resubmit urb so we continue receiving */ urb->dev = port->serial->dev; -if (port->port.count) -if ((err =usb_submit_urb (urb,GFP_ATOMIC )) !=0 ) { -dbg ("%s - resubmit read urb failed. (%d)" , __func__, err); - } +if (port->port.count) { + err =usb_submit_urb (urb,GFP_ATOMIC ); +if (err !=0 ) +dbg ("%s - resubmit read urb failed. (%d)" , + __func__, err); + } }static void usa49wg_indat_callback (struct urb *urb)
@@ -858,7 +869,7 @@ static void usa49wg_indat_callback(struct urb *urb)unsigned char *data = urb->transfer_buffer;int status = urb->status; -dbg ("%s" , __func__); +dbg ("%s" , __func__); serial = urb->context;
@@ -876,7 +887,7 @@ static void usa49wg_indat_callback(struct urb *urb)/* Check port number from message*/ if (data[i] >= serial->num_ports) { -dbg ("%s - Unexpected port number %d" , +dbg ("%s - Unexpected port number %d" , __func__, data[i]);return ; }
@@ -929,7 +940,7 @@ static void usa49wg_indat_callback(struct urb *urb)/* not used, usa-49 doesn't have per-port control endpoints */ static void usa49_outcont_callback (struct urb *urb) { -dbg ("%s" , __func__); +dbg ("%s" , __func__); }static void usa90_indat_callback (struct urb *urb)
@@ -942,7 +953,7 @@ static void usa90_indat_callback(struct urb *urb)unsigned char *data = urb->transfer_buffer;int status = urb->status; -dbg ("%s" , __func__); +dbg ("%s" , __func__); endpoint =usb_pipeendpoint (urb->pipe);
@@ -957,27 +968,25 @@ static void usa90_indat_callback(struct urb *urb) tty = port->port.tty;if (urb->actual_length) { -/* if current mode is DMA, looks like usa28 format -otherwise looks like usa26 data format */ +otherwise looks like usa26 data format */ if (p_priv->baud >57600 ) { -for (i =0 ; i < urb->actual_length ; ++i) +for (i =0 ; i < urb->actual_length ; ++i)tty_insert_flip_char (tty, data[i],0 ); - } -else { - + }else {/* 0x80 bit is error flag */ if ((data[0 ] &0x80 ) ==0 ) { -/* no errors on individual bytes, only possible overrun err*/ +/* no errors on individual bytes, only +possible overrun err*/ if (data[0 ] &RXERROR_OVERRUN ) - err =TTY_OVERRUN ; -else err =0 ; -for (i =1 ; i < urb->actual_length ; ++i) -tty_insert_flip_char (tty, data[i], err); - - } -else { + err =TTY_OVERRUN ; +else + err =0 ; +for (i =1 ; i < urb->actual_length ; ++i) +tty_insert_flip_char (tty, data[i], + err); + }else {/* some bytes had errors, every byte has status */ dbg ("%s - RX error!!!!" , __func__);for (i =0 ; i +1 < urb->actual_length; i +=2 ) {
@@ -989,19 +998,22 @@ static void usa90_indat_callback(struct urb *urb)if (stat &RXERROR_PARITY ) flag |=TTY_PARITY ;/* XXX should handle break (0x10) */ -tty_insert_flip_char (tty, data[i+1 ], flag); +tty_insert_flip_char (tty, data[i+1 ], + flag); } } }tty_flip_buffer_push (tty); } - +/* Resubmit urb so we continue receiving */ urb->dev = port->serial->dev; -if (port->port.count) -if ((err =usb_submit_urb (urb,GFP_ATOMIC )) !=0 ) { -dbg ("%s - resubmit read urb failed. (%d)" , __func__, err); - } +if (port->port.count) { + err =usb_submit_urb (urb,GFP_ATOMIC ); +if (err !=0 ) +dbg ("%s - resubmit read urb failed. (%d)" , + __func__, err); + }return ; }
@@ -1033,7 +1045,7 @@ static void usa90_instat_callback(struct urb *urb) port = serial->port[0 ]; p_priv =usb_get_serial_port_data (port); - +/* Update handshaking pin state information */ old_dcd_state = p_priv->dcd_state; p_priv->cts_state = ((msg->cts) ?1 :0 );
@@ -1048,12 +1060,12 @@ static void usa90_instat_callback(struct urb *urb)/* else */ /* wake_up_interruptible(&p_priv->open_wait); */ } - +/* Resubmit urb so we continue receiving */ urb->dev = serial->dev; -if ((err =usb_submit_urb (urb,GFP_ATOMIC )) !=0 ) { + err =usb_submit_urb (urb,GFP_ATOMIC ); +if (err !=0 )dbg ("%s - resubmit read urb failed. (%d)" , __func__, err); - } exit: ; }
@@ -1067,8 +1079,9 @@ static void usa90_outcont_callback(struct urb *urb) p_priv =usb_get_serial_port_data (port);if (p_priv->resend_cont) { -dbg ("%s - sending setup" , __func__); -keyspan_usa90_send_setup (port->serial, port, p_priv->resend_cont -1 ); +dbg ("%s - sending setup" , __func__); +keyspan_usa90_send_setup (port->serial, port, + p_priv->resend_cont -1 ); } }
@@ -1084,7 +1097,7 @@ static void usa67_instat_callback(struct urb *urb)int old_dcd_state;int status = urb->status; -dbg ("%s" , __func__); +dbg ("%s" , __func__); serial = urb->context;
@@ -1093,7 +1106,8 @@ static void usa67_instat_callback(struct urb *urb)return ; } -if (urb->actual_length !=sizeof (struct keyspan_usa67_portStatusMessage )) { +if (urb->actual_length != +sizeof (struct keyspan_usa67_portStatusMessage )) {dbg ("%s - bad length %d" , __func__, urb->actual_length);return ; }
@@ -1104,7 +1118,7 @@ static void usa67_instat_callback(struct urb *urb)/* Check port number from message and retrieve private data */ if (msg->port >= serial->num_ports) { -dbg ("%s - Unexpected port number %d" , __func__, msg->port); +dbg ("%s - Unexpected port number %d" , __func__, msg->port);return ; }
@@ -1138,7 +1152,7 @@ static void usa67_glocont_callback(struct urb *urb)struct keyspan_port_private *p_priv;int i; -dbg ("%s" , __func__); +dbg ("%s" , __func__); serial = urb->context;for (i =0 ; i < serial->num_ports; ++i) {
@@ -1146,7 +1160,7 @@ static void usa67_glocont_callback(struct urb *urb) p_priv =usb_get_serial_port_data (port);if (p_priv->resend_cont) { -dbg ("%s - sending setup" , __func__); +dbg ("%s - sending setup" , __func__);keyspan_usa67_send_setup (serial, port, p_priv->resend_cont -1 );break ;
@@ -1169,20 +1183,23 @@ static int keyspan_write_room(struct tty_struct *tty)/* FIXME: locking */ if (d_details->msg_format == msg_usa90) - data_len =64 ; + data_len =64 ;else data_len =63 ; flip = p_priv->out_flip;/* Check both endpoints to see if any are available. */ -if ((this_urb = p_priv->out_urbs[flip]) !=NULL ) { + this_urb = p_priv->out_urbs[flip]; +if (this_urb !=NULL ) {if (this_urb->status != -EINPROGRESS ) -return (data_len); - flip = (flip +1 ) & d_details->outdat_endp_flip; -if ((this_urb = p_priv->out_urbs[flip]) !=NULL ) +return data_len; + flip = (flip +1 ) & d_details->outdat_endp_flip; + this_urb = p_priv->out_urbs[flip]; +if (this_urb !=NULL ) {if (this_urb->status != -EINPROGRESS ) -return (data_len); +return data_len; + } }return 0 ; }
@@ -1220,25 +1237,28 @@ static int keyspan_open(struct tty_struct *tty,/* Reset low level data toggle and start reading from endpoints */ for (i =0 ; i <2 ; i++) { -if ((urb = p_priv->in_urbs[i]) ==NULL ) + urb = p_priv->in_urbs[i]; +if (urb ==NULL )continue ; urb->dev = serial->dev; -/* make sure endpoint data toggle is synchronized with the device */ - +/* make sure endpoint data toggle is synchronized +with the device */ usb_clear_halt (urb->dev, urb->pipe); - -if ((err =usb_submit_urb (urb,GFP_KERNEL )) !=0 ) { -dbg ("%s - submit urb %d failed (%d)" , __func__, i, err); - } + err =usb_submit_urb (urb,GFP_KERNEL ); +if (err !=0 ) +dbg ("%s - submit urb %d failed (%d)" , + __func__, i, err); }/* Reset low level data toggle on out endpoints */ for (i =0 ; i <2 ; i++) { -if ((urb = p_priv->out_urbs[i]) ==NULL ) + urb = p_priv->out_urbs[i]; +if (urb ==NULL )continue ; urb->dev = serial->dev; -/* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 0); */ +/* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), +usb_pipeout(urb->pipe), 0); */ }/* get the terminal config for the setup message now so we don't
@@ -1262,8 +1282,8 @@ static int keyspan_open(struct tty_struct *tty, p_priv->flow_control = (cflag &CRTSCTS )? flow_cts: flow_none;keyspan_send_setup (port,1 ); -//mdelay(100); -//keyspan_set_termios(port, NULL); +/* mdelay(100); */ +/* keyspan_set_termios(port, NULL); */ return 0 ; }
@@ -1285,15 +1305,15 @@ static void keyspan_close(struct tty_struct *tty,dbg ("%s" , __func__); s_priv =usb_get_serial_data (serial); p_priv =usb_get_serial_port_data (port); - + p_priv->rts_state =0 ; p_priv->dtr_state =0 ; - +if (serial->dev) {keyspan_send_setup (port,2 );/* pilot-xfer seems to work best with this delay */ mdelay (100 ); -// keyspan_set_termios(port, NULL); +/* keyspan_set_termios(port, NULL); */ }/*while (p_priv->outcont_urb->status == -EINPROGRESS) {
@@ -1316,8 +1336,8 @@ static void keyspan_close(struct tty_struct *tty, } -/* download the firmware to a pre-renumeration device */ -static int keyspan_fake_startup (struct usb_serial *serial) +/* download the firmware to a pre-renumeration device */ +static int keyspan_fake_startup (struct usb_serial *serial) {int response;const struct ezusb_hex_record *record;
@@ -1326,10 +1346,11 @@ static int keyspan_fake_startup (struct usb_serial *serial)dbg ("Keyspan startup version %04x product %04x" ,le16_to_cpu (serial->dev->descriptor.bcdDevice),le16_to_cpu (serial->dev->descriptor.idProduct)); - -if ((le16_to_cpu (serial->dev->descriptor.bcdDevice) &0x8000 ) !=0x8000 ) { + +if ((le16_to_cpu (serial->dev->descriptor.bcdDevice) &0x8000 ) + !=0x8000 ) {dbg ("Firmware already loaded. Quitting." ); -return (1 ); +return 1 ; }/* Select firmware image on the basis of idProduct */
@@ -1358,12 +1379,12 @@ static int keyspan_fake_startup (struct usb_serial *serial) record = &keyspan_usa19_firmware[0 ]; fw_name ="USA19" ;break ; - +case keyspan_usa19qi_pre_product_id: record = &keyspan_usa19qi_firmware[0 ]; fw_name ="USA19QI" ;break ; - +case keyspan_mpr_pre_product_id: record = &keyspan_mpr_firmware[0 ]; fw_name ="MPR" ;
@@ -1373,17 +1394,17 @@ static int keyspan_fake_startup (struct usb_serial *serial) record = &keyspan_usa19qw_firmware[0 ]; fw_name ="USA19QI" ;break ; - +case keyspan_usa18x_pre_product_id: record = &keyspan_usa18x_firmware[0 ]; fw_name ="USA18X" ;break ; - +case keyspan_usa19w_pre_product_id: record = &keyspan_usa19w_firmware[0 ]; fw_name ="USA19W" ;break ; - +case keyspan_usa49w_pre_product_id: record = &keyspan_usa49w_firmware[0 ]; fw_name ="USA49W" ;
@@ -1401,8 +1422,10 @@ static int keyspan_fake_startup (struct usb_serial *serial) }if (record ==NULL ) { -dev_err (&serial->dev->dev,"Required keyspan firmware image (%s) unavailable.\n" , fw_name); -return (1 ); +dev_err (&serial->dev->dev, +"Required keyspan firmware image (%s) unavailable.\n" , + fw_name); +return 1 ; }dbg ("Uploading Keyspan %s firmware." , fw_name);
@@ -1410,15 +1433,16 @@ static int keyspan_fake_startup (struct usb_serial *serial)/* download the firmware image */ response =ezusb_set_reset (serial,1 ); -while (record->address !=0xffff ) { +while (record->address !=0xffff ) { response =ezusb_writememory (serial, record->address, (unsigned char *)record->data, record->data_size,0xa0 );if (response <0 ) { -dev_err (&serial->dev->dev,"ezusb_writememory failed for Keyspan" -"firmware (%d %04X %p %d)\n" , - response, - record->address, record->data, record->data_size); +dev_err (&serial->dev->dev, +"ezusb_writememory failed for Keyspan firmware (%d %04X %p %d)\n" , + response, + record->address, record->data, + record->data_size);break ; } record++;
@@ -1428,7 +1452,7 @@ static int keyspan_fake_startup (struct usb_serial *serial) response =ezusb_set_reset (serial,0 );/* we don't want this device to have a driver assigned to it. */ -return (1 ); +return 1 ; }/* Helper functions used by keyspan_setup_urbs */
@@ -1450,7 +1474,7 @@ static struct usb_endpoint_descriptor const *find_ep(struct usb_serial const *sereturn NULL ; } -static struct urb *keyspan_setup_urb (struct usb_serial *serial,int endpoint, +static struct urb *keyspan_setup_urb (struct usb_serial *serial,int endpoint,int dir,void *ctx,char *buf,int len,void (*callback)(struct urb *)) {
@@ -1461,10 +1485,10 @@ static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint,if (endpoint ==-1 )return NULL ;/* endpoint not needed */ -dbg ("%s - alloc for endpoint %d." , __func__, endpoint); +dbg ("%s - alloc for endpoint %d." , __func__, endpoint); urb =usb_alloc_urb (0 ,GFP_KERNEL );/* No ISO */ if (urb ==NULL ) { -dbg ("%s - alloc for endpoint %d failed." , __func__, endpoint); +dbg ("%s - alloc for endpoint %d failed." , __func__, endpoint);return NULL ; }
@@ -1537,7 +1561,7 @@ static struct callbacks { }, {/* msg_usa90 callbacks */ .instat_callback = usa90_instat_callback, - .glocont_callback = usa28_glocont_callback, + .glocont_callback = usa28_glocont_callback, .indat_callback = usa90_indat_callback, .outdat_callback = usa2x_outdat_callback, .inack_callback = usa28_inack_callback,
@@ -1565,16 +1589,16 @@ static void keyspan_setup_urbs(struct usb_serial *serial)struct callbacks *cback;int endp; -dbg ("%s" , __func__); +dbg ("%s" , __func__); s_priv =usb_get_serial_data (serial); d_details = s_priv->device_details; -/* Setup values for the various callback routines */ +/* Setup values for the various callback routines */ cback = &keyspan_callbacks[d_details->msg_format]; -/* Allocate and set up urbs for each one that is in use, -starting with instat endpoints */ +/* Allocate and set up urbs for each one that is in use, +starting with instat endpoints */ s_priv->instat_urb = keyspan_setup_urb (serial, d_details->instat_endpoint, USB_DIR_IN, serial, s_priv->instat_buf, INSTAT_BUFLEN,
@@ -1590,8 +1614,8 @@ static void keyspan_setup_urbs(struct usb_serial *serial) serial, s_priv->glocont_buf,GLOCONT_BUFLEN , cback->glocont_callback); -/* Setup endpoints for each port specific thing */ -for (i =0 ; i < d_details->num_ports; i ++) { +/* Setup endpoints for each port specific thing */ +for (i =0 ; i < d_details->num_ports; i++) { port = serial->port[i]; p_priv =usb_get_serial_port_data (port);
@@ -1627,8 +1651,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial) (serial, d_details->outcont_endpoints[i],USB_DIR_OUT , port, p_priv->outcont_buffer,64 , cback->outcont_callback); - } - + } }/* usa19 function doesn't require prescaler */
@@ -1636,46 +1659,39 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, u8 *rate_low, u8 *prescaler, int portnum) {u32 b16,/* baud rate times 16 (actual rate used internally) */ - div,/* divisor */ + div,/* divisor */ cnt;/* inverse of divisor (programmed into 8051) */ - -dbg ("%s - %d." , __func__, baud_rate); -/* prevent divide by zero... */ -if ( (b16 = (baud_rate *16L )) ==0 ) { -return (KEYSPAN_INVALID_BAUD_RATE ); - } - -/* Any "standard" rate over 57k6 is marginal on the USA-19 -as we run out of divisor resolution. */ -if (baud_rate >57600 ) { -return (KEYSPAN_INVALID_BAUD_RATE ); - } - -/* calculate the divisor and the counter (its inverse) */ -if ( (div = (baudclk / b16)) ==0 ) { -return (KEYSPAN_INVALID_BAUD_RATE ); - } -else { +dbg ("%s - %d." , __func__, baud_rate); + +/* prevent divide by zero... */ + b16 = baud_rate * 16L +if (b16 ==0 ) +return KEYSPAN_INVALID_BAUD_RATE ; +/* Any "standard" rate over 57k6 is marginal on the USA-19 +as we run out of divisor resolution. */ +if (baud_rate >57600 ) +return KEYSPAN_INVALID_BAUD_RATE ; + +/* calculate the divisor and the counter (its inverse) */ + div = baudclk / b16; +if (div ==0 ) +return KEYSPAN_INVALID_BAUD_RATE ; +else cnt =0 - div; - } -if (div >0xffff ) { -return (KEYSPAN_INVALID_BAUD_RATE ); - } +if (div >0xffff ) +return KEYSPAN_INVALID_BAUD_RATE ; -/* return the counter values if non-null */ -if (rate_low) { +/* return the counter values if non-null */ +if (rate_low) *rate_low = (u8) (cnt &0xff ); - } -if (rate_hi) { +if (rate_hi) *rate_hi = (u8) ((cnt >>8 ) &0xff ); - } -if (rate_low && rate_hi) { -dbg ("%s - %d %02x %02x." , __func__, baud_rate, *rate_hi, *rate_low); - } - -return (KEYSPAN_BAUD_RATE_OK ); +if (rate_low && rate_hi) +dbg ("%s - %d %02x %02x." , + __func__, baud_rate, *rate_hi, *rate_low); +return KEYSPAN_BAUD_RATE_OK ; }/* usa19hs function doesn't require prescaler */
@@ -1683,34 +1699,35 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, u8 *rate_low, u8 *prescaler, int portnum) {u32 b16,/* baud rate times 16 (actual rate used internally) */ - div;/* divisor */ - -dbg ("%s - %d." , __func__, baud_rate); + div;/* divisor */ -/* prevent divide by zero... */ -if ( (b16 = (baud_rate *16L )) ==0 ) -return (KEYSPAN_INVALID_BAUD_RATE ); - +dbg ("%s - %d." , __func__, baud_rate); +/* prevent divide by zero... */ + b16 = baud_rate *16L ; +if (b16 ==0 ) +return KEYSPAN_INVALID_BAUD_RATE ; -/* calculate the divisor */ -if ( (div = (baudclk / b16)) ==0 ) -return (KEYSPAN_INVALID_BAUD_RATE ); +/* calculate the divisor */ + div = baudclk / b16; +if (div ==0 ) +return KEYSPAN_INVALID_BAUD_RATE ; -if (div >0xffff ) -return (KEYSPAN_INVALID_BAUD_RATE ); +if (div >0xffff ) +return KEYSPAN_INVALID_BAUD_RATE ; -/* return the counter values if non-null */ -if (rate_low) +/* return the counter values if non-null */ +if (rate_low) *rate_low = (u8) (div &0xff ); - -if (rate_hi) + +if (rate_hi) *rate_hi = (u8) ((div >>8 ) &0xff ); - -if (rate_low && rate_hi) -dbg ("%s - %d %02x %02x." , __func__, baud_rate, *rate_hi, *rate_low); - -return (KEYSPAN_BAUD_RATE_OK ); + +if (rate_low && rate_hi) +dbg ("%s - %d %02x %02x." , + __func__, baud_rate, *rate_hi, *rate_low); + +return KEYSPAN_BAUD_RATE_OK ; } static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
@@ -1718,64 +1735,61 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, {u32 b16,/* baud rate times 16 (actual rate used internally) */ clk,/* clock with 13/8 prescaler */ - div,/* divisor using 13/8 prescaler */ + div,/* divisor using 13/8 prescaler */ res,/* resulting baud rate using 13/8 prescaler */ diff,/* error using 13/8 prescaler */ smallest_diff;u8 best_prescaler;int i; -dbg ("%s - %d." , __func__, baud_rate); +dbg ("%s - %d." , __func__, baud_rate); -/* prevent divide by zero */ -if ( (b16 = baud_rate *16L ) ==0 ) { -return (KEYSPAN_INVALID_BAUD_RATE ); - } +/* prevent divide by zero */ + b16 = baud_rate *16L ; +if (b16 ==0 ) +return KEYSPAN_INVALID_BAUD_RATE ; -/* Calculate prescaler by trying them all and looking -for best fit */ - -/* start with largest possible difference */ +/* Calculate prescaler by trying them all and looking +for best fit */ + +/* start with largest possible difference */ smallest_diff =0xffffffff ;/* 0 is an invalid prescaler, used as a flag */ best_prescaler =0 ; -for (i =8 ; i <=0xff ; ++i) { +for (i =8 ; i <=0xff ; ++i) { clk = (baudclk *8 ) / (u32 ) i; - -if ( (div = clk / b16) ==0 ) { + + div = clk / b16; +if (div ==0 )continue ; - } res = clk / div; - diff= (res > b16) ? (res-b16) : (b16-res); + diff = (res > b16) ? (res-b16) : (b16-res); -if (diff < smallest_diff) { +if (diff < smallest_diff) { best_prescaler = i; smallest_diff = diff; } } -if (best_prescaler ==0 ) { -return (KEYSPAN_INVALID_BAUD_RATE ); - } +if (best_prescaler ==0 ) +return KEYSPAN_INVALID_BAUD_RATE ; clk = (baudclk *8 ) / (u32 ) best_prescaler; div = clk / b16; -/* return the divisor and prescaler if non-null */ -if (rate_low) { +/* return the divisor and prescaler if non-null */ +if (rate_low) *rate_low = (u8) (div &0xff ); - } -if (rate_hi) { +if (rate_hi) *rate_hi = (u8) ((div >>8 ) &0xff ); - }if (prescaler) { *prescaler = best_prescaler;/* dbg("%s - %d %d", __func__, *prescaler, div); */ } -return (KEYSPAN_BAUD_RATE_OK ); +return KEYSPAN_BAUD_RATE_OK ; }/* USA-28 supports different maximum baud rates on each port */
@@ -1783,57 +1797,51 @@ static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, u8 *rate_low, u8 *prescaler, int portnum) {u32 b16,/* baud rate times 16 (actual rate used internally) */ - div,/* divisor */ + div,/* divisor */ cnt;/* inverse of divisor (programmed into 8051) */ -dbg ("%s - %d." , __func__, baud_rate); +dbg ("%s - %d." , __func__, baud_rate);/* prevent divide by zero */ -if ((b16 = baud_rate *16L ) ==0 ) -return (KEYSPAN_INVALID_BAUD_RATE ); - -/* calculate the divisor and the counter (its inverse) */ -if ((div = (KEYSPAN_USA28_BAUDCLK / b16)) ==0 ) { -return (KEYSPAN_INVALID_BAUD_RATE ); - } -else { + b16 = baud_rate *16L ; +if (b16 ==0 ) +return KEYSPAN_INVALID_BAUD_RATE ; + +/* calculate the divisor and the counter (its inverse) */ + div =KEYSPAN_USA28_BAUDCLK / b16; +if (div ==0 ) +return KEYSPAN_INVALID_BAUD_RATE ; +else cnt =0 - div; - } -/* check for out of range, based on portnum, -and return result */ -if (portnum ==0 ) { -if (div >0xffff ) -return (KEYSPAN_INVALID_BAUD_RATE ); - } -else { -if (portnum ==1 ) { -if (div >0xff ) { -return (KEYSPAN_INVALID_BAUD_RATE ); - } - } -else { -return (KEYSPAN_INVALID_BAUD_RATE ); - } +/* check for out of range, based on portnum, +and return result */ +if (portnum ==0 ) { +if (div >0xffff ) +return KEYSPAN_INVALID_BAUD_RATE ; + }else { +if (portnum ==1 ) { +if (div >0xff ) +return KEYSPAN_INVALID_BAUD_RATE ; + }else +return KEYSPAN_INVALID_BAUD_RATE ; }/* return the counter values if not NULL (port 1 will ignore retHi) */ -if (rate_low) { +if (rate_low) *rate_low = (u8) (cnt &0xff ); - } -if (rate_hi) { +if (rate_hi) *rate_hi = (u8) ((cnt >>8 ) &0xff ); - } -dbg ("%s - %d OK." , __func__, baud_rate); -return (KEYSPAN_BAUD_RATE_OK ); +dbg ("%s - %d OK." , __func__, baud_rate); +return KEYSPAN_BAUD_RATE_OK ; }static int keyspan_usa26_send_setup (struct usb_serial *serial,struct usb_serial_port *port,int reset_port) { -struct keyspan_usa26_portControlMessage msg; +struct keyspan_usa26_portControlMessage msg;struct keyspan_serial_private *s_priv;struct keyspan_port_private *p_priv;const struct keyspan_device_details *d_details;
@@ -1841,7 +1849,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,struct urb *this_urb;int device_port, err; -dbg ("%s reset=%d" , __func__, reset_port); +dbg ("%s reset=%d" , __func__, reset_port); s_priv =usb_get_serial_data (serial); p_priv =usb_get_serial_port_data (port);
@@ -1864,22 +1872,22 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,if ((reset_port +1 ) > p_priv->resend_cont) p_priv->resend_cont = reset_port +1 ;if (this_urb->status == -EINPROGRESS ) { -/* dbg ("%s - already writing", __func__); */ +/* dbg("%s - already writing", __func__); */ mdelay (5 ); -return (-1 ); +return -1 ; } -memset (&msg,0 ,sizeof (struct keyspan_usa26_portControlMessage )); - -/* Only set baud rate if it's changed */ +memset (&msg,0 ,sizeof (struct keyspan_usa26_portControlMessage )); + +/* Only set baud rate if it's changed */ if (p_priv->old_baud != p_priv->baud) { p_priv->old_baud = p_priv->baud; msg.setClocking =0xff ;if (d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, &msg.baudHi, - &msg.baudLo, &msg.prescaler, device_port) ==KEYSPAN_INVALID_BAUD_RATE ) { -dbg ("%s - Invalid baud rate %d requested, using 9600." , __func__, - p_priv->baud); + &msg.baudLo, &msg.prescaler, device_port) ==KEYSPAN_INVALID_BAUD_RATE ) { +dbg ("%s - Invalid baud rate %d requested, using 9600." , + __func__, p_priv->baud); msg.baudLo =0 ; msg.baudHi =125 ;/* Values for 9600 baud */ msg.prescaler =10 ;
@@ -1905,7 +1913,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,if (p_priv->cflag &PARENB ) {/* note USA_PARITY_NONE == 0 */ msg.lcr |= (p_priv->cflag &PARODD )? -USA_PARITY_ODD :USA_PARITY_EVEN ; +USA_PARITY_ODD :USA_PARITY_EVEN ; } msg.setLcr =0xff ;
@@ -1946,7 +1954,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,/* Sending intermediate configs */ else { - msg._txOn = (! p_priv->break_on); + msg._txOn = (!p_priv->break_on); msg._txOff =0 ; msg.txFlush =0 ; msg.txBreak = (p_priv->break_on);
@@ -1958,23 +1966,23 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, msg.resetDataToggle =0x0 ; } -/* Do handshaking outputs */ +/* Do handshaking outputs */ msg.setTxTriState_setRts =0xff ; msg.txTriState_rts = p_priv->rts_state; msg.setHskoa_setDtr =0xff ; msg.hskoa_dtr = p_priv->dtr_state; - + p_priv->resend_cont =0 ; -memcpy (this_urb->transfer_buffer, &msg,sizeof (msg)); - +memcpy (this_urb->transfer_buffer, &msg,sizeof (msg)); +/* send the data out the device on control endpoint */ this_urb->transfer_buffer_length =sizeof (msg); this_urb->dev = serial->dev; -if ((err =usb_submit_urb (this_urb,GFP_ATOMIC )) !=0 ) { + err =usb_submit_urb (this_urb,GFP_ATOMIC ); +if (err !=0 )dbg ("%s - usb_submit_urb(setup) failed (%d)" , __func__, err); - }#if 0 else { dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__
@@ -1990,14 +1998,14 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, struct usb_serial_port *port, int reset_port) { -struct keyspan_usa28_portControlMessage msg; +struct keyspan_usa28_portControlMessage msg;struct keyspan_serial_private *s_priv;struct keyspan_port_private *p_priv;const struct keyspan_device_details *d_details;struct urb *this_urb;int device_port, err; -dbg ("%s" , __func__); +dbg ("%s" , __func__); s_priv =usb_get_serial_data (serial); p_priv =usb_get_serial_port_data (port);
@@ -2005,7 +2013,8 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, device_port = port->number - port->serial->minor;/* only do something if we have a bulk out endpoint */ -if ((this_urb = p_priv->outcont_urb) ==NULL ) { + this_urb = p_priv->outcont_urb; +if (this_urb ==NULL ) {dbg ("%s - oops no urb." , __func__);return -1 ; }
@@ -2015,17 +2024,18 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,if ((reset_port +1 ) > p_priv->resend_cont) p_priv->resend_cont = reset_port +1 ;if (this_urb->status == -EINPROGRESS ) { -dbg ("%s already writing" , __func__); +dbg ("%s already writing" , __func__);mdelay (5 ); -return (-1 ); +return -1 ; } -memset (&msg,0 ,sizeof (struct keyspan_usa28_portControlMessage )); +memset (&msg,0 ,sizeof (struct keyspan_usa28_portControlMessage )); msg.setBaudRate =1 ;if (d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, - &msg.baudHi, &msg.baudLo,NULL , device_port) ==KEYSPAN_INVALID_BAUD_RATE ) { -dbg ("%s - Invalid baud rate requested %d." , __func__, p_priv->baud); + &msg.baudHi, &msg.baudLo,NULL , device_port) ==KEYSPAN_INVALID_BAUD_RATE ) { +dbg ("%s - Invalid baud rate requested %d." , + __func__, p_priv->baud); msg.baudLo =0xff ; msg.baudHi =0xb2 ;/* Values for 9600 baud */ }
@@ -2036,7 +2046,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, msg.ctsFlowControl = (p_priv->flow_control == flow_cts); msg.xonFlowControl =0 ; -/* Do handshaking outputs, DTR is inverted relative to RTS */ +/* Do handshaking outputs, DTR is inverted relative to RTS */ msg.rts = p_priv->rts_state; msg.dtr = p_priv->dtr_state;
@@ -2078,7 +2088,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, }/* Sending intermediate configs */ else { - msg._txOn = (! p_priv->break_on); + msg._txOn = (!p_priv->break_on); msg._txOff =0 ; msg.txFlush =0 ; msg.txForceXoff =0 ;
@@ -2092,15 +2102,15 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, } p_priv->resend_cont =0 ; -memcpy (this_urb->transfer_buffer, &msg,sizeof (msg)); +memcpy (this_urb->transfer_buffer, &msg,sizeof (msg));/* send the data out the device on control endpoint */ this_urb->transfer_buffer_length =sizeof (msg); this_urb->dev = serial->dev; -if ((err =usb_submit_urb (this_urb,GFP_ATOMIC )) !=0 ) { + err =usb_submit_urb (this_urb,GFP_ATOMIC ); +if (err !=0 )dbg ("%s - usb_submit_urb(setup) failed" , __func__); - }#if 0 else { dbg("%s - usb_submit_urb(setup) OK %d bytes", __func__,
@@ -2123,7 +2133,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,struct urb *this_urb;int err, device_port; -dbg ("%s" , __func__); +dbg ("%s" , __func__); s_priv =usb_get_serial_data (serial); p_priv =usb_get_serial_port_data (port);
@@ -2134,7 +2144,9 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,/* Work out which port within the device is being setup */ device_port = port->number - port->serial->minor; -dbg ("%s - endpoint %d port %d (%d)" ,__func__,usb_pipeendpoint (this_urb->pipe), port->number, device_port); +dbg ("%s - endpoint %d port %d (%d)" , + __func__,usb_pipeendpoint (this_urb->pipe), + port->number, device_port);/* Make sure we have an urb then send the message */ if (this_urb ==NULL ) {
@@ -2148,30 +2160,30 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, p_priv->resend_cont = reset_port +1 ;if (this_urb->status == -EINPROGRESS ) { -/* dbg ("%s - already writing", __func__); */ +/* dbg("%s - already writing", __func__); */ mdelay (5 ); -return (-1 ); +return -1 ; } -memset (&msg,0 ,sizeof (struct keyspan_usa49_portControlMessage )); +memset (&msg,0 ,sizeof (struct keyspan_usa49_portControlMessage ));/*msg.portNumber = port->number;*/ msg.portNumber = device_port; - -/* Only set baud rate if it's changed */ + +/* Only set baud rate if it's changed */ if (p_priv->old_baud != p_priv->baud) { p_priv->old_baud = p_priv->baud; msg.setClocking =0xff ;if (d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, &msg.baudHi, - &msg.baudLo, &msg.prescaler, device_port) ==KEYSPAN_INVALID_BAUD_RATE ) { -dbg ("%s - Invalid baud rate %d requested, using 9600." , __func__, - p_priv->baud); + &msg.baudLo, &msg.prescaler, device_port) ==KEYSPAN_INVALID_BAUD_RATE ) { +dbg ("%s - Invalid baud rate %d requested, using 9600." , + __func__, p_priv->baud); msg.baudLo =0 ; msg.baudHi =125 ;/* Values for 9600 baud */ msg.prescaler =10 ; } -//msg.setPrescaler = 0xff; +/* msg.setPrescaler = 0xff; */ } msg.lcr = (p_priv->cflag &CSTOPB )?STOPBITS_678_2 :STOPBITS_5678_1 ;
@@ -2192,19 +2204,19 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,if (p_priv->cflag &PARENB ) {/* note USA_PARITY_NONE == 0 */ msg.lcr |= (p_priv->cflag &PARODD )? -USA_PARITY_ODD :USA_PARITY_EVEN ; +USA_PARITY_ODD :USA_PARITY_EVEN ; } msg.setLcr =0xff ; msg.ctsFlowControl = (p_priv->flow_control == flow_cts); msg.xonFlowControl =0 ; msg.setFlowControl =0xff ; - + msg.forwardingLength =16 ; msg.xonChar =17 ; msg.xoffChar =19 ; -/* Opening port */ +/* Opening port */ if (reset_port ==1 ) { msg._txOn =1 ; msg._txOff =0 ;
@@ -2236,7 +2248,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, }/* Sending intermediate configs */ else { - msg._txOn = (! p_priv->break_on); + msg._txOn = (!p_priv->break_on); msg._txOff =0 ; msg.txFlush =0 ; msg.txBreak = (p_priv->break_on);
@@ -2250,16 +2262,17 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, msg.disablePort =0 ; } -/* Do handshaking outputs */ +/* Do handshaking outputs */ msg.setRts =0xff ; msg.rts = p_priv->rts_state; msg.setDtr =0xff ; msg.dtr = p_priv->dtr_state; - + p_priv->resend_cont =0 ; -/* if the device is a 49wg, we send control message on usb control EP 0 */ +/* if the device is a 49wg, we send control message on usb +control EP 0 */ if (d_details->product_id == keyspan_usa49wg_product_id) { dr = (void *)(s_priv->ctrl_buf);
@@ -2269,23 +2282,24 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, dr->wIndex =0 ; dr->wLength =cpu_to_le16 (sizeof (msg)); -memcpy (s_priv->glocont_buf, &msg,sizeof (msg)); +memcpy (s_priv->glocont_buf, &msg,sizeof (msg)); -usb_fill_control_urb (this_urb, serial->dev,usb_sndctrlpipe (serial->dev,0 ), - (unsigned char *)dr, s_priv->glocont_buf,sizeof (msg), - usa49_glocont_callback, serial); +usb_fill_control_urb (this_urb, serial->dev, +usb_sndctrlpipe (serial->dev,0 ), + (unsigned char *)dr, s_priv->glocont_buf, +sizeof (msg), usa49_glocont_callback, serial); } else {memcpy (this_urb->transfer_buffer, &msg,sizeof (msg)); - +/* send the data out the device on control endpoint */ this_urb->transfer_buffer_length =sizeof (msg); this_urb->dev = serial->dev; } -if ((err =usb_submit_urb (this_urb,GFP_ATOMIC )) !=0 ) { + err =usb_submit_urb (this_urb,GFP_ATOMIC ); +if (err !=0 )dbg ("%s - usb_submit_urb(setup) failed (%d)" , __func__, err); - }#if 0 else { dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__,
@@ -2301,7 +2315,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, struct usb_serial_port *port, int reset_port) { -struct keyspan_usa90_portControlMessage msg; +struct keyspan_usa90_portControlMessage msg;struct keyspan_serial_private *s_priv;struct keyspan_port_private *p_priv;const struct keyspan_device_details *d_details;
@@ -2309,14 +2323,15 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,int err;u8 prescaler; -dbg ("%s" , __func__); +dbg ("%s" , __func__); s_priv =usb_get_serial_data (serial); p_priv =usb_get_serial_port_data (port); d_details = s_priv->device_details;/* only do something if we have a bulk out endpoint */ -if ((this_urb = p_priv->outcont_urb) ==NULL ) { + this_urb = p_priv->outcont_urb; +if (this_urb ==NULL ) {dbg ("%s - oops no urb." , __func__);return -1 ; }
@@ -2326,24 +2341,24 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,if ((reset_port +1 ) > p_priv->resend_cont) p_priv->resend_cont = reset_port +1 ;if (this_urb->status == -EINPROGRESS ) { -dbg ("%s already writing" , __func__); +dbg ("%s already writing" , __func__);mdelay (5 ); -return (-1 ); +return -1 ; } -memset (&msg,0 ,sizeof (struct keyspan_usa90_portControlMessage )); +memset (&msg,0 ,sizeof (struct keyspan_usa90_portControlMessage )); -/* Only set baud rate if it's changed */ +/* Only set baud rate if it's changed */ if (p_priv->old_baud != p_priv->baud) { p_priv->old_baud = p_priv->baud; msg.setClocking =0x01 ;if (d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, &msg.baudHi, - &msg.baudLo, &prescaler,0 ) ==KEYSPAN_INVALID_BAUD_RATE ) { -dbg ("%s - Invalid baud rate %d requested, using 9600." , __func__, - p_priv->baud); + &msg.baudLo, &prescaler,0 ) ==KEYSPAN_INVALID_BAUD_RATE ) { +dbg ("%s - Invalid baud rate %d requested, using 9600." , + __func__, p_priv->baud); p_priv->baud =9600 ; - d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, + d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, &msg.baudHi, &msg.baudLo, &prescaler,0 ); } msg.setRxMode =1 ;
@@ -2351,13 +2366,10 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, }/* modes must always be correctly specified */ -if (p_priv->baud >57600 ) - { +if (p_priv->baud >57600 ) { msg.rxMode =RXMODE_DMA ; msg.txMode =TXMODE_DMA ; - } -else - { + }else { msg.rxMode =RXMODE_BYHAND ; msg.txMode =TXMODE_BYHAND ; }
@@ -2380,7 +2392,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,if (p_priv->cflag &PARENB ) {/* note USA_PARITY_NONE == 0 */ msg.lcr |= (p_priv->cflag &PARODD )? -USA_PARITY_ODD :USA_PARITY_EVEN ; +USA_PARITY_ODD :USA_PARITY_EVEN ; }if (p_priv->old_cflag != p_priv->cflag) { p_priv->old_cflag = p_priv->cflag;
@@ -2391,23 +2403,22 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, msg.txFlowControl =TXFLOW_CTS ; msg.setTxFlowControl =0x01 ; msg.setRxFlowControl =0x01 ; - + msg.rxForwardingLength =16 ; - msg.rxForwardingTimeout =16 ; + msg.rxForwardingTimeout =16 ; msg.txAckSetting =0 ; msg.xonChar =17 ; msg.xoffChar =19 ; -/* Opening port */ +/* Opening port */ if (reset_port ==1 ) { msg.portEnabled =1 ; msg.rxFlush =1 ; msg.txBreak = (p_priv->break_on); }/* Closing port */ -else if (reset_port ==2 ) { +else if (reset_port ==2 ) msg.portEnabled =0 ; - }/* Sending intermediate configs */ else {if (port->port.count)
@@ -2415,23 +2426,23 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, msg.txBreak = (p_priv->break_on); } -/* Do handshaking outputs */ +/* Do handshaking outputs */ msg.setRts =0x01 ; msg.rts = p_priv->rts_state; msg.setDtr =0x01 ; msg.dtr = p_priv->dtr_state; - + p_priv->resend_cont =0 ; -memcpy (this_urb->transfer_buffer, &msg,sizeof (msg)); - +memcpy (this_urb->transfer_buffer, &msg,sizeof (msg)); +/* send the data out the device on control endpoint */ this_urb->transfer_buffer_length =sizeof (msg); this_urb->dev = serial->dev; -if ((err =usb_submit_urb (this_urb,GFP_ATOMIC )) !=0 ) { + err =usb_submit_urb (this_urb,GFP_ATOMIC ); +if (err !=0 )dbg ("%s - usb_submit_urb(setup) failed (%d)" , __func__, err); - }return 0 ; }
@@ -2446,7 +2457,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,struct urb *this_urb;int err, device_port; -dbg ("%s" , __func__); +dbg ("%s" , __func__); s_priv =usb_get_serial_data (serial); p_priv =usb_get_serial_port_data (port);
@@ -2469,9 +2480,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,if ((reset_port +1 ) > p_priv->resend_cont) p_priv->resend_cont = reset_port +1 ;if (this_urb->status == -EINPROGRESS ) { -/* dbg ("%s - already writing", __func__); */ +/* dbg("%s - already writing", __func__); */ mdelay (5 ); -return (-1 ); +return -1 ; }memset (&msg,0 ,sizeof (struct keyspan_usa67_portControlMessage ));
@@ -2484,9 +2495,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, msg.setClocking =0xff ;if (d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, &msg.baudHi, - &msg.baudLo, &msg.prescaler, device_port) ==KEYSPAN_INVALID_BAUD_RATE ) { -dbg ("%s - Invalid baud rate %d requested, using 9600." , __func__, - p_priv->baud); + &msg.baudLo, &msg.prescaler, device_port) ==KEYSPAN_INVALID_BAUD_RATE ) { +dbg ("%s - Invalid baud rate %d requested, using 9600." , + __func__, p_priv->baud); msg.baudLo =0 ; msg.baudHi =125 ;/* Values for 9600 baud */ msg.prescaler =10 ;
@@ -2512,7 +2523,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,if (p_priv->cflag &PARENB ) {/* note USA_PARITY_NONE == 0 */ msg.lcr |= (p_priv->cflag &PARODD )? -USA_PARITY_ODD :USA_PARITY_EVEN ; +USA_PARITY_ODD :USA_PARITY_EVEN ; } msg.setLcr =0xff ;
@@ -2549,7 +2560,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, msg.resetDataToggle =0 ; }else {/* Sending intermediate configs */ - msg._txOn = (! p_priv->break_on); + msg._txOn = (!p_priv->break_on); msg._txOff =0 ; msg.txFlush =0 ; msg.txBreak = (p_priv->break_on);
@@ -2589,7 +2600,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)struct keyspan_serial_private *s_priv;const struct keyspan_device_details *d_details; -dbg ("%s" , __func__); +dbg ("%s" , __func__); s_priv =usb_get_serial_data (serial); d_details = s_priv->device_details;
@@ -2616,7 +2627,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)/* Gets called by the "real" driver (ie once firmware is loaded and renumeration has taken place. */ -static int keyspan_startup (struct usb_serial *serial) +static int keyspan_startup (struct usb_serial *serial) {int i, err;struct usb_serial_port *port;
@@ -2627,17 +2638,20 @@ static int keyspan_startup (struct usb_serial *serial)dbg ("%s" , __func__);for (i =0 ; (d_details = keyspan_devices[i]) !=NULL ; ++i) -if (d_details->product_id ==le16_to_cpu (serial->dev->descriptor.idProduct)) +if (d_details->product_id == +le16_to_cpu (serial->dev->descriptor.idProduct))break ;if (d_details ==NULL ) { -dev_err (&serial->dev->dev,"%s - unknown product id %x\n" , __func__,le16_to_cpu (serial->dev->descriptor.idProduct)); +dev_err (&serial->dev->dev,"%s - unknown product id %x\n" , + __func__,le16_to_cpu (serial->dev->descriptor.idProduct));return 1 ; }/* Setup private data for serial driver */ s_priv =kzalloc (sizeof (struct keyspan_serial_private ),GFP_KERNEL );if (!s_priv) { -dbg ("%s - kmalloc for keyspan_serial_private failed." , __func__); +dbg ("%s - kmalloc for keyspan_serial_private failed." , + __func__);return -ENOMEM ; }
@@ -2647,10 +2661,11 @@ static int keyspan_startup (struct usb_serial *serial)/* Now setup per port private data */ for (i =0 ; i < serial->num_ports; i++) { port = serial->port[i]; - p_priv =kzalloc (sizeof (struct keyspan_port_private ),GFP_KERNEL ); + p_priv =kzalloc (sizeof (struct keyspan_port_private ), +GFP_KERNEL );if (!p_priv) {dbg ("%s - kmalloc for keyspan_port_private (%d) failed!." , __func__, i); -return (1 ); +return 1 ; } p_priv->device_details = d_details;usb_set_serial_port_data (port, p_priv);
@@ -2672,11 +2687,11 @@ static int keyspan_startup (struct usb_serial *serial)dbg ("%s - submit indat urb failed %d" , __func__, err); } - +return 0 ; } -static void keyspan_shutdown (struct usb_serial *serial) +static void keyspan_shutdown (struct usb_serial *serial) {int i, j;struct usb_serial_port *port;
@@ -2728,8 +2743,8 @@ static void keyspan_shutdown (struct usb_serial *serial) } } -MODULE_AUTHOR (DRIVER_AUTHOR ); -MODULE_DESCRIPTION (DRIVER_DESC ); +MODULE_AUTHOR (DRIVER_AUTHOR ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );module_param (debug, bool,S_IRUGO |S_IWUSR );
PATCH 51/70 keyspan: Use string flip functions when possible
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/keyspan.c | 18 ++++++++---------- 1 files changed, 8 insertions(+), 10 deletions(-)
drivers/usb/serial/keyspan.c +8 -10
@@ -575,7 +575,7 @@ static void usa26_glocont_callback(struct urb *urb)static void usa28_indat_callback (struct urb *urb) { -int i, err; +int err;struct usb_serial_port *port;struct tty_struct *tty;unsigned char *data;
@@ -604,8 +604,7 @@ static void usa28_indat_callback(struct urb *urb) tty = port->port.tty;if (urb->actual_length) { -for (i =0 ; i < urb->actual_length ; ++i) -tty_insert_flip_char (tty, data[i],0 ); +tty_insert_flip_string (tty, data, urb->actual_length);tty_flip_buffer_push (tty); }
@@ -831,8 +830,8 @@ static void usa49_indat_callback(struct urb *urb)/* 0x80 bit is error flag */ if ((data[0 ] &0x80 ) ==0 ) {/* no error on any byte */ -for (i =1 ; i < urb->actual_length ; ++i) -tty_insert_flip_char (tty, data[i],0 ); +tty_insert_flip_string (tty, data +1 , + urb->actual_length -1 ); }else {/* some bytes had errors, every byte has status */ for (i =0 ; i +1 < urb->actual_length; i +=2 ) {
@@ -971,10 +970,9 @@ static void usa90_indat_callback(struct urb *urb)/* if current mode is DMA, looks like usa28 format otherwise looks like usa26 data format */ -if (p_priv->baud >57600 ) { -for (i =0 ; i < urb->actual_length ; ++i) -tty_insert_flip_char (tty, data[i],0 ); - }else { +if (p_priv->baud >57600 ) +tty_insert_flip_string (tty, data, urb->actual_length); +else {/* 0x80 bit is error flag */ if ((data[0 ] &0x80 ) ==0 ) {/* no errors on individual bytes, only
@@ -1665,7 +1663,7 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,dbg ("%s - %d." , __func__, baud_rate);/* prevent divide by zero... */ - b16 = baud_rate * 16L + b16 = baud_rate *16L ;if (b16 ==0 )return KEYSPAN_INVALID_BAUD_RATE ;/* Any "standard" rate over 57k6 is marginal on the USA-19
PATCH 52/70 tty-usb-keyspan-pda: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/keyspan_pda.c | 168 +++++++++++++++++++++----------------- 1 files changed, 95 insertions(+), 73 deletions(-)
drivers/usb/serial/keyspan_pda.c +95 -73
@@ -10,8 +10,9 @@* the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * -* See Documentation/usb/usb-serial.txt for more information on using this driver -* +* See Documentation/usb/usb-serial.txt for more information on using this +* driver +* * (09/07/2001) gkh * cleaned up the Xircom support. Added ids for Entregra device which is * the same as the Xircom device. Enabled the code to be compiled for
@@ -21,23 +22,24 @@* support for Xircom PGSDB9 * * (05/31/2001) gkh -* switched from using spinlock to a semaphore, which fixes lots of problems. +* switched from using spinlock to a semaphore, which fixes lots of +* problems. * * (04/08/2001) gb * Identify version on module load. -* +* * (11/01/2000) Adam J. Richter * usb_device_id table support -* +* * (10/05/2000) gkh * Fixed bug with urb->dev not being set properly, now that the usb * core needs it. -* +* * (08/28/2000) gkh * Added locks for SMP safeness. -* Fixed MOD_INC and MOD_DEC logic and the ability to open a port more +* Fixed MOD_INC and MOD_DEC logic and the ability to open a port more * than once. -* +* * (07/20/2000) borchers * - keyspan_pda_write no longer sleeps if it is called on interrupt time; * PPP and the line discipline with stty echo on can call write on
@@ -55,14 +57,14 @@* than done directly from the callback to avoid the race in write_chan * - keyspan_pda_chars_in_buffer also indicates its buffer is full if the * urb status is -EINPROGRESS, meaning it cannot write at the moment -* +* * (07/19/2000) gkh * Added module_init and module_exit functions to handle the fact that this * driver is a loadable module now. * * (03/26/2000) gkh * Split driver up into device specific pieces. -* +* */
@@ -76,7 +78,7 @@#include <linux/module.h> #include <linux/spinlock.h> #include <linux/workqueue.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/usb/serial.h>
@@ -88,7 +90,8 @@ struct ezusb_hex_record {__u8 data[16 ]; }; -/* 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 )#define KEYSPAN #else
@@ -147,7 +150,7 @@ static struct usb_device_id id_table_combined [] = { { }/* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE (usb, id_table_combined);static struct usb_driver keyspan_pda_driver = { .name ="keyspan_pda" ,
@@ -171,9 +174,9 @@ static struct usb_device_id id_table_fake [] = {#ifdef XIRCOM static struct usb_device_id id_table_fake_xircom [] = { - {USB_DEVICE (XIRCOM_VENDOR_ID ,XIRCOM_FAKE_ID ) }, - {USB_DEVICE (ENTREGRA_VENDOR_ID ,ENTREGRA_FAKE_ID ) }, - { } + {USB_DEVICE (XIRCOM_VENDOR_ID ,XIRCOM_FAKE_ID ) }, + {USB_DEVICE (ENTREGRA_VENDOR_ID ,ENTREGRA_FAKE_ID ) }, + { } };#endif
@@ -196,7 +199,7 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work)dbg (" request_unthrottle" );/* ask the device to tell us when the tx buffer becomes sufficiently empty */ - result =usb_control_msg (serial->dev, + result =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ),7 ,/* request_unthrottle */ USB_TYPE_VENDOR | USB_RECIP_INTERFACE
@@ -207,15 +210,15 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work)0 , 2000);if (result <0 ) -dbg ("%s - error %d from usb_control_msg" , +dbg ("%s - error %d from usb_control_msg" , __func__, result); } -static void keyspan_pda_rx_interrupt (struct urb *urb) +static void keyspan_pda_rx_interrupt (struct urb *urb) {struct usb_serial_port *port = urb->context; -struct tty_struct *tty = port->port.tty; +struct tty_struct *tty = port->port.tty;unsigned char *data = urb->transfer_buffer;int i;int retval;
@@ -240,14 +243,13 @@ static void keyspan_pda_rx_interrupt (struct urb *urb) goto exit; } -/* see if the message is data or a status interrupt */ +/* see if the message is data or a status interrupt */ switch (data[0 ]) {case 0 :/* rest of message is rx data */ if (urb->actual_length) { -for (i =1 ; i < urb->actual_length ; ++i) { +for (i =1 ; i < urb->actual_length ; ++i)tty_insert_flip_char (tty, data[i],0 ); - }tty_flip_buffer_push (tty); }break ;
@@ -271,9 +273,9 @@ static void keyspan_pda_rx_interrupt (struct urb *urb) } exit: - retval =usb_submit_urb (urb,GFP_ATOMIC ); + retval =usb_submit_urb (urb,GFP_ATOMIC );if (retval) -err ("%s - usb_submit_urb failed with result %d" , +err ("%s - usb_submit_urb failed with result %d" , __func__, retval); }
@@ -304,32 +306,52 @@ static void keyspan_pda_rx_unthrottle(struct tty_struct *tty) } -static speed_t keyspan_pda_setbaud (struct usb_serial *serial,speed_t baud) +static speed_t keyspan_pda_setbaud (struct usb_serial *serial,speed_t baud) {int rc;int bindex; -switch (baud) { -case 110 : bindex =0 ;break ; -case 300 : bindex =1 ;break ; -case 1200 : bindex =2 ;break ; -case 2400 : bindex =3 ;break ; -case 4800 : bindex =4 ;break ; -case 9600 : bindex =5 ;break ; -case 19200 : bindex =6 ;break ; -case 38400 : bindex =7 ;break ; -case 57600 : bindex =8 ;break ; -case 115200 : bindex =9 ;break ; -default : - bindex =5 ;/* Default to 9600 */ - baud =9600 ; +switch (baud) { +case 110 : + bindex =0 ; +break ; +case 300 : + bindex =1 ; +break ; +case 1200 : + bindex =2 ; +break ; +case 2400 : + bindex =3 ; +break ; +case 4800 : + bindex =4 ; +break ; +case 9600 : + bindex =5 ; +break ; +case 19200 : + bindex =6 ; +break ; +case 38400 : + bindex =7 ; +break ; +case 57600 : + bindex =8 ; +break ; +case 115200 : + bindex =9 ; +break ; +default : + bindex =5 ;/* Default to 9600 */ + baud =9600 ; }/* rather than figure out how to sleep while waiting for this to complete, I just use the "legacy" API. */ rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 0, /* set baud */ - USB_TYPE_VENDOR + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, /* type */ bindex, /* value */
@@ -355,11 +377,11 @@ static void keyspan_pda_break_ctl(struct tty_struct *tty, int break_state)else value =0 ;/* clear break */ result =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), -4 ,/* set break */ -USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , - value,0 ,NULL ,0 ,2000 ); +4 ,/* set break */ +USB_TYPE_VENDOR |USB_RECIP_INTERFACE |USB_DIR_OUT , + value,0 ,NULL ,0 ,2000 );if (result <0 ) -dbg ("%s - error %d from usb_control_msg" , +dbg ("%s - error %d from usb_control_msg" , __func__, result);/* there is something funky about this.. the TCSBRK that 'cu' performs ought to translate into a break_ctl(-1),break_ctl(0) pair HZ/4
@@ -502,10 +524,10 @@ static int keyspan_pda_write(struct tty_struct *tty,select() or poll() too) until we receive that unthrottle interrupt. Block if we can't write anything at all, otherwise write as much as we can. */ -dbg ("keyspan_pda_write(%d)" ,count); +dbg ("keyspan_pda_write(%d)" , count);if (count ==0 ) {dbg (" write request of 0 bytes" ); -return (0 ); +return 0 ; }/* we might block because of:
@@ -532,7 +554,7 @@ static int keyspan_pda_write(struct tty_struct *tty,scheduler time, since usb_control_msg() sleeps. */ if (count > priv->tx_room && !in_interrupt ()) {unsigned char room; - rc =usb_control_msg (serial->dev, + rc =usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev,0 ),6 ,/* write_room */ USB_TYPE_VENDOR | USB_RECIP_INTERFACE
@@ -563,7 +585,7 @@ static int keyspan_pda_write(struct tty_struct *tty,if (count) {/* now transfer data */ -memcpy (port->write_urb->transfer_buffer, buf, count); +memcpy (port->write_urb->transfer_buffer, buf, count);/* send the data out the bulk port */ port->write_urb->transfer_buffer_length = count;
@@ -575,8 +597,7 @@ static int keyspan_pda_write(struct tty_struct *tty,dbg (" usb_submit_urb(write bulk) failed" ); goto exit; } - } -else { + }else {/* There wasn't any room left, so we are throttled until the buffer empties a bit */ request_unthrottle =1 ;
@@ -595,7 +616,7 @@ exit: } -static void keyspan_pda_write_bulk_callback (struct urb *urb) +static void keyspan_pda_write_bulk_callback (struct urb *urb) {struct usb_serial_port *port = urb->context;struct keyspan_pda_private *priv;
@@ -616,7 +637,7 @@ static int keyspan_pda_write_room(struct tty_struct *tty)/* used by n_tty.c for processing of tabs and such. Giving it our conservative guess is probably good enough, but needs testing by running a console through the device. */ -return (priv->tx_room); +return priv->tx_room; }
@@ -674,7 +695,7 @@ static int keyspan_pda_open(struct tty_struct *tty,/* the normal serial device seems to always turn on DTR and RTS here, so do the same */ if (tty && (tty->termios->c_cflag &CBAUD )) -keyspan_pda_set_modem_info (serial, (1 <<7 ) | (1 <<2 ) ); +keyspan_pda_set_modem_info (serial, (1 <<7 ) | (1 <<2 ));else keyspan_pda_set_modem_info (serial,0 );
@@ -697,7 +718,8 @@ static void keyspan_pda_close(struct tty_struct *tty,struct usb_serial *serial = port->serial;if (serial->dev) { -/* the normal serial device seems to always shut off DTR and RTS now */ +/* the normal serial device seems to always shut +off DTR and RTS now */ if (tty->termios->c_cflag &HUPCL )keyspan_pda_set_modem_info (serial,0 );
@@ -709,7 +731,7 @@ static void keyspan_pda_close(struct tty_struct *tty,/* download the firmware to a "fake" device (pre-renumeration) */ -static int keyspan_pda_fake_startup (struct usb_serial *serial) +static int keyspan_pda_fake_startup (struct usb_serial *serial) {int response;const struct ezusb_hex_record *record =NULL ;
@@ -731,14 +753,14 @@ static int keyspan_pda_fake_startup (struct usb_serial *serial)return -ENODEV ; } -while (record->address !=0xffff ) { +while (record->address !=0xffff ) { response =ezusb_writememory (serial, record->address, (unsigned char *)record->data, record->data_size,0xa0 );if (response <0 ) {err ("ezusb_writememory failed for Keyspan PDA " "firmware (%d %04X %p %d)" , - response, + response, record->address, record->data, record->data_size);break ; }
@@ -749,10 +771,10 @@ static int keyspan_pda_fake_startup (struct usb_serial *serial) response =ezusb_set_reset (serial,0 );/* we want this device to fail to have a driver assigned to it. */ -return (1 ); +return 1 ; } -static int keyspan_pda_startup (struct usb_serial *serial) +static int keyspan_pda_startup (struct usb_serial *serial) {struct keyspan_pda_private *priv;
@@ -762,20 +784,20 @@ static int keyspan_pda_startup (struct usb_serial *serial) priv =kmalloc (sizeof (struct keyspan_pda_private ),GFP_KERNEL );if (!priv) -return (1 );/* error */ +return 1 ;/* error */ usb_set_serial_port_data (serial->port[0 ], priv);init_waitqueue_head (&serial->port[0 ]->write_wait);INIT_WORK (&priv->wakeup_work, keyspan_pda_wakeup_write);INIT_WORK (&priv->unthrottle_work, keyspan_pda_request_unthrottle); priv->serial = serial; priv->port = serial->port[0 ]; -return (0 ); +return 0 ; } -static void keyspan_pda_shutdown (struct usb_serial *serial) +static void keyspan_pda_shutdown (struct usb_serial *serial) {dbg ("%s" , __func__); - +kfree (usb_get_serial_port_data (serial->port[0 ])); }
@@ -834,7 +856,7 @@ static struct usb_serial_driver keyspan_pda_device = { }; -static int __init keyspan_pda_init (void ) +static int __init keyspan_pda_init (void ) {int retval; retval =usb_serial_register (&keyspan_pda_device);
@@ -855,7 +877,7 @@ static int __init keyspan_pda_init (void) goto failed_usb_register;info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; -failed_usb_register: +failed_usb_register:#ifdef XIRCOM usb_serial_deregister (&xircom_pgs_fake_device); failed_xircom_register:
@@ -872,15 +894,15 @@ failed_pda_register: } -static void __exit keyspan_pda_exit (void) +static void __exit keyspan_pda_exit(void) { -usb_deregister (&keyspan_pda_driver); -usb_serial_deregister (&keyspan_pda_device); +usb_deregister (&keyspan_pda_driver); +usb_serial_deregister (&keyspan_pda_device);#ifdef KEYSPAN -usb_serial_deregister (&keyspan_pda_fake_device); +usb_serial_deregister (&keyspan_pda_fake_device);#endif #ifdef XIRCOM -usb_serial_deregister (&xircom_pgs_fake_device); +usb_serial_deregister (&xircom_pgs_fake_device);#endif }
@@ -888,8 +910,8 @@ static void __exit keyspan_pda_exit (void)module_init (keyspan_pda_init);module_exit (keyspan_pda_exit); -MODULE_AUTHOR (DRIVER_AUTHOR ); -MODULE_DESCRIPTION (DRIVER_DESC ); +MODULE_AUTHOR (DRIVER_AUTHOR ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );module_param (debug, bool,S_IRUGO |S_IWUSR );
PATCH 53/70 tty-usb-kl5kusb105: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/kl5kusb105.c | 389 +++++++++++++++++++-------------------- 1 files changed, 188 insertions(+), 201 deletions(-)
drivers/usb/serial/kl5kusb105.c +188 -201
@@ -15,12 +15,12 @@* Neither Palm, nor their contractor (MCCI) or their supplier (KLSI) provided * information that was not already available. * -* It seems that KLSI bought some silicon-design information from ScanLogic, +* It seems that KLSI bought some silicon-design information from ScanLogic, * whose SL11R processor is at the core of the KL5KUSB chipset from KLSI. * KLSI has firmware available for their devices; it is probable that the * firmware differs from that used by KLSI in their products. If you have an -* original KLSI device and can provide some information on it, I would be -* most interested in adding support for it here. If you have any information +* original KLSI device and can provide some information on it, I would be +* most interested in adding support for it here. If you have any information * on the protocol used (or find errors in my reverse-engineered stuff), please * let me know. *
@@ -40,7 +40,7 @@* 0.2 - TIOCMGET works, so autopilot(1) can be used! * 0.1 - can be used to to pilot-xfer -p /dev/ttyUSB0 -l * -* The driver skeleton is mainly based on mct_u232.c and various other +* The driver skeleton is mainly based on mct_u232.c and various other * pieces of code shamelessly copied from the drivers/usb/serial/ directory. */
@@ -53,7 +53,7 @@#include <linux/tty_driver.h> #include <linux/tty_flip.h> #include <linux/module.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <asm/unaligned.h> #include <linux/usb.h> #include <linux/usb/serial.h>
@@ -72,37 +72,25 @@ static int debug;/* * Function prototypes */ -static int klsi_105_startup (struct usb_serial *serial); -static void klsi_105_shutdown (struct usb_serial *serial); -static int klsi_105_open (struct tty_struct *tty, -struct usb_serial_port *port, -struct file *filp); -static void klsi_105_close (struct tty_struct *tty, -struct usb_serial_port *port, -struct file *filp); -static int klsi_105_write (struct tty_struct *tty, -struct usb_serial_port *port, -const unsigned char *buf, -int count); -static void klsi_105_write_bulk_callback (struct urb *urb); -static int klsi_105_chars_in_buffer (struct tty_struct *tty); -static int klsi_105_write_room (struct tty_struct *tty); - -static void klsi_105_read_bulk_callback (struct urb *urb); -static void klsi_105_set_termios (struct tty_struct *tty, -struct usb_serial_port *port, -struct ktermios *old); -static void klsi_105_throttle (struct tty_struct *tty); -static void klsi_105_unthrottle (struct tty_struct *tty); -/* -static void klsi_105_break_ctl (struct tty_struct *tty, -int break_state ); -*/ -static int klsi_105_tiocmget (struct tty_struct *tty, -struct file *file); -static int klsi_105_tiocmset (struct tty_struct *tty, -struct file *file,unsigned int set, -unsigned int clear); +static int klsi_105_startup (struct usb_serial *serial); +static void klsi_105_shutdown (struct usb_serial *serial); +static int klsi_105_open (struct tty_struct *tty, +struct usb_serial_port *port,struct file *filp); +static void klsi_105_close (struct tty_struct *tty, +struct usb_serial_port *port,struct file *filp); +static int klsi_105_write (struct tty_struct *tty, +struct usb_serial_port *port,const unsigned char *buf,int count); +static void klsi_105_write_bulk_callback (struct urb *urb); +static int klsi_105_chars_in_buffer (struct tty_struct *tty); +static int klsi_105_write_room (struct tty_struct *tty); +static void klsi_105_read_bulk_callback (struct urb *urb); +static void klsi_105_set_termios (struct tty_struct *tty, +struct usb_serial_port *port,struct ktermios *old); +static void klsi_105_throttle (struct tty_struct *tty); +static void klsi_105_unthrottle (struct tty_struct *tty); +static int klsi_105_tiocmget((struct tty_struct *tty, struct file *file); +static int klsi_105_tiocmset (struct tty_struct *tty,struct file *file, +unsigned int set,unsigned int clear);/* * All of the device info needed for the KLSI converters.
@@ -113,7 +101,7 @@ static struct usb_device_id id_table [] = { { }/* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table); +MODULE_DEVICE_TABLE (usb, id_table);static struct usb_driver kl5kusb105d_driver = { .name ="kl5kusb105d" ,
@@ -138,7 +126,7 @@ static struct usb_serial_driver kl5kusb105d_device = { .write_bulk_callback = klsi_105_write_bulk_callback, .chars_in_buffer = klsi_105_chars_in_buffer, .write_room = klsi_105_write_room, - .read_bulk_callback =klsi_105_read_bulk_callback, + .read_bulk_callback = klsi_105_read_bulk_callback, .set_termios = klsi_105_set_termios,/*.break_ctl = klsi_105_break_ctl,*/ .tiocmget = klsi_105_tiocmget,
@@ -165,7 +153,7 @@ struct klsi_105_private {struct ktermios termios;unsigned long line_state;/* modem line settings */ /* write pool */ -struct urb * write_urb_pool[NUM_URBS ]; +struct urb *write_urb_pool[NUM_URBS ];spinlock_t lock;unsigned long bytes_in;unsigned long bytes_out;
@@ -184,15 +172,15 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port, {int rc; - rc =usb_control_msg (port->serial->dev, -usb_sndctrlpipe (port->serial->dev,0 ), -KL5KUSB105A_SIO_SET_DATA , -USB_TYPE_VENDOR |USB_DIR_OUT |USB_RECIP_INTERFACE , -0 ,/* value */ -0 ,/* index */ - settings, -sizeof (struct klsi_105_port_settings ), -KLSI_TIMEOUT ); + rc =usb_control_msg (port->serial->dev, +usb_sndctrlpipe (port->serial->dev,0 ), +KL5KUSB105A_SIO_SET_DATA , +USB_TYPE_VENDOR |USB_DIR_OUT |USB_RECIP_INTERFACE , +0 ,/* value */ +0 ,/* index */ + settings, +sizeof (struct klsi_105_port_settings ), +KLSI_TIMEOUT );if (rc <0 )err ("Change port settings failed (error = %d)" , rc); info("%s - %d byte block, baudrate %x, databits %d, u1 %d, u2 %d",
@@ -200,7 +188,7 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port, settings->pktlen, settings->baudrate, settings->databits, settings->unknown1, settings->unknown2); -return rc; +return rc; }/* klsi_105_chg_port_settings */ /* translate a 16-bit status value from the device to linux's TIO bits */
@@ -214,9 +202,9 @@ static unsigned long klsi_105_status2linestate(const __u16 status)return res; } -/* +/* * Read line control via vendor command and return result through -* *line_state_p +* *line_state_p */ /* It seems that the status buffer has always only 2 bytes length */ #define KLSI_STATUSBUF_LEN 2
@@ -224,14 +212,14 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, unsigned long *line_state_p) {int rc; -__u8 status_buf[KLSI_STATUSBUF_LEN ] = {-1 ,-1 }; +__u8 status_buf[KLSI_STATUSBUF_LEN ] = {-1 ,-1 };__u16 status;info ("%s - sending SIO Poll request" , __func__); - rc = usb_control_msg(port->serial->dev, + rc = usb_control_msg(port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0), KL5KUSB105A_SIO_POLL, - USB_TYPE_VENDOR | USB_DIR_IN, + USB_TYPE_VENDOR | USB_DIR_IN, 0, /* value */ 0, /* index */ status_buf, KLSI_STATUSBUF_LEN,
@@ -247,8 +235,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, *line_state_p =klsi_105_status2linestate (status); } - -return rc; +return rc; }
@@ -256,7 +243,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,* Driver's tty interface functions */ -static int klsi_105_startup (struct usb_serial *serial) +static int klsi_105_startup (struct usb_serial *serial) {struct klsi_105_private *priv;int i, j;
@@ -266,7 +253,7 @@ static int klsi_105_startup (struct usb_serial *serial)*/ /* allocate the private data structure */ -for (i=0 ; i<serial->num_ports; i++) { +for (i =0 ; i < serial->num_ports; i++) { priv =kmalloc (sizeof (struct klsi_105_private ),GFP_KERNEL );if (!priv) {
@@ -287,9 +274,9 @@ static int klsi_105_startup (struct usb_serial *serial) priv->bytes_out =0 ;usb_set_serial_port_data (serial->port[i], priv); -spin_lock_init (&priv->lock); -for (j=0 ; j<NUM_URBS ; j++) { -struct urb * urb =usb_alloc_urb (0 ,GFP_KERNEL ); +spin_lock_init (&priv->lock); +for (j =0 ; j <NUM_URBS ; j++) { +struct urb *urb =usb_alloc_urb (0 ,GFP_KERNEL ); priv->write_urb_pool[j] = urb;if (urb ==NULL ) {
@@ -297,10 +284,11 @@ static int klsi_105_startup (struct usb_serial *serial) goto err_cleanup; } - urb->transfer_buffer =kmalloc (URB_TRANSFER_BUFFER_SIZE , -GFP_KERNEL ); + urb->transfer_buffer = +kmalloc (URB_TRANSFER_BUFFER_SIZE ,GFP_KERNEL );if (!urb->transfer_buffer) { -err ("%s - out of memory for urb buffers." , __func__); +err ("%s - out of memory for urb buffers." , + __func__); goto err_cleanup; } }
@@ -308,13 +296,13 @@ static int klsi_105_startup (struct usb_serial *serial)/* priv->termios is left uninitalized until port opening */ init_waitqueue_head (&serial->port[i]->write_wait); } - +return 0 ; err_cleanup:for (; i >=0 ; i--) { priv =usb_get_serial_port_data (serial->port[i]); -for (j=0 ; j <NUM_URBS ; j++) { +for (j =0 ; j <NUM_URBS ; j++) {if (priv->write_urb_pool[j]) {kfree (priv->write_urb_pool[j]->transfer_buffer);usb_free_urb (priv->write_urb_pool[j]);
@@ -326,22 +314,23 @@ err_cleanup: }/* klsi_105_startup */ -static void klsi_105_shutdown (struct usb_serial *serial) +static void klsi_105_shutdown (struct usb_serial *serial) {int i; - +dbg ("%s" , __func__);/* stop reads and writes on all ports */ -for (i=0 ; i < serial->num_ports; ++i) { -struct klsi_105_private *priv =usb_get_serial_port_data (serial->port[i]); +for (i =0 ; i < serial->num_ports; ++i) { +struct klsi_105_private *priv = +usb_get_serial_port_data (serial->port[i]);unsigned long flags;if (priv) {/* kill our write urb pool */ int j;struct urb **write_urbs = priv->write_urb_pool; -spin_lock_irqsave (&priv->lock,flags); +spin_lock_irqsave (&priv->lock, flags);for (j =0 ; j <NUM_URBS ; j++) {if (write_urbs[j]) {
@@ -353,12 +342,10 @@ static void klsi_105_shutdown (struct usb_serial *serial)* oopses. */ /* usb_kill_urb(write_urbs[j]); */ kfree (write_urbs[j]->transfer_buffer); -usb_free_urb (write_urbs[j]); +usb_free_urb (write_urbs[j]); } } - -spin_unlock_irqrestore (&priv->lock, flags); - +spin_unlock_irqrestore (&priv->lock, flags);kfree (priv);usb_set_serial_port_data (serial->port[i],NULL ); }
@@ -384,7 +371,7 @@ static int klsi_105_open(struct tty_struct *tty,/* Do a defined restart: * Set up sane default baud rate and send the 'READ_ON' -* vendor command. +* vendor command. * FIXME: set modem line control (how?) * Then read the modem line control and store values in * priv->line_state.
@@ -395,24 +382,24 @@ static int klsi_105_open(struct tty_struct *tty, cfg.unknown1 =0 ; cfg.unknown2 =1 ;klsi_105_chg_port_settings (port, &cfg); - +/* set up termios structure */ -spin_lock_irqsave (&priv->lock, flags); +spin_lock_irqsave (&priv->lock, flags); priv->termios.c_iflag = tty->termios->c_iflag; priv->termios.c_oflag = tty->termios->c_oflag; priv->termios.c_cflag = tty->termios->c_cflag; priv->termios.c_lflag = tty->termios->c_lflag; -for (i=0 ; i<NCCS ; i++) +for (i =0 ; i <NCCS ; i++) priv->termios.c_cc[i] = tty->termios->c_cc[i]; priv->cfg.pktlen = cfg.pktlen; priv->cfg.baudrate = cfg.baudrate; priv->cfg.databits = cfg.databits; priv->cfg.unknown1 = cfg.unknown1; priv->cfg.unknown2 = cfg.unknown2; -spin_unlock_irqrestore (&priv->lock, flags); +spin_unlock_irqrestore (&priv->lock, flags);/* READ_ON and urb submission */ - usb_fill_bulk_urb(port->read_urb, port->serial->dev, + usb_fill_bulk_urb(port->read_urb, port->serial->dev, usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer,
@@ -428,7 +415,7 @@ static int klsi_105_open(struct tty_struct *tty, } rc = usb_control_msg(port->serial->dev, - usb_sndctrlpipe(port->serial->dev,0), + usb_sndctrlpipe(port->serial->dev, 0), KL5KUSB105A_SIO_CONFIGURE, USB_TYPE_VENDOR|USB_DIR_OUT|USB_RECIP_INTERFACE, KL5KUSB105A_SIO_CONFIGURE_READ_ON,
@@ -439,14 +426,14 @@ static int klsi_105_open(struct tty_struct *tty,if (rc <0 ) {err ("Enabling read failed (error = %d)" , rc); retval = rc; - }else + }else dbg ("%s - enabled reading" , __func__); rc =klsi_105_get_line_state (port, &line_state);if (rc >=0 ) { -spin_lock_irqsave (&priv->lock, flags); +spin_lock_irqsave (&priv->lock, flags); priv->line_state = line_state; -spin_unlock_irqrestore (&priv->lock, flags); + spin_unlock_irqrestore*&priv->lock, flags);dbg ("%s - read line state 0x%lx" , __func__, line_state); retval =0 ; }else
@@ -468,14 +455,14 @@ static void klsi_105_close(struct tty_struct *tty,mutex_lock (&port->serial->disc_mutex);if (!port->serial->disconnected) {/* send READ_OFF */ - rc =usb_control_msg (port->serial->dev, -usb_sndctrlpipe (port->serial->dev,0 ), -KL5KUSB105A_SIO_CONFIGURE , -USB_TYPE_VENDOR |USB_DIR_OUT , -KL5KUSB105A_SIO_CONFIGURE_READ_OFF , -0 ,/* index */ -NULL ,0 , -KLSI_TIMEOUT ); + rc =usb_control_msg (port->serial->dev, +usb_sndctrlpipe (port->serial->dev,0 ), +KL5KUSB105A_SIO_CONFIGURE , +USB_TYPE_VENDOR |USB_DIR_OUT , +KL5KUSB105A_SIO_CONFIGURE_READ_OFF , +0 ,/* index */ +NULL ,0 , +KLSI_TIMEOUT );if (rc <0 )err ("Disabling read failed (error = %d)" , rc); }
@@ -488,12 +475,13 @@ static void klsi_105_close(struct tty_struct *tty,/* FIXME */ /* wgg - do I need this? I think so. */ usb_kill_urb (port->interrupt_in_urb); -info ("kl5kusb105 port stats: %ld bytes in, %ld bytes out" , priv->bytes_in, priv->bytes_out); +info ("kl5kusb105 port stats: %ld bytes in, %ld bytes out" , + priv->bytes_in, priv->bytes_out); }/* klsi_105_close */ /* We need to write a complete 64-byte data block and encode the -* number actually sent in the first double-byte, LSB-order. That +* number actually sent in the first double-byte, LSB-order. That * leaves at most 62 bytes of payload. */ #define KLSI_105_DATA_OFFSET 2/* in the bulk urb data block */
@@ -504,7 +492,7 @@ static int klsi_105_write(struct tty_struct *tty, {struct klsi_105_private *priv =usb_get_serial_port_data (port);int result, size; -int bytes_sent=0 ; +int bytes_sent =0 ;dbg ("%s - port %d" , __func__, port->number);
@@ -513,34 +501,37 @@ static int klsi_105_write(struct tty_struct *tty,struct urb *urb =NULL ;unsigned long flags;int i; -/* since the pool is per-port we might not need the spin lock !? */ -spin_lock_irqsave (&priv->lock, flags); -for (i=0 ; i<NUM_URBS ; i++) { +/* since the pool is per-port we might not need +the spin lock !? */ +spin_lock_irqsave (&priv->lock, flags); +for (i =0 ; i <NUM_URBS ; i++) {if (priv->write_urb_pool[i]->status != -EINPROGRESS ) { urb = priv->write_urb_pool[i];dbg ("%s - using pool URB %d" , __func__, i);break ; } } -spin_unlock_irqrestore (&priv->lock, flags); +spin_unlock_irqrestore (&priv->lock, flags); -if (urb==NULL ) { +if (urb ==NULL ) {dbg ("%s - no more free urbs" , __func__); goto exit; }if (urb->transfer_buffer ==NULL ) { - urb->transfer_buffer =kmalloc (URB_TRANSFER_BUFFER_SIZE ,GFP_ATOMIC ); + urb->transfer_buffer = +kmalloc (URB_TRANSFER_BUFFER_SIZE ,GFP_ATOMIC );if (urb->transfer_buffer ==NULL ) {err ("%s - no more kernel memory..." , __func__); goto exit; } } - size =min (count, port->bulk_out_size -KLSI_105_DATA_OFFSET ); - size =min (size,URB_TRANSFER_BUFFER_SIZE -KLSI_105_DATA_OFFSET ); + size =min (count, port->bulk_out_size -KLSI_105_DATA_OFFSET ); + size =min (size,URB_TRANSFER_BUFFER_SIZE - +KLSI_105_DATA_OFFSET ); -memcpy (urb->transfer_buffer +KLSI_105_DATA_OFFSET , buf, size); +memcpy (urb->transfer_buffer +KLSI_105_DATA_OFFSET , buf, size);/* write payload size into transfer buffer */ ((__u8 *)urb->transfer_buffer)[0 ] = (__u8) (size &0xFF );
@@ -558,7 +549,8 @@ static int klsi_105_write(struct tty_struct *tty,/* send the data out the bulk port */ result =usb_submit_urb (urb,GFP_ATOMIC );if (result) { -err ("%s - failed submitting write urb, error %d" , __func__, result); +err ("%s - failed submitting write urb, error %d" , + __func__, result); goto exit; } buf += size;
@@ -567,12 +559,12 @@ static int klsi_105_write(struct tty_struct *tty, } exit:/* lockless, but it's for debug info only... */ - priv->bytes_out+=bytes_sent; + priv->bytes_out += bytes_sent;return bytes_sent;/* that's how much we wrote */ }/* klsi_105_write */ -static void klsi_105_write_bulk_callback (struct urb *urb) +static void klsi_105_write_bulk_callback (struct urb *urb) {struct usb_serial_port *port = urb->context;int status = urb->status;
@@ -590,7 +582,7 @@ static void klsi_105_write_bulk_callback ( struct urb *urb)/* return number of characters currently in the writing process */ -static int klsi_105_chars_in_buffer (struct tty_struct *tty) +static int klsi_105_chars_in_buffer (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;int chars =0 ;
@@ -598,21 +590,20 @@ static int klsi_105_chars_in_buffer (struct tty_struct *tty)unsigned long flags;struct klsi_105_private *priv =usb_get_serial_port_data (port); -spin_lock_irqsave (&priv->lock, flags); +spin_lock_irqsave (&priv->lock, flags);for (i =0 ; i <NUM_URBS ; ++i) { -if (priv->write_urb_pool[i]->status == -EINPROGRESS ) { +if (priv->write_urb_pool[i]->status == -EINPROGRESS ) chars +=URB_TRANSFER_BUFFER_SIZE ; - } } -spin_unlock_irqrestore (&priv->lock, flags); +spin_unlock_irqrestore (&priv->lock, flags);dbg ("%s - returns %d" , __func__, chars); -return (chars); +return chars; } -static int klsi_105_write_room (struct tty_struct *tty) +static int klsi_105_write_room (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;unsigned long flags;
@@ -620,22 +611,21 @@ static int klsi_105_write_room (struct tty_struct *tty)int room =0 ;struct klsi_105_private *priv =usb_get_serial_port_data (port); -spin_lock_irqsave (&priv->lock, flags); +spin_lock_irqsave (&priv->lock, flags);for (i =0 ; i <NUM_URBS ; ++i) { -if (priv->write_urb_pool[i]->status != -EINPROGRESS ) { +if (priv->write_urb_pool[i]->status != -EINPROGRESS ) room +=URB_TRANSFER_BUFFER_SIZE ; - } } -spin_unlock_irqrestore (&priv->lock, flags); +spin_unlock_irqrestore (&priv->lock, flags);dbg ("%s - returns %d" , __func__, room); -return (room); +return room; } -static void klsi_105_read_bulk_callback (struct urb *urb) +static void klsi_105_read_bulk_callback (struct urb *urb) {struct usb_serial_port *port = urb->context;struct klsi_105_private *priv =usb_get_serial_port_data (port);
@@ -674,7 +664,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb)* against re-entry an then mixed-up data because of * intermixed tty_flip_buffer_push()s * FIXME -*/ +*/ usb_serial_debug_data (debug, &port->dev, __func__, urb->actual_length, data);
@@ -694,7 +684,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb) priv->bytes_in += bytes_sent; }/* Continue trying to always read */ - usb_fill_bulk_urb(port->read_urb, port->serial->dev, + usb_fill_bulk_urb(port->read_urb, port->serial->dev, usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer,
@@ -703,13 +693,14 @@ static void klsi_105_read_bulk_callback (struct urb *urb) port); rc =usb_submit_urb (port->read_urb,GFP_ATOMIC );if (rc) -err ("%s - failed resubmitting read urb, error %d" , __func__, rc); +err ("%s - failed resubmitting read urb, error %d" , + __func__, rc); }/* klsi_105_read_bulk_callback */ -static void klsi_105_set_termios (struct tty_struct *tty, -struct usb_serial_port *port, -struct ktermios *old_termios) +static void klsi_105_set_termios (struct tty_struct *tty, +struct usb_serial_port *port, +struct ktermios *old_termios) {struct klsi_105_private *priv =usb_get_serial_port_data (port);unsigned int iflag = tty->termios->c_iflag;
@@ -719,65 +710,63 @@ static void klsi_105_set_termios (struct tty_struct *tty,struct klsi_105_port_settings cfg;unsigned long flags;speed_t baud; - +/* lock while we are modifying the settings */ -spin_lock_irqsave (&priv->lock, flags); - +spin_lock_irqsave (&priv->lock, flags); +/* * Update baud rate */ baud =tty_get_baud_rate (tty); -if ( (cflag &CBAUD ) != (old_cflag &CBAUD ) ) { -/* reassert DTR and (maybe) RTS on transition from B0 */ -if ( (old_cflag &CBAUD ) ==B0 ) { +if ((cflag &CBAUD ) != (old_cflag &CBAUD )) { +/* reassert DTR and (maybe) RTS on transition from B0 */ +if ((old_cflag &CBAUD ) ==B0 ) {dbg ("%s: baud was B0" , __func__);#if 0 priv->control_state |=TIOCM_DTR ;/* don't set RTS if using hardware flow control */ -if (!(old_cflag &CRTSCTS )) { +if (!(old_cflag &CRTSCTS )) priv->control_state |=TIOCM_RTS ; - }mct_u232_set_modem_ctrl (serial, priv->control_state);#endif } } -switch (baud) { -case 0 :/* handled below */ -break ; -case 1200 : - priv->cfg.baudrate = kl5kusb105a_sio_b1200; -break ; -case 2400 : - priv->cfg.baudrate = kl5kusb105a_sio_b2400; -break ; -case 4800 : - priv->cfg.baudrate = kl5kusb105a_sio_b4800; -break ; -case 9600 : +switch (baud) { +case 0 :/* handled below */ +break ; +case 1200 : + priv->cfg.baudrate = kl5kusb105a_sio_b1200; +break ; +case 2400 : + priv->cfg.baudrate = kl5kusb105a_sio_b2400; +break ; +case 4800 : + priv->cfg.baudrate = kl5kusb105a_sio_b4800; +break ; +case 9600 : + priv->cfg.baudrate = kl5kusb105a_sio_b9600; +break ; +case 19200 : + priv->cfg.baudrate = kl5kusb105a_sio_b19200; +break ; +case 38400 : + priv->cfg.baudrate = kl5kusb105a_sio_b38400; +break ; +case 57600 : + priv->cfg.baudrate = kl5kusb105a_sio_b57600; +break ; +case 115200 : + priv->cfg.baudrate = kl5kusb105a_sio_b115200; +break ; +default : +dbg ("KLSI USB->Serial converter:" +" unsupported baudrate request, using default of 9600" ); priv->cfg.baudrate = kl5kusb105a_sio_b9600; -break ; -case 19200 : - priv->cfg.baudrate = kl5kusb105a_sio_b19200; -break ; -case 38400 : - priv->cfg.baudrate = kl5kusb105a_sio_b38400; -break ; -case 57600 : - priv->cfg.baudrate = kl5kusb105a_sio_b57600; -break ; -case 115200 : - priv->cfg.baudrate = kl5kusb105a_sio_b115200; -break ; -default : -dbg ("KLSI USB->Serial converter:" -" unsupported baudrate request, using default" -" of 9600" ); - priv->cfg.baudrate = kl5kusb105a_sio_b9600; - baud =9600 ; -break ; + baud =9600 ; +break ; } -if ((cflag &CBAUD ) ==B0 ) { +if ((cflag &CBAUD ) ==B0 ) {dbg ("%s: baud is B0" , __func__);/* Drop RTS and DTR */ /* maybe this should be simulated by sending read
@@ -786,7 +775,7 @@ static void klsi_105_set_termios (struct tty_struct *tty, ;#if 0 priv->control_state &= ~(TIOCM_DTR |TIOCM_RTS ); -mct_u232_set_modem_ctrl (serial, priv->control_state); +mct_u232_set_modem_ctrl (serial, priv->control_state);#endif }tty_encode_baud_rate (tty, baud, baud);
@@ -796,11 +785,11 @@ static void klsi_105_set_termios (struct tty_struct *tty,switch (cflag &CSIZE ) {case CS5 :dbg ("%s - 5 bits/byte not supported" , __func__); -spin_unlock_irqrestore (&priv->lock, flags); +spin_unlock_irqrestore (&priv->lock, flags);return ;case CS6 :dbg ("%s - 6 bits/byte not supported" , __func__); -spin_unlock_irqrestore (&priv->lock, flags); +spin_unlock_irqrestore (&priv->lock, flags);return ;case CS7 : priv->cfg.databits = kl5kusb105a_dtb_7;
@@ -819,8 +808,7 @@ static void klsi_105_set_termios (struct tty_struct *tty,* Update line control register (LCR) */ if ((cflag & (PARENB |PARODD )) != (old_cflag & (PARENB |PARODD )) - || (cflag &CSTOPB ) != (old_cflag &CSTOPB ) ) { - + || (cflag &CSTOPB ) != (old_cflag &CSTOPB )) {/* Not currently supported */ tty->termios->c_cflag &= ~(PARENB |PARODD |CSTOPB );#if 0
@@ -841,20 +829,18 @@ static void klsi_105_set_termios (struct tty_struct *tty,#endif ; } -/* * Set flow control: well, I do not really now how to handle DTR/RTS. * Just do what we have seen with SniffUSB on Win98. */ -if ( (iflag &IXOFF ) != (old_iflag &IXOFF ) +if ((iflag &IXOFF ) != (old_iflag &IXOFF ) || (iflag &IXON ) != (old_iflag &IXON ) - || (cflag &CRTSCTS ) != (old_cflag &CRTSCTS ) ) { - + || (cflag &CRTSCTS ) != (old_cflag &CRTSCTS )) {/* Not currently supported */ tty->termios->c_cflag &= ~CRTSCTS ;/* Drop DTR/RTS if no flow control otherwise assert */ #if 0 -if ((iflag &IXOFF ) || (iflag &IXON ) || (cflag &CRTSCTS ) ) +if ((iflag &IXOFF ) || (iflag &IXON ) || (cflag &CRTSCTS )) priv->control_state |=TIOCM_DTR |TIOCM_RTS ;else priv->control_state &= ~(TIOCM_DTR |TIOCM_RTS );
@@ -862,20 +848,21 @@ static void klsi_105_set_termios (struct tty_struct *tty,#endif ; } -memcpy (&cfg, &priv->cfg,sizeof (cfg)); -spin_unlock_irqrestore (&priv->lock, flags); - +memcpy (&cfg, &priv->cfg,sizeof (cfg)); +spin_unlock_irqrestore (&priv->lock, flags); +/* now commit changes to device */ klsi_105_chg_port_settings (port, &cfg); }/* klsi_105_set_termios */ #if 0 -static void mct_u232_break_ctl (struct tty_struct *tty,int break_state ) +static void mct_u232_break_ctl (struct tty_struct *tty,int break_state) {struct usb_serial_port *port = tty->driver_data;struct usb_serial *serial = port->serial; -struct mct_u232_private *priv = (struct mct_u232_private *)port->private; +struct mct_u232_private *priv = + (struct mct_u232_private *)port->private;unsigned char lcr = priv->last_lcr;dbg ("%sstate=%d" , __func__, break_state);
@@ -887,7 +874,7 @@ static void mct_u232_break_ctl( struct tty_struct *tty, int break_state ) } /* mct_u232_break_ctl */#endif -static int klsi_105_tiocmget (struct tty_struct *tty,struct file *file) +static int klsi_105_tiocmget (struct tty_struct *tty,struct file *file) {struct usb_serial_port *port = tty->driver_data;struct klsi_105_private *priv =usb_get_serial_port_data (port);
@@ -903,18 +890,18 @@ static int klsi_105_tiocmget (struct tty_struct *tty, struct file *file)return rc; } -spin_lock_irqsave (&priv->lock, flags); +spin_lock_irqsave (&priv->lock, flags); priv->line_state = line_state; -spin_unlock_irqrestore (&priv->lock, flags); +spin_unlock_irqrestore (&priv->lock, flags);dbg ("%s - read line state 0x%lx" , __func__, line_state);return (int )line_state; } -static int klsi_105_tiocmset (struct tty_struct *tty,struct file *file, -unsigned int set,unsigned int clear) +static int klsi_105_tiocmset (struct tty_struct *tty,struct file *file, +unsigned int set,unsigned int clear) {int retval = -EINVAL ; - +dbg ("%s" , __func__);/* if this ever gets implemented, it should be done something like this:
@@ -939,14 +926,14 @@ static int klsi_105_tiocmset (struct tty_struct *tty, struct file *file,return retval; } -static void klsi_105_throttle (struct tty_struct *tty) +static void klsi_105_throttle (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;dbg ("%s - port %d" , __func__, port->number);usb_kill_urb (port->read_urb); } -static void klsi_105_unthrottle (struct tty_struct *tty) +static void klsi_105_unthrottle (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;int result;
@@ -962,7 +949,7 @@ static void klsi_105_unthrottle (struct tty_struct *tty) -static int __init klsi_105_init (void ) +static int __init klsi_105_init (void ) {int retval; retval =usb_serial_register (&kl5kusb105d_device);
@@ -981,19 +968,19 @@ failed_usb_serial_register: } -static void __exit klsi_105_exit (void) +static void __exit klsi_105_exit(void) { -usb_deregister (&kl5kusb105d_driver); -usb_serial_deregister (&kl5kusb105d_device); +usb_deregister (&kl5kusb105d_driver); +usb_serial_deregister (&kl5kusb105d_device); } -module_init (klsi_105_init); -module_exit (klsi_105_exit); +module_init (klsi_105_init); +module_exit (klsi_105_exit); -MODULE_AUTHOR (DRIVER_AUTHOR ); -MODULE_DESCRIPTION (DRIVER_DESC ); -MODULE_LICENSE ("GPL" ); +MODULE_AUTHOR (DRIVER_AUTHOR ); +MODULE_DESCRIPTION (DRIVER_DESC ); +MODULE_LICENSE ("GPL" );module_param (debug, bool,S_IRUGO |S_IWUSR );
PATCH 54/70 keyspan_pda: Use string flip functions
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/keyspan_pda.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/usb/serial/keyspan_pda.c +2 -3
@@ -220,7 +220,6 @@ static void keyspan_pda_rx_interrupt(struct urb *urb)struct usb_serial_port *port = urb->context;struct tty_struct *tty = port->port.tty;unsigned char *data = urb->transfer_buffer; -int i;int retval;int status = urb->status;struct keyspan_pda_private *priv;
@@ -248,8 +247,8 @@ static void keyspan_pda_rx_interrupt(struct urb *urb)case 0 :/* rest of message is rx data */ if (urb->actual_length) { -for (i =1 ; i < urb->actual_length ; ++i) -tty_insert_flip_char (tty, data[i],0 ); +tty_insert_flip_string (tty, data +1 , + urb->actual_length -1 );tty_flip_buffer_push (tty); }break ;
PATCH 55/70 tty-usb-kobil-sct: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/kl5kusb105.c | 4 drivers/usb/serial/kobil_sct.c | 557 +++++++++++++++++++++------------------ 2 files changed, 299 insertions(+), 262 deletions(-)
drivers/usb/serial/kl5kusb105.c +2 -2
@@ -88,7 +88,7 @@ static void klsi_105_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old);static void klsi_105_throttle (struct tty_struct *tty);static void klsi_105_unthrottle (struct tty_struct *tty); -static int klsi_105_tiocmget((struct tty_struct *tty, struct file *file); +static int klsi_105_tiocmget (struct tty_struct *tty,struct file *file);static int klsi_105_tiocmset (struct tty_struct *tty,struct file *file,unsigned int set,unsigned int clear);
@@ -433,7 +433,7 @@ static int klsi_105_open(struct tty_struct *tty,if (rc >=0 ) {spin_lock_irqsave (&priv->lock, flags); priv->line_state = line_state; - spin_unlock_irqrestore*&priv->lock, flags); +spin_unlock_irqrestore (&priv->lock, flags);dbg ("%s - read line state 0x%lx" , __func__, line_state); retval =0 ; }else
drivers/usb/serial/kobil_sct.c +297 -260
855 lines not on this page · raw message
PATCH 56/70 kobil_sct: Fix ioctls
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/kobil_sct.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/usb/serial/kobil_sct.c +4 -2
@@ -640,9 +640,11 @@ static void kobil_set_termios(struct tty_struct *tty, priv =usb_get_serial_port_data (port);if (priv->device_type ==KOBIL_USBTWIN_PRODUCT_ID || - priv->device_type ==KOBIL_KAAN_SIM_PRODUCT_ID ) + priv->device_type ==KOBIL_KAAN_SIM_PRODUCT_ID ) {/* This device doesn't support ioctl calls */ + *tty->termios = *old;return ; + } speed =tty_get_baud_rate (tty);switch (speed) {
@@ -704,7 +706,7 @@ static int kobil_ioctl(struct tty_struct *tty, struct file *file,if (priv->device_type ==KOBIL_USBTWIN_PRODUCT_ID || priv->device_type ==KOBIL_KAAN_SIM_PRODUCT_ID )/* This device doesn't support ioctl calls */ -return 0 ; +return -ENOIOCTLCMD ;switch (cmd) {case TCFLSH :
PATCH 57/70 tty-usb-mct-u232: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/mct_u232.c | 273 +++++++++++++++++++++-------------------- 1 files changed, 141 insertions(+), 132 deletions(-)
drivers/usb/serial/mct_u232.c +141 -132
@@ -33,10 +33,11 @@* - Fixed an endianess problem with the baudrate selection for PowerPC. * * 06-Dec-2001 Martin Hamilton <[email protected]> -* Added support for the Belkin F5U109 DB9 adaptor +* - Added support for the Belkin F5U109 DB9 adaptor * * 30-May-2001 Greg Kroah-Hartman -* switched from using spinlock to a semaphore, which fixes lots of problems. +* - switched from using spinlock to a semaphore, which fixes lots of +* problems. * * 04-May-2001 Stelian Pop * - Set the maximum bulk output size for Sitecom U232-P25 model to 16 bytes
@@ -49,7 +50,7 @@* 08-Apr-2001 gb * - Identify version on module load. * -* 06-Jan-2001 Cornel Ciocirlan +* 06-Jan-2001 Cornel Ciocirlan * - Added support for Sitecom U232-P25 model (Product Id 0x0230) * - Added support for D-Link DU-H3SP USB BAY (Product Id 0x0200) *
@@ -59,8 +60,8 @@* (lots of things will change if/when the usb-serial core changes to * handle these issues. * -* 27-Nov-2000 Wolfgang Grandegger -* A version for kernel 2.4.0-test10 released to the Linux community +* 27-Nov-2000 Wolfgang Grandegge +* A version for kernel 2.4.0-test10 released to the Linux community * (via linux-usb-devel). */
@@ -73,7 +74,7 @@#include <linux/tty_flip.h> #include <linux/module.h> #include <linux/spinlock.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/usb/serial.h> #include "mct_u232.h"
@@ -90,27 +91,21 @@ static int debug;/* * Function prototypes */ -static int mct_u232_startup (struct usb_serial *serial); -static void mct_u232_shutdown (struct usb_serial *serial); -static int mct_u232_open (struct tty_struct *tty, -struct usb_serial_port *port, -struct file *filp); -static void mct_u232_close (struct tty_struct *tty, -struct usb_serial_port *port, -struct file *filp); -static void mct_u232_read_int_callback (struct urb *urb); -static void mct_u232_set_termios (struct tty_struct *tty, -struct usb_serial_port *port, -struct ktermios * old); -static void mct_u232_break_ctl (struct tty_struct *tty, -int break_state ); -static int mct_u232_tiocmget (struct tty_struct *tty, -struct file *file); -static int mct_u232_tiocmset (struct tty_struct *tty, -struct file *file,unsigned int set, -unsigned int clear); -static void mct_u232_throttle (struct tty_struct *tty); -static void mct_u232_unthrottle (struct tty_struct *tty); +static int mct_u232_startup (struct usb_serial *serial); +static void mct_u232_shutdown (struct usb_serial *serial); +static int mct_u232_open (struct tty_struct *tty, +struct usb_serial_port *port,struct file *filp); +static void mct_u232_close (struct tty_struct *tty, +struct usb_serial_port *port,struct file *filp); +static void mct_u232_read_int_callback (struct urb *urb); +static void mct_u232_set_termios (struct tty_struct *tty, +struct usb_serial_port *port,struct ktermios *old); +static void mct_u232_break_ctl (struct tty_struct *tty,int break_state); +static int mct_u232_tiocmget (struct tty_struct *tty,struct file *file); +static int mct_u232_tiocmset (struct tty_struct *tty,struct file *file, +unsigned int set,unsigned int clear); +static void mct_u232_throttle (struct tty_struct *tty); +static void mct_u232_unthrottle (struct tty_struct *tty);/*
@@ -124,7 +119,7 @@ static struct usb_device_id id_table_combined [] = { { }/* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE (usb, id_table_combined);static struct usb_driver mct_u232_driver = { .name ="mct_u232" ,
@@ -178,23 +173,34 @@ struct mct_u232_private {* Later day 2.6.0-test kernels have new baud rates like B230400 which * we do not know how to support. We ignore them for the moment. */ -static int mct_u232_calculate_baud_rate (struct usb_serial *serial,speed_t value,speed_t *result) +static int mct_u232_calculate_baud_rate (struct usb_serial *serial, +speed_t value,speed_t *result) { *result = value;if (le16_to_cpu (serial->dev->descriptor.idProduct) ==MCT_U232_SITECOM_PID - ||le16_to_cpu (serial->dev->descriptor.idProduct) ==MCT_U232_BELKIN_F5U109_PID ) { + ||le16_to_cpu (serial->dev->descriptor.idProduct) ==MCT_U232_BELKIN_F5U109_PID ) {switch (value) { -case 300 :return 0x01 ; -case 600 :return 0x02 ;/* this one not tested */ -case 1200 :return 0x03 ; -case 2400 :return 0x04 ; -case 4800 :return 0x06 ; -case 9600 :return 0x08 ; -case 19200 :return 0x09 ; -case 38400 :return 0x0a ; -case 57600 :return 0x0b ; -case 115200 :return 0x0c ; +case 300 : +return 0x01 ; +case 600 : +return 0x02 ;/* this one not tested */ +case 1200 : +return 0x03 ; +case 2400 : +return 0x04 ; +case 4800 : +return 0x06 ; +case 9600 : +return 0x08 ; +case 19200 : +return 0x09 ; +case 38400 : +return 0x0a ; +case 57600 : +return 0x0b ; +case 115200 : +return 0x0c ;default : *result =9600 ;return 0x08 ;
@@ -226,18 +232,19 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty, struct usb_serial *serial, struct usb_serial_port *port, speed_t value) { __le32 divisor; -int rc; -unsigned char zero_byte =0 ; -unsigned char cts_enable_byte =0 ; -speed_t speed; - - divisor =cpu_to_le32 (mct_u232_calculate_baud_rate (serial, value, &speed)); - - rc =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), -MCT_U232_SET_BAUD_RATE_REQUEST , -MCT_U232_SET_REQUEST_TYPE , -0 ,0 , &divisor,MCT_U232_SET_BAUD_RATE_SIZE , -WDR_TIMEOUT ); +int rc; +unsigned char zero_byte =0 ; +unsigned char cts_enable_byte =0 ; +speed_t speed; + + divisor =cpu_to_le32 (mct_u232_calculate_baud_rate (serial, value, + &speed)); + + rc =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), +MCT_U232_SET_BAUD_RATE_REQUEST , +MCT_U232_SET_REQUEST_TYPE , +0 ,0 , &divisor,MCT_U232_SET_BAUD_RATE_SIZE , +WDR_TIMEOUT );if (rc <0 )/*FIXME: What value speed results */ err ("Set BAUD RATE %d failed (error = %d)" , value, rc);else
@@ -256,55 +263,55 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,whether data will be transmitted to a device which is not asserting the 'CTS' signal. If the second message's data byte is zero, data will be transmitted even if 'CTS' is not asserted (i.e. no hardware -flow control). if the second message's data byte is nonzero (a value -of 1 is used by this driver), data will not be transmitted to a device -which is not asserting 'CTS'. +flow control). if the second message's data byte is nonzero (a +value of 1 is used by this driver), data will not be transmitted to +a device which is not asserting 'CTS'. */ rc =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), -MCT_U232_SET_UNKNOWN1_REQUEST , -MCT_U232_SET_REQUEST_TYPE , -0 ,0 , &zero_byte,MCT_U232_SET_UNKNOWN1_SIZE , -WDR_TIMEOUT ); +MCT_U232_SET_UNKNOWN1_REQUEST , +MCT_U232_SET_REQUEST_TYPE , +0 ,0 , &zero_byte,MCT_U232_SET_UNKNOWN1_SIZE , +WDR_TIMEOUT );if (rc <0 ) -err ("Sending USB device request code %d failed (error = %d)" , +err ("Sending USB device request code %d failed (error = %d)" ,MCT_U232_SET_UNKNOWN1_REQUEST , rc); -if (port &&C_CRTSCTS (tty)) { +if (port &&C_CRTSCTS (tty)) cts_enable_byte =1 ; - } -dbg ("set_baud_rate: send second control message, data = %02X" , cts_enable_byte); +dbg ("set_baud_rate: send second control message, data = %02X" , + cts_enable_byte); rc =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), -MCT_U232_SET_CTS_REQUEST , -MCT_U232_SET_REQUEST_TYPE , -0 ,0 , &cts_enable_byte,MCT_U232_SET_CTS_SIZE , -WDR_TIMEOUT ); +MCT_U232_SET_CTS_REQUEST , +MCT_U232_SET_REQUEST_TYPE , +0 ,0 , &cts_enable_byte,MCT_U232_SET_CTS_SIZE , +WDR_TIMEOUT );if (rc <0 ) -err ("Sending USB device request code %d failed (error = %d)" , -MCT_U232_SET_CTS_REQUEST , rc); +err ("Sending USB device request code %d failed (error = %d)" , +MCT_U232_SET_CTS_REQUEST , rc); -return rc; +return rc; }/* mct_u232_set_baud_rate */ static int mct_u232_set_line_ctrl (struct usb_serial *serial,unsigned char lcr) { -int rc; - rc =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), -MCT_U232_SET_LINE_CTRL_REQUEST , -MCT_U232_SET_REQUEST_TYPE , -0 ,0 , &lcr,MCT_U232_SET_LINE_CTRL_SIZE , -WDR_TIMEOUT ); +int rc; + rc =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), +MCT_U232_SET_LINE_CTRL_REQUEST , +MCT_U232_SET_REQUEST_TYPE , +0 ,0 , &lcr,MCT_U232_SET_LINE_CTRL_SIZE , +WDR_TIMEOUT );if (rc <0 )err ("Set LINE CTRL 0x%x failed (error = %d)" , lcr, rc);dbg ("set_line_ctrl: 0x%x" , lcr); -return rc; +return rc; }/* mct_u232_set_line_ctrl */ static int mct_u232_set_modem_ctrl (struct usb_serial *serial,unsigned int control_state) { -int rc; +int rc;unsigned char mcr =MCT_U232_MCR_NONE ;if (control_state &TIOCM_DTR )
@@ -312,37 +319,39 @@ static int mct_u232_set_modem_ctrl(struct usb_serial *serial,if (control_state &TIOCM_RTS ) mcr |=MCT_U232_MCR_RTS ; - rc =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), -MCT_U232_SET_MODEM_CTRL_REQUEST , -MCT_U232_SET_REQUEST_TYPE , -0 ,0 , &mcr,MCT_U232_SET_MODEM_CTRL_SIZE , -WDR_TIMEOUT ); + rc =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), +MCT_U232_SET_MODEM_CTRL_REQUEST , +MCT_U232_SET_REQUEST_TYPE , +0 ,0 , &mcr,MCT_U232_SET_MODEM_CTRL_SIZE , +WDR_TIMEOUT );if (rc <0 )err ("Set MODEM CTRL 0x%x failed (error = %d)" , mcr, rc);dbg ("set_modem_ctrl: state=0x%x ==> mcr=0x%x" , control_state, mcr); -return rc; +return rc; }/* mct_u232_set_modem_ctrl */ -static int mct_u232_get_modem_stat (struct usb_serial *serial,unsigned char *msr) +static int mct_u232_get_modem_stat (struct usb_serial *serial, +unsigned char *msr) { -int rc; - rc =usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev,0 ), -MCT_U232_GET_MODEM_STAT_REQUEST , -MCT_U232_GET_REQUEST_TYPE , -0 ,0 , msr,MCT_U232_GET_MODEM_STAT_SIZE , -WDR_TIMEOUT ); +int rc; + rc =usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev,0 ), +MCT_U232_GET_MODEM_STAT_REQUEST , +MCT_U232_GET_REQUEST_TYPE , +0 ,0 , msr,MCT_U232_GET_MODEM_STAT_SIZE , +WDR_TIMEOUT );if (rc <0 ) {err ("Get MODEM STATus failed (error = %d)" , rc); *msr =0 ; }dbg ("get_modem_stat: 0x%x" , *msr); -return rc; +return rc; }/* mct_u232_get_modem_stat */ -static void mct_u232_msr_to_state (unsigned int *control_state,unsigned char msr) +static void mct_u232_msr_to_state (unsigned int *control_state, +unsigned char msr) { -/* Translate Control Line states */ +/* Translate Control Line states */ if (msr &MCT_U232_MSR_DSR ) *control_state |=TIOCM_DSR ;else
@@ -359,14 +368,14 @@ static void mct_u232_msr_to_state(unsigned int *control_state, unsigned char msr *control_state |=TIOCM_CD ; else *control_state &= ~TIOCM_CD ; -dbg ("msr_to_state: msr=0x%x ==> state=0x%x" , msr, *control_state); +dbg ("msr_to_state: msr=0x%x ==> state=0x%x" , msr, *control_state); }/* mct_u232_msr_to_state */ /* * Driver's tty interface functions */ -static int mct_u232_startup (struct usb_serial *serial) +static int mct_u232_startup (struct usb_serial *serial) {struct mct_u232_private *priv;struct usb_serial_port *port, *rport;
@@ -388,18 +397,18 @@ static int mct_u232_startup (struct usb_serial *serial) rport->interrupt_in_urb =NULL ; port->read_urb->context = port; -return (0 ); +return 0 ; }/* mct_u232_startup */ -static void mct_u232_shutdown (struct usb_serial *serial) +static void mct_u232_shutdown (struct usb_serial *serial) {struct mct_u232_private *priv;int i; - +dbg ("%s" , __func__); -for (i=0 ; i < serial->num_ports; ++i) { +for (i =0 ; i < serial->num_ports; ++i) {/* My special items, the standard routines free my urbs */ priv =usb_get_serial_port_data (serial->port[i]);if (priv) {
@@ -409,7 +418,7 @@ static void mct_u232_shutdown (struct usb_serial *serial) } }/* mct_u232_shutdown */ -static int mct_u232_open (struct tty_struct *tty, +static int mct_u232_open (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp) {struct usb_serial *serial = port->serial;
@@ -427,10 +436,11 @@ static int mct_u232_open (struct tty_struct *tty,* it seems to be able to accept only 16 bytes (and that's what * SniffUSB says too...) */ -if (le16_to_cpu (serial->dev->descriptor.idProduct) ==MCT_U232_SITECOM_PID ) +if (le16_to_cpu (serial->dev->descriptor.idProduct) + ==MCT_U232_SITECOM_PID ) port->bulk_out_size =16 ; -/* Do a defined restart: the normal serial device seems to +/* Do a defined restart: the normal serial device seems to * always turn on DTR and RTS here, so do the same. I'm not * sure if this is really necessary. But it should not harm * either.
@@ -440,8 +450,8 @@ static int mct_u232_open (struct tty_struct *tty, priv->control_state =TIOCM_DTR |TIOCM_RTS ; else priv->control_state = 0; - - priv->last_lcr = (MCT_U232_DATA_BITS_8 | + + priv->last_lcr = (MCT_U232_DATA_BITS_8 |MCT_U232_PARITY_NONE |MCT_U232_STOP_BITS_1 ); control_state = priv->control_state;
@@ -488,7 +498,7 @@ static void mct_u232_close(struct tty_struct *tty,struct mct_u232_private *priv =usb_get_serial_port_data (port);dbg ("%s port %d" , __func__, port->number); -if (tty) { +if (tty) { c_cflag = tty->termios->c_cflag;mutex_lock (&port->serial->disc_mutex);if (c_cflag &HUPCL && !port->serial->disconnected) {
@@ -512,7 +522,7 @@ static void mct_u232_close(struct tty_struct *tty, }/* mct_u232_close */ -static void mct_u232_read_int_callback (struct urb *urb) +static void mct_u232_read_int_callback (struct urb *urb) {struct usb_serial_port *port = urb->context;struct mct_u232_private *priv =usb_get_serial_port_data (port);
@@ -545,8 +555,9 @@ static void mct_u232_read_int_callback (struct urb *urb)return ; } -dbg ("%s - port %d" , __func__, port->number); -usb_serial_debug_data (debug, &port->dev, __func__, urb->actual_length, data); +dbg ("%s - port %d" , __func__, port->number); +usb_serial_debug_data (debug, &port->dev, __func__, + urb->actual_length, data);/* * Work-a-round: handle the 'usual' bulk-in pipe here
@@ -555,26 +566,25 @@ static void mct_u232_read_int_callback (struct urb *urb)int i; tty = port->port.tty;if (urb->actual_length) { -for (i =0 ; i < urb->actual_length ; ++i) { +for (i =0 ; i < urb->actual_length ; ++i)tty_insert_flip_char (tty, data[i],0 ); - }tty_flip_buffer_push (tty); } goto exit; } - +/* * The interrupt-in pipe signals exceptional conditions (modem line * signal changes and errors). data[0] holds MSR, data[1] holds LSR. */ spin_lock_irqsave (&priv->lock, flags); priv->last_msr = data[MCT_U232_MSR_INDEX ]; - +/* Record Control Line states */ mct_u232_msr_to_state (&priv->control_state, priv->last_msr);#if 0 -/* Not yet handled. See belin_sa.c for further information */ +/* Not yet handled. See belkin_sa.c for further information */ /* Now to report any errors */ priv->last_lsr = data[MCT_U232_LSR_INDEX ];/*
@@ -600,15 +610,15 @@ static void mct_u232_read_int_callback (struct urb *urb)#endif spin_unlock_irqrestore (&priv->lock, flags); exit: - retval =usb_submit_urb (urb,GFP_ATOMIC ); + retval =usb_submit_urb (urb,GFP_ATOMIC );if (retval) -err ("%s - usb_submit_urb failed with result %d" , +err ("%s - usb_submit_urb failed with result %d" , __func__, retval); }/* mct_u232_read_int_callback */ -static void mct_u232_set_termios (struct tty_struct *tty, -struct usb_serial_port *port, -struct ktermios *old_termios) +static void mct_u232_set_termios (struct tty_struct *tty, +struct usb_serial_port *port, +struct ktermios *old_termios) {struct usb_serial *serial = port->serial;struct mct_u232_private *priv =usb_get_serial_port_data (port);
@@ -632,7 +642,7 @@ static void mct_u232_set_termios (struct tty_struct *tty,* Premature optimization is the root of all evil. */ -/* reassert DTR and RTS on transition from B0 */ +/* reassert DTR and RTS on transition from B0 */ if ((old_cflag &CBAUD ) ==B0 ) {dbg ("%s: baud was B0" , __func__); control_state |=TIOCM_DTR |TIOCM_RTS ;
@@ -641,11 +651,11 @@ static void mct_u232_set_termios (struct tty_struct *tty,mct_u232_set_baud_rate (tty, serial, port,tty_get_baud_rate (tty)); -if ((cflag &CBAUD ) ==B0 ) { +if ((cflag &CBAUD ) ==B0 ) {dbg ("%s: baud is B0" , __func__);/* Drop RTS and DTR */ control_state &= ~(TIOCM_DTR |TIOCM_RTS ); -mct_u232_set_modem_ctrl (serial, control_state); +mct_u232_set_modem_ctrl (serial, control_state); }/*
@@ -717,7 +727,7 @@ static int mct_u232_tiocmget(struct tty_struct *tty, struct file *file)struct mct_u232_private *priv =usb_get_serial_port_data (port);unsigned int control_state;unsigned long flags; - +dbg ("%s" , __func__);spin_lock_irqsave (&priv->lock, flags);
@@ -735,7 +745,7 @@ static int mct_u232_tiocmset(struct tty_struct *tty, struct file *file,struct mct_u232_private *priv =usb_get_serial_port_data (port);unsigned int control_state;unsigned long flags; - +dbg ("%s" , __func__);spin_lock_irqsave (&priv->lock, flags);
@@ -798,7 +808,7 @@ static void mct_u232_unthrottle(struct tty_struct *tty) } } -static int __init mct_u232_init (void ) +static int __init mct_u232_init (void ) {int retval; retval =usb_serial_register (&mct_u232_device);
@@ -816,18 +826,17 @@ failed_usb_serial_register: } -static void __exit mct_u232_exit (void) +static void __exit mct_u232_exit(void) { -usb_deregister (&mct_u232_driver); -usb_serial_deregister (&mct_u232_device); +usb_deregister (&mct_u232_driver); +usb_serial_deregister (&mct_u232_device); } - -module_init (mct_u232_init); +module_init (mct_u232_init);module_exit (mct_u232_exit); -MODULE_AUTHOR (DRIVER_AUTHOR ); -MODULE_DESCRIPTION (DRIVER_DESC ); +MODULE_AUTHOR (DRIVER_AUTHOR ); +MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );module_param (debug, bool,S_IRUGO |S_IWUSR );
PATCH 58/70 mct_u232: Use flip buffer functions
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/mct_u232.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/usb/serial/mct_u232.c +1 -3
@@ -563,11 +563,9 @@ static void mct_u232_read_int_callback(struct urb *urb)* Work-a-round: handle the 'usual' bulk-in pipe here */ if (urb->transfer_buffer_length >2 ) { -int i; tty = port->port.tty;if (urb->actual_length) { -for (i =0 ; i < urb->actual_length ; ++i) -tty_insert_flip_char (tty, data[i],0 ); +tty_insert_flip_string (tty, data, urb->actual_length);tty_flip_buffer_push (tty); } goto exit;
PATCH 59/70 tty-usb-pl2303: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/pl2303.c | 64 ++++++++++++++++++++++++------------------- 1 files changed, 36 insertions(+), 28 deletions(-)
drivers/usb/serial/pl2303.c +36 -28
@@ -10,7 +10,8 @@* modify it under the terms of the GNU General Public License version * 2 as published by the Free Software Foundation. * -* See Documentation/usb/usb-serial.txt for more information on using this driver +* See Documentation/usb/usb-serial.txt for more information on using this +* driver * */
@@ -25,7 +26,7 @@#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/spinlock.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/usb/serial.h> #include "pl2303.h"
@@ -115,7 +116,7 @@ static struct usb_driver pl2303_driver = {#define CONTROL_RTS 0x02#define BREAK_REQUEST_TYPE 0x21 -#define BREAK_REQUEST 0x23 +#define BREAK_REQUEST 0x23#define BREAK_ON 0xffff#define BREAK_OFF 0x0000
@@ -221,7 +222,7 @@ static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb)if (pb ==NULL )return 0 ; -return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size); +return (pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size; }/*
@@ -235,7 +236,7 @@ static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb)if (pb ==NULL )return 0 ; -return ((pb->buf_size + pb->buf_get - pb->buf_put -1 ) % pb->buf_size); +return (pb->buf_size + pb->buf_get - pb->buf_put -1 ) % pb->buf_size; }/*
@@ -394,7 +395,7 @@ static int pl2303_startup(struct usb_serial *serial) cleanup:kfree (buf); -for (--i; i>=0 ; --i) { +for (--i; i >=0 ; --i) { priv =usb_get_serial_port_data (serial->port[i]);pl2303_buf_free (priv->buf);kfree (priv);
@@ -406,7 +407,7 @@ cleanup:static int set_control_lines (struct usb_device *dev,u8 value) {int retval; - + retval =usb_control_msg (dev,usb_sndctrlpipe (dev,0 ),SET_CONTROL_REQUEST ,SET_CONTROL_REQUEST_TYPE , value,0 ,NULL ,0 ,100 );
@@ -451,7 +452,7 @@ static void pl2303_send(struct usb_serial_port *port)dev_err (&port->dev,"%s - failed submitting write urb," " error %d\n" , __func__, result); priv->write_urb_in_use =0 ; -// TODO: reschedule pl2303_send +/* TODO: reschedule pl2303_send */ }usb_serial_port_softint (port);
@@ -560,11 +561,19 @@ static void pl2303_set_termios(struct tty_struct *tty,if (cflag &CSIZE ) {switch (cflag &CSIZE ) { -case CS5 : buf[6 ] =5 ;break ; -case CS6 : buf[6 ] =6 ;break ; -case CS7 : buf[6 ] =7 ;break ; -default : -case CS8 : buf[6 ] =8 ;break ; +case CS5 : + buf[6 ] =5 ; +break ; +case CS6 : + buf[6 ] =6 ; +break ; +case CS7 : + buf[6 ] =7 ; +break ; +default : +case CS8 : + buf[6 ] =8 ; +break ; }dbg ("%s - data bits = %d" , __func__, buf[6 ]); }
@@ -693,7 +702,7 @@ static void pl2303_close(struct tty_struct *tty,/* that is not unnecessarily long) */ bps =tty_get_baud_rate (tty);if (bps >1200 ) - timeout =max ((HZ *2560 )/bps,HZ /10 ); + timeout =max ((HZ *2560 )/bps,HZ /10 );else timeout =2 *HZ ;schedule_timeout_interruptible (timeout);
@@ -739,7 +748,7 @@ static int pl2303_open(struct tty_struct *tty,if (tty)pl2303_set_termios (tty, port, &tmp_termios); -//FIXME: need to assert RTS and DTR if CRTSCTS off +/* FIXME: need to assert RTS and DTR if CRTSCTS off */ dbg ("%s - submitting read urb" , __func__); port->read_urb->dev = serial->dev;
@@ -842,12 +851,12 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) status = priv->line_status;spin_unlock_irqrestore (&priv->lock, flags); - changed=prevstatus^status; + changed = prevstatus ^ status;if (((arg &TIOCM_RNG ) && (changed &UART_RING )) || ((arg &TIOCM_DSR ) && (changed &UART_DSR )) || ((arg &TIOCM_CD ) && (changed &UART_DCD )) || - ((arg &TIOCM_CTS ) && (changed &UART_CTS )) ) { + ((arg &TIOCM_CTS ) && (changed &UART_CTS ))) {return 0 ; } prevstatus = status;
@@ -863,15 +872,13 @@ static int pl2303_ioctl(struct tty_struct *tty, struct file *file,dbg ("%s (%d) cmd = 0x%04x" , __func__, port->number, cmd);switch (cmd) { -case TIOCMIWAIT : -dbg ("%s (%d) TIOCMIWAIT" , __func__, port->number); -return wait_modem_info (port, arg); - -default : -dbg ("%s not supported = 0x%04x" , __func__, cmd); -break ; +case TIOCMIWAIT : +dbg ("%s (%d) TIOCMIWAIT" , __func__, port->number); +return wait_modem_info (port, arg); +default : +dbg ("%s not supported = 0x%04x" , __func__, cmd); +break ; } -return -ENOIOCTLCMD ; }
@@ -888,7 +895,8 @@ static void pl2303_break_ctl(struct tty_struct *tty, int break_state) state =BREAK_OFF ; else state =BREAK_ON ; -dbg ("%s - turning break %s" , __func__, state==BREAK_OFF ?"off" :"on" ); +dbg ("%s - turning break %s" , __func__, + state ==BREAK_OFF ?"off" :"on" ); result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), BREAK_REQUEST, BREAK_REQUEST_TYPE, state,
@@ -942,7 +950,7 @@ static void pl2303_update_line_status(struct usb_serial_port *port,if (actual_length < length)return ; -/* Save off the uart status for others to look at */ +/* Save off the uart status for others to look at */ spin_lock_irqsave (&priv->lock, flags); priv->line_status = data[status_idx];spin_unlock_irqrestore (&priv->lock, flags);
@@ -1041,7 +1049,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)/* break takes precedence over parity, */ /* which takes precedence over framing errors */ -if (line_status &UART_BREAK_ERROR ) +if (line_status &UART_BREAK_ERROR ) tty_flag =TTY_BREAK ;else if (line_status &UART_PARITY_ERROR ) tty_flag =TTY_PARITY ;
PATCH 60/70 tty-usb-sierra: Coding style - minor
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/sierra.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/serial/sierra.c +1 -1
@@ -757,7 +757,7 @@ failed_device_register: static void __exit sierra_exit(void) { -usb_deregister (&sierra_driver); +usb_deregister (&sierra_driver);usb_serial_deregister (&sierra_device); }
PATCH 61/70 tty-usb-spcp8x5: Minor coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/spcp8x5.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/usb/serial/spcp8x5.c +2 -2
@@ -208,7 +208,7 @@ static inline unsigned int ringbuf_avail_data(struct ringbuf *pb) {if (pb ==NULL )return 0 ; -return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size); +return (pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size; }/* get the number of space in the pipo */
@@ -216,7 +216,7 @@ static inline unsigned int ringbuf_avail_space(struct ringbuf *pb) {if (pb ==NULL )return 0 ; -return ((pb->buf_size + pb->buf_get - pb->buf_put -1 ) % pb->buf_size); +return (pb->buf_size + pb->buf_get - pb->buf_put -1 ) % pb->buf_size; }/* put count data into pipo */
PATCH 62/70 tty-usb-ti-usb: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/ti_usb_3410_5052.c | 270 +++++++++++++++++++-------------- 1 files changed, 153 insertions(+), 117 deletions(-)
drivers/usb/serial/ti_usb_3410_5052.c +153 -117
@@ -16,7 +16,7 @@* For questions or problems with this driver, contact Texas Instruments * technical support, or Al Borchers <[email protected]>, or * Peter Berger <[email protected]>. -* +* * 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 * configuration.
@@ -82,7 +82,7 @@#include <linux/serial.h> #include <linux/circ_buf.h> #include <linux/mutex.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/usb/serial.h>
@@ -158,21 +158,22 @@ struct ti_device {static int ti_startup (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, -struct file *file); +struct file *file);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, -const unsigned char *data,int count); +const unsigned char *data,int count);static int ti_write_room (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_unthrottle (struct tty_struct *tty); -static int ti_ioctl (struct tty_struct *tty,struct file *file,unsigned int cmd,unsigned long arg); -static void ti_set_termios (struct tty_struct *tty,struct usb_serial_port *port, -struct ktermios *old_termios); +static int ti_ioctl (struct tty_struct *tty,struct file *file, +unsigned int cmd,unsigned long arg); +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_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_interrupt_callback (struct urb *urb);static void ti_bulk_in_callback (struct urb *urb);
@@ -331,19 +332,25 @@ module_param(debug, bool, S_IRUGO | S_IWUSR);MODULE_PARM_DESC (debug,"Enable debugging, 0=no, 1=yes" );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_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_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_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_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_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);
@@ -352,18 +359,18 @@ MODULE_DEVICE_TABLE(usb, ti_id_table_combined);static int __init ti_init (void ) { -int i,j; +int i, j;int ret;/* insert extra vendor and product ids */ 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].idProduct = product_3410[i]; 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 ; -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].idProduct = product_5052[i]; ti_id_table_5052[j].match_flags =USB_DEVICE_ID_MATCH_DEVICE ;
@@ -432,7 +439,8 @@ static int ti_startup(struct usb_serial *serial)/* determine device type */ if (usb_match_id (serial->interface, ti_id_table_3410)) 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 (dev->descriptor.bNumConfigurations ==1 ) {
@@ -451,7 +459,7 @@ static int ti_startup(struct usb_serial *serial) status = -ENODEV ; goto free_tdev; - } + }/* the second configuration must be set (in sysfs by hotplug script) */ if (dev->actconfig->desc.bConfigurationValue ==TI_BOOT_CONFIG ) {
@@ -468,7 +476,8 @@ static int ti_startup(struct usb_serial *serial) goto free_tports; }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_closing_wait = closing_wait;init_waitqueue_head (&tport->tp_msr_wait);
@@ -485,11 +494,11 @@ static int ti_startup(struct usb_serial *serial)usb_set_serial_port_data (serial->port[i], tport); tport->tp_uart_mode =0 ;/* default is RS232 */ } - +return 0 ; free_tports: -for (--i; i>=0 ; --i) { +for (--i; i >=0 ; --i) { tport =usb_get_serial_port_data (serial->port[i]);ti_buf_free (tport->tp_write_buf);kfree (tport);
@@ -510,7 +519,7 @@ static void ti_shutdown(struct usb_serial *serial)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]);if (tport) {ti_buf_free (tport->tp_write_buf);
@@ -533,8 +542,8 @@ static int ti_open(struct tty_struct *tty,struct urb *urb;int port_number;int status; -__u16 open_settings = (__u8)(TI_PIPE_MODE_CONTINOUS | -TI_PIPE_TIMEOUT_ENABLE | +__u16 open_settings = (__u8)(TI_PIPE_MODE_CONTINOUS | +TI_PIPE_TIMEOUT_ENABLE | (TI_TRANSFER_TIMEOUT <<2 ));dbg ("%s - port %d" , __func__, port->number);
@@ -565,7 +574,8 @@ static int ti_open(struct tty_struct *tty,dbg ("%s - start interrupt in urb" , __func__); urb = tdev->td_serial->port[0 ]->interrupt_in_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 ; goto release_lock; }
@@ -574,7 +584,9 @@ static int ti_open(struct tty_struct *tty, urb->dev = dev; status =usb_submit_urb (urb,GFP_KERNEL );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; } }
@@ -586,7 +598,8 @@ static int ti_open(struct tty_struct *tty, status =ti_command_out_sync (tdev,TI_OPEN_PORT , (__u8)(TI_UART1_PORT + port_number), open_settings,NULL ,0 );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; }
@@ -594,7 +607,8 @@ static int ti_open(struct tty_struct *tty, status =ti_command_out_sync (tdev,TI_START_PORT , (__u8)(TI_UART1_PORT + port_number),0 ,NULL ,0 );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; }
@@ -602,13 +616,15 @@ static int ti_open(struct tty_struct *tty, status =ti_command_out_sync (tdev,TI_PURGE_PORT , (__u8)(TI_UART1_PORT + port_number),TI_PURGE_INPUT ,NULL ,0 );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; } status =ti_command_out_sync (tdev,TI_PURGE_PORT , (__u8)(TI_UART1_PORT + port_number),TI_PURGE_OUTPUT ,NULL ,0 );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; }
@@ -624,7 +640,8 @@ static int ti_open(struct tty_struct *tty, status =ti_command_out_sync (tdev,TI_OPEN_PORT , (__u8)(TI_UART1_PORT + port_number), open_settings,NULL ,0 );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; }
@@ -632,7 +649,8 @@ static int ti_open(struct tty_struct *tty, status =ti_command_out_sync (tdev,TI_START_PORT , (__u8)(TI_UART1_PORT + port_number),0 ,NULL ,0 );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; }
@@ -650,7 +668,8 @@ static int ti_open(struct tty_struct *tty, urb->dev = dev; status =usb_submit_urb (urb,GFP_KERNEL );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; }
@@ -679,7 +698,7 @@ static void ti_close(struct tty_struct *tty, struct usb_serial_port *port,int do_unlock;dbg ("%s - port %d" , __func__, port->number); - + tdev =usb_get_serial_data (port->serial); tport =usb_get_serial_port_data (port);if (tdev ==NULL || tport ==NULL )
@@ -699,7 +718,9 @@ static void ti_close(struct tty_struct *tty, struct usb_serial_port *port, status =ti_command_out_sync (tdev,TI_CLOSE_PORT , (__u8)(TI_UART1_PORT + port_number),0 ,NULL ,0 );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 */ do_unlock = !mutex_lock_interruptible (&tdev->td_open_close_lock);
@@ -753,7 +774,7 @@ static int ti_write_room(struct tty_struct *tty)if (tport ==NULL )return -ENODEV ; - +spin_lock_irqsave (&tport->tp_lock, flags); room =ti_buf_space_avail (tport->tp_write_buf);spin_unlock_irqrestore (&tport->tp_lock, flags);
@@ -814,7 +835,8 @@ static void ti_unthrottle(struct tty_struct *tty)if (I_IXOFF (tty) ||C_CRTSCTS (tty)) { status =ti_restart_read (tport, tty);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); } }
@@ -833,44 +855,42 @@ static int ti_ioctl(struct tty_struct *tty, struct file *file,return -ENODEV ;switch (cmd) { -case TIOCGSERIAL : -dbg ("%s - (%d) TIOCGSERIAL" , __func__, port->number); -return ti_get_serial_info (tport, (struct serial_struct __user *)arg); -break ; - -case TIOCSSERIAL : -dbg ("%s - (%d) TIOCSSERIAL" , __func__, port->number); -return ti_set_serial_info (tport, (struct serial_struct __user *)arg); -break ; - -case TIOCMIWAIT : -dbg ("%s - (%d) TIOCMIWAIT" , __func__, port->number); - cprev = tport->tp_icount; -while (1 ) { -interruptible_sleep_on (&tport->tp_msr_wait); -if (signal_pending (current)) -return -ERESTARTSYS ; - cnow = tport->tp_icount; -if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && - cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) -return -EIO ;/* no change => error */ -if (((arg &TIOCM_RNG ) && (cnow.rng != cprev.rng)) || - ((arg &TIOCM_DSR ) && (cnow.dsr != cprev.dsr)) || - ((arg &TIOCM_CD ) && (cnow.dcd != cprev.dcd)) || - ((arg &TIOCM_CTS ) && (cnow.cts != cprev.cts)) ) { -return 0 ; - } - cprev = cnow; - } -break ; - -case TIOCGICOUNT : -dbg ("%s - (%d) TIOCGICOUNT RX=%d, TX=%d" , __func__, port->number, tport->tp_icount.rx, tport->tp_icount.tx); -if (copy_to_user ((void __user *)arg, &tport->tp_icount,sizeof (tport->tp_icount))) -return -EFAULT ; -return 0 ; +case TIOCGSERIAL : +dbg ("%s - (%d) TIOCGSERIAL" , __func__, port->number); +return ti_get_serial_info (tport, + (struct serial_struct __user *)arg); +case TIOCSSERIAL : +dbg ("%s - (%d) TIOCSSERIAL" , __func__, port->number); +return ti_set_serial_info (tport, + (struct serial_struct __user *)arg); +case TIOCMIWAIT : +dbg ("%s - (%d) TIOCMIWAIT" , __func__, port->number); + cprev = tport->tp_icount; +while (1 ) { +interruptible_sleep_on (&tport->tp_msr_wait); +if (signal_pending (current)) +return -ERESTARTSYS ; + cnow = tport->tp_icount; +if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && + cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) +return -EIO ;/* no change => error */ +if (((arg &TIOCM_RNG ) && (cnow.rng != cprev.rng)) || + ((arg &TIOCM_DSR ) && (cnow.dsr != cprev.dsr)) || + ((arg &TIOCM_CD ) && (cnow.dcd != cprev.dcd)) || + ((arg &TIOCM_CTS ) && (cnow.cts != cprev.cts))) +return 0 ; + cprev = cnow; + } +break ; +case TIOCGICOUNT : +dbg ("%s - (%d) TIOCGICOUNT RX=%d, TX=%d" , + __func__, port->number, + tport->tp_icount.rx, tport->tp_icount.tx); +if (copy_to_user ((void __user *)arg, &tport->tp_icount, +sizeof (tport->tp_icount))) +return -EFAULT ; +return 0 ; } -return -ENOIOCTLCMD ; }
@@ -880,7 +900,7 @@ static void ti_set_termios(struct tty_struct *tty, {struct ti_port *tport =usb_get_serial_port_data (port);struct ti_uart_config *config; -tcflag_t cflag,iflag; +tcflag_t cflag, iflag;int baud;int status;int port_number = port->number - port->serial->minor;
@@ -892,7 +912,8 @@ static void ti_set_termios(struct tty_struct *tty, iflag = tty->termios->c_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 )return ;
@@ -911,19 +932,19 @@ static void ti_set_termios(struct tty_struct *tty, config->bUartMode = (__u8)(tport->tp_uart_mode);switch (cflag &CSIZE ) { -case CS5 : - config->bDataBits =TI_UART_5_DATA_BITS ; -break ; -case CS6 : - config->bDataBits =TI_UART_6_DATA_BITS ; -break ; -case CS7 : - config->bDataBits =TI_UART_7_DATA_BITS ; -break ; -default : -case CS8 : - config->bDataBits =TI_UART_8_DATA_BITS ; -break ; +case CS5 : + config->bDataBits =TI_UART_5_DATA_BITS ; +break ; +case CS6 : + config->bDataBits =TI_UART_6_DATA_BITS ; +break ; +case CS7 : + config->bDataBits =TI_UART_7_DATA_BITS ; +break ; +default : +case CS8 : + config->bDataBits =TI_UART_8_DATA_BITS ; +break ; }/* CMSPAR isn't supported by this driver */
@@ -939,7 +960,7 @@ static void ti_set_termios(struct tty_struct *tty, } }else { config->wFlags &= ~TI_UART_ENABLE_PARITY_CHECKING ; - config->bParity =TI_UART_NO_PARITY ; + config->bParity =TI_UART_NO_PARITY ; }if (cflag &CSTOPB )
@@ -992,7 +1013,8 @@ static void ti_set_termios(struct tty_struct *tty, (__u8)(TI_UART1_PORT + port_number),0 , (__u8 *)config, sizeof(*config));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 */ mcr = tport->tp_shadow_mcr;
@@ -1001,7 +1023,9 @@ static void ti_set_termios(struct tty_struct *tty, mcr &= ~(TI_MCR_DTR |TI_MCR_RTS ); status =ti_set_mcr (tport, mcr);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); }
@@ -1143,10 +1167,12 @@ static void ti_interrupt_callback(struct urb *urb) port_number =TI_GET_PORT_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) { -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; }
@@ -1158,7 +1184,8 @@ static void ti_interrupt_callback(struct urb *urb)switch (function) {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 ;case TI_CODE_MODEM_STATUS :
@@ -1168,7 +1195,8 @@ static void ti_interrupt_callback(struct urb *urb)break ;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 ; }
@@ -1202,7 +1230,7 @@ static void ti_bulk_in_callback(struct urb *urb)return ;default :dev_err (dev,"%s - nonzero urb status, %d\n" , - __func__, status ); + __func__, status); tport->tp_tdev->td_urb_error =1 ;wake_up_interruptible (&tport->tp_write_wait); }
@@ -1222,8 +1250,9 @@ static void ti_bulk_in_callback(struct urb *urb)if (!tport->tp_is_open)dbg ("%s - port closed, dropping data" , __func__);else -ti_recv (&urb->dev->dev, port->port.tty, urb->transfer_buffer, - urb->actual_length); +ti_recv (&urb->dev->dev, port->port.tty, + urb->transfer_buffer, + urb->actual_length);spin_lock (&tport->tp_lock); tport->tp_icount.rx += urb->actual_length;
@@ -1287,8 +1316,9 @@ static void ti_recv(struct device *dev, struct tty_struct *tty, do { cnt = tty_buffer_request_room(tty, length); if (cnt < length) { - dev_err(dev, "%s - dropping data, %d bytes lost\n", __func__, length - cnt); - if(cnt == 0) + dev_err(dev, "%s - dropping data, %d bytes lost\n", + __func__, length - cnt); + if (cnt == 0) break; } tty_insert_flip_string(tty, data, cnt);
@@ -1330,7 +1360,8 @@ static void ti_send(struct ti_port *tport)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_sndbulkpipe(port->serial->dev,
@@ -1340,8 +1371,9 @@ static void ti_send(struct ti_port *tport) result =usb_submit_urb (port->write_urb,GFP_ATOMIC );if (result) { -dev_err (&port->dev,"%s - submit write urb failed, %d\n" , __func__, result); - tport->tp_write_urb_in_use =0 ; +dev_err (&port->dev,"%s - submit write urb failed, %d\n" , + __func__, result); + tport->tp_write_urb_in_use =0 ;/* TODO: reschedule ti_send */ }else {spin_lock_irqsave (&tport->tp_lock, flags);
@@ -1376,7 +1408,7 @@ static int ti_set_mcr(struct ti_port *tport, unsigned int mcr)static int ti_get_lsr (struct ti_port *tport) { -int size,status; +int size, status;struct ti_device *tdev = tport->tp_tdev;struct usb_serial_port *port = tport->tp_port;int port_number = port->number - port->serial->minor;
@@ -1394,7 +1426,9 @@ static int ti_get_lsr(struct ti_port *tport) status =ti_command_in_sync (tdev,TI_GET_PORT_STATUS , (__u8)(TI_UART1_PORT +port_number),0 , (__u8 *)data, size);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; }
@@ -1630,7 +1664,8 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr,struct ti_write_data_bytes *data;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 ; data =kmalloc (size,GFP_KERNEL );
@@ -1667,12 +1702,12 @@ static int ti_do_download(struct usb_device *dev, int pipe,struct ti_firmware_header *header;int status;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]); 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 ))); header->bCheckSum = cs;
@@ -1731,11 +1766,12 @@ static int ti_download_firmware(struct ti_device *tdev, int type)ti_do_download (dev, pipe, buffer, fw_p->size);kfree (buffer); } -#ifdef CONFIG_USB_SERIAL_TI_FIRMWARE +#ifdef CONFIG_USB_SERIAL_TI_FIRMWARE release_firmware (fw_p); -#endif +#endif 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; }
@@ -1807,7 +1843,7 @@ static void ti_buf_clear(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 ); }
@@ -1820,7 +1856,7 @@ static int ti_buf_data_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 ); }