digi_acceleport: coding style

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>
This commit is contained in:
Alan Cox 2008-07-22 11:11:02 +01:00 committed by Linus Torvalds
parent 77336828c0
commit 41ad427da1

View File

@ -241,7 +241,7 @@
#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>
@ -592,7 +592,8 @@ __releases(lock)
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;
@ -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;
@ -695,7 +697,8 @@ static int digi_write_inb_command(struct usb_serial_port *port,
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)) {
|| 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;
@ -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))
@ -835,7 +843,8 @@ 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);
@ -918,7 +927,8 @@ static void digi_set_termios(struct tty_struct *tty,
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 */
@ -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);
}
@ -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;
@ -1250,11 +1263,13 @@ static void digi_write_bulk_callback(struct urb *urb)
= (unsigned char)DIGI_CMD_SEND_DATA;
*((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,
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;
@ -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);
@ -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;
@ -1627,7 +1646,8 @@ 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);
}
@ -1708,7 +1728,8 @@ static int digi_read_inb_callback(struct urb *urb)
tty_insert_flip_string(tty, data, len);
else {
for (i = 0; i < len; i++)
tty_insert_flip_char(tty, data[i], flag);
tty_insert_flip_char(tty,
data[i], flag);
}
tty_flip_buffer_push(tty);
}
@ -1720,7 +1741,7 @@ 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;
}
@ -1742,6 +1763,7 @@ 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);
@ -1761,28 +1783,30 @@ 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;
else