Subject: USB: option card driver coding style tweaks

From: Andrew Morton <[email-masked]>
Date: Wed, 27 Jul 2005 01:08:30 -0700

Signed-off-by: Andrew Morton <[email-masked]>
Signed-off-by: Greg Kroah-Hartman <[email-masked]>

---
 drivers/usb/serial/option.c |  195 ++++++++++++++++++++------------------------
 1 files changed, 89 insertions(+), 106 deletions(-)

--- gregkh-2.6.orig/drivers/usb/serial/option.c	2005-07-27 13:02:51.000000000 -0700
+++ gregkh-2.6/drivers/usb/serial/option.c	2005-07-27 22:35:26.000000000 -0700
@@ -45,29 +45,29 @@
 #include "usb-serial.h"
 
 /* Function prototypes */
-static int  option_open (struct usb_serial_port *port, struct file *filp);
-static void option_close (struct usb_serial_port *port, struct file *filp);
-static int  option_startup (struct usb_serial *serial);
-static void option_shutdown (struct usb_serial *serial);
-static void option_rx_throttle (struct usb_serial_port *port);
-static void option_rx_unthrottle (struct usb_serial_port *port);
-static int  option_write_room (struct usb_serial_port *port);
+static int  option_open(struct usb_serial_port *port, struct file *filp);
+static void option_close(struct usb_serial_port *port, struct file *filp);
+static int  option_startup(struct usb_serial *serial);
+static void option_shutdown(struct usb_serial *serial);
+static void option_rx_throttle(struct usb_serial_port *port);
+static void option_rx_unthrottle(struct usb_serial_port *port);
+static int  option_write_room(struct usb_serial_port *port);
 
 static void option_instat_callback(struct urb *urb, struct pt_regs *regs);
 
-static int  option_write (struct usb_serial_port *port,
-                          const unsigned char *buf, int count);
+static int option_write(struct usb_serial_port *port,
+			const unsigned char *buf, int count);
 
-static int  option_chars_in_buffer (struct usb_serial_port *port);
-static int  option_ioctl (struct usb_serial_port *port, struct file *file,
-                          unsigned int cmd, unsigned long arg);
-static void option_set_termios (struct usb_serial_port *port,
-                                struct termios *old);
-static void option_break_ctl (struct usb_serial_port *port, int break_state);
-static int  option_tiocmget (struct usb_serial_port *port, struct file *file);
-static int  option_tiocmset (struct usb_serial_port *port, struct file *file,
-                             unsigned int set, unsigned int clear);
-static int  option_send_setup (struct usb_serial_port *port);
+static int  option_chars_in_buffer(struct usb_serial_port *port);
+static int  option_ioctl(struct usb_serial_port *port, struct file *file,
+			unsigned int cmd, unsigned long arg);
+static void option_set_termios(struct usb_serial_port *port,
+				struct termios *old);
+static void option_break_ctl(struct usb_serial_port *port, int break_state);
+static int  option_tiocmget(struct usb_serial_port *port, struct file *file);
+static int  option_tiocmset(struct usb_serial_port *port, struct file *file,
+				unsigned int set, unsigned int clear);
+static int  option_send_setup(struct usb_serial_port *port);
 
 /* Vendor and product IDs */
 #define OPTION_VENDOR_ID			0x0AF0
@@ -76,7 +76,6 @@
 #define OPTION_PRODUCT_FUSION	0x6000
 #define OPTION_PRODUCT_FUSION2	0x6300
 
-
 static struct usb_device_id option_ids[] = {
 	{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) },
 	{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) },
@@ -129,7 +128,6 @@
 #define debug 0
 #endif
 
-
 /* per port private data */
 
 #define N_IN_URB 4
@@ -156,10 +154,8 @@
 	unsigned long tx_start_time[N_OUT_URB];
 };
 
-
 /* Functions used by new usb-serial code. */
-static int __init
-option_init (void)
+static int __init option_init(void)
 {
 	int retval;
 	retval = usb_serial_register(&option_3port_device);
@@ -179,8 +175,7 @@
 	return retval;
 }
 
