digi_acceleport: coding style
authorAlan Cox <alan@redhat.com>
Tue, 22 Jul 2008 10:11:02 +0000 (11:11 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 Jul 2008 20:03:23 +0000 (13:03 -0700)
Code tidy

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>
drivers/usb/serial/digi_acceleport.c

index dc92dbfc962e305d7954193be0050fb7bbc2d630..240aad1acaab80f8a802b6b67cd4f3ffed911a9d 100644 (file)
 #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/wait.h>
 #include <linux/usb/serial.h>
@@ -441,8 +441,8 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
        unsigned int modem_signals, int interruptible);
 static int digi_transmit_idle(struct usb_serial_port *port,
        unsigned long timeout);
-static void digi_rx_throttle (struct tty_struct *tty);
-static void digi_rx_unthrottle (struct tty_struct *tty);
+static void digi_rx_throttle(struct tty_struct *tty);
+static void digi_rx_unthrottle(struct tty_struct *tty);
 static void digi_set_termios(struct tty_struct *tty,
                struct usb_serial_port *port, struct ktermios *old_termios);
 static void digi_break_ctl(struct tty_struct *tty, int break_state);
@@ -486,7 +486,7 @@ static struct usb_device_id id_table_4 [] = {
        { }                                             /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table_combined);
+MODULE_DEVICE_TABLE(usb, id_table_combined);
 
 static struct usb_driver digi_driver = {
        .name =         "digi_acceleport",
@@ -555,17 +555,17 @@ static struct usb_serial_driver digi_acceleport_4_device = {
 /* Functions */
 
 /*
-*  Cond Wait Interruptible Timeout Irqrestore
-*
-*  Do spin_unlock_irqrestore and interruptible_sleep_on_timeout
-*  so that wake ups are not lost if they occur between the unlock
-*  and the sleep.  In other words, spin_unlock_irqrestore and
-*  interruptible_sleep_on_timeout are "atomic" with respect to
-*  wake ups.  This is used to implement condition variables.
-*
-*  interruptible_sleep_on_timeout is deprecated and has been replaced
-*  with the equivalent code.
-*/
+ *  Cond Wait Interruptible Timeout Irqrestore
+ *
+ *  Do spin_unlock_irqrestore and interruptible_sleep_on_timeout
+ *  so that wake ups are not lost if they occur between the unlock
+ *  and the sleep.  In other words, spin_unlock_irqrestore and
+ *  interruptible_sleep_on_timeout are "atomic" with respect to
+ *  wake ups.  This is used to implement condition variables.
+ *
+ *  interruptible_sleep_on_timeout is deprecated and has been replaced
+ *  with the equivalent code.
+ */
 
 static long cond_wait_interruptible_timeout_irqrestore(
        wait_queue_head_t *q, long timeout,
@@ -584,15 +584,16 @@ __releases(lock)
 
 
 /*
-*  Digi Wakeup Write
-*
-*  Wake up port, line discipline, and tty processes sleeping
-*  on writes.
-*/
+ *  Digi Wakeup Write
+ *
+ *  Wake up port, line discipline, and tty processes sleeping
+ *  on writes.
+ */
 
 static void digi_wakeup_write_lock(struct work_struct *work)
 {
-       struct digi_port *priv = container_of(work, struct digi_port, dp_wakeup_work);
+       struct digi_port *priv =
+                       container_of(work, struct digi_port, dp_wakeup_work);
        struct usb_serial_port *port = priv->dp_port;
        unsigned long flags;
 
@@ -608,15 +609,15 @@ static void digi_wakeup_write(struct usb_serial_port *port)
 
 
 /*
-*  Digi Write OOB Command
-*
-*  Write commands on the out of band port.  Commands are 4
-*  bytes each, multiple commands can be sent at once, and
-*  no command will be split across USB packets.  Returns 0
-*  if successful, -EINTR if interrupted while sleeping and
-*  the interruptible flag is true, or a negative error
-*  returned by usb_submit_urb.
-*/
+ *  Digi Write OOB Command
+ *
+ *  Write commands on the out of band port.  Commands are 4
+ *  bytes each, multiple commands can be sent at once, and
+ *  no command will be split across USB packets.  Returns 0
+ *  if successful, -EINTR if interrupted while sleeping and
+ *  the interruptible flag is true, or a negative error
+ *  returned by usb_submit_urb.
+ */
 
 static int digi_write_oob_command(struct usb_serial_port *port,
        unsigned char *buf, int count, int interruptible)
@@ -631,8 +632,8 @@ static int digi_write_oob_command(struct usb_serial_port *port,
        dbg("digi_write_oob_command: TOP: port=%d, count=%d", oob_priv->dp_port_num, count);
 
        spin_lock_irqsave(&oob_priv->dp_port_lock, flags);
-       while(count > 0) {
-               while(oob_port->write_urb->status == -EINPROGRESS
+       while (count > 0) {
+               while (oob_port->write_urb->status == -EINPROGRESS
                        || oob_priv->dp_write_urb_in_use) {
                        cond_wait_interruptible_timeout_irqrestore(
                                &oob_port->write_wait, DIGI_RETRY_TIMEOUT,
@@ -649,7 +650,8 @@ static int digi_write_oob_command(struct usb_serial_port *port,
                memcpy(oob_port->write_urb->transfer_buffer, buf, len);
                oob_port->write_urb->transfer_buffer_length = len;
                oob_port->write_urb->dev = port->serial->dev;
-               if ((ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC)) == 0) {
+               ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC);
+               if (ret == 0) {
                        oob_priv->dp_write_urb_in_use = 1;
                        count -= len;
                        buf += len;
@@ -664,16 +666,16 @@ static int digi_write_oob_command(struct usb_serial_port *port,
 
 
 /*
-*  Digi Write In Band Command
-*
-*  Write commands on the given port.  Commands are 4
-*  bytes each, multiple commands can be sent at once, and
-*  no command will be split across USB packets.  If timeout
-*  is non-zero, write in band command will return after
-*  waiting unsuccessfully for the URB status to clear for
-*  timeout ticks.  Returns 0 if successful, or a negative
-*  error returned by digi_write.
-*/
+ *  Digi Write In Band Command
+ *
+ *  Write commands on the given port.  Commands are 4
+ *  bytes each, multiple commands can be sent at once, and
+ *  no command will be split across USB packets.  If timeout
+ *  is non-zero, write in band command will return after
+ *  waiting unsuccessfully for the URB status to clear for
+ *  timeout ticks.  Returns 0 if successful, or a negative
+ *  error returned by digi_write.
+ */
 
 static int digi_write_inb_command(struct usb_serial_port *port,
        unsigned char *buf, int count, unsigned long timeout)
@@ -693,9 +695,10 @@ static int digi_write_inb_command(struct usb_serial_port *port,
                timeout = ULONG_MAX;
 
        spin_lock_irqsave(&priv->dp_port_lock, flags);
-       while(count > 0 && ret == 0) {
-               while((port->write_urb->status == -EINPROGRESS
-                       || priv->dp_write_urb_in_use) && time_before(jiffies, timeout)) {
+       while (count > 0 && ret == 0) {
+               while ((port->write_urb->status == -EINPROGRESS
+                               || priv->dp_write_urb_in_use)
+                                       && time_before(jiffies, timeout)) {
                        cond_wait_interruptible_timeout_irqrestore(
                                &port->write_wait, DIGI_RETRY_TIMEOUT,
                                &priv->dp_port_lock, flags);
@@ -726,7 +729,8 @@ static int digi_write_inb_command(struct usb_serial_port *port,
                }
                port->write_urb->dev = port->serial->dev;
 
-               if ((ret = usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0) {
+               ret = usb_submit_urb(port->write_urb, GFP_ATOMIC);
+               if (ret == 0) {
                        priv->dp_write_urb_in_use = 1;
                        priv->dp_out_buf_len = 0;
                        count -= len;
@@ -744,14 +748,14 @@ static int digi_write_inb_command(struct usb_serial_port *port,
 
 
 /*
-*  Digi Set Modem Signals
-*
-*  Sets or clears DTR and RTS on the port, according to the
-*  modem_signals argument.  Use TIOCM_DTR and TIOCM_RTS flags
-*  for the modem_signals argument.  Returns 0 if successful,
-*  -EINTR if interrupted while sleeping, or a non-zero error
-*  returned by usb_submit_urb.
-*/
+ *  Digi Set Modem Signals
+ *
+ *  Sets or clears DTR and RTS on the port, according to the
+ *  modem_signals argument.  Use TIOCM_DTR and TIOCM_RTS flags
+ *  for the modem_signals argument.  Returns 0 if successful,
+ *  -EINTR if interrupted while sleeping, or a non-zero error
+ *  returned by usb_submit_urb.
+ */
 
 static int digi_set_modem_signals(struct usb_serial_port *port,
        unsigned int modem_signals, int interruptible)
@@ -759,7 +763,7 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
 
        int ret;
        struct digi_port *port_priv = usb_get_serial_port_data(port);
-       struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port;
+       struct usb_serial_port *oob_port = (struct usb_serial_port *) ((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port;
        struct digi_port *oob_priv = usb_get_serial_port_data(oob_port);
        unsigned char *data = oob_port->write_urb->transfer_buffer;
        unsigned long flags = 0;
@@ -771,7 +775,8 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
        spin_lock_irqsave(&oob_priv->dp_port_lock, flags);
        spin_lock(&port_priv->dp_port_lock);
 
-       while(oob_port->write_urb->status == -EINPROGRESS || oob_priv->dp_write_urb_in_use) {
+       while (oob_port->write_urb->status == -EINPROGRESS ||
+                                       oob_priv->dp_write_urb_in_use) {
                spin_unlock(&port_priv->dp_port_lock);
                cond_wait_interruptible_timeout_irqrestore(
                        &oob_port->write_wait, DIGI_RETRY_TIMEOUT,
@@ -783,17 +788,20 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
        }
        data[0] = DIGI_CMD_SET_DTR_SIGNAL;
        data[1] = port_priv->dp_port_num;
-       data[2] = (modem_signals&TIOCM_DTR) ? DIGI_DTR_ACTIVE : DIGI_DTR_INACTIVE;
+       data[2] = (modem_signals & TIOCM_DTR) ?
+                                       DIGI_DTR_ACTIVE : DIGI_DTR_INACTIVE;
        data[3] = 0;
        data[4] = DIGI_CMD_SET_RTS_SIGNAL;
        data[5] = port_priv->dp_port_num;
-       data[6] = (modem_signals&TIOCM_RTS) ? DIGI_RTS_ACTIVE : DIGI_RTS_INACTIVE;
+       data[6] = (modem_signals & TIOCM_RTS) ?
+                                       DIGI_RTS_ACTIVE : DIGI_RTS_INACTIVE;
        data[7] = 0;
 
        oob_port->write_urb->transfer_buffer_length = 8;
        oob_port->write_urb->dev = port->serial->dev;
 
-       if ((ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC)) == 0) {
+       ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC);
+       if (ret == 0) {
                oob_priv->dp_write_urb_in_use = 1;
                port_priv->dp_modem_signals =
                        (port_priv->dp_modem_signals&~(TIOCM_DTR|TIOCM_RTS))
@@ -807,16 +815,16 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
 }
 
 /*
-*  Digi Transmit Idle
-*
-*  Digi transmit idle waits, up to timeout ticks, for the transmitter
-*  to go idle.  It returns 0 if successful or a negative error.
-*
-*  There are race conditions here if more than one process is calling
-*  digi_transmit_idle on the same port at the same time.  However, this
-*  is only called from close, and only one process can be in close on a
-*  port at a time, so its ok.
-*/
+ *  Digi Transmit Idle
+ *
+ *  Digi transmit idle waits, up to timeout ticks, for the transmitter
+ *  to go idle.  It returns 0 if successful or a negative error.
+ *
+ *  There are race conditions here if more than one process is calling
+ *  digi_transmit_idle on the same port at the same time.  However, this
+ *  is only called from close, and only one process can be in close on a
+ *  port at a time, so its ok.
+ */
 
 static int digi_transmit_idle(struct usb_serial_port *port,
        unsigned long timeout)
@@ -835,12 +843,13 @@ static int digi_transmit_idle(struct usb_serial_port *port,
 
        timeout += jiffies;
 
-       if ((ret = digi_write_inb_command(port, buf, 2, timeout - jiffies)) != 0)
+       ret = digi_write_inb_command(port, buf, 2, timeout - jiffies);
+       if (ret != 0)
                return ret;
 
        spin_lock_irqsave(&priv->dp_port_lock, flags);
 
-       while(time_before(jiffies, timeout) && !priv->dp_transmit_idle) {
+       while (time_before(jiffies, timeout) && !priv->dp_transmit_idle) {
                cond_wait_interruptible_timeout_irqrestore(
                        &priv->dp_transmit_idle_wait, DIGI_RETRY_TIMEOUT,
                        &priv->dp_port_lock, flags);
@@ -901,7 +910,7 @@ static void digi_rx_unthrottle(struct tty_struct *tty)
 }
 
 
-static void digi_set_termios(struct tty_struct *tty, 
+static void digi_set_termios(struct tty_struct *tty,
                struct usb_serial_port *port, struct ktermios *old_termios)
 {
        struct digi_port *priv = usb_get_serial_port_data(port);
@@ -911,14 +920,15 @@ static void digi_set_termios(struct tty_struct *tty,
        unsigned int old_cflag = old_termios->c_cflag;
        unsigned char buf[32];
        unsigned int modem_signals;
-       int arg,ret;
+       int arg, ret;
        int i = 0;
        speed_t baud;
 
        dbg("digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, old_cflag=0x%x", priv->dp_port_num, iflag, old_iflag, cflag, old_cflag);
 
        /* set baud rate */
-       if ((baud = tty_get_baud_rate(tty)) != tty_termios_baud_rate(old_termios)) {
+       baud = tty_get_baud_rate(tty);
+       if (baud != tty_termios_baud_rate(old_termios)) {
                arg = -1;
 
                /* reassert DTR and (maybe) RTS on transition from B0 */
@@ -932,30 +942,30 @@ static void digi_set_termios(struct tty_struct *tty,
                        digi_set_modem_signals(port, modem_signals, 1);
                }
                switch (baud) {
-                       /* drop DTR and RTS on transition to B0 */
-                       case 0: digi_set_modem_signals(port, 0, 1); break;
-                       case 50: arg = DIGI_BAUD_50; break;
-                       case 75: arg = DIGI_BAUD_75; break;
-                       case 110: arg = DIGI_BAUD_110; break;
-                       case 150: arg = DIGI_BAUD_150; break;
-                       case 200: arg = DIGI_BAUD_200; break;
-                       case 300: arg = DIGI_BAUD_300; break;
-                       case 600: arg = DIGI_BAUD_600; break;
-                       case 1200: arg = DIGI_BAUD_1200; break;
-                       case 1800: arg = DIGI_BAUD_1800; break;
-                       case 2400: arg = DIGI_BAUD_2400; break;
-                       case 4800: arg = DIGI_BAUD_4800; break;
-                       case 9600: arg = DIGI_BAUD_9600; break;
-                       case 19200: arg = DIGI_BAUD_19200; break;
-                       case 38400: arg = DIGI_BAUD_38400; break;
-                       case 57600: arg = DIGI_BAUD_57600; break;
-                       case 115200: arg = DIGI_BAUD_115200; break;
-                       case 230400: arg = DIGI_BAUD_230400; break;
-                       case 460800: arg = DIGI_BAUD_460800; break;
-                       default:
-                               arg = DIGI_BAUD_9600;
-                               baud = 9600;
-                               break;
+               /* drop DTR and RTS on transition to B0 */
+               case 0: digi_set_modem_signals(port, 0, 1); break;
+               case 50: arg = DIGI_BAUD_50; break;
+               case 75: arg = DIGI_BAUD_75; break;
+               case 110: arg = DIGI_BAUD_110; break;
+               case 150: arg = DIGI_BAUD_150; break;
+               case 200: arg = DIGI_BAUD_200; break;
+               case 300: arg = DIGI_BAUD_300; break;
+               case 600: arg = DIGI_BAUD_600; break;
+               case 1200: arg = DIGI_BAUD_1200; break;
+               case 1800: arg = DIGI_BAUD_1800; break;
+               case 2400: arg = DIGI_BAUD_2400; break;
+               case 4800: arg = DIGI_BAUD_4800; break;
+               case 9600: arg = DIGI_BAUD_9600; break;
+               case 19200: arg = DIGI_BAUD_19200; break;
+               case 38400: arg = DIGI_BAUD_38400; break;
+               case 57600: arg = DIGI_BAUD_57600; break;
+               case 115200: arg = DIGI_BAUD_115200; break;
+               case 230400: arg = DIGI_BAUD_230400; break;
+               case 460800: arg = DIGI_BAUD_460800; break;
+               default:
+                       arg = DIGI_BAUD_9600;
+                       baud = 9600;
+                       break;
                }
                if (arg != -1) {
                        buf[i++] = DIGI_CMD_SET_BAUD_RATE;
@@ -1081,7 +1091,8 @@ static void digi_set_termios(struct tty_struct *tty,
                buf[i++] = arg;
                buf[i++] = 0;
        }
-       if ((ret = digi_write_oob_command(port, buf, i, 1)) != 0)
+       ret = digi_write_oob_command(port, buf, i, 1);
+       if (ret != 0)
                dbg("digi_set_termios: write oob failed, ret=%d", ret);
        tty_encode_baud_rate(tty, baud, baud);
 }
@@ -1137,7 +1148,7 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
                                        const unsigned char *buf, int count)
 {
 
-       int ret,data_len,new_len;
+       int ret, data_len, new_len;
        struct digi_port *priv = usb_get_serial_port_data(port);
        unsigned char *data = port->write_urb->transfer_buffer;
        unsigned long flags = 0;
@@ -1155,7 +1166,8 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
        spin_lock_irqsave(&priv->dp_port_lock, flags);
 
        /* wait for urb status clear to submit another urb */
-       if (port->write_urb->status == -EINPROGRESS || priv->dp_write_urb_in_use) {
+       if (port->write_urb->status == -EINPROGRESS ||
+                                       priv->dp_write_urb_in_use) {
                /* buffer data if count is 1 (probably put_char) if possible */
                if (count == 1 && priv->dp_out_buf_len < DIGI_OUT_BUF_SIZE) {
                        priv->dp_out_buf[priv->dp_out_buf_len++] = *buf;
@@ -1190,7 +1202,8 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
        /* copy in new data */
        memcpy(data, buf, new_len);
 
-       if ((ret = usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0) {
+       ret = usb_submit_urb(port->write_urb, GFP_ATOMIC);
+       if (ret == 0) {
                priv->dp_write_urb_in_use = 1;
                ret = new_len;
                priv->dp_out_buf_len = 0;
@@ -1204,7 +1217,7 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
        dbg("digi_write: returning %d", ret);
        return ret;
 
-} 
+}
 
 static void digi_write_bulk_callback(struct urb *urb)
 {
@@ -1219,13 +1232,13 @@ static void digi_write_bulk_callback(struct urb *urb)
        dbg("digi_write_bulk_callback: TOP, urb->status=%d", status);
 
        /* port and serial sanity check */
-       if (port == NULL || (priv=usb_get_serial_port_data(port)) == NULL) {
+       if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) {
                err("%s: port or port->private is NULL, status=%d",
                    __func__, status);
                return;
        }
        serial = port->serial;
-       if (serial == NULL || (serial_priv=usb_get_serial_data(serial)) == NULL) {
+       if (serial == NULL || (serial_priv = usb_get_serial_data(serial)) == NULL) {
                err("%s: serial or serial->private is NULL, status=%d",
                    __func__, status);
                return;
@@ -1248,13 +1261,15 @@ static void digi_write_bulk_callback(struct urb *urb)
            && priv->dp_out_buf_len > 0) {
                *((unsigned char *)(port->write_urb->transfer_buffer))
                        = (unsigned char)DIGI_CMD_SEND_DATA;
-               *((unsigned char *)(port->write_urb->transfer_buffer)+1)
+               *((unsigned char *)(port->write_urb->transfer_buffer) + 1)
                        = (unsigned char)priv->dp_out_buf_len;
-               port->write_urb->transfer_buffer_length = priv->dp_out_buf_len+2;
+               port->write_urb->transfer_buffer_length =
+                                               priv->dp_out_buf_len + 2;
                port->write_urb->dev = serial->dev;
-               memcpy(port->write_urb->transfer_buffer+2, priv->dp_out_buf,
+               memcpy(port->write_urb->transfer_buffer + 2, priv->dp_out_buf,
                        priv->dp_out_buf_len);
-               if ((ret = usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0) {
+               ret = usb_submit_urb(port->write_urb, GFP_ATOMIC);
+               if (ret == 0) {
                        priv->dp_write_urb_in_use = 1;
                        priv->dp_out_buf_len = 0;
                }
@@ -1280,7 +1295,8 @@ static int digi_write_room(struct tty_struct *tty)
 
        spin_lock_irqsave(&priv->dp_port_lock, flags);
 
-       if (port->write_urb->status == -EINPROGRESS || priv->dp_write_urb_in_use)
+       if (port->write_urb->status == -EINPROGRESS ||
+                                       priv->dp_write_urb_in_use)
                room = 0;
        else
                room = port->bulk_out_size - 2 - priv->dp_out_buf_len;
@@ -1336,7 +1352,7 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port,
        }
 
        /* wait for a close in progress to finish */
-       while(priv->dp_in_close) {
+       while (priv->dp_in_close) {
                cond_wait_interruptible_timeout_irqrestore(
                        &priv->dp_close_wait, DIGI_RETRY_TIMEOUT,
                        &priv->dp_port_lock, flags);
@@ -1346,7 +1362,7 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port,
        }
 
        spin_unlock_irqrestore(&priv->dp_port_lock, flags);
+
        /* read modem signals automatically whenever they change */
        buf[0] = DIGI_CMD_READ_INPUT_SIGNALS;
        buf[1] = priv->dp_port_num;
@@ -1359,7 +1375,8 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port,
        buf[6] = DIGI_FLUSH_TX | DIGI_FLUSH_RX;
        buf[7] = 0;
 
-       if ((ret = digi_write_oob_command(port, buf, 8, 1)) != 0)
+       ret = digi_write_oob_command(port, buf, 8, 1);
+       if (ret != 0)
                dbg("digi_open: write oob failed, ret=%d", ret);
 
        /* set termios settings */
@@ -1410,9 +1427,8 @@ static void digi_close(struct tty_struct *tty, struct usb_serial_port *port,
 
        if (port->serial->dev) {
                /* wait for transmit idle */
-               if ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0) {
+               if ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0)
                        digi_transmit_idle(port, DIGI_CLOSE_TIMEOUT);
-               }
                /* drop DTR and RTS */
                digi_set_modem_signals(port, 0, 0);
 
@@ -1446,11 +1462,13 @@ static void digi_close(struct tty_struct *tty, struct usb_serial_port *port,
                buf[18] = DIGI_FLUSH_TX | DIGI_FLUSH_RX;
                buf[19] = 0;
 
-               if ((ret = digi_write_oob_command(port, buf, 20, 0)) != 0)
+               ret = digi_write_oob_command(port, buf, 20, 0);
+               if (ret != 0)
                        dbg("digi_close: write oob failed, ret=%d", ret);
 
                /* wait for final commands on oob port to complete */
-               prepare_to_wait(&priv->dp_flush_wait, &wait, TASK_INTERRUPTIBLE);
+               prepare_to_wait(&priv->dp_flush_wait, &wait,
+                                                       TASK_INTERRUPTIBLE);
                schedule_timeout(DIGI_CLOSE_TIMEOUT);
                finish_wait(&priv->dp_flush_wait, &wait);
 
@@ -1470,15 +1488,15 @@ exit:
 
 
 /*
-*  Digi Startup Device
-*
-*  Starts reads on all ports.  Must be called AFTER startup, with
-*  urbs initialized.  Returns 0 if successful, non-zero error otherwise.
-*/
+ *  Digi Startup Device
+ *
+ *  Starts reads on all ports.  Must be called AFTER startup, with
+ *  urbs initialized.  Returns 0 if successful, non-zero error otherwise.
+ */
 
 static int digi_startup_device(struct usb_serial *serial)
 {
-       int i,ret = 0;
+       int i, ret = 0;
        struct digi_serial *serial_priv = usb_get_serial_data(serial);
        struct usb_serial_port *port;
 
@@ -1496,7 +1514,8 @@ static int digi_startup_device(struct usb_serial *serial)
        for (i = 0; i < serial->type->num_ports + 1; i++) {
                port = serial->port[i];
                port->write_urb->dev = port->serial->dev;
-               if ((ret = usb_submit_urb(port->read_urb, GFP_KERNEL)) != 0) {
+               ret = usb_submit_urb(port->read_urb, GFP_KERNEL);
+               if (ret != 0) {
                        err("%s: usb_submit_urb failed, ret=%d, port=%d",
                                        __func__, ret, i);
                        break;
@@ -1517,7 +1536,7 @@ static int digi_startup(struct usb_serial *serial)
 
        /* allocate the private data structures for all ports */
        /* number of regular ports + 1 for the out-of-band port */
-       for(i = 0; i < serial->type->num_ports + 1; i++) {
+       for (i = 0; i < serial->type->num_ports + 1; i++) {
                /* allocate port private structure */
                priv = kmalloc(sizeof(struct digi_port), GFP_KERNEL);
                if (priv == NULL) {
@@ -1580,7 +1599,7 @@ static void digi_shutdown(struct usb_serial *serial)
 
        /* free the private data structures for all ports */
        /* number of regular ports + 1 for the out-of-band port */
-       for(i = 0; i < serial->type->num_ports + 1; i++)
+       for (i = 0; i < serial->type->num_ports + 1; i++)
                kfree(usb_get_serial_port_data(serial->port[i]));
        kfree(usb_get_serial_data(serial));
 }
@@ -1603,7 +1622,7 @@ static void digi_read_bulk_callback(struct urb *urb)
                return;
        }
        if (port->serial == NULL ||
-               (serial_priv=usb_get_serial_data(port->serial)) == NULL) {
+               (serial_priv = usb_get_serial_data(port->serial)) == NULL) {
                err("%s: serial is bad or serial->private is NULL, status=%d",
                        __func__, status);
                return;
@@ -1627,22 +1646,23 @@ static void digi_read_bulk_callback(struct urb *urb)
 
        /* continue read */
        urb->dev = port->serial->dev;
-       if ((ret = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
+       ret = usb_submit_urb(urb, GFP_ATOMIC);
+       if (ret != 0) {
                err("%s: failed resubmitting urb, ret=%d, port=%d",
                    __func__, ret, priv->dp_port_num);
        }
 
 }
 
-/* 
-*  Digi Read INB Callback
-*
-*  Digi Read INB Callback handles reads on the in band ports, sending
-*  the data on to the tty subsystem.  When called we know port and
-*  port->private are not NULL and port->serial has been validated.
-*  It returns 0 if successful, 1 if successful but the port is
-*  throttled, and -1 if the sanity checks failed.
-*/
+/*
+ *  Digi Read INB Callback
+ *
+ *  Digi Read INB Callback handles reads on the in band ports, sending
+ *  the data on to the tty subsystem.  When called we know port and
+ *  port->private are not NULL and port->serial has been validated.
+ *  It returns 0 if successful, 1 if successful but the port is
+ *  throttled, and -1 if the sanity checks failed.
+ */
 
 static int digi_read_inb_callback(struct urb *urb)
 {
@@ -1653,8 +1673,8 @@ static int digi_read_inb_callback(struct urb *urb)
        int opcode = ((unsigned char *)urb->transfer_buffer)[0];
        int len = ((unsigned char *)urb->transfer_buffer)[1];
        int port_status = ((unsigned char *)urb->transfer_buffer)[2];
-       unsigned char *data = ((unsigned char *)urb->transfer_buffer)+3;
-       int flag,throttled;
+       unsigned char *data = ((unsigned char *)urb->transfer_buffer) + 3;
+       int flag, throttled;
        int i;
        int status = urb->status;
 
@@ -1665,7 +1685,7 @@ static int digi_read_inb_callback(struct urb *urb)
 
        /* short/multiple packet check */
        if (urb->actual_length != len + 2) {
-               err("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, "
+               err("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, "
                    "port=%d, opcode=%d, len=%d, actual_length=%d, "
                    "status=%d", __func__, status, priv->dp_port_num,
                    opcode, len, urb->actual_length, port_status);
@@ -1707,8 +1727,9 @@ static int digi_read_inb_callback(struct urb *urb)
                        if (flag == TTY_NORMAL)
                                tty_insert_flip_string(tty, data, len);
                        else {
-                               for(i = 0; i < len; i++)
-                                       tty_insert_flip_char(tty, data[i], flag);
+                               for (i = 0; i < len; i++)
+                                       tty_insert_flip_char(tty,
+                                                               data[i], flag);
                        }
                        tty_flip_buffer_push(tty);
                }
@@ -1720,19 +1741,19 @@ static int digi_read_inb_callback(struct urb *urb)
        else if (opcode != DIGI_CMD_RECEIVE_DATA)
                dbg("%s: unknown opcode: %d", __func__, opcode);
 
-       return(throttled ? 1 : 0);
+       return throttled ? 1 : 0;
 
 }
 
 
-/* 
-*  Digi Read OOB Callback
-*
-*  Digi Read OOB Callback handles reads on the out of band port.
-*  When called we know port and port->private are not NULL and
-*  the port->serial is valid.  It returns 0 if successful, and
-*  -1 if the sanity checks failed.
-*/
+/*
+ *  Digi Read OOB Callback
+ *
+ *  Digi Read OOB Callback handles reads on the out of band port.
+ *  When called we know port and port->private are not NULL and
+ *  the port->serial is valid.  It returns 0 if successful, and
+ *  -1 if the sanity checks failed.
+ */
 
 static int digi_read_oob_callback(struct urb *urb)
 {
@@ -1742,12 +1763,13 @@ static int digi_read_oob_callback(struct urb *urb)
        struct digi_port *priv = usb_get_serial_port_data(port);
        int opcode, line, status, val;
        int i;
+       unsigned int rts;
 
        dbg("digi_read_oob_callback: port=%d, len=%d",
                        priv->dp_port_num, urb->actual_length);
 
        /* handle each oob command */
-       for(i = 0; i < urb->actual_length - 3;) {
+       for (i = 0; i < urb->actual_length - 3;) {
                opcode = ((unsigned char *)urb->transfer_buffer)[i++];
                line = ((unsigned char *)urb->transfer_buffer)[i++];
                status = ((unsigned char *)urb->transfer_buffer)[i++];
@@ -1761,27 +1783,29 @@ static int digi_read_oob_callback(struct urb *urb)
 
                port = serial->port[line];
 
-               if ((priv=usb_get_serial_port_data(port)) == NULL)
+               priv = usb_get_serial_port_data(port);
+               if (priv == NULL)
                        return -1;
 
+               rts = 0;
+               if (port->port.count)
+                       rts = port->port.tty->termios->c_cflag & CRTSCTS;
+
                if (opcode == DIGI_CMD_READ_INPUT_SIGNALS) {
                        spin_lock(&priv->dp_port_lock);
                        /* convert from digi flags to termiox flags */
                        if (val & DIGI_READ_INPUT_SIGNALS_CTS) {
                                priv->dp_modem_signals |= TIOCM_CTS;
                                /* port must be open to use tty struct */
-                               if (port->port.count
-                                       && port->port.tty->termios->c_cflag & CRTSCTS) {
+                               if (rts) {
                                        port->port.tty->hw_stopped = 0;
                                        digi_wakeup_write(port);
                                }
                        } else {
                                priv->dp_modem_signals &= ~TIOCM_CTS;
                                /* port must be open to use tty struct */
-                               if (port->port.count
-                                       && port->port.tty->termios->c_cflag & CRTSCTS) {
+                               if (rts)
                                        port->port.tty->hw_stopped = 1;
-                               }
                        }
                        if (val & DIGI_READ_INPUT_SIGNALS_DSR)
                                priv->dp_modem_signals |= TIOCM_DSR;
@@ -1818,7 +1842,7 @@ static int __init digi_init(void)
        if (retval)
                goto failed_acceleport_2_device;
        retval = usb_serial_register(&digi_acceleport_4_device);
-       if (retval) 
+       if (retval)
                goto failed_acceleport_4_device;
        retval = usb_register(&digi_driver);
        if (retval)