diff options
author | Alan Cox <alan@redhat.com> | 2008-07-22 11:13:42 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-22 13:03:25 -0700 |
commit | 9e70f319d14ac4dd077de7fc835a391ece804500 (patch) | |
tree | ea5550d3a0a092469eeb69f2c46e326a7b486696 /drivers/usb/serial | |
parent | f035a8ad158f0bdc94125004488b0ea8438edaa9 (diff) | |
download | op-kernel-dev-9e70f319d14ac4dd077de7fc835a391ece804500.zip op-kernel-dev-9e70f319d14ac4dd077de7fc835a391ece804500.tar.gz |
tty-usb-keyspan-pda: Coding style
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r-- | drivers/usb/serial/keyspan_pda.c | 161 |
1 files changed, 91 insertions, 70 deletions
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 24a08ac..b60012c 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -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. - * + * */ @@ -78,7 +80,7 @@ #include <linux/workqueue.h> #include <linux/firmware.h> #include <linux/ihex.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/usb/serial.h> @@ -135,7 +137,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", @@ -159,9 +161,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 @@ -184,7 +186,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 @@ -195,15 +197,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; @@ -228,14 +230,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; @@ -259,9 +260,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); } @@ -292,32 +293,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 */ @@ -343,11 +364,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 @@ -490,10 +511,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: @@ -520,7 +541,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 @@ -551,7 +572,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; @@ -563,8 +584,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; @@ -583,7 +603,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; @@ -604,7 +624,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; } @@ -662,7 +682,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); @@ -685,7 +705,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); @@ -697,7 +718,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 char *fw_name; @@ -746,10 +767,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; @@ -759,20 +780,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])); } @@ -831,7 +852,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); @@ -852,7 +873,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: @@ -869,15 +890,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 } @@ -885,8 +906,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); |