-static void __exit
-option_exit (void)
+static void __exit option_exit(void)
 {
 	usb_deregister (&option_driver);
 	usb_serial_deregister (&option_3port_device);
@@ -189,39 +184,31 @@
 module_init(option_init);
 module_exit(option_exit);
 
-static void
-option_rx_throttle (struct usb_serial_port *port)
+static void option_rx_throttle(struct usb_serial_port *port)
 {
 	dbg("%s", __FUNCTION__);
 }
 
-
-static void
-option_rx_unthrottle (struct usb_serial_port *port)
+static void option_rx_unthrottle(struct usb_serial_port *port)
 {
 	dbg("%s", __FUNCTION__);
 }
 
-
-static void
-option_break_ctl (struct usb_serial_port *port, int break_state)
+static void option_break_ctl(struct usb_serial_port *port, int break_state)
 {
 	/* Unfortunately, I don't know how to send a break */
 	dbg("%s", __FUNCTION__);
 }
 
-
-static void
-option_set_termios (struct usb_serial_port *port,
-                    struct termios *old_termios)
+static void option_set_termios(struct usb_serial_port *port,
+			struct termios *old_termios)
 {
 	dbg("%s", __FUNCTION__);
 
 	option_send_setup(port);
 }
 
-static int
-option_tiocmget (struct usb_serial_port *port, struct file *file)
+static int option_tiocmget(struct usb_serial_port *port, struct file *file)
 {
 	unsigned int value;
 	struct option_port_private *portdata;
@@ -238,9 +225,8 @@
 	return value;
 }
 
-static int
-option_tiocmset (struct usb_serial_port *port, struct file *file,
-                 unsigned int set, unsigned int clear)
+static int option_tiocmset(struct usb_serial_port *port, struct file *file,
+			unsigned int set, unsigned int clear)
 {
 	struct option_port_private *portdata;
 
@@ -258,17 +244,15 @@
 	return option_send_setup(port);
 }
 
-static int
-option_ioctl (struct usb_serial_port *port, struct file *file,
-              unsigned int cmd, unsigned long arg)
+static int option_ioctl(struct usb_serial_port *port, struct file *file,
+			unsigned int cmd, unsigned long arg)
 {
 	return -ENOIOCTLCMD;
 }
 
 /* Write */
-static int
-option_write (struct usb_serial_port *port,
-			  const unsigned char *buf, int count)
+static int option_write(struct usb_serial_port *port,
+			const unsigned char *buf, int count)
 {
 	struct option_port_private *portdata;
 	int i;
@@ -291,16 +275,19 @@
 		if (this_urb->status == -EINPROGRESS) {
 			if (this_urb->transfer_flags & URB_ASYNC_UNLINK)
 				continue;
-			if (time_before(jiffies, portdata->tx_start_time[i] + 10 * HZ))
+			if (time_before(jiffies,
+					portdata->tx_start_time[i] + 10 * HZ))
 				continue;
 			this_urb->transfer_flags |= URB_ASYNC_UNLINK;
 			usb_unlink_urb(this_urb);
 			continue;
 		}
 		if (this_urb->status != 0)
-			dbg("usb_write %p failed (err=%d)", this_urb, this_urb->status);
+			dbg("usb_write %p failed (err=%d)",
+				this_urb, this_urb->status);
 
-		dbg("%s: endpoint %d buf %d", __FUNCTION__, usb_pipeendpoint(this_urb->pipe), i);
+		dbg("%s: endpoint %d buf %d", __FUNCTION__,
+			usb_pipeendpoint(this_urb->pipe), i);
 
 		/* send the data */
 		memcpy (this_urb->transfer_buffer, buf, todo);
@@ -310,7 +297,9 @@
 		this_urb->dev = port->serial->dev;
 		err = usb_submit_urb(this_urb, GFP_ATOMIC);
 		if (err) {
-			dbg("usb_submit_urb %p (write bulk) failed (%d, has %d)", this_urb, err, this_urb->status);
+			dbg("usb_submit_urb %p (write bulk) failed "
+				"(%d, has %d)", this_urb,
+				err, this_urb->status);
 			continue;
 		}
 		portdata->tx_start_time[i] = jiffies;
@@ -323,8 +312,7 @@
 	return count;
 }
 
-static void
-option_indat_callback (struct urb *urb, struct pt_regs *regs)
+static void option_indat_callback(struct urb *urb, struct pt_regs *regs)
 {
 	int i, err;
 	int endpoint;
@@ -357,14 +345,14 @@
 		if (port->open_count && urb->status != -ESHUTDOWN) {
 			err = usb_submit_urb(urb, GFP_ATOMIC);
 			if (err)
-				printk(KERN_ERR "%s: resubmit read urb failed. (%d)", __FUNCTION__, err);
+				printk(KERN_ERR "%s: resubmit read urb failed. "
+					"(%d)", __FUNCTION__, err);
 		}
 	}
 	return;
 }
 
