[PATCH] USB: option card driver coding style tweaks
authorAndrew Morton <akpm@osdl.org>
Wed, 27 Jul 2005 08:08:30 +0000 (01:08 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 8 Sep 2005 23:22:15 +0000 (16:22 -0700)
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/serial/option.c

index e9256408757ffdf3a7f5cc3a832bf8b503c808c9..4f985f43e79e859cbe8de3a989744c3d8b95955a 100644 (file)
 #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 @@ static int  option_send_setup (struct usb_serial_port *port);
 #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 @@ static int debug;
 #define debug 0
 #endif
 
-
 /* per port private data */
 
 #define N_IN_URB 4
@@ -156,10 +154,8 @@ struct option_port_private {
        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 @@ failed_3port_device_register:
        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 @@ option_exit (void)
 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 @@ option_tiocmget (struct usb_serial_port *port, struct file *file)
        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 @@ option_tiocmset (struct usb_serial_port *port, struct file *file,
        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 @@ option_write (struct usb_serial_port *port,
                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 @@ option_write (struct usb_serial_port *port,
                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 @@ option_write (struct usb_serial_port *port,
        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 @@ option_indat_callback (struct urb *urb, struct pt_regs *regs)
                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 @@ option_outdat_callback (struct urb *urb, struct pt_regs *regs)
                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 @@ option_instat_callback (struct urb *urb, struct pt_regs *regs)
                        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 @@ option_instat_callback (struct urb *urb, struct pt_regs *regs)
                        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 @@ option_instat_callback (struct urb *urb, struct pt_regs *regs)
                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 @@ option_write_room (struct usb_serial_port *port)
        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 @@ option_chars_in_buffer (struct usb_serial_port *port)
        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 @@ option_open (struct usb_serial_port *port, struct file *filp)
                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 @@ option_open (struct usb_serial_port *port, struct file *filp)
                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 @@ option_open (struct usb_serial_port *port, struct file *filp)
        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 @@ stop_urb (struct urb *urb)
        }
 }
 
-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 @@ option_close (struct usb_serial_port *port, struct file *filp)
        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 @@ option_setup_urb (struct usb_serial *serial, int endpoint,
 }
 
 /* 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 @@ option_setup_urbs (struct usb_serial *serial)
        }
 }
 
-
-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 @@ option_send_setup (struct usb_serial_port *port)
                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 @@ option_startup (struct usb_serial *serial)
        /* 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 @@ option_startup (struct usb_serial *serial)
                        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 @@ option_startup (struct usb_serial *serial)
        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;