tty-usb-kl5kusb105: 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>
This commit is contained in:
Alan Cox 2008-07-22 11:14:00 +01:00 committed by Linus Torvalds
parent 8dd03a5b2b
commit 0c265f4e85

View file

@ -53,7 +53,7 @@
#include <linux/tty_driver.h> #include <linux/tty_driver.h>
#include <linux/tty_flip.h> #include <linux/tty_flip.h>
#include <linux/module.h> #include <linux/module.h>
#include <asm/uaccess.h> #include <linux/uaccess.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/usb/serial.h> #include <linux/usb/serial.h>
@ -75,34 +75,22 @@ static int debug;
static int klsi_105_startup(struct usb_serial *serial); static int klsi_105_startup(struct usb_serial *serial);
static void klsi_105_shutdown(struct usb_serial *serial); static void klsi_105_shutdown(struct usb_serial *serial);
static int klsi_105_open(struct tty_struct *tty, static int klsi_105_open(struct tty_struct *tty,
struct usb_serial_port *port, struct usb_serial_port *port, struct file *filp);
struct file *filp);
static void klsi_105_close(struct tty_struct *tty, static void klsi_105_close(struct tty_struct *tty,
struct usb_serial_port *port, struct usb_serial_port *port, struct file *filp);
struct file *filp);
static int klsi_105_write(struct tty_struct *tty, static int klsi_105_write(struct tty_struct *tty,
struct usb_serial_port *port, struct usb_serial_port *port, const unsigned char *buf, int count);
const unsigned char *buf,
int count);
static void klsi_105_write_bulk_callback(struct urb *urb); 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_chars_in_buffer(struct tty_struct *tty);
static int klsi_105_write_room(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_read_bulk_callback(struct urb *urb);
static void klsi_105_set_termios(struct tty_struct *tty, static void klsi_105_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct usb_serial_port *port, struct ktermios *old);
struct ktermios *old);
static void klsi_105_throttle(struct tty_struct *tty); static void klsi_105_throttle(struct tty_struct *tty);
static void klsi_105_unthrottle(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 void klsi_105_break_ctl (struct tty_struct *tty, static int klsi_105_tiocmset(struct tty_struct *tty, struct file *file,
int break_state ); unsigned int set, unsigned int clear);
*/
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. * All of the device info needed for the KLSI converters.
@ -247,7 +235,6 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
*line_state_p = klsi_105_status2linestate(status); *line_state_p = klsi_105_status2linestate(status);
} }
return rc; return rc;
} }
@ -297,10 +284,11 @@ static int klsi_105_startup (struct usb_serial *serial)
goto err_cleanup; goto err_cleanup;
} }
urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, urb->transfer_buffer =
GFP_KERNEL); kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
if (!urb->transfer_buffer) { 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; goto err_cleanup;
} }
} }
@ -334,7 +322,8 @@ static void klsi_105_shutdown (struct usb_serial *serial)
/* stop reads and writes on all ports */ /* stop reads and writes on all ports */
for (i = 0; i < serial->num_ports; ++i) { for (i = 0; i < serial->num_ports; ++i) {
struct klsi_105_private *priv = usb_get_serial_port_data(serial->port[i]); struct klsi_105_private *priv =
usb_get_serial_port_data(serial->port[i]);
unsigned long flags; unsigned long flags;
if (priv) { if (priv) {
@ -356,9 +345,7 @@ static void klsi_105_shutdown (struct usb_serial *serial)
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); kfree(priv);
usb_set_serial_port_data(serial->port[i], NULL); usb_set_serial_port_data(serial->port[i], NULL);
} }
@ -488,7 +475,8 @@ static void klsi_105_close(struct tty_struct *tty,
/* FIXME */ /* FIXME */
/* wgg - do I need this? I think so. */ /* wgg - do I need this? I think so. */
usb_kill_urb(port->interrupt_in_urb); 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 */ } /* klsi_105_close */
@ -513,7 +501,8 @@ static int klsi_105_write(struct tty_struct *tty,
struct urb *urb = NULL; struct urb *urb = NULL;
unsigned long flags; unsigned long flags;
int i; int i;
/* since the pool is per-port we might not need the spin lock !? */ /* since the pool is per-port we might not need
the spin lock !? */
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
for (i = 0; i < NUM_URBS; i++) { for (i = 0; i < NUM_URBS; i++) {
if (priv->write_urb_pool[i]->status != -EINPROGRESS) { if (priv->write_urb_pool[i]->status != -EINPROGRESS) {
@ -530,7 +519,8 @@ static int klsi_105_write(struct tty_struct *tty,
} }
if (urb->transfer_buffer == NULL) { 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) { if (urb->transfer_buffer == NULL) {
err("%s - no more kernel memory...", __func__); err("%s - no more kernel memory...", __func__);
goto exit; goto exit;
@ -538,7 +528,8 @@ static int klsi_105_write(struct tty_struct *tty,
} }
size = min(count, port->bulk_out_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); 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);
@ -558,7 +549,8 @@ static int klsi_105_write(struct tty_struct *tty,
/* send the data out the bulk port */ /* send the data out the bulk port */
result = usb_submit_urb(urb, GFP_ATOMIC); result = usb_submit_urb(urb, GFP_ATOMIC);
if (result) { if (result) {
err("%s - failed submitting write urb, error %d", __func__, result); err("%s - failed submitting write urb, error %d",
__func__, result);
goto exit; goto exit;
} }
buf += size; buf += size;
@ -601,15 +593,14 @@ static int klsi_105_chars_in_buffer (struct tty_struct *tty)
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
for (i = 0; i < NUM_URBS; ++i) { 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; chars += URB_TRANSFER_BUFFER_SIZE;
} }
}
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
dbg("%s - returns %d", __func__, chars); 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)
@ -622,15 +613,14 @@ static int klsi_105_write_room (struct tty_struct *tty)
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
for (i = 0; i < NUM_URBS; ++i) { 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; room += URB_TRANSFER_BUFFER_SIZE;
} }
}
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
dbg("%s - returns %d", __func__, room); dbg("%s - returns %d", __func__, room);
return (room); return room;
} }
@ -703,7 +693,8 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
port); port);
rc = usb_submit_urb(port->read_urb, GFP_ATOMIC); rc = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (rc) 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 */ } /* klsi_105_read_bulk_callback */
@ -735,9 +726,8 @@ static void klsi_105_set_termios (struct tty_struct *tty,
#if 0 #if 0
priv->control_state |= TIOCM_DTR; priv->control_state |= TIOCM_DTR;
/* don't set RTS if using hardware flow control */ /* don't set RTS if using hardware flow control */
if (!(old_cflag & CRTSCTS)) { if (!(old_cflag & CRTSCTS))
priv->control_state |= TIOCM_RTS; priv->control_state |= TIOCM_RTS;
}
mct_u232_set_modem_ctrl(serial, priv->control_state); mct_u232_set_modem_ctrl(serial, priv->control_state);
#endif #endif
} }
@ -771,8 +761,7 @@ static void klsi_105_set_termios (struct tty_struct *tty,
break; break;
default: default:
dbg("KLSI USB->Serial converter:" dbg("KLSI USB->Serial converter:"
" unsupported baudrate request, using default" " unsupported baudrate request, using default of 9600");
" of 9600");
priv->cfg.baudrate = kl5kusb105a_sio_b9600; priv->cfg.baudrate = kl5kusb105a_sio_b9600;
baud = 9600; baud = 9600;
break; break;
@ -820,7 +809,6 @@ static void klsi_105_set_termios (struct tty_struct *tty,
*/ */
if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD)) if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD))
|| (cflag & CSTOPB) != (old_cflag & CSTOPB)) { || (cflag & CSTOPB) != (old_cflag & CSTOPB)) {
/* Not currently supported */ /* Not currently supported */
tty->termios->c_cflag &= ~(PARENB|PARODD|CSTOPB); tty->termios->c_cflag &= ~(PARENB|PARODD|CSTOPB);
#if 0 #if 0
@ -841,7 +829,6 @@ static void klsi_105_set_termios (struct tty_struct *tty,
#endif #endif
; ;
} }
/* /*
* Set flow control: well, I do not really now how to handle DTR/RTS. * Set flow control: well, I do not really now how to handle DTR/RTS.
* Just do what we have seen with SniffUSB on Win98. * Just do what we have seen with SniffUSB on Win98.
@ -849,7 +836,6 @@ static void klsi_105_set_termios (struct tty_struct *tty,
if ((iflag & IXOFF) != (old_iflag & IXOFF) if ((iflag & IXOFF) != (old_iflag & IXOFF)
|| (iflag & IXON) != (old_iflag & IXON) || (iflag & IXON) != (old_iflag & IXON)
|| (cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { || (cflag & CRTSCTS) != (old_cflag & CRTSCTS)) {
/* Not currently supported */ /* Not currently supported */
tty->termios->c_cflag &= ~CRTSCTS; tty->termios->c_cflag &= ~CRTSCTS;
/* Drop DTR/RTS if no flow control otherwise assert */ /* Drop DTR/RTS if no flow control otherwise assert */
@ -875,7 +861,8 @@ static void mct_u232_break_ctl( struct tty_struct *tty, int break_state )
{ {
struct usb_serial_port *port = tty->driver_data; struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial; 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; unsigned char lcr = priv->last_lcr;
dbg("%sstate=%d", __func__, break_state); dbg("%sstate=%d", __func__, break_state);