-static void
-option_outdat_callback (struct urb *urb, struct pt_regs *regs)
+static void option_outdat_callback(struct urb *urb, struct pt_regs *regs)
 {
 	struct usb_serial_port *port;
 
@@ -376,8 +364,7 @@
 		schedule_work(&port->work);
 }
 
-static void
-option_instat_callback (struct urb *urb, struct pt_regs *regs)
+static void option_instat_callback(struct urb *urb, struct pt_regs *regs)
 {
 	int err;
 	struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
@@ -395,10 +382,12 @@
 			dbg("%s: NULL req_pkt\n", __FUNCTION__);
 			return;
 		}
-		if ((req_pkt->bRequestType == 0xA1) && (req_pkt->bRequest == 0x20)) {
+		if ((req_pkt->bRequestType == 0xA1) &&
+				(req_pkt->bRequest == 0x20)) {
 			int old_dcd_state;
 			unsigned char signals = *((unsigned char *)
-					urb->transfer_buffer + sizeof(struct usb_ctrlrequest));
+					urb->transfer_buffer +
+					sizeof(struct usb_ctrlrequest));
 
 			dbg("%s: signal x%x", __FUNCTION__, signals);
 
@@ -408,12 +397,13 @@
 			portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
 			portdata->ri_state = ((signals & 0x08) ? 1 : 0);
 
-			if (port->tty && !C_CLOCAL(port->tty)
-					&& old_dcd_state && !portdata->dcd_state) {
+			if (port->tty && !C_CLOCAL(port->tty) &&
+					old_dcd_state && !portdata->dcd_state)
 				tty_hangup(port->tty);
-			}
-		} else
-			dbg("%s: type %x req %x", __FUNCTION__, req_pkt->bRequestType,req_pkt->bRequest);
+		} else {
+			dbg("%s: type %x req %x", __FUNCTION__,
+				req_pkt->bRequestType,req_pkt->bRequest);
+		}
 	} else
 		dbg("%s: error %d", __FUNCTION__, urb->status);
 
@@ -422,13 +412,12 @@
 		urb->dev = serial->dev;
 		err = usb_submit_urb(urb, GFP_ATOMIC);
 		if (err)
-			dbg("%s: resubmit intr urb failed. (%d)", __FUNCTION__, err);
+			dbg("%s: resubmit intr urb failed. (%d)",
+				__FUNCTION__, err);
 	}
 }
 
-
-static int
-option_write_room (struct usb_serial_port *port)
+static int option_write_room(struct usb_serial_port *port)
 {
 	struct option_port_private *portdata;
 	int i;
@@ -447,9 +436,7 @@
 	return data_len;
 }
 
-
-static int
-option_chars_in_buffer (struct usb_serial_port *port)
+static int option_chars_in_buffer(struct usb_serial_port *port)
 {
 	struct option_port_private *portdata;
 	int i;
@@ -467,9 +454,7 @@
 	return data_len;
 }
 
-
-static int
-option_open (struct usb_serial_port *port, struct file *filp)
+static int option_open(struct usb_serial_port *port, struct file *filp)
 {
 	struct option_port_private *portdata;
 	struct usb_serial *serial = port->serial;
@@ -490,17 +475,21 @@
 		if (! urb)
 			continue;
 		if (urb->dev != serial->dev) {
-			dbg("%s: dev %p != %p", __FUNCTION__, urb->dev, serial->dev);
+			dbg("%s: dev %p != %p", __FUNCTION__,
+				urb->dev, serial->dev);
 			continue;
 		}
 
-		/* 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);
 
 		err = usb_submit_urb(urb, GFP_KERNEL);
 		if (err) {
-			dbg("%s: submit urb %d failed (%d) %d", __FUNCTION__, i, err,
+			dbg("%s: submit urb %d failed (%d) %d",
+				__FUNCTION__, i, err,
 				urb->transfer_buffer_length);
 		}
 	}
@@ -511,7 +500,8 @@
 		if (! urb)
 			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); */
 	}
 
 	port->tty->low_latency = 1;
@@ -521,8 +511,7 @@
 	return (0);
 }
 
-static inline void
-stop_urb (struct urb *urb)
+static inline void stop_urb(struct urb *urb)
 {
 	if (urb && urb->status == -EINPROGRESS) {
 		urb->transfer_flags &= ~URB_ASYNC_UNLINK;
@@ -530,8 +519,7 @@
 	}
 }
 
-static void
-option_close (struct usb_serial_port *port, struct file *filp)
+static void option_close(struct usb_serial_port *port, struct file *filp)
 {
 	int i;
 	struct usb_serial *serial = port->serial;
@@ -555,12 +543,10 @@
 	port->tty = NULL;
 }
 
-
 /* Helper functions used by option_setup_urbs */
-static struct urb *
-option_setup_urb (struct usb_serial *serial, int endpoint,
-                  int dir, void *ctx, char *buf, int len,
-                  void (*callback)(struct urb *, struct pt_regs *regs))
+static struct urb *option_setup_urb(struct usb_serial *serial, int endpoint,
+		int dir, void *ctx, char *buf, int len,
+		void (*callback)(struct urb *, struct pt_regs *regs))
 {
 	struct urb *urb;
 
@@ -582,8 +568,7 @@
 }
 
 /* Setup urbs */
-static void
-option_setup_urbs (struct usb_serial *serial)
+static void option_setup_urbs(struct usb_serial *serial)
 {
 	int j;
 	struct usb_serial_port *port;
@@ -609,9 +594,7 @@
 	}
 }
 
-
-static int
-option_send_setup (struct usb_serial_port *port)
+static int option_send_setup(struct usb_serial_port *port)
 {
 	struct usb_serial *serial = port->serial;
 	struct option_port_private *portdata;
@@ -627,16 +610,15 @@
 		if (portdata->rts_state)
 			val |= 0x02;
 
-		return usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
-					0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT);
+		return usb_control_msg(serial->dev,
+				usb_rcvctrlpipe(serial->dev, 0),
+				0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT);
 	}
 
 	return 0;
 }
 
-
-static int
-option_startup (struct usb_serial *serial)
+static int option_startup(struct usb_serial *serial)
 {
 	int i, err;
 	struct usb_serial_port *port;
@@ -647,9 +629,10 @@
 	/* Now setup per port private data */
 	for (i = 0; i < serial->num_ports; i++) {
 		port = serial->port[i];
-		portdata = kmalloc(sizeof(struct option_port_private), GFP_KERNEL);
+		portdata = kmalloc(sizeof(*portdata), GFP_KERNEL);
 		if (!portdata) {
-			dbg("%s: kmalloc for option_port_private (%d) failed!.", __FUNCTION__, i);
+			dbg("%s: kmalloc for option_port_private (%d) failed!.",
+					__FUNCTION__, i);
 			return (1);
 		}
 		memset(portdata, 0, sizeof(struct option_port_private));
@@ -660,7 +643,8 @@
 			continue;
 		err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
 		if (err)
-			dbg("%s: submit irq_in urb failed %d", __FUNCTION__, err);
+			dbg("%s: submit irq_in urb failed %d",
+				__FUNCTION__, err);
 	}
 
 	option_setup_urbs(serial);
@@ -668,8 +652,7 @@
 	return (0);
 }
 
-static void
-option_shutdown (struct usb_serial *serial)
+static void option_shutdown(struct usb_serial *serial)
 {
 	int i, j;
 	struct usb_serial_port *port;