[PATCH 00/70] tty updates proposed for 2.6.27 - Kernel

This is a discussion on [PATCH 00/70] tty updates proposed for 2.6.27 - Kernel ; From: Alan Cox Signed-off-by: Alan Cox --- drivers/usb/serial/mct_u232.c | 273 +++++++++++++++++++++-------------------- 1 files changed, 141 insertions(+), 132 deletions(-) diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index 7bce430..7a804d6 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c @@ -33,10 +33,11 @@ * - Fixed an endianess problem with ...

+ Reply to Thread
Page 3 of 4 FirstFirst 1 2 3 4 LastLast
Results 41 to 60 of 77

Thread: [PATCH 00/70] tty updates proposed for 2.6.27

  1. [PATCH 57/70] tty-usb-mct-u232: Coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/mct_u232.c | 273 +++++++++++++++++++++--------------------
    1 files changed, 141 insertions(+), 132 deletions(-)


    diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
    index 7bce430..7a804d6 100644
    --- a/drivers/usb/serial/mct_u232.c
    +++ b/drivers/usb/serial/mct_u232.c
    @@ -33,10 +33,11 @@
    * - Fixed an endianess problem with the baudrate selection for PowerPC.
    *
    * 06-Dec-2001 Martin Hamilton
    - * Added support for the Belkin F5U109 DB9 adaptor
    + * - Added support for the Belkin F5U109 DB9 adaptor
    *
    * 30-May-2001 Greg Kroah-Hartman
    - * switched from using spinlock to a semaphore, which fixes lots of problems.
    + * - switched from using spinlock to a semaphore, which fixes lots of
    + * problems.
    *
    * 04-May-2001 Stelian Pop
    * - Set the maximum bulk output size for Sitecom U232-P25 model to 16 bytes
    @@ -49,7 +50,7 @@
    * 08-Apr-2001 gb
    * - Identify version on module load.
    *
    - * 06-Jan-2001 Cornel Ciocirlan
    + * 06-Jan-2001 Cornel Ciocirlan
    * - Added support for Sitecom U232-P25 model (Product Id 0x0230)
    * - Added support for D-Link DU-H3SP USB BAY (Product Id 0x0200)
    *
    @@ -59,8 +60,8 @@
    * (lots of things will change if/when the usb-serial core changes to
    * handle these issues.
    *
    - * 27-Nov-2000 Wolfgang Grandegger
    - * A version for kernel 2.4.0-test10 released to the Linux community
    + * 27-Nov-2000 Wolfgang Grandegge
    + * A version for kernel 2.4.0-test10 released to the Linux community
    * (via linux-usb-devel).
    */

    @@ -73,7 +74,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include
    #include "mct_u232.h"
    @@ -90,27 +91,21 @@ static int debug;
    /*
    * Function prototypes
    */
    -static int mct_u232_startup (struct usb_serial *serial);
    -static void mct_u232_shutdown (struct usb_serial *serial);
    -static int mct_u232_open (struct tty_struct *tty,
    - struct usb_serial_port *port,
    - struct file *filp);
    -static void mct_u232_close (struct tty_struct *tty,
    - struct usb_serial_port *port,
    - struct file *filp);
    -static void mct_u232_read_int_callback (struct urb *urb);
    -static void mct_u232_set_termios (struct tty_struct *tty,
    - struct usb_serial_port *port,
    - struct ktermios * old);
    -static void mct_u232_break_ctl (struct tty_struct *tty,
    - int break_state );
    -static int mct_u232_tiocmget (struct tty_struct *tty,
    - struct file *file);
    -static int mct_u232_tiocmset (struct tty_struct *tty,
    - struct file *file, unsigned int set,
    - unsigned int clear);
    -static void mct_u232_throttle (struct tty_struct *tty);
    -static void mct_u232_unthrottle (struct tty_struct *tty);
    +static int mct_u232_startup(struct usb_serial *serial);
    +static void mct_u232_shutdown(struct usb_serial *serial);
    +static int mct_u232_open(struct tty_struct *tty,
    + struct usb_serial_port *port, struct file *filp);
    +static void mct_u232_close(struct tty_struct *tty,
    + struct usb_serial_port *port, struct file *filp);
    +static void mct_u232_read_int_callback(struct urb *urb);
    +static void mct_u232_set_termios(struct tty_struct *tty,
    + struct usb_serial_port *port, struct ktermios *old);
    +static void mct_u232_break_ctl(struct tty_struct *tty, int break_state);
    +static int mct_u232_tiocmget(struct tty_struct *tty, struct file *file);
    +static int mct_u232_tiocmset(struct tty_struct *tty, struct file *file,
    + unsigned int set, unsigned int clear);
    +static void mct_u232_throttle(struct tty_struct *tty);
    +static void mct_u232_unthrottle(struct tty_struct *tty);


    /*
    @@ -124,7 +119,7 @@ static struct usb_device_id id_table_combined [] = {
    { } /* Terminating entry */
    };

    -MODULE_DEVICE_TABLE (usb, id_table_combined);
    +MODULE_DEVICE_TABLE(usb, id_table_combined);

    static struct usb_driver mct_u232_driver = {
    .name = "mct_u232",
    @@ -178,23 +173,34 @@ struct mct_u232_private {
    * Later day 2.6.0-test kernels have new baud rates like B230400 which
    * we do not know how to support. We ignore them for the moment.
    */
    -static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value, speed_t *result)
    +static int mct_u232_calculate_baud_rate(struct usb_serial *serial,
    + speed_t value, speed_t *result)
    {
    *result = value;

    if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID
    - || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) {
    + || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) {
    switch (value) {
    - case 300: return 0x01;
    - case 600: return 0x02; /* this one not tested */
    - case 1200: return 0x03;
    - case 2400: return 0x04;
    - case 4800: return 0x06;
    - case 9600: return 0x08;
    - case 19200: return 0x09;
    - case 38400: return 0x0a;
    - case 57600: return 0x0b;
    - case 115200: return 0x0c;
    + case 300:
    + return 0x01;
    + case 600:
    + return 0x02; /* this one not tested */
    + case 1200:
    + return 0x03;
    + case 2400:
    + return 0x04;
    + case 4800:
    + return 0x06;
    + case 9600:
    + return 0x08;
    + case 19200:
    + return 0x09;
    + case 38400:
    + return 0x0a;
    + case 57600:
    + return 0x0b;
    + case 115200:
    + return 0x0c;
    default:
    *result = 9600;
    return 0x08;
    @@ -226,18 +232,19 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,
    struct usb_serial *serial, struct usb_serial_port *port, speed_t value)
    {
    __le32 divisor;
    - int rc;
    - unsigned char zero_byte = 0;
    - unsigned char cts_enable_byte = 0;
    - speed_t speed;
    -
    - divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value, &speed));
    -
    - rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
    - MCT_U232_SET_BAUD_RATE_REQUEST,
    - MCT_U232_SET_REQUEST_TYPE,
    - 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE,
    - WDR_TIMEOUT);
    + int rc;
    + unsigned char zero_byte = 0;
    + unsigned char cts_enable_byte = 0;
    + speed_t speed;
    +
    + divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value,
    + &speed));
    +
    + rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
    + MCT_U232_SET_BAUD_RATE_REQUEST,
    + MCT_U232_SET_REQUEST_TYPE,
    + 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE,
    + WDR_TIMEOUT);
    if (rc < 0) /*FIXME: What value speed results */
    err("Set BAUD RATE %d failed (error = %d)", value, rc);
    else
    @@ -256,55 +263,55 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,
    whether data will be transmitted to a device which is not asserting
    the 'CTS' signal. If the second message's data byte is zero, data
    will be transmitted even if 'CTS' is not asserted (i.e. no hardware
    - flow control). if the second message's data byte is nonzero (a value
    - of 1 is used by this driver), data will not be transmitted to a device
    - which is not asserting 'CTS'.
    + flow control). if the second message's data byte is nonzero (a
    + value of 1 is used by this driver), data will not be transmitted to
    + a device which is not asserting 'CTS'.
    */

    rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
    - MCT_U232_SET_UNKNOWN1_REQUEST,
    - MCT_U232_SET_REQUEST_TYPE,
    - 0, 0, &zero_byte, MCT_U232_SET_UNKNOWN1_SIZE,
    - WDR_TIMEOUT);
    + MCT_U232_SET_UNKNOWN1_REQUEST,
    + MCT_U232_SET_REQUEST_TYPE,
    + 0, 0, &zero_byte, MCT_U232_SET_UNKNOWN1_SIZE,
    + WDR_TIMEOUT);
    if (rc < 0)
    - err("Sending USB device request code %d failed (error = %d)",
    + err("Sending USB device request code %d failed (error = %d)",
    MCT_U232_SET_UNKNOWN1_REQUEST, rc);

    - if (port && C_CRTSCTS(tty)) {
    + if (port && C_CRTSCTS(tty))
    cts_enable_byte = 1;
    - }

    - dbg("set_baud_rate: send second control message, data = %02X", cts_enable_byte);
    + dbg("set_baud_rate: send second control message, data = %02X",
    + cts_enable_byte);
    rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
    - MCT_U232_SET_CTS_REQUEST,
    - MCT_U232_SET_REQUEST_TYPE,
    - 0, 0, &cts_enable_byte, MCT_U232_SET_CTS_SIZE,
    - WDR_TIMEOUT);
    + MCT_U232_SET_CTS_REQUEST,
    + MCT_U232_SET_REQUEST_TYPE,
    + 0, 0, &cts_enable_byte, MCT_U232_SET_CTS_SIZE,
    + WDR_TIMEOUT);
    if (rc < 0)
    - err("Sending USB device request code %d failed (error = %d)",
    - MCT_U232_SET_CTS_REQUEST, rc);
    + err("Sending USB device request code %d failed (error = %d)",
    + MCT_U232_SET_CTS_REQUEST, rc);

    - return rc;
    + return rc;
    } /* mct_u232_set_baud_rate */

    static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr)
    {
    - int rc;
    - rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
    - MCT_U232_SET_LINE_CTRL_REQUEST,
    - MCT_U232_SET_REQUEST_TYPE,
    - 0, 0, &lcr, MCT_U232_SET_LINE_CTRL_SIZE,
    - WDR_TIMEOUT);
    + int rc;
    + rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
    + MCT_U232_SET_LINE_CTRL_REQUEST,
    + MCT_U232_SET_REQUEST_TYPE,
    + 0, 0, &lcr, MCT_U232_SET_LINE_CTRL_SIZE,
    + WDR_TIMEOUT);
    if (rc < 0)
    err("Set LINE CTRL 0x%x failed (error = %d)", lcr, rc);
    dbg("set_line_ctrl: 0x%x", lcr);
    - return rc;
    + return rc;
    } /* mct_u232_set_line_ctrl */

    static int mct_u232_set_modem_ctrl(struct usb_serial *serial,
    unsigned int control_state)
    {
    - int rc;
    + int rc;
    unsigned char mcr = MCT_U232_MCR_NONE;

    if (control_state & TIOCM_DTR)
    @@ -312,37 +319,39 @@ static int mct_u232_set_modem_ctrl(struct usb_serial *serial,
    if (control_state & TIOCM_RTS)
    mcr |= MCT_U232_MCR_RTS;

    - rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
    - MCT_U232_SET_MODEM_CTRL_REQUEST,
    - MCT_U232_SET_REQUEST_TYPE,
    - 0, 0, &mcr, MCT_U232_SET_MODEM_CTRL_SIZE,
    - WDR_TIMEOUT);
    + rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
    + MCT_U232_SET_MODEM_CTRL_REQUEST,
    + MCT_U232_SET_REQUEST_TYPE,
    + 0, 0, &mcr, MCT_U232_SET_MODEM_CTRL_SIZE,
    + WDR_TIMEOUT);
    if (rc < 0)
    err("Set MODEM CTRL 0x%x failed (error = %d)", mcr, rc);
    dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr);

    - return rc;
    + return rc;
    } /* mct_u232_set_modem_ctrl */

    -static int mct_u232_get_modem_stat(struct usb_serial *serial, unsigned char *msr)
    +static int mct_u232_get_modem_stat(struct usb_serial *serial,
    + unsigned char *msr)
    {
    - int rc;
    - rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
    - MCT_U232_GET_MODEM_STAT_REQUEST,
    - MCT_U232_GET_REQUEST_TYPE,
    - 0, 0, msr, MCT_U232_GET_MODEM_STAT_SIZE,
    - WDR_TIMEOUT);
    + int rc;
    + rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
    + MCT_U232_GET_MODEM_STAT_REQUEST,
    + MCT_U232_GET_REQUEST_TYPE,
    + 0, 0, msr, MCT_U232_GET_MODEM_STAT_SIZE,
    + WDR_TIMEOUT);
    if (rc < 0) {
    err("Get MODEM STATus failed (error = %d)", rc);
    *msr = 0;
    }
    dbg("get_modem_stat: 0x%x", *msr);
    - return rc;
    + return rc;
    } /* mct_u232_get_modem_stat */

    -static void mct_u232_msr_to_state(unsigned int *control_state, unsigned char msr)
    +static void mct_u232_msr_to_state(unsigned int *control_state,
    + unsigned char msr)
    {
    - /* Translate Control Line states */
    + /* Translate Control Line states */
    if (msr & MCT_U232_MSR_DSR)
    *control_state |= TIOCM_DSR;
    else
    @@ -359,14 +368,14 @@ static void mct_u232_msr_to_state(unsigned int *control_state, unsigned char msr
    *control_state |= TIOCM_CD;
    else
    *control_state &= ~TIOCM_CD;
    - dbg("msr_to_state: msr=0x%x ==> state=0x%x", msr, *control_state);
    + dbg("msr_to_state: msr=0x%x ==> state=0x%x", msr, *control_state);
    } /* mct_u232_msr_to_state */

    /*
    * Driver's tty interface functions
    */

    -static int mct_u232_startup (struct usb_serial *serial)
    +static int mct_u232_startup(struct usb_serial *serial)
    {
    struct mct_u232_private *priv;
    struct usb_serial_port *port, *rport;
    @@ -388,18 +397,18 @@ static int mct_u232_startup (struct usb_serial *serial)
    rport->interrupt_in_urb = NULL;
    port->read_urb->context = port;

    - return (0);
    + return 0;
    } /* mct_u232_startup */


    -static void mct_u232_shutdown (struct usb_serial *serial)
    +static void mct_u232_shutdown(struct usb_serial *serial)
    {
    struct mct_u232_private *priv;
    int i;
    -
    +
    dbg("%s", __func__);

    - for (i=0; i < serial->num_ports; ++i) {
    + for (i = 0; i < serial->num_ports; ++i) {
    /* My special items, the standard routines free my urbs */
    priv = usb_get_serial_port_data(serial->port[i]);
    if (priv) {
    @@ -409,7 +418,7 @@ static void mct_u232_shutdown (struct usb_serial *serial)
    }
    } /* mct_u232_shutdown */

    -static int mct_u232_open (struct tty_struct *tty,
    +static int mct_u232_open(struct tty_struct *tty,
    struct usb_serial_port *port, struct file *filp)
    {
    struct usb_serial *serial = port->serial;
    @@ -427,10 +436,11 @@ static int mct_u232_open (struct tty_struct *tty,
    * it seems to be able to accept only 16 bytes (and that's what
    * SniffUSB says too...)
    */
    - if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID)
    + if (le16_to_cpu(serial->dev->descriptor.idProduct)
    + == MCT_U232_SITECOM_PID)
    port->bulk_out_size = 16;

    - /* Do a defined restart: the normal serial device seems to
    + /* Do a defined restart: the normal serial device seems to
    * always turn on DTR and RTS here, so do the same. I'm not
    * sure if this is really necessary. But it should not harm
    * either.
    @@ -440,8 +450,8 @@ static int mct_u232_open (struct tty_struct *tty,
    priv->control_state = TIOCM_DTR | TIOCM_RTS;
    else
    priv->control_state = 0;
    -
    - priv->last_lcr = (MCT_U232_DATA_BITS_8 |
    +
    + priv->last_lcr = (MCT_U232_DATA_BITS_8 |
    MCT_U232_PARITY_NONE |
    MCT_U232_STOP_BITS_1);
    control_state = priv->control_state;
    @@ -488,7 +498,7 @@ static void mct_u232_close(struct tty_struct *tty,
    struct mct_u232_private *priv = usb_get_serial_port_data(port);
    dbg("%s port %d", __func__, port->number);

    - if (tty) {
    + if (tty) {
    c_cflag = tty->termios->c_cflag;
    mutex_lock(&port->serial->disc_mutex);
    if (c_cflag & HUPCL && !port->serial->disconnected) {
    @@ -512,7 +522,7 @@ static void mct_u232_close(struct tty_struct *tty,
    } /* mct_u232_close */


    -static void mct_u232_read_int_callback (struct urb *urb)
    +static void mct_u232_read_int_callback(struct urb *urb)
    {
    struct usb_serial_port *port = urb->context;
    struct mct_u232_private *priv = usb_get_serial_port_data(port);
    @@ -545,8 +555,9 @@ static void mct_u232_read_int_callback (struct urb *urb)
    return;
    }

    - dbg("%s - port %d", __func__, port->number);
    - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
    + dbg("%s - port %d", __func__, port->number);
    + usb_serial_debug_data(debug, &port->dev, __func__,
    + urb->actual_length, data);

    /*
    * Work-a-round: handle the 'usual' bulk-in pipe here
    @@ -555,26 +566,25 @@ static void mct_u232_read_int_callback (struct urb *urb)
    int i;
    tty = port->port.tty;
    if (urb->actual_length) {
    - for (i = 0; i < urb->actual_length ; ++i) {
    + for (i = 0; i < urb->actual_length ; ++i)
    tty_insert_flip_char(tty, data[i], 0);
    - }
    tty_flip_buffer_push(tty);
    }
    goto exit;
    }
    -
    +
    /*
    * The interrupt-in pipe signals exceptional conditions (modem line
    * signal changes and errors). data[0] holds MSR, data[1] holds LSR.
    */
    spin_lock_irqsave(&priv->lock, flags);
    priv->last_msr = data[MCT_U232_MSR_INDEX];
    -
    +
    /* Record Control Line states */
    mct_u232_msr_to_state(&priv->control_state, priv->last_msr);

    #if 0
    - /* Not yet handled. See belin_sa.c for further information */
    + /* Not yet handled. See belkin_sa.c for further information */
    /* Now to report any errors */
    priv->last_lsr = data[MCT_U232_LSR_INDEX];
    /*
    @@ -600,15 +610,15 @@ static void mct_u232_read_int_callback (struct urb *urb)
    #endif
    spin_unlock_irqrestore(&priv->lock, flags);
    exit:
    - retval = usb_submit_urb (urb, GFP_ATOMIC);
    + retval = usb_submit_urb(urb, GFP_ATOMIC);
    if (retval)
    - err ("%s - usb_submit_urb failed with result %d",
    + err("%s - usb_submit_urb failed with result %d",
    __func__, retval);
    } /* mct_u232_read_int_callback */

    -static void mct_u232_set_termios (struct tty_struct *tty,
    - struct usb_serial_port *port,
    - struct ktermios *old_termios)
    +static void mct_u232_set_termios(struct tty_struct *tty,
    + struct usb_serial_port *port,
    + struct ktermios *old_termios)
    {
    struct usb_serial *serial = port->serial;
    struct mct_u232_private *priv = usb_get_serial_port_data(port);
    @@ -632,7 +642,7 @@ static void mct_u232_set_termios (struct tty_struct *tty,
    * Premature optimization is the root of all evil.
    */

    - /* reassert DTR and RTS on transition from B0 */
    + /* reassert DTR and RTS on transition from B0 */
    if ((old_cflag & CBAUD) == B0) {
    dbg("%s: baud was B0", __func__);
    control_state |= TIOCM_DTR | TIOCM_RTS;
    @@ -641,11 +651,11 @@ static void mct_u232_set_termios (struct tty_struct *tty,

    mct_u232_set_baud_rate(tty, serial, port, tty_get_baud_rate(tty));

    - if ((cflag & CBAUD) == B0 ) {
    + if ((cflag & CBAUD) == B0) {
    dbg("%s: baud is B0", __func__);
    /* Drop RTS and DTR */
    control_state &= ~(TIOCM_DTR | TIOCM_RTS);
    - mct_u232_set_modem_ctrl(serial, control_state);
    + mct_u232_set_modem_ctrl(serial, control_state);
    }

    /*
    @@ -717,7 +727,7 @@ static int mct_u232_tiocmget(struct tty_struct *tty, struct file *file)
    struct mct_u232_private *priv = usb_get_serial_port_data(port);
    unsigned int control_state;
    unsigned long flags;
    -
    +
    dbg("%s", __func__);

    spin_lock_irqsave(&priv->lock, flags);
    @@ -735,7 +745,7 @@ static int mct_u232_tiocmset(struct tty_struct *tty, struct file *file,
    struct mct_u232_private *priv = usb_get_serial_port_data(port);
    unsigned int control_state;
    unsigned long flags;
    -
    +
    dbg("%s", __func__);

    spin_lock_irqsave(&priv->lock, flags);
    @@ -798,7 +808,7 @@ static void mct_u232_unthrottle(struct tty_struct *tty)
    }
    }

    -static int __init mct_u232_init (void)
    +static int __init mct_u232_init(void)
    {
    int retval;
    retval = usb_serial_register(&mct_u232_device);
    @@ -816,18 +826,17 @@ failed_usb_serial_register:
    }


    -static void __exit mct_u232_exit (void)
    +static void __exit mct_u232_exit(void)
    {
    - usb_deregister (&mct_u232_driver);
    - usb_serial_deregister (&mct_u232_device);
    + usb_deregister(&mct_u232_driver);
    + usb_serial_deregister(&mct_u232_device);
    }

    -
    -module_init (mct_u232_init);
    +module_init(mct_u232_init);
    module_exit(mct_u232_exit);

    -MODULE_AUTHOR( DRIVER_AUTHOR );
    -MODULE_DESCRIPTION( DRIVER_DESC );
    +MODULE_AUTHOR(DRIVER_AUTHOR);
    +MODULE_DESCRIPTION(DRIVER_DESC);
    MODULE_LICENSE("GPL");

    module_param(debug, bool, S_IRUGO | S_IWUSR);

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. [PATCH 48/70] tty-usb-ir-usb: Clean up to coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/ir-usb.c | 373 +++++++++++++++++++++++--------------------
    1 files changed, 201 insertions(+), 172 deletions(-)


    diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
    index 43dd970..19bff6a 100644
    --- a/drivers/usb/serial/ir-usb.c
    +++ b/drivers/usb/serial/ir-usb.c
    @@ -19,7 +19,8 @@
    * was written by Roman Weissgaerber , Dag Brattli
    * , and Jean Tourrilhes
    *
    - * See Documentation/usb/usb-serial.txt for more information on using this driver
    + * See Documentation/usb/usb-serial.txt for more information on using this
    + * driver
    *
    * 2007_Jun_21 Alan Cox
    * Minimal cleanups for some of the driver problens and tty layer abuse.
    @@ -59,7 +60,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include

    @@ -105,28 +106,32 @@ static int buffer_size;
    /* if overridden by the user, then use the specified number of XBOFs */
    static int xbof = -1;

    -static int ir_startup (struct usb_serial *serial);
    -static int ir_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filep);
    -static void ir_close(struct tty_struct *tty, struct usb_serial_port *port, struct file *filep);
    -static int ir_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
    -static void ir_write_bulk_callback (struct urb *urb);
    -static void ir_read_bulk_callback (struct urb *urb);
    -static void ir_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios);
    +static int ir_startup(struct usb_serial *serial);
    +static int ir_open(struct tty_struct *tty, struct usb_serial_port *port,
    + struct file *filep);
    +static void ir_close(struct tty_struct *tty, struct usb_serial_port *port,
    + struct file *filep);
    +static int ir_write(struct tty_struct *tty, struct usb_serial_port *port,
    + const unsigned char *buf, int count);
    +static void ir_write_bulk_callback(struct urb *urb);
    +static void ir_read_bulk_callback(struct urb *urb);
    +static void ir_set_termios(struct tty_struct *tty,
    + struct usb_serial_port *port, struct ktermios *old_termios);

    -/* Not that this lot means you can only have one per system */
    -static u8 ir_baud = 0;
    -static u8 ir_xbof = 0;
    -static u8 ir_add_bof = 0;
    +/* FIXME: Note that this lot means you can only have one per system */
    +static u8 ir_baud;
    +static u8 ir_xbof;
    +static u8 ir_add_bof;

    static struct usb_device_id id_table [] = {
    { USB_DEVICE(0x050f, 0x0180) }, /* KC Technology, KC-180 */
    { USB_DEVICE(0x08e9, 0x0100) }, /* XTNDAccess */
    { USB_DEVICE(0x09c4, 0x0011) }, /* ACTiSys ACT-IR2000U */
    - { USB_INTERFACE_INFO (USB_CLASS_APP_SPEC, USB_CLASS_IRDA, 0) },
    + { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, USB_CLASS_IRDA, 0) },
    { } /* Terminating entry */
    };

    -MODULE_DEVICE_TABLE (usb, id_table);
    +MODULE_DEVICE_TABLE(usb, id_table);

    static struct usb_driver ir_driver = {
    .name = "ir-usb",
    @@ -159,7 +164,7 @@ static inline void irda_usb_dump_class_desc(struct irda_class_desc *desc)
    {
    dbg("bLength=%x", desc->bLength);
    dbg("bDescriptorType=%x", desc->bDescriptorType);
    - dbg("bcdSpecRevision=%x", desc->bcdSpecRevision);
    + dbg("bcdSpecRevision=%x", desc->bcdSpecRevision);
    dbg("bmDataSize=%x", desc->bmDataSize);
    dbg("bmWindowSize=%x", desc->bmWindowSize);
    dbg("bmMinTurnaroundTime=%d", desc->bmMinTurnaroundTime);
    @@ -181,25 +186,26 @@ static inline void irda_usb_dump_class_desc(struct irda_class_desc *desc)
    *
    * Based on the same function in drivers/net/irda/irda-usb.c
    */
    -static struct irda_class_desc *irda_usb_find_class_desc(struct usb_device *dev, unsigned int ifnum)
    +static struct irda_class_desc *irda_usb_find_class_desc(struct usb_device *dev,
    + unsigned int ifnum)
    {
    struct irda_class_desc *desc;
    int ret;
    -
    - desc = kzalloc(sizeof (struct irda_class_desc), GFP_KERNEL);
    - if (desc == NULL)
    +
    + desc = kzalloc(sizeof(struct irda_class_desc), GFP_KERNEL);
    + if (desc == NULL)
    return NULL;
    -
    - ret = usb_control_msg(dev, usb_rcvctrlpipe(dev,0),
    +
    + ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
    IU_REQ_GET_CLASS_DESC,
    USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
    0, ifnum, desc, sizeof(*desc), 1000);
    -
    +
    dbg("%s - ret=%d", __func__, ret);
    if (ret < sizeof(*desc)) {
    dbg("%s - class descriptor read %s (%d)",
    __func__,
    - (ret<0) ? "failed" : "too short",
    + (ret < 0) ? "failed" : "too short",
    ret);
    goto error;
    }
    @@ -207,7 +213,7 @@ static struct irda_class_desc *irda_usb_find_class_desc(struct usb_device *dev,
    dbg("%s - bad class descriptor type", __func__);
    goto error;
    }
    -
    +
    irda_usb_dump_class_desc(desc);
    return desc;
    error:
    @@ -220,34 +226,44 @@ static u8 ir_xbof_change(u8 xbof)
    {
    u8 result;
    /* reference irda-usb.c */
    - switch(xbof) {
    - case 48: result = 0x10; break;
    - case 28:
    - case 24: result = 0x20; break;
    - default:
    - case 12: result = 0x30; break;
    - case 5:
    - case 6: result = 0x40; break;
    - case 3: result = 0x50; break;
    - case 2: result = 0x60; break;
    - case 1: result = 0x70; break;
    - case 0: result = 0x80; break;
    + switch (xbof) {
    + case 48:
    + result = 0x10;
    + break;
    + case 28:
    + case 24:result = 0x20;
    + break;
    + default:
    + case 12:result = 0x30;
    + break;
    + case 5:
    + case 6:result = 0x40;
    + break;
    + case 3:result = 0x50;
    + break;
    + case 2:result = 0x60;
    + break;
    + case 1:result = 0x70;
    + break;
    + case 0:result = 0x80;
    + break;
    }
    - return(result);
    + return result;
    }


    -static int ir_startup (struct usb_serial *serial)
    +static int ir_startup(struct usb_serial *serial)
    {
    struct irda_class_desc *irda_desc;

    - irda_desc = irda_usb_find_class_desc (serial->dev, 0);
    + irda_desc = irda_usb_find_class_desc(serial->dev, 0);
    if (irda_desc == NULL) {
    - dev_err (&serial->dev->dev, "IRDA class descriptor not found, device not bound\n");
    + dev_err(&serial->dev->dev,
    + "IRDA class descriptor not found, device not bound\n");
    return -ENODEV;
    }

    - dbg ("%s - Baud rates supported:%s%s%s%s%s%s%s%s%s",
    + dbg("%s - Baud rates supported:%s%s%s%s%s%s%s%s%s",
    __func__,
    (irda_desc->wBaudRate & 0x0001) ? " 2400" : "",
    (irda_desc->wBaudRate & 0x0002) ? " 9600" : "",
    @@ -259,21 +275,35 @@ static int ir_startup (struct usb_serial *serial)
    (irda_desc->wBaudRate & 0x0080) ? " 1152000" : "",
    (irda_desc->wBaudRate & 0x0100) ? " 4000000" : "");

    - switch( irda_desc->bmAdditionalBOFs ) {
    - case 0x01: ir_add_bof = 48; break;
    - case 0x02: ir_add_bof = 24; break;
    - case 0x04: ir_add_bof = 12; break;
    - case 0x08: ir_add_bof = 6; break;
    - case 0x10: ir_add_bof = 3; break;
    - case 0x20: ir_add_bof = 2; break;
    - case 0x40: ir_add_bof = 1; break;
    - case 0x80: ir_add_bof = 0; break;
    - default:;
    + switch (irda_desc->bmAdditionalBOFs) {
    + case 0x01:
    + ir_add_bof = 48;
    + break;
    + case 0x02:
    + ir_add_bof = 24;
    + break;
    + case 0x04:
    + ir_add_bof = 12;
    + break;
    + case 0x08:
    + ir_add_bof = 6;
    + break;
    + case 0x10:
    + ir_add_bof = 3;
    + break;
    + case 0x20:
    + ir_add_bof = 2;
    + break;
    + case 0x40:
    + ir_add_bof = 1;
    + break;
    + case 0x80:
    + ir_add_bof = 0;
    + break;
    + default:;
    }
    -
    - kfree (irda_desc);
    -
    - return 0;
    + kfree(irda_desc);
    + return 0;
    }

    static int ir_open(struct tty_struct *tty,
    @@ -286,47 +316,48 @@ static int ir_open(struct tty_struct *tty,

    if (buffer_size) {
    /* override the default buffer sizes */
    - buffer = kmalloc (buffer_size, GFP_KERNEL);
    + buffer = kmalloc(buffer_size, GFP_KERNEL);
    if (!buffer) {
    - dev_err (&port->dev, "%s - out of memory.\n", __func__);
    + dev_err(&port->dev, "%s - out of memory.\n", __func__);
    return -ENOMEM;
    }
    - kfree (port->read_urb->transfer_buffer);
    + kfree(port->read_urb->transfer_buffer);
    port->read_urb->transfer_buffer = buffer;
    port->read_urb->transfer_buffer_length = buffer_size;

    - buffer = kmalloc (buffer_size, GFP_KERNEL);
    + buffer = kmalloc(buffer_size, GFP_KERNEL);
    if (!buffer) {
    - dev_err (&port->dev, "%s - out of memory.\n", __func__);
    + dev_err(&port->dev, "%s - out of memory.\n",
    + __func__);
    return -ENOMEM;
    }
    - kfree (port->write_urb->transfer_buffer);
    + kfree(port->write_urb->transfer_buffer);
    port->write_urb->transfer_buffer = buffer;
    port->write_urb->transfer_buffer_length = buffer_size;
    port->bulk_out_size = buffer_size;
    }

    /* Start reading from the device */
    - usb_fill_bulk_urb (
    - port->read_urb,
    - port->serial->dev,
    - usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
    - port->read_urb->transfer_buffer,
    - port->read_urb->transfer_buffer_length,
    - ir_read_bulk_callback,
    - port);
    + usb_fill_bulk_urb(port->read_urb, port->serial->dev,
    + usb_rcvbulkpipe(port->serial->dev,
    + port->bulk_in_endpointAddress),
    + port->read_urb->transfer_buffer,
    + port->read_urb->transfer_buffer_length,
    + ir_read_bulk_callback, port);
    result = usb_submit_urb(port->read_urb, GFP_KERNEL);
    if (result)
    - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result);
    + dev_err(&port->dev,
    + "%s - failed submitting read urb, error %d\n",
    + __func__, result);

    return result;
    }

    static void ir_close(struct tty_struct *tty,
    - struct usb_serial_port *port, struct file * filp)
    + struct usb_serial_port *port, struct file *filp)
    {
    dbg("%s - port %d", __func__, port->number);
    -
    +
    /* shutdown our bulk read */
    usb_kill_urb(port->read_urb);
    }
    @@ -365,31 +396,29 @@ static int ir_write(struct tty_struct *tty, struct usb_serial_port *port,
    *transfer_buffer = ir_xbof | ir_baud;
    ++transfer_buffer;

    - memcpy (transfer_buffer, buf, transfer_size);
    + memcpy(transfer_buffer, buf, transfer_size);

    - usb_fill_bulk_urb (
    - port->write_urb,
    - port->serial->dev,
    - usb_sndbulkpipe(port->serial->dev,
    - port->bulk_out_endpointAddress),
    - port->write_urb->transfer_buffer,
    - transfer_size + 1,
    - ir_write_bulk_callback,
    - port);
    + usb_fill_bulk_urb(port->write_urb, port->serial->dev,
    + usb_sndbulkpipe(port->serial->dev,
    + port->bulk_out_endpointAddress),
    + port->write_urb->transfer_buffer,
    + transfer_size + 1, ir_write_bulk_callback, port);

    port->write_urb->transfer_flags = URB_ZERO_PACKET;

    - result = usb_submit_urb (port->write_urb, GFP_ATOMIC);
    + result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
    if (result) {
    port->write_urb_busy = 0;
    - dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result);
    + dev_err(&port->dev,
    + "%s - failed submitting write urb, error %d\n",
    + __func__, result);
    } else
    result = transfer_size;

    return result;
    }

    -static void ir_write_bulk_callback (struct urb *urb)
    +static void ir_write_bulk_callback(struct urb *urb)
    {
    struct usb_serial_port *port = urb->context;
    int status = urb->status;
    @@ -403,17 +432,13 @@ static void ir_write_bulk_callback (struct urb *urb)
    return;
    }

    - usb_serial_debug_data (
    - debug,
    - &port->dev,
    - __func__,
    - urb->actual_length,
    - urb->transfer_buffer);
    + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length,
    + urb->transfer_buffer);

    usb_serial_port_softint(port);
    }

    -static void ir_read_bulk_callback (struct urb *urb)
    +static void ir_read_bulk_callback(struct urb *urb)
    {
    struct usb_serial_port *port = urb->context;
    struct tty_struct *tty;
    @@ -429,64 +454,52 @@ static void ir_read_bulk_callback (struct urb *urb)
    }

    switch (status) {
    - case 0: /* Successful */
    -
    - /*
    - * The first byte of the packet we get from the device
    - * contains a busy indicator and baud rate change.
    - * See section 5.4.1.2 of the USB IrDA spec.
    - */
    - if ((*data & 0x0f) > 0)
    - ir_baud = *data & 0x0f;
    -
    - usb_serial_debug_data (
    - debug,
    - &port->dev,
    - __func__,
    - urb->actual_length,
    - data);
    -
    - tty = port->port.tty;
    -
    - if (tty_buffer_request_room(tty, urb->actual_length - 1)) {
    - tty_insert_flip_string(tty, data+1, urb->actual_length - 1);
    - tty_flip_buffer_push(tty);
    - }
    -
    - /*
    - * No break here.
    - * We want to resubmit the urb so we can read
    - * again.
    - */
    + case 0: /* Successful */
    +
    + /*
    + * The first byte of the packet we get from the device
    + * contains a busy indicator and baud rate change.
    + * See section 5.4.1.2 of the USB IrDA spec.
    + */
    + if ((*data & 0x0f) > 0)
    + ir_baud = *data & 0x0f;
    +
    + usb_serial_debug_data(debug, &port->dev, __func__,
    + urb->actual_length, data);
    + tty = port->port.tty;
    +
    + if (tty_buffer_request_room(tty, urb->actual_length - 1)) {
    + tty_insert_flip_string(tty, data + 1,
    + urb->actual_length - 1);
    + tty_flip_buffer_push(tty);
    + }

    - case -EPROTO: /* taking inspiration from pl2303.c */
    + /*
    + * No break here.
    + * We want to resubmit the urb so we can read
    + * again.
    + */

    - /* Continue trying to always read */
    - usb_fill_bulk_urb (
    - port->read_urb,
    - port->serial->dev,
    + case -EPROTO: /* taking inspiration from pl2303.c */
    + /* Continue trying to always read */
    + usb_fill_bulk_urb(port->read_urb, port->serial->dev,
    usb_rcvbulkpipe(port->serial->dev,
    port->bulk_in_endpointAddress),
    port->read_urb->transfer_buffer,
    port->read_urb->transfer_buffer_length,
    - ir_read_bulk_callback,
    - port);
    -
    - result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
    - if (result)
    - dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n",
    - __func__, result);
    -
    - break ;
    -
    - default:
    - dbg("%s - nonzero read bulk status received: %d",
    - __func__,
    - status);
    - break ;
    -
    + ir_read_bulk_callback, port);
    +
    + result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
    + if (result)
    + dev_err(&port->dev,
    + "%s - failed resubmitting read urb, error %d\n",
    + __func__, result);
    + break;
    + default:
    + dbg("%s - nonzero read bulk status received: %d",
    + __func__, status);
    + break;
    }
    -
    return;
    }

    @@ -509,19 +522,36 @@ static void ir_set_termios(struct tty_struct *tty,
    */

    switch (baud) {
    - case 2400: ir_baud = SPEED_2400; break;
    - case 9600: ir_baud = SPEED_9600; break;
    - case 19200: ir_baud = SPEED_19200; break;
    - case 38400: ir_baud = SPEED_38400; break;
    - case 57600: ir_baud = SPEED_57600; break;
    - case 115200: ir_baud = SPEED_115200; break;
    - case 576000: ir_baud = SPEED_576000; break;
    - case 1152000: ir_baud = SPEED_1152000; break;
    - case 4000000: ir_baud = SPEED_4000000; break;
    - break;
    - default:
    - ir_baud = SPEED_9600;
    - baud = 9600;
    + case 2400:
    + ir_baud = SPEED_2400;
    + break;
    + case 9600:
    + ir_baud = SPEED_9600;
    + break;
    + case 19200:
    + ir_baud = SPEED_19200;
    + break;
    + case 38400:
    + ir_baud = SPEED_38400;
    + break;
    + case 57600:
    + ir_baud = SPEED_57600;
    + break;
    + case 115200:
    + ir_baud = SPEED_115200;
    + break;
    + case 576000:
    + ir_baud = SPEED_576000;
    + break;
    + case 1152000:
    + ir_baud = SPEED_1152000;
    + break;
    + case 4000000:
    + ir_baud = SPEED_4000000;
    + break;
    + default:
    + ir_baud = SPEED_9600;
    + baud = 9600;
    }

    if (xbof == -1)
    @@ -537,20 +567,19 @@ static void ir_set_termios(struct tty_struct *tty,
    transfer_buffer = port->write_urb->transfer_buffer;
    *transfer_buffer = ir_xbof | ir_baud;

    - usb_fill_bulk_urb (
    - port->write_urb,
    - port->serial->dev,
    - usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress),
    - port->write_urb->transfer_buffer,
    - 1,
    - ir_write_bulk_callback,
    - port);
    + usb_fill_bulk_urb(port->write_urb, port->serial->dev,
    + usb_sndbulkpipe(port->serial->dev,
    + port->bulk_out_endpointAddress),
    + port->write_urb->transfer_buffer,
    + 1, ir_write_bulk_callback, port);

    port->write_urb->transfer_flags = URB_ZERO_PACKET;

    - result = usb_submit_urb (port->write_urb, GFP_KERNEL);
    + result = usb_submit_urb(port->write_urb, GFP_KERNEL);
    if (result)
    - dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result);
    + dev_err(&port->dev,
    + "%s - failed submitting write urb, error %d\n",
    + __func__, result);

    /* Only speed changes are supported */
    tty_termios_copy_hw(tty->termios, old_termios);
    @@ -558,14 +587,14 @@ static void ir_set_termios(struct tty_struct *tty,
    }


    -static int __init ir_init (void)
    +static int __init ir_init(void)
    {
    int retval;
    retval = usb_serial_register(&ir_device);
    if (retval)
    goto failed_usb_serial_register;
    retval = usb_register(&ir_driver);
    - if (retval)
    + if (retval)
    goto failed_usb_register;
    info(DRIVER_DESC " " DRIVER_VERSION);
    return 0;
    @@ -576,10 +605,10 @@ failed_usb_serial_register:
    }


    -static void __exit ir_exit (void)
    +static void __exit ir_exit(void)
    {
    - usb_deregister (&ir_driver);
    - usb_serial_deregister (&ir_device);
    + usb_deregister(&ir_driver);
    + usb_serial_deregister(&ir_device);
    }



    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  3. [PATCH 52/70] tty-usb-keyspan-pda: Coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/keyspan_pda.c | 168 +++++++++++++++++++++-----------------
    1 files changed, 95 insertions(+), 73 deletions(-)


    diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
    index a7538d7..928f545 100644
    --- a/drivers/usb/serial/keyspan_pda.c
    +++ b/drivers/usb/serial/keyspan_pda.c
    @@ -10,8 +10,9 @@
    * the Free Software Foundation; either version 2 of the License, or
    * (at your option) any later version.
    *
    - * See Documentation/usb/usb-serial.txt for more information on using this driver
    - *
    + * See Documentation/usb/usb-serial.txt for more information on using this
    + * driver
    + *
    * (09/07/2001) gkh
    * cleaned up the Xircom support. Added ids for Entregra device which is
    * the same as the Xircom device. Enabled the code to be compiled for
    @@ -21,23 +22,24 @@
    * support for Xircom PGSDB9
    *
    * (05/31/2001) gkh
    - * switched from using spinlock to a semaphore, which fixes lots of problems.
    + * switched from using spinlock to a semaphore, which fixes lots of
    + * problems.
    *
    * (04/08/2001) gb
    * Identify version on module load.
    - *
    + *
    * (11/01/2000) Adam J. Richter
    * usb_device_id table support
    - *
    + *
    * (10/05/2000) gkh
    * Fixed bug with urb->dev not being set properly, now that the usb
    * core needs it.
    - *
    + *
    * (08/28/2000) gkh
    * Added locks for SMP safeness.
    - * Fixed MOD_INC and MOD_DEC logic and the ability to open a port more
    + * Fixed MOD_INC and MOD_DEC logic and the ability to open a port more
    * than once.
    - *
    + *
    * (07/20/2000) borchers
    * - keyspan_pda_write no longer sleeps if it is called on interrupt time;
    * PPP and the line discipline with stty echo on can call write on
    @@ -55,14 +57,14 @@
    * than done directly from the callback to avoid the race in write_chan
    * - keyspan_pda_chars_in_buffer also indicates its buffer is full if the
    * urb status is -EINPROGRESS, meaning it cannot write at the moment
    - *
    + *
    * (07/19/2000) gkh
    * Added module_init and module_exit functions to handle the fact that this
    * driver is a loadable module now.
    *
    * (03/26/2000) gkh
    * Split driver up into device specific pieces.
    - *
    + *
    */


    @@ -76,7 +78,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include

    @@ -88,7 +90,8 @@ struct ezusb_hex_record {
    __u8 data[16];
    };

    -/* make a simple define to handle if we are compiling keyspan_pda or xircom support */
    +/* make a simple define to handle if we are compiling keyspan_pda
    + or xircom support */
    #if defined(CONFIG_USB_SERIAL_KEYSPAN_PDA) || defined(CONFIG_USB_SERIAL_KEYSPAN_PDA_MODULE)
    #define KEYSPAN
    #else
    @@ -147,7 +150,7 @@ static struct usb_device_id id_table_combined [] = {
    { } /* Terminating entry */
    };

    -MODULE_DEVICE_TABLE (usb, id_table_combined);
    +MODULE_DEVICE_TABLE(usb, id_table_combined);

    static struct usb_driver keyspan_pda_driver = {
    .name = "keyspan_pda",
    @@ -171,9 +174,9 @@ static struct usb_device_id id_table_fake [] = {

    #ifdef XIRCOM
    static struct usb_device_id id_table_fake_xircom [] = {
    - { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) },
    - { USB_DEVICE(ENTREGRA_VENDOR_ID, ENTREGRA_FAKE_ID) },
    - { }
    + { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) },
    + { USB_DEVICE(ENTREGRA_VENDOR_ID, ENTREGRA_FAKE_ID) },
    + { }
    };
    #endif

    @@ -196,7 +199,7 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work)
    dbg(" request_unthrottle");
    /* ask the device to tell us when the tx buffer becomes
    sufficiently empty */
    - result = usb_control_msg(serial->dev,
    + result = usb_control_msg(serial->dev,
    usb_sndctrlpipe(serial->dev, 0),
    7, /* request_unthrottle */
    USB_TYPE_VENDOR | USB_RECIP_INTERFACE
    @@ -207,15 +210,15 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work)
    0,
    2000);
    if (result < 0)
    - dbg("%s - error %d from usb_control_msg",
    + dbg("%s - error %d from usb_control_msg",
    __func__, result);
    }


    -static void keyspan_pda_rx_interrupt (struct urb *urb)
    +static void keyspan_pda_rx_interrupt(struct urb *urb)
    {
    struct usb_serial_port *port = urb->context;
    - struct tty_struct *tty = port->port.tty;
    + struct tty_struct *tty = port->port.tty;
    unsigned char *data = urb->transfer_buffer;
    int i;
    int retval;
    @@ -240,14 +243,13 @@ static void keyspan_pda_rx_interrupt (struct urb *urb)
    goto exit;
    }

    - /* see if the message is data or a status interrupt */
    + /* see if the message is data or a status interrupt */
    switch (data[0]) {
    case 0:
    /* rest of message is rx data */
    if (urb->actual_length) {
    - for (i = 1; i < urb->actual_length ; ++i) {
    + for (i = 1; i < urb->actual_length ; ++i)
    tty_insert_flip_char(tty, data[i], 0);
    - }
    tty_flip_buffer_push(tty);
    }
    break;
    @@ -271,9 +273,9 @@ static void keyspan_pda_rx_interrupt (struct urb *urb)
    }

    exit:
    - retval = usb_submit_urb (urb, GFP_ATOMIC);
    + retval = usb_submit_urb(urb, GFP_ATOMIC);
    if (retval)
    - err ("%s - usb_submit_urb failed with result %d",
    + err("%s - usb_submit_urb failed with result %d",
    __func__, retval);
    }

    @@ -304,32 +306,52 @@ static void keyspan_pda_rx_unthrottle(struct tty_struct *tty)
    }


    -static speed_t keyspan_pda_setbaud (struct usb_serial *serial, speed_t baud)
    +static speed_t keyspan_pda_setbaud(struct usb_serial *serial, speed_t baud)
    {
    int rc;
    int bindex;

    - switch(baud) {
    - case 110: bindex = 0; break;
    - case 300: bindex = 1; break;
    - case 1200: bindex = 2; break;
    - case 2400: bindex = 3; break;
    - case 4800: bindex = 4; break;
    - case 9600: bindex = 5; break;
    - case 19200: bindex = 6; break;
    - case 38400: bindex = 7; break;
    - case 57600: bindex = 8; break;
    - case 115200: bindex = 9; break;
    - default:
    - bindex = 5; /* Default to 9600 */
    - baud = 9600;
    + switch (baud) {
    + case 110:
    + bindex = 0;
    + break;
    + case 300:
    + bindex = 1;
    + break;
    + case 1200:
    + bindex = 2;
    + break;
    + case 2400:
    + bindex = 3;
    + break;
    + case 4800:
    + bindex = 4;
    + break;
    + case 9600:
    + bindex = 5;
    + break;
    + case 19200:
    + bindex = 6;
    + break;
    + case 38400:
    + bindex = 7;
    + break;
    + case 57600:
    + bindex = 8;
    + break;
    + case 115200:
    + bindex = 9;
    + break;
    + default:
    + bindex = 5; /* Default to 9600 */
    + baud = 9600;
    }

    /* rather than figure out how to sleep while waiting for this
    to complete, I just use the "legacy" API. */
    rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
    0, /* set baud */
    - USB_TYPE_VENDOR
    + USB_TYPE_VENDOR
    | USB_RECIP_INTERFACE
    | USB_DIR_OUT, /* type */
    bindex, /* value */
    @@ -355,11 +377,11 @@ static void keyspan_pda_break_ctl(struct tty_struct *tty, int break_state)
    else
    value = 0; /* clear break */
    result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
    - 4, /* set break */
    - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    - value, 0, NULL, 0, 2000);
    + 4, /* set break */
    + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    + value, 0, NULL, 0, 2000);
    if (result < 0)
    - dbg("%s - error %d from usb_control_msg",
    + dbg("%s - error %d from usb_control_msg",
    __func__, result);
    /* there is something funky about this.. the TCSBRK that 'cu' performs
    ought to translate into a break_ctl(-1),break_ctl(0) pair HZ/4
    @@ -502,10 +524,10 @@ static int keyspan_pda_write(struct tty_struct *tty,
    select() or poll() too) until we receive that unthrottle interrupt.
    Block if we can't write anything at all, otherwise write as much as
    we can. */
    - dbg("keyspan_pda_write(%d)",count);
    + dbg("keyspan_pda_write(%d)", count);
    if (count == 0) {
    dbg(" write request of 0 bytes");
    - return (0);
    + return 0;
    }

    /* we might block because of:
    @@ -532,7 +554,7 @@ static int keyspan_pda_write(struct tty_struct *tty,
    scheduler time, since usb_control_msg() sleeps. */
    if (count > priv->tx_room && !in_interrupt()) {
    unsigned char room;
    - rc = usb_control_msg(serial->dev,
    + rc = usb_control_msg(serial->dev,
    usb_rcvctrlpipe(serial->dev, 0),
    6, /* write_room */
    USB_TYPE_VENDOR | USB_RECIP_INTERFACE
    @@ -563,7 +585,7 @@ static int keyspan_pda_write(struct tty_struct *tty,

    if (count) {
    /* now transfer data */
    - memcpy (port->write_urb->transfer_buffer, buf, count);
    + memcpy(port->write_urb->transfer_buffer, buf, count);
    /* send the data out the bulk port */
    port->write_urb->transfer_buffer_length = count;

    @@ -575,8 +597,7 @@ static int keyspan_pda_write(struct tty_struct *tty,
    dbg(" usb_submit_urb(write bulk) failed");
    goto exit;
    }
    - }
    - else {
    + } else {
    /* There wasn't any room left, so we are throttled until
    the buffer empties a bit */
    request_unthrottle = 1;
    @@ -595,7 +616,7 @@ exit:
    }


    -static void keyspan_pda_write_bulk_callback (struct urb *urb)
    +static void keyspan_pda_write_bulk_callback(struct urb *urb)
    {
    struct usb_serial_port *port = urb->context;
    struct keyspan_pda_private *priv;
    @@ -616,7 +637,7 @@ static int keyspan_pda_write_room(struct tty_struct *tty)
    /* used by n_tty.c for processing of tabs and such. Giving it our
    conservative guess is probably good enough, but needs testing by
    running a console through the device. */
    - return (priv->tx_room);
    + return priv->tx_room;
    }


    @@ -674,7 +695,7 @@ static int keyspan_pda_open(struct tty_struct *tty,
    /* the normal serial device seems to always turn on DTR and RTS here,
    so do the same */
    if (tty && (tty->termios->c_cflag & CBAUD))
    - keyspan_pda_set_modem_info(serial, (1<<7) | (1<<2) );
    + keyspan_pda_set_modem_info(serial, (1<<7) | (1<<2));
    else
    keyspan_pda_set_modem_info(serial, 0);

    @@ -697,7 +718,8 @@ static void keyspan_pda_close(struct tty_struct *tty,
    struct usb_serial *serial = port->serial;

    if (serial->dev) {
    - /* the normal serial device seems to always shut off DTR and RTS now */
    + /* the normal serial device seems to always shut
    + off DTR and RTS now */
    if (tty->termios->c_cflag & HUPCL)
    keyspan_pda_set_modem_info(serial, 0);

    @@ -709,7 +731,7 @@ static void keyspan_pda_close(struct tty_struct *tty,


    /* download the firmware to a "fake" device (pre-renumeration) */
    -static int keyspan_pda_fake_startup (struct usb_serial *serial)
    +static int keyspan_pda_fake_startup(struct usb_serial *serial)
    {
    int response;
    const struct ezusb_hex_record *record = NULL;
    @@ -731,14 +753,14 @@ static int keyspan_pda_fake_startup (struct usb_serial *serial)
    return -ENODEV;
    }

    - while(record->address != 0xffff) {
    + while (record->address != 0xffff) {
    response = ezusb_writememory(serial, record->address,
    (unsigned char *)record->data,
    record->data_size, 0xa0);
    if (response < 0) {
    err("ezusb_writememory failed for Keyspan PDA "
    "firmware (%d %04X %p %d)",
    - response,
    + response,
    record->address, record->data, record->data_size);
    break;
    }
    @@ -749,10 +771,10 @@ static int keyspan_pda_fake_startup (struct usb_serial *serial)
    response = ezusb_set_reset(serial, 0);

    /* we want this device to fail to have a driver assigned to it. */
    - return (1);
    + return 1;
    }

    -static int keyspan_pda_startup (struct usb_serial *serial)
    +static int keyspan_pda_startup(struct usb_serial *serial)
    {

    struct keyspan_pda_private *priv;
    @@ -762,20 +784,20 @@ static int keyspan_pda_startup (struct usb_serial *serial)

    priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL);
    if (!priv)
    - return (1); /* error */
    + return 1; /* error */
    usb_set_serial_port_data(serial->port[0], priv);
    init_waitqueue_head(&serial->port[0]->write_wait);
    INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write);
    INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle);
    priv->serial = serial;
    priv->port = serial->port[0];
    - return (0);
    + return 0;
    }

    -static void keyspan_pda_shutdown (struct usb_serial *serial)
    +static void keyspan_pda_shutdown(struct usb_serial *serial)
    {
    dbg("%s", __func__);
    -
    +
    kfree(usb_get_serial_port_data(serial->port[0]));
    }

    @@ -834,7 +856,7 @@ static struct usb_serial_driver keyspan_pda_device = {
    };


    -static int __init keyspan_pda_init (void)
    +static int __init keyspan_pda_init(void)
    {
    int retval;
    retval = usb_serial_register(&keyspan_pda_device);
    @@ -855,7 +877,7 @@ static int __init keyspan_pda_init (void)
    goto failed_usb_register;
    info(DRIVER_DESC " " DRIVER_VERSION);
    return 0;
    -failed_usb_register:
    +failed_usb_register:
    #ifdef XIRCOM
    usb_serial_deregister(&xircom_pgs_fake_device);
    failed_xircom_register:
    @@ -872,15 +894,15 @@ failed_pda_register:
    }


    -static void __exit keyspan_pda_exit (void)
    +static void __exit keyspan_pda_exit(void)
    {
    - usb_deregister (&keyspan_pda_driver);
    - usb_serial_deregister (&keyspan_pda_device);
    + usb_deregister(&keyspan_pda_driver);
    + usb_serial_deregister(&keyspan_pda_device);
    #ifdef KEYSPAN
    - usb_serial_deregister (&keyspan_pda_fake_device);
    + usb_serial_deregister(&keyspan_pda_fake_device);
    #endif
    #ifdef XIRCOM
    - usb_serial_deregister (&xircom_pgs_fake_device);
    + usb_serial_deregister(&xircom_pgs_fake_device);
    #endif
    }

    @@ -888,8 +910,8 @@ static void __exit keyspan_pda_exit (void)
    module_init(keyspan_pda_init);
    module_exit(keyspan_pda_exit);

    -MODULE_AUTHOR( DRIVER_AUTHOR );
    -MODULE_DESCRIPTION( DRIVER_DESC );
    +MODULE_AUTHOR(DRIVER_AUTHOR);
    +MODULE_DESCRIPTION(DRIVER_DESC);
    MODULE_LICENSE("GPL");

    module_param(debug, bool, S_IRUGO | S_IWUSR);

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  4. [PATCH 36/70] ftdi_sio: Coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/ftdi_sio.c | 1078 ++++++++++++++++++++++-------------------
    drivers/usb/serial/ftdi_sio.h | 126 ++---
    2 files changed, 635 insertions(+), 569 deletions(-)


    diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
    index cde50b0..44de3a0 100644
    --- a/drivers/usb/serial/ftdi_sio.c
    +++ b/drivers/usb/serial/ftdi_sio.c
    @@ -12,7 +12,8 @@
    * the Free Software Foundation; either version 2 of the License, or
    * (at your option) any later version.
    *
    - * See Documentation/usb/usb-serial.txt for more information on using this driver
    + * See Documentation/usb/usb-serial.txt for more information on using this
    + * driver
    *
    * See http://ftdi-usb-sio.sourceforge.net for upto date testing info
    * and extra documentation
    @@ -25,7 +26,8 @@
    /* Bill Ryder - bryder@sgi.com - wrote the FTDI_SIO implementation */
    /* Thanx to FTDI for so kindly providing details of the protocol required */
    /* to talk to the device */
    -/* Thanx to gkh and the rest of the usb dev group for all code I have assimilated :-) */
    +/* Thanx to gkh and the rest of the usb dev group for all code I have
    + assimilated :-) */

    #include
    #include
    @@ -36,7 +38,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include
    #include
    @@ -55,17 +57,22 @@ static __u16 product;

    struct ftdi_private {
    ftdi_chip_type_t chip_type;
    - /* type of the device, either SIO or FT8U232AM */
    + /* type of device, either SIO or FT8U232AM */
    int baud_base; /* baud base clock for divisor setting */
    - int custom_divisor; /* custom_divisor kludge, this is for baud_base (different from what goes to the chip!) */
    + int custom_divisor; /* custom_divisor kludge, this is for
    + baud_base (different from what goes to the
    + chip!) */
    __u16 last_set_data_urb_value ;
    - /* the last data state set - needed for doing a break */
    - int write_offset; /* This is the offset in the usb data block to write the serial data -
    - * it is different between devices
    + /* the last data state set - needed for doing
    + * a break
    + */
    + int write_offset; /* This is the offset in the usb data block to
    + * write the serial data - it varies between
    + * devices
    */
    int flags; /* some ASYNC_xxxx flags are supported */
    unsigned long last_dtr_rts; /* saved modem control outputs */
    - wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
    + wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
    char prev_status, diff_status; /* Used for TIOCMIWAIT */
    __u8 rx_flags; /* receive state flags (throttling) */
    spinlock_t rx_lock; /* spinlock for receive state */
    @@ -76,8 +83,10 @@ struct ftdi_private {

    __u16 interface; /* FT2232C port interface (0 for FT232/245) */

    - speed_t force_baud; /* if non-zero, force the baud rate to this value */
    - int force_rtscts; /* if non-zero, force RTS-CTS to always be enabled */
    + speed_t force_baud; /* if non-zero, force the baud rate to
    + this value */
    + int force_rtscts; /* if non-zero, force RTS-CTS to always
    + be enabled */

    spinlock_t tx_lock; /* spinlock for transmit state */
    unsigned long tx_bytes;
    @@ -88,13 +97,14 @@ struct ftdi_private {
    /* struct ftdi_sio_quirk is used by devices requiring special attention. */
    struct ftdi_sio_quirk {
    int (*probe)(struct usb_serial *);
    - void (*port_probe)(struct ftdi_private *); /* Special settings for probed ports. */
    + /* Special settings for probed ports. */
    + void (*port_probe)(struct ftdi_private *);
    };

    -static int ftdi_jtag_probe (struct usb_serial *serial);
    -static int ftdi_mtxorb_hack_setup (struct usb_serial *serial);
    -static void ftdi_USB_UIRT_setup (struct ftdi_private *priv);
    -static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv);
    +static int ftdi_jtag_probe(struct usb_serial *serial);
    +static int ftdi_mtxorb_hack_setup(struct usb_serial *serial);
    +static void ftdi_USB_UIRT_setup(struct ftdi_private *priv);
    +static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv);

    static struct ftdi_sio_quirk ftdi_jtag_quirk = {
    .probe = ftdi_jtag_probe,
    @@ -174,270 +184,270 @@ static struct usb_device_id id_table_combined [] = {
    { USB_DEVICE(FTDI_VID, FTDI_MTXORB_4_PID) },
    { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) },
    { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0100_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0101_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0102_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0103_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0104_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0105_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0106_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0107_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0108_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0109_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010A_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010B_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010C_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010D_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010E_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010F_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0110_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0111_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0112_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0113_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0114_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0115_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0116_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0117_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0118_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0119_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011A_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011B_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011C_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011D_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011E_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011F_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0120_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0121_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0122_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0123_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0124_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0125_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0126_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0127_PID),
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0100_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0101_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0102_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0103_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0104_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0105_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0106_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0107_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0108_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0109_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010A_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010B_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010C_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010D_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010E_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010F_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0110_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0111_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0112_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0113_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0114_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0115_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0116_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0117_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0118_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0119_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011A_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011B_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011C_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011D_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011E_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011F_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0120_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0121_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0122_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0123_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0124_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0125_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0126_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0127_PID),
    .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0128_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0129_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012A_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012B_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012C_PID),
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0128_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0129_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012A_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012B_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012C_PID),
    .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012D_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012E_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012F_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0130_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0131_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0132_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0133_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0134_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0135_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0136_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0137_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0138_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0139_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013A_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013B_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013C_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013D_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013E_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013F_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0140_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0141_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0142_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0143_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0144_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0145_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0146_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0147_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0148_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0149_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014A_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014B_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014C_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014D_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014E_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014F_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0150_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0151_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0152_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0153_PID),
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012D_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012E_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012F_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0130_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0131_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0132_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0133_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0134_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0135_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0136_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0137_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0138_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0139_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013A_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013B_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013C_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013D_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013E_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013F_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0140_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0141_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0142_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0143_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0144_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0145_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0146_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0147_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0148_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0149_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014A_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014B_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014C_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014D_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014E_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014F_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0150_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0151_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0152_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0153_PID),
    .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0154_PID),
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0154_PID),
    .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0155_PID),
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0155_PID),
    .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0156_PID),
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0156_PID),
    .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0157_PID),
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0157_PID),
    .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0158_PID),
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0158_PID),
    .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0159_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015A_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015B_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015C_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015D_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015E_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015F_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0160_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0161_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0162_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0163_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0164_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0165_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0166_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0167_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0168_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0169_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016A_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016B_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016C_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016D_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016E_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016F_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0170_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0171_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0172_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0173_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0174_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0175_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0176_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0177_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0178_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0179_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017A_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017B_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017C_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017D_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017E_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017F_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0180_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0181_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0182_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0183_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0184_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0185_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0186_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0187_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0188_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0189_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018A_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018B_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018C_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018D_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018E_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018F_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0190_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0191_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0192_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0193_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0194_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0195_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0196_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0197_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0198_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0199_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019A_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019B_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019C_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019D_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019E_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019F_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A0_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A1_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A2_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A3_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A4_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A5_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A6_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A7_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A8_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A9_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AA_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AB_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AC_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AD_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AE_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AF_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B0_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B1_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B2_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B3_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B4_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B5_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B6_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B7_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B8_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B9_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BA_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BB_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BC_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BD_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BE_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BF_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C0_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C1_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C2_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C3_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C4_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C5_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C6_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C7_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C8_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C9_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CA_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CB_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CC_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CD_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CE_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CF_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D0_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D1_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D2_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D3_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D4_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D5_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D6_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D7_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D8_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D9_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DA_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DB_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DC_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DD_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DE_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DF_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E0_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E1_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E2_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E3_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E4_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E5_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E6_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E7_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E8_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E9_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EA_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EB_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EC_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01ED_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EE_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EF_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F0_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F1_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F2_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F3_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F4_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F5_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F6_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F7_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F8_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F9_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FA_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FB_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FC_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FD_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FE_PID) },
    - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FF_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0159_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015A_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015B_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015C_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015D_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015E_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015F_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0160_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0161_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0162_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0163_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0164_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0165_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0166_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0167_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0168_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0169_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016A_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016B_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016C_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016D_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016E_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016F_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0170_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0171_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0172_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0173_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0174_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0175_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0176_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0177_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0178_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0179_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017A_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017B_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017C_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017D_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017E_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017F_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0180_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0181_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0182_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0183_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0184_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0185_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0186_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0187_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0188_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0189_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018A_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018B_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018C_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018D_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018E_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018F_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0190_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0191_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0192_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0193_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0194_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0195_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0196_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0197_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0198_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0199_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019A_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019B_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019C_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019D_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019E_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019F_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A0_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A1_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A2_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A3_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A4_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A5_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A6_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A7_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A8_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A9_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AA_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AB_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AC_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AD_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AE_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AF_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B0_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B1_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B2_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B3_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B4_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B5_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B6_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B7_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B8_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B9_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BA_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BB_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BC_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BD_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BE_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BF_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C0_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C1_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C2_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C3_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C4_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C5_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C6_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C7_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C8_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C9_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CA_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CB_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CC_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CD_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CE_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CF_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D0_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D1_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D2_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D3_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D4_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D5_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D6_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D7_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D8_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D9_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DA_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DB_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DC_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DD_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DE_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DF_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E0_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E1_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E2_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E3_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E4_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E5_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E6_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E7_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E8_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E9_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EA_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EB_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EC_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01ED_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EE_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EF_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F0_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F1_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F2_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F3_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F4_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F5_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F6_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F7_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F8_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F9_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FA_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FB_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FC_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FD_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FE_PID) },
    + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FF_PID) },
    { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) },
    { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) },
    { USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) },
    @@ -641,7 +651,7 @@ static struct usb_device_id id_table_combined [] = {
    { } /* Terminating entry */
    };

    -MODULE_DEVICE_TABLE (usb, id_table_combined);
    +MODULE_DEVICE_TABLE(usb, id_table_combined);

    static struct usb_driver ftdi_driver = {
    .name = "ftdi_sio",
    @@ -677,30 +687,37 @@ static const char *ftdi_chip_name[] = {
    | ASYNC_SPD_CUST | ASYNC_SPD_SHI | ASYNC_SPD_WARP)

    /* function prototypes for a FTDI serial converter */
    -static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_id *id);
    -static void ftdi_shutdown (struct usb_serial *serial);
    -static int ftdi_sio_port_probe (struct usb_serial_port *port);
    -static int ftdi_sio_port_remove (struct usb_serial_port *port);
    -static int ftdi_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
    -static void ftdi_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
    -static int ftdi_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
    -static int ftdi_write_room (struct tty_struct *tty);
    -static int ftdi_chars_in_buffer (struct tty_struct *tty);
    -static void ftdi_write_bulk_callback (struct urb *urb);
    -static void ftdi_read_bulk_callback (struct urb *urb);
    -static void ftdi_process_read (struct work_struct *work);
    -static void ftdi_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old);
    -static int ftdi_tiocmget (struct tty_struct *tty, struct file *file);
    -static int ftdi_tiocmset (struct tty_struct *tty, struct file * file, unsigned int set, unsigned int clear);
    -static int ftdi_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg);
    -static void ftdi_break_ctl (struct tty_struct *tty, int break_state );
    -static void ftdi_throttle (struct tty_struct *tty);
    -static void ftdi_unthrottle (struct tty_struct *tty);
    -
    -static unsigned short int ftdi_232am_baud_base_to_divisor (int baud, int base);
    -static unsigned short int ftdi_232am_baud_to_divisor (int baud);
    -static __u32 ftdi_232bm_baud_base_to_divisor (int baud, int base);
    -static __u32 ftdi_232bm_baud_to_divisor (int baud);
    +static int ftdi_sio_probe(struct usb_serial *serial,
    + const struct usb_device_id *id);
    +static void ftdi_shutdown(struct usb_serial *serial);
    +static int ftdi_sio_port_probe(struct usb_serial_port *port);
    +static int ftdi_sio_port_remove(struct usb_serial_port *port);
    +static int ftdi_open(struct tty_struct *tty,
    + struct usb_serial_port *port, struct file *filp);
    +static void ftdi_close(struct tty_struct *tty,
    + struct usb_serial_port *port, struct file *filp);
    +static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
    + const unsigned char *buf, int count);
    +static int ftdi_write_room(struct tty_struct *tty);
    +static int ftdi_chars_in_buffer(struct tty_struct *tty);
    +static void ftdi_write_bulk_callback(struct urb *urb);
    +static void ftdi_read_bulk_callback(struct urb *urb);
    +static void ftdi_process_read(struct work_struct *work);
    +static void ftdi_set_termios(struct tty_struct *tty,
    + struct usb_serial_port *port, struct ktermios *old);
    +static int ftdi_tiocmget(struct tty_struct *tty, struct file *file);
    +static int ftdi_tiocmset(struct tty_struct *tty, struct file *file,
    + unsigned int set, unsigned int clear);
    +static int ftdi_ioctl(struct tty_struct *tty, struct file *file,
    + unsigned int cmd, unsigned long arg);
    +static void ftdi_break_ctl(struct tty_struct *tty, int break_state);
    +static void ftdi_throttle(struct tty_struct *tty);
    +static void ftdi_unthrottle(struct tty_struct *tty);
    +
    +static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base);
    +static unsigned short int ftdi_232am_baud_to_divisor(int baud);
    +static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base);
    +static __u32 ftdi_232bm_baud_to_divisor(int baud);

    static struct usb_serial_driver ftdi_sio_device = {
    .driver = {
    @@ -751,44 +768,54 @@ static struct usb_serial_driver ftdi_sio_device = {
    static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base)
    {
    unsigned short int divisor;
    - int divisor3 = base / 2 / baud; // divisor shifted 3 bits to the left
    - if ((divisor3 & 0x7) == 7) divisor3 ++; // round x.7/8 up to x+1
    + /* divisor shifted 3 bits to the left */
    + int divisor3 = base / 2 / baud;
    + if ((divisor3 & 0x7) == 7)
    + divisor3++; /* round x.7/8 up to x+1 */
    divisor = divisor3 >> 3;
    divisor3 &= 0x7;
    - if (divisor3 == 1) divisor |= 0xc000; else // 0.125
    - if (divisor3 >= 4) divisor |= 0x4000; else // 0.5
    - if (divisor3 != 0) divisor |= 0x8000; // 0.25
    - if (divisor == 1) divisor = 0; /* special case for maximum baud rate */
    + if (divisor3 == 1)
    + divisor |= 0xc000;
    + else if (divisor3 >= 4)
    + divisor |= 0x4000;
    + else if (divisor3 != 0)
    + divisor |= 0x8000;
    + else if (divisor == 1)
    + divisor = 0; /* special case for maximum baud rate */
    return divisor;
    }

    static unsigned short int ftdi_232am_baud_to_divisor(int baud)
    {
    - return(ftdi_232am_baud_base_to_divisor(baud, 48000000));
    + return ftdi_232am_baud_base_to_divisor(baud, 48000000);
    }

    static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base)
    {
    static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 };
    __u32 divisor;
    - int divisor3 = base / 2 / baud; // divisor shifted 3 bits to the left
    + /* divisor shifted 3 bits to the left */
    + int divisor3 = base / 2 / baud;
    divisor = divisor3 >> 3;
    divisor |= (__u32)divfrac[divisor3 & 0x7] << 14;
    /* Deal with special cases for highest baud rates. */
    - if (divisor == 1) divisor = 0; else // 1.0
    - if (divisor == 0x4001) divisor = 1; // 1.5
    + if (divisor == 1)
    + divisor = 0;
    + else if (divisor == 0x4001)
    + divisor = 1;
    return divisor;
    }

    static __u32 ftdi_232bm_baud_to_divisor(int baud)
    {
    - return(ftdi_232bm_baud_base_to_divisor(baud, 48000000));
    + return ftdi_232bm_baud_base_to_divisor(baud, 48000000);
    }

    #define set_mctrl(port, set) update_mctrl((port), (set), 0)
    #define clear_mctrl(port, clear) update_mctrl((port), 0, (clear))

    -static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned int clear)
    +static int update_mctrl(struct usb_serial_port *port, unsigned int set,
    + unsigned int clear)
    {
    struct ftdi_private *priv = usb_get_serial_port_data(port);
    char *buf;
    @@ -842,7 +869,8 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned
    }


    -static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *port)
    +static __u32 get_ftdi_divisor(struct tty_struct *tty,
    + struct usb_serial_port *port)
    { /* get_ftdi_divisor */
    struct ftdi_private *priv = usb_get_serial_port_data(port);
    __u32 div_value = 0;
    @@ -850,48 +878,56 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po
    int baud;

    /*
    - * The logic involved in setting the baudrate can be cleanly split in 3 steps.
    - * Obtaining the actual baud rate is a little tricky since unix traditionally
    - * somehow ignored the possibility to set non-standard baud rates.
    + * The logic involved in setting the baudrate can be cleanly split into
    + * 3 steps.
    * 1. Standard baud rates are set in tty->termios->c_cflag
    - * 2. If these are not enough, you can set any speed using alt_speed as follows:
    + * 2. If these are not enough, you can set any speed using alt_speed as
    + * follows:
    * - set tty->termios->c_cflag speed to B38400
    * - set your real speed in tty->alt_speed; it gets ignored when
    * alt_speed==0, (or)
    - * - call TIOCSSERIAL ioctl with (struct serial_struct) set as follows:
    - * flags & ASYNC_SPD_MASK == ASYNC_SPD_[HI, VHI, SHI, WARP], this just
    - * sets alt_speed to (HI: 57600, VHI: 115200, SHI: 230400, WARP: 460800)
    + * - call TIOCSSERIAL ioctl with (struct serial_struct) set as
    + * follows:
    + * flags & ASYNC_SPD_MASK == ASYNC_SPD_[HI, VHI, SHI, WARP],
    + * this just sets alt_speed to (HI: 57600, VHI: 115200,
    + * SHI: 230400, WARP: 460800)
    * ** Steps 1, 2 are done courtesy of tty_get_baud_rate
    * 3. You can also set baud rate by setting custom divisor as follows
    * - set tty->termios->c_cflag speed to B38400
    - * - call TIOCSSERIAL ioctl with (struct serial_struct) set as follows:
    + * - call TIOCSSERIAL ioctl with (struct serial_struct) set as
    + * follows:
    * o flags & ASYNC_SPD_MASK == ASYNC_SPD_CUST
    * o custom_divisor set to baud_base / your_new_baudrate
    - * ** Step 3 is done courtesy of code borrowed from serial.c - I should really
    - * spend some time and separate+move this common code to serial.c, it is
    - * replicated in nearly every serial driver you see.
    + * ** Step 3 is done courtesy of code borrowed from serial.c
    + * I should really spend some time and separate + move this common
    + * code to serial.c, it is replicated in nearly every serial driver
    + * you see.
    */

    - /* 1. Get the baud rate from the tty settings, this observes alt_speed hack */
    + /* 1. Get the baud rate from the tty settings, this observes
    + alt_speed hack */

    baud = tty_get_baud_rate(tty);
    dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud);

    - /* 2. Observe async-compatible custom_divisor hack, update baudrate if needed */
    + /* 2. Observe async-compatible custom_divisor hack, update baudrate
    + if needed */

    if (baud == 38400 &&
    ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
    (priv->custom_divisor)) {
    baud = priv->baud_base / priv->custom_divisor;
    - dbg("%s - custom divisor %d sets baud rate to %d", __func__, priv->custom_divisor, baud);
    + dbg("%s - custom divisor %d sets baud rate to %d",
    + __func__, priv->custom_divisor, baud);
    }

    /* 3. Convert baudrate to device-specific divisor */

    - if (!baud) baud = 9600;
    - switch(priv->chip_type) {
    + if (!baud)
    + baud = 9600;
    + switch (priv->chip_type) {
    case SIO: /* SIO chip */
    - switch(baud) {
    + switch (baud) {
    case 300: div_value = ftdi_sio_b300; break;
    case 600: div_value = ftdi_sio_b600; break;
    case 1200: div_value = ftdi_sio_b1200; break;
    @@ -904,7 +940,8 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po
    case 115200: div_value = ftdi_sio_b115200; break;
    } /* baud */
    if (div_value == 0) {
    - dbg("%s - Baudrate (%d) requested is not supported", __func__, baud);
    + dbg("%s - Baudrate (%d) requested is not supported",
    + __func__, baud);
    div_value = ftdi_sio_b9600;
    baud = 9600;
    div_okay = 0;
    @@ -914,7 +951,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po
    if (baud <= 3000000) {
    div_value = ftdi_232am_baud_to_divisor(baud);
    } else {
    - dbg("%s - Baud rate too high!", __func__);
    + dbg("%s - Baud rate too high!", __func__);
    baud = 9600;
    div_value = ftdi_232am_baud_to_divisor(9600);
    div_okay = 0;
    @@ -926,7 +963,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po
    if (baud <= 3000000) {
    div_value = ftdi_232bm_baud_to_divisor(baud);
    } else {
    - dbg("%s - Baud rate too high!", __func__);
    + dbg("%s - Baud rate too high!", __func__);
    div_value = ftdi_232bm_baud_to_divisor(9600);
    div_okay = 0;
    baud = 9600;
    @@ -941,14 +978,14 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po
    }

    tty_encode_baud_rate(tty, baud, baud);
    - return(div_value);
    + return div_value;
    }

    static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)
    {
    struct ftdi_private *priv = usb_get_serial_port_data(port);
    char *buf;
    - __u16 urb_value;
    + __u16 urb_value;
    __u16 urb_index;
    __u32 urb_index_value;
    int rv;
    @@ -977,7 +1014,8 @@ static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)



    -static int get_serial_info(struct usb_serial_port * port, struct serial_struct __user * retinfo)
    +static int get_serial_info(struct usb_serial_port *port,
    + struct serial_struct __user *retinfo)
    {
    struct ftdi_private *priv = usb_get_serial_port_data(port);
    struct serial_struct tmp;
    @@ -995,7 +1033,7 @@ static int get_serial_info(struct usb_serial_port * port, struct serial_struct _


    static int set_serial_info(struct tty_struct *tty,
    - struct usb_serial_port * port, struct serial_struct __user * newinfo)
    + struct usb_serial_port *port, struct serial_struct __user *newinfo)
    { /* set_serial_info */
    struct ftdi_private *priv = usb_get_serial_port_data(port);
    struct serial_struct new_serial;
    @@ -1003,7 +1041,7 @@ static int set_serial_info(struct tty_struct *tty,

    if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
    return -EFAULT;
    - old_priv = * priv;
    + old_priv = *priv;

    /* Do error checking and permission checking */

    @@ -1024,7 +1062,7 @@ static int set_serial_info(struct tty_struct *tty,
    /* Make the changes - these are privileged changes! */

    priv->flags = ((priv->flags & ~ASYNC_FLAGS) |
    - (new_serial.flags & ASYNC_FLAGS));
    + (new_serial.flags & ASYNC_FLAGS));
    priv->custom_divisor = new_serial.custom_divisor;

    tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
    @@ -1078,11 +1116,10 @@ static void ftdi_determine_type(struct usb_serial_port *port)
    priv->chip_type = FT2232C;
    /* Determine interface code. */
    inter = serial->interface->altsetting->desc.bInterfaceNumber;
    - if (inter == 0) {
    + if (inter == 0)
    priv->interface = PIT_SIOA;
    - } else {
    + else
    priv->interface = PIT_SIOB;
    - }
    /* BM-type devices have a bug where bcdDevice gets set
    * to 0x200 when iSerialNumber is 0. */
    if (version < 0x500) {
    @@ -1116,7 +1153,8 @@ static void ftdi_determine_type(struct usb_serial_port *port)
    * ************************************************** *************************
    */

    -static ssize_t show_latency_timer(struct device *dev, struct device_attribute *attr, char *buf)
    +static ssize_t show_latency_timer(struct device *dev,
    + struct device_attribute *attr, char *buf)
    {
    struct usb_serial_port *port = to_usb_serial_port(dev);
    struct ftdi_private *priv = usb_get_serial_port_data(port);
    @@ -1125,14 +1163,14 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *a
    int rv = 0;


    - dbg("%s",__func__);
    + dbg("%s", __func__);

    rv = usb_control_msg(udev,
    usb_rcvctrlpipe(udev, 0),
    FTDI_SIO_GET_LATENCY_TIMER_REQUEST,
    FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE,
    0, priv->interface,
    - (char*) &latency, 1, WDR_TIMEOUT);
    + (char *) &latency, 1, WDR_TIMEOUT);

    if (rv < 0) {
    dev_err(dev, "Unable to read latency timer: %i\n", rv);
    @@ -1142,8 +1180,9 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *a
    }

    /* Write a new value of the latency timer, in units of milliseconds. */
    -static ssize_t store_latency_timer(struct device *dev, struct device_attribute *attr, const char *valbuf,
    - size_t count)
    +static ssize_t store_latency_timer(struct device *dev,
    + struct device_attribute *attr, const char *valbuf,
    + size_t count)
    {
    struct usb_serial_port *port = to_usb_serial_port(dev);
    struct ftdi_private *priv = usb_get_serial_port_data(port);
    @@ -1171,8 +1210,8 @@ static ssize_t store_latency_timer(struct device *dev, struct device_attribute *

    /* Write an event character directly to the FTDI register. The ASCII
    value is in the low 8 bits, with the enable bit in the 9th bit. */
    -static ssize_t store_event_char(struct device *dev, struct device_attribute *attr, const char *valbuf,
    - size_t count)
    +static ssize_t store_event_char(struct device *dev,
    + struct device_attribute *attr, const char *valbuf, size_t count)
    {
    struct usb_serial_port *port = to_usb_serial_port(dev);
    struct ftdi_private *priv = usb_get_serial_port_data(port);
    @@ -1198,7 +1237,8 @@ static ssize_t store_event_char(struct device *dev, struct device_attribute *att
    return count;
    }

    -static DEVICE_ATTR(latency_timer, S_IWUSR | S_IRUGO, show_latency_timer, store_latency_timer);
    +static DEVICE_ATTR(latency_timer, S_IWUSR | S_IRUGO, show_latency_timer,
    + store_latency_timer);
    static DEVICE_ATTR(event_char, S_IWUSR, NULL, store_event_char);

    static int create_sysfs_attrs(struct usb_serial_port *port)
    @@ -1206,7 +1246,7 @@ static int create_sysfs_attrs(struct usb_serial_port *port)
    struct ftdi_private *priv = usb_get_serial_port_data(port);
    int retval = 0;

    - dbg("%s",__func__);
    + dbg("%s", __func__);

    /* XXX I've no idea if the original SIO supports the event_char
    * sysfs parameter, so I'm playing it safe. */
    @@ -1228,7 +1268,7 @@ static void remove_sysfs_attrs(struct usb_serial_port *port)
    {
    struct ftdi_private *priv = usb_get_serial_port_data(port);

    - dbg("%s",__func__);
    + dbg("%s", __func__);

    /* XXX see create_sysfs_attrs */
    if (priv->chip_type != SIO) {
    @@ -1249,9 +1289,11 @@ static void remove_sysfs_attrs(struct usb_serial_port *port)
    */

    /* Probe function to check for special devices */
    -static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_id *id)
    +static int ftdi_sio_probe(struct usb_serial *serial,
    + const struct usb_device_id *id)
    {
    - struct ftdi_sio_quirk *quirk = (struct ftdi_sio_quirk *)id->driver_info;
    + struct ftdi_sio_quirk *quirk =
    + (struct ftdi_sio_quirk *)id->driver_info;

    if (quirk && quirk->probe) {
    int ret = quirk->probe(serial);
    @@ -1270,17 +1312,18 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
    struct ftdi_sio_quirk *quirk = usb_get_serial_data(port->serial);


    - dbg("%s",__func__);
    + dbg("%s", __func__);

    priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL);
    - if (!priv){
    - err("%s- kmalloc(%Zd) failed.", __func__, sizeof(struct ftdi_private));
    + if (!priv) {
    + err("%s- kmalloc(%Zd) failed.", __func__,
    + sizeof(struct ftdi_private));
    return -ENOMEM;
    }

    spin_lock_init(&priv->rx_lock);
    spin_lock_init(&priv->tx_lock);
    - init_waitqueue_head(&priv->delta_msr_wait);
    + init_waitqueue_head(&priv->delta_msr_wait);
    /* This will push the characters through immediately rather
    than queue a task to deliver them */
    priv->flags = ASYNC_LOW_LATENCY;
    @@ -1290,9 +1333,9 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)

    /* Increase the size of read buffers */
    kfree(port->bulk_in_buffer);
    - port->bulk_in_buffer = kmalloc (BUFSZ, GFP_KERNEL);
    + port->bulk_in_buffer = kmalloc(BUFSZ, GFP_KERNEL);
    if (!port->bulk_in_buffer) {
    - kfree (priv);
    + kfree(priv);
    return -ENOMEM;
    }
    if (port->read_urb) {
    @@ -1305,7 +1348,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)

    /* Free port's existing write urb and transfer buffer. */
    if (port->write_urb) {
    - usb_free_urb (port->write_urb);
    + usb_free_urb(port->write_urb);
    port->write_urb = NULL;
    }
    kfree(port->bulk_out_buffer);
    @@ -1313,7 +1356,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)

    usb_set_serial_port_data(port, priv);

    - ftdi_determine_type (port);
    + ftdi_determine_type(port);
    create_sysfs_attrs(port);
    return 0;
    }
    @@ -1321,9 +1364,9 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
    /* Setup for the USB-UIRT device, which requires hardwired
    * baudrate (38400 gets mapped to 312500) */
    /* Called from usbserial:serial_probe */
    -static void ftdi_USB_UIRT_setup (struct ftdi_private *priv)
    +static void ftdi_USB_UIRT_setup(struct ftdi_private *priv)
    {
    - dbg("%s",__func__);
    + dbg("%s", __func__);

    priv->flags |= ASYNC_SPD_CUST;
    priv->custom_divisor = 77;
    @@ -1332,9 +1375,10 @@ static void ftdi_USB_UIRT_setup (struct ftdi_private *priv)

    /* Setup for the HE-TIRA1 device, which requires hardwired
    * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */
    -static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv)
    +
    +static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv)
    {
    - dbg("%s",__func__);
    + dbg("%s", __func__);

    priv->flags |= ASYNC_SPD_CUST;
    priv->custom_divisor = 240;
    @@ -1352,7 +1396,7 @@ static int ftdi_jtag_probe(struct usb_serial *serial)
    struct usb_device *udev = serial->dev;
    struct usb_interface *interface = serial->interface;

    - dbg("%s",__func__);
    + dbg("%s", __func__);

    if (interface == udev->actconfig->interface[0]) {
    info("Ignoring serial port reserved for JTAG");
    @@ -1386,7 +1430,7 @@ static int ftdi_mtxorb_hack_setup(struct usb_serial *serial)
    * calls __serial_close for each open of the port
    * shutdown is called then (ie ftdi_shutdown)
    */
    -static void ftdi_shutdown (struct usb_serial *serial)
    +static void ftdi_shutdown(struct usb_serial *serial)
    {
    dbg("%s", __func__);
    }
    @@ -1400,7 +1444,7 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)
    remove_sysfs_attrs(port);

    /* all open ports are closed at this point
    - * (by usbserial.c:__serial_close, which calls ftdi_close)
    + * (by usbserial.c:__serial_close, which calls ftdi_close)
    */

    if (priv) {
    @@ -1461,12 +1505,14 @@ static int ftdi_open(struct tty_struct *tty,
    /* Start reading from the device */
    priv->rx_processed = 0;
    usb_fill_bulk_urb(port->read_urb, dev,
    - usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress),
    - port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
    - ftdi_read_bulk_callback, port);
    + usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress),
    + port->read_urb->transfer_buffer,
    + port->read_urb->transfer_buffer_length,
    + ftdi_read_bulk_callback, port);
    result = usb_submit_urb(port->read_urb, GFP_KERNEL);
    if (result)
    - err("%s - failed submitting read urb, error %d", __func__, result);
    + err("%s - failed submitting read urb, error %d",
    + __func__, result);


    return result;
    @@ -1492,7 +1538,7 @@ static void ftdi_close(struct tty_struct *tty,
    dbg("%s", __func__);

    mutex_lock(&port->serial->disc_mutex);
    - if (c_cflag & HUPCL && !port->serial->disconnected){
    + if (c_cflag & HUPCL && !port->serial->disconnected) {
    /* Disable flow control */
    if (usb_control_msg(port->serial->dev,
    usb_sndctrlpipe(port->serial->dev, 0),
    @@ -1552,7 +1598,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
    spin_unlock_irqrestore(&priv->tx_lock, flags);

    data_offset = priv->write_offset;
    - dbg("data_offset set to %d",data_offset);
    + dbg("data_offset set to %d", data_offset);

    /* Determine total transfer size */
    transfer_size = count;
    @@ -1563,7 +1609,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
    (PKTSZ - data_offset)));
    }

    - buffer = kmalloc (transfer_size, GFP_ATOMIC);
    + buffer = kmalloc(transfer_size, GFP_ATOMIC);
    if (!buffer) {
    err("%s ran out of kernel memory for urb ...", __func__);
    count = -ENOMEM;
    @@ -1579,20 +1625,20 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,

    /* Copy data */
    if (data_offset > 0) {
    - /* Original sio requires control byte at start of each packet. */
    + /* Original sio requires control byte at start of
    + each packet. */
    int user_pktsz = PKTSZ - data_offset;
    int todo = count;
    unsigned char *first_byte = buffer;
    const unsigned char *current_position = buf;

    while (todo > 0) {
    - if (user_pktsz > todo) {
    + if (user_pktsz > todo)
    user_pktsz = todo;
    - }
    /* Write the control byte at the front of the packet*/
    *first_byte = 1 | ((user_pktsz) << 2);
    /* Copy data for packet */
    - memcpy (first_byte + data_offset,
    + memcpy(first_byte + data_offset,
    current_position, user_pktsz);
    first_byte += user_pktsz + data_offset;
    current_position += user_pktsz;
    @@ -1601,20 +1647,23 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
    } else {
    /* No control byte required. */
    /* Copy in the data to send */
    - memcpy (buffer, buf, count);
    + memcpy(buffer, buf, count);
    }

    - usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, buffer);
    + usb_serial_debug_data(debug, &port->dev, __func__,
    + transfer_size, buffer);

    /* fill the buffer and send it */
    usb_fill_bulk_urb(urb, port->serial->dev,
    - usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress),
    - buffer, transfer_size,
    - ftdi_write_bulk_callback, port);
    + usb_sndbulkpipe(port->serial->dev,
    + port->bulk_out_endpointAddress),
    + buffer, transfer_size,
    + ftdi_write_bulk_callback, port);

    status = usb_submit_urb(urb, GFP_ATOMIC);
    if (status) {
    - err("%s - failed submitting write urb, error %d", __func__, status);
    + err("%s - failed submitting write urb, error %d",
    + __func__, status);
    count = status;
    goto error;
    } else {
    @@ -1633,7 +1682,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
    error:
    usb_free_urb(urb);
    error_no_urb:
    - kfree (buffer);
    + kfree(buffer);
    error_no_buffer:
    spin_lock_irqsave(&priv->tx_lock, flags);
    priv->tx_outstanding_urbs--;
    @@ -1644,7 +1693,7 @@ error_no_buffer:

    /* This function may get called when the device is closed */

    -static void ftdi_write_bulk_callback (struct urb *urb)
    +static void ftdi_write_bulk_callback(struct urb *urb)
    {
    unsigned long flags;
    struct usb_serial_port *port = urb->context;
    @@ -1654,7 +1703,7 @@ static void ftdi_write_bulk_callback (struct urb *urb)
    int status = urb->status;

    /* free up the transfer buffer, as usb_free_urb() does not do this */
    - kfree (urb->transfer_buffer);
    + kfree(urb->transfer_buffer);

    dbg("%s - port %d", __func__, port->number);

    @@ -1737,9 +1786,11 @@ static void ftdi_read_bulk_callback(struct urb *urb)
    int status = urb->status;

    if (urb->number_of_packets > 0) {
    - err("%s transfer_buffer_length %d actual_length %d number of packets %d",__func__,
    - urb->transfer_buffer_length, urb->actual_length, urb->number_of_packets );
    - err("%s transfer_flags %x ", __func__,urb->transfer_flags );
    + err("%s transfer_buffer_length %d actual_length %d number of packets %d",
    + __func__,
    + urb->transfer_buffer_length,
    + urb->actual_length, urb->number_of_packets);
    + err("%s transfer_flags %x ", __func__, urb->transfer_flags);
    }

    dbg("%s - port %d", __func__, port->number);
    @@ -1749,7 +1800,7 @@ static void ftdi_read_bulk_callback(struct urb *urb)

    tty = port->port.tty;
    if (!tty) {
    - dbg("%s - bad tty pointer - exiting",__func__);
    + dbg("%s - bad tty pointer - exiting", __func__);
    return;
    }

    @@ -1759,14 +1810,13 @@ static void ftdi_read_bulk_callback(struct urb *urb)
    return;
    }

    - if (urb != port->read_urb) {
    + if (urb != port->read_urb)
    err("%s - Not my urb!", __func__);
    - }

    if (status) {
    - /* This will happen at close every time so it is a dbg not an err */
    - dbg("(this is ok on close) nonzero read bulk status received: "
    - "%d", status);
    + /* This will happen at close every time so it is a dbg not an
    + err */
    + dbg("(this is ok on close) nonzero read bulk status received: %d", status);
    return;
    }

    @@ -1782,7 +1832,7 @@ static void ftdi_read_bulk_callback(struct urb *urb)
    } /* ftdi_read_bulk_callback */


    -static void ftdi_process_read (struct work_struct *work)
    +static void ftdi_process_read(struct work_struct *work)
    { /* ftdi_process_read */
    struct ftdi_private *priv =
    container_of(work, struct ftdi_private, rx_work.work);
    @@ -1805,7 +1855,7 @@ static void ftdi_process_read (struct work_struct *work)

    tty = port->port.tty;
    if (!tty) {
    - dbg("%s - bad tty pointer - exiting",__func__);
    + dbg("%s - bad tty pointer - exiting", __func__);
    return;
    }

    @@ -1829,11 +1879,11 @@ static void ftdi_process_read (struct work_struct *work)
    urb->actual_length - priv->rx_processed);
    } else {
    /* The first two bytes of every read packet are status */
    - if (urb->actual_length > 2) {
    - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
    - } else {
    - dbg("Status only: %03oo %03oo",data[0],data[1]);
    - }
    + if (urb->actual_length > 2)
    + usb_serial_debug_data(debug, &port->dev, __func__,
    + urb->actual_length, data);
    + else
    + dbg("Status only: %03oo %03oo", data[0], data[1]);
    }


    @@ -1843,16 +1893,19 @@ static void ftdi_process_read (struct work_struct *work)
    /* if CD is dropped and the line is not CLOCAL then we should hangup */

    need_flip = 0;
    - for (packet_offset = priv->rx_processed; packet_offset < urb->actual_length; packet_offset += PKTSZ) {
    + for (packet_offset = priv->rx_processed;
    + packet_offset < urb->actual_length; packet_offset += PKTSZ) {
    int length;

    - /* Compare new line status to the old one, signal if different */
    - /* N.B. packet may be processed more than once, but differences
    - * are only processed once. */
    + /* Compare new line status to the old one, signal if different/
    + N.B. packet may be processed more than once, but differences
    + are only processed once. */
    if (priv != NULL) {
    - char new_status = data[packet_offset+0] & FTDI_STATUS_B0_MASK;
    + char new_status = data[packet_offset + 0] &
    + FTDI_STATUS_B0_MASK;
    if (new_status != priv->prev_status) {
    - priv->diff_status |= new_status ^ priv->prev_status;
    + priv->diff_status |=
    + new_status ^ priv->prev_status;
    wake_up_interruptible(&priv->delta_msr_wait);
    priv->prev_status = new_status;
    }
    @@ -1869,30 +1922,31 @@ static void ftdi_process_read (struct work_struct *work)
    break;
    }
    if (tty_buffer_request_room(tty, length) < length) {
    - /* break out & wait for throttling/unthrottling to happen */
    + /* break out & wait for throttling/unthrottling to
    + happen */
    dbg("%s - receive room low", __func__);
    break;
    }

    /* Handle errors and break */
    error_flag = TTY_NORMAL;
    - /* Although the device uses a bitmask and hence can have multiple */
    - /* errors on a packet - the order here sets the priority the */
    - /* error is returned to the tty layer */
    + /* Although the device uses a bitmask and hence can have
    + multiple errors on a packet - the order here sets the
    + priority the error is returned to the tty layer */

    - if ( data[packet_offset+1] & FTDI_RS_OE ) {
    + if (data[packet_offset+1] & FTDI_RS_OE) {
    error_flag = TTY_OVERRUN;
    dbg("OVERRRUN error");
    }
    - if ( data[packet_offset+1] & FTDI_RS_BI ) {
    + if (data[packet_offset+1] & FTDI_RS_BI) {
    error_flag = TTY_BREAK;
    dbg("BREAK received");
    }
    - if ( data[packet_offset+1] & FTDI_RS_PE ) {
    + if (data[packet_offset+1] & FTDI_RS_PE) {
    error_flag = TTY_PARITY;
    dbg("PARITY error");
    }
    - if ( data[packet_offset+1] & FTDI_RS_FE ) {
    + if (data[packet_offset+1] & FTDI_RS_FE) {
    error_flag = TTY_FRAME;
    dbg("FRAMING error");
    }
    @@ -1901,7 +1955,8 @@ static void ftdi_process_read (struct work_struct *work)
    /* Note that the error flag is duplicated for
    every character received since we don't know
    which character it applied to */
    - tty_insert_flip_char(tty, data[packet_offset+i], error_flag);
    + tty_insert_flip_char(tty,
    + data[packet_offset + i], error_flag);
    }
    need_flip = 1;
    }
    @@ -1909,19 +1964,19 @@ static void ftdi_process_read (struct work_struct *work)
    #ifdef NOT_CORRECT_BUT_KEEPING_IT_FOR_NOW
    /* if a parity error is detected you get status packets forever
    until a character is sent without a parity error.
    - This doesn't work well since the application receives a never
    - ending stream of bad data - even though new data hasn't been sent.
    - Therefore I (bill) have taken this out.
    + This doesn't work well since the application receives a
    + never ending stream of bad data - even though new data
    + hasn't been sent. Therefore I (bill) have taken this out.
    However - this might make sense for framing errors and so on
    so I am leaving the code in for now.
    */
    else {
    - if (error_flag != TTY_NORMAL){
    + if (error_flag != TTY_NORMAL) {
    dbg("error_flag is not normal");
    - /* In this case it is just status - if that is an error send a bad character */
    - if(tty->flip.count >= TTY_FLIPBUF_SIZE) {
    + /* In this case it is just status - if that is
    + an error send a bad character */
    + if (tty->flip.count >= TTY_FLIPBUF_SIZE)
    tty_flip_buffer_push(tty);
    - }
    tty_insert_flip_char(tty, 0xff, error_flag);
    need_flip = 1;
    }
    @@ -1930,9 +1985,8 @@ static void ftdi_process_read (struct work_struct *work)
    } /* "for(packet_offset=0..." */

    /* Low latency */
    - if (need_flip) {
    + if (need_flip)
    tty_flip_buffer_push(tty);
    - }

    if (packet_offset < urb->actual_length) {
    /* not completely processed - record progress */
    @@ -1951,12 +2005,11 @@ static void ftdi_process_read (struct work_struct *work)
    }
    spin_unlock_irqrestore(&priv->rx_lock, flags);
    /* if the port is closed stop trying to read */
    - if (port->port.count > 0){
    + if (port->port.count > 0)
    /* delay processing of remainder */
    schedule_delayed_work(&priv->rx_work, 1);
    - } else {
    + else
    dbg("%s - port is closed", __func__);
    - }
    return;
    }

    @@ -1964,19 +2017,20 @@ static void ftdi_process_read (struct work_struct *work)
    priv->rx_processed = 0;

    /* if the port is closed stop trying to read */
    - if (port->port.count > 0){
    + if (port->port.count > 0) {
    /* Continue trying to always read */
    usb_fill_bulk_urb(port->read_urb, port->serial->dev,
    - usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
    - port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
    - ftdi_read_bulk_callback, port);
    + usb_rcvbulkpipe(port->serial->dev,
    + port->bulk_in_endpointAddress),
    + port->read_urb->transfer_buffer,
    + port->read_urb->transfer_buffer_length,
    + ftdi_read_bulk_callback, port);

    result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
    if (result)
    - err("%s - failed resubmitting read urb, error %d", __func__, result);
    + err("%s - failed resubmitting read urb, error %d",
    + __func__, result);
    }
    -
    - return;
    } /* ftdi_process_read */


    @@ -1991,22 +2045,23 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
    /* see drivers/char/tty_io.c to see it used */
    /* last_set_data_urb_value NEVER has the break bit set in it */

    - if (break_state) {
    + if (break_state)
    urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK;
    - } else {
    + else
    urb_value = priv->last_set_data_urb_value;
    - }
    -

    - if (usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
    - FTDI_SIO_SET_DATA_REQUEST,
    - FTDI_SIO_SET_DATA_REQUEST_TYPE,
    - urb_value , priv->interface,
    - buf, 0, WDR_TIMEOUT) < 0) {
    - err("%s FAILED to enable/disable break state (state was %d)", __func__,break_state);
    + if (usb_control_msg(port->serial->dev,
    + usb_sndctrlpipe(port->serial->dev, 0),
    + FTDI_SIO_SET_DATA_REQUEST,
    + FTDI_SIO_SET_DATA_REQUEST_TYPE,
    + urb_value , priv->interface,
    + buf, 0, WDR_TIMEOUT) < 0) {
    + err("%s FAILED to enable/disable break state (state was %d)",
    + __func__, break_state);
    }

    - dbg("%s break state is %d - urb is %d", __func__,break_state, urb_value);
    + dbg("%s break state is %d - urb is %d", __func__,
    + break_state, urb_value);

    }

    @@ -2026,14 +2081,15 @@ static void ftdi_set_termios(struct tty_struct *tty,
    __u16 urb_value; /* will hold the new flags */
    char buf[1]; /* Perhaps I should dynamically alloc this? */

    - // Added for xon/xoff support
    + /* Added for xon/xoff support */
    unsigned int iflag = termios->c_iflag;
    unsigned char vstop;
    unsigned char vstart;

    dbg("%s", __func__);

    - /* Force baud rate if this device requires it, unless it is set to B0. */
    + /* Force baud rate if this device requires it, unless it is set to
    + B0. */
    if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) {
    dbg("%s: forcing baud rate for this device", __func__);
    tty_encode_baud_rate(tty, priv->force_baud,
    @@ -2052,8 +2108,8 @@ static void ftdi_set_termios(struct tty_struct *tty,
    not - so just do the change regardless - should be able to
    compare old_termios and tty->termios */
    /* NOTE These routines can get interrupted by
    - ftdi_sio_read_bulk_callback - need to examine what this
    - means - don't see any problems yet */
    + ftdi_sio_read_bulk_callback - need to examine what this means -
    + don't see any problems yet */

    /* Set number of data bits, parity, stop bits */

    @@ -2077,8 +2133,8 @@ static void ftdi_set_termios(struct tty_struct *tty,
    }
    }

    - /* This is needed by the break command since it uses the same command - but is
    - * or'ed with this value */
    + /* This is needed by the break command since it uses the same command
    + - but is or'ed with this value */
    priv->last_set_data_urb_value = urb_value;

    if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
    @@ -2090,7 +2146,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
    }

    /* Now do the baudrate */
    - if ((cflag & CBAUD) == B0 ) {
    + if ((cflag & CBAUD) == B0) {
    /* Disable flow control */
    if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
    FTDI_SIO_SET_FLOW_CTRL_REQUEST,
    @@ -2103,13 +2159,11 @@ static void ftdi_set_termios(struct tty_struct *tty,
    clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
    } else {
    /* set the baudrate determined before */
    - if (change_speed(tty, port)) {
    + if (change_speed(tty, port))
    err("%s urb failed to set baudrate", __func__);
    - }
    /* Ensure RTS and DTR are raised when baudrate changed from 0 */
    - if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) {
    + if (!old_termios || (old_termios->c_cflag & CBAUD) == B0)
    set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
    - }
    }

    /* Set flow control */
    @@ -2129,18 +2183,22 @@ static void ftdi_set_termios(struct tty_struct *tty,
    /*
    * Xon/Xoff code
    *
    - * Check the IXOFF status in the iflag component of the termios structure
    - * if IXOFF is not set, the pre-xon/xoff code is executed.
    - */
    + * Check the IXOFF status in the iflag component of the
    + * termios structure. If IXOFF is not set, the pre-xon/xoff
    + * code is executed.
    + */
    if (iflag & IXOFF) {
    - dbg("%s request to enable xonxoff iflag=%04x",__func__,iflag);
    - // Try to enable the XON/XOFF on the ftdi_sio
    - // Set the vstart and vstop -- could have been done up above where
    - // a lot of other dereferencing is done but that would be very
    - // inefficient as vstart and vstop are not always needed
    + dbg("%s request to enable xonxoff iflag=%04x",
    + __func__, iflag);
    + /* Try to enable the XON/XOFF on the ftdi_sio
    + * Set the vstart and vstop -- could have been done up
    + * above where a lot of other dereferencing is done but
    + * that would be very inefficient as vstart and vstop
    + * are not always needed.
    + */
    vstart = termios->c_cc[VSTART];
    vstop = termios->c_cc[VSTOP];
    - urb_value=(vstop << 8) | (vstart);
    + urb_value = (vstop << 8) | (vstart);

    if (usb_control_msg(dev,
    usb_sndctrlpipe(dev, 0),
    @@ -2152,8 +2210,9 @@ static void ftdi_set_termios(struct tty_struct *tty,
    err("urb failed to set to xon/xoff flow control");
    }
    } else {
    - /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */
    - /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */
    + /* else clause to only run if cflag ! CRTSCTS and iflag
    + * ! XOFF. CHECKME Assuming XON/XOFF handled by tty
    + * stack - not by device */
    dbg("%s Turning off hardware flow control", __func__);
    if (usb_control_msg(dev,
    usb_sndctrlpipe(dev, 0),
    @@ -2180,32 +2239,35 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
    switch (priv->chip_type) {
    case SIO:
    /* Request the status from the device */
    - if ((ret = usb_control_msg(port->serial->dev,
    - usb_rcvctrlpipe(port->serial->dev, 0),
    - FTDI_SIO_GET_MODEM_STATUS_REQUEST,
    - FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
    - 0, 0,
    - buf, 1, WDR_TIMEOUT)) < 0 ) {
    + ret = usb_control_msg(port->serial->dev,
    + usb_rcvctrlpipe(port->serial->dev, 0),
    + FTDI_SIO_GET_MODEM_STATUS_REQUEST,
    + FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
    + 0, 0,
    + buf, 1, WDR_TIMEOUT);
    + if (ret < 0) {
    err("%s Could not get modem status of device - err: %d", __func__,
    ret);
    - return(ret);
    + return ret;
    }
    break;
    case FT8U232AM:
    case FT232BM:
    case FT2232C:
    case FT232RL:
    - /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same
    - format as the data returned from the in point */
    - if ((ret = usb_control_msg(port->serial->dev,
    - usb_rcvctrlpipe(port->serial->dev, 0),
    - FTDI_SIO_GET_MODEM_STATUS_REQUEST,
    - FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
    - 0, priv->interface,
    - buf, 2, WDR_TIMEOUT)) < 0 ) {
    + /* the 8U232AM returns a two byte value (the sio is a 1 byte
    + value) - in the same format as the data returned from the in
    + point */
    + ret = usb_control_msg(port->serial->dev,
    + usb_rcvctrlpipe(port->serial->dev, 0),
    + FTDI_SIO_GET_MODEM_STATUS_REQUEST,
    + FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
    + 0, priv->interface,
    + buf, 2, WDR_TIMEOUT);
    + if (ret < 0) {
    err("%s Could not get modem status of device - err: %d", __func__,
    ret);
    - return(ret);
    + return ret;
    }
    break;
    default:
    @@ -2220,7 +2282,7 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
    priv->last_dtr_rts;
    }

    -static int ftdi_tiocmset(struct tty_struct *tty, struct file * file,
    +static int ftdi_tiocmset(struct tty_struct *tty, struct file *file,
    unsigned int set, unsigned int clear)
    {
    struct usb_serial_port *port = tty->driver_data;
    @@ -2229,7 +2291,8 @@ static int ftdi_tiocmset(struct tty_struct *tty, struct file * file,
    }


    -static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg)
    +static int ftdi_ioctl(struct tty_struct *tty, struct file *file,
    + unsigned int cmd, unsigned long arg)
    {
    struct usb_serial_port *port = tty->driver_data;
    struct ftdi_private *priv = usb_get_serial_port_data(port);
    @@ -2240,10 +2303,12 @@ static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int c
    switch (cmd) {

    case TIOCGSERIAL: /* gets serial port data */
    - return get_serial_info(port, (struct serial_struct __user *) arg);
    + return get_serial_info(port,
    + (struct serial_struct __user *) arg);

    case TIOCSSERIAL: /* sets serial port data */
    - return set_serial_info(tty, port, (struct serial_struct __user *) arg);
    + return set_serial_info(tty, port,
    + (struct serial_struct __user *) arg);

    /*
    * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
    @@ -2262,23 +2327,24 @@ static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int c
    else {
    char diff = priv->diff_status;

    - if (diff == 0) {
    + if (diff == 0)
    return -EIO; /* no change => error */
    - }

    /* Consume all events */
    priv->diff_status = 0;

    - /* Return 0 if caller wanted to know about these bits */
    - if ( ((arg & TIOCM_RNG) && (diff & FTDI_RS0_RI)) ||
    - ((arg & TIOCM_DSR) && (diff & FTDI_RS0_DSR)) ||
    - ((arg & TIOCM_CD) && (diff & FTDI_RS0_RLSD)) ||
    - ((arg & TIOCM_CTS) && (diff & FTDI_RS0_CTS)) ) {
    + /* Return 0 if caller wanted to know about
    + these bits */
    + if (((arg & TIOCM_RNG) && (diff & FTDI_RS0_RI)) ||
    + ((arg & TIOCM_DSR) && (diff & FTDI_RS0_DSR)) ||
    + ((arg & TIOCM_CD) && (diff & FTDI_RS0_RLSD)) ||
    + ((arg & TIOCM_CTS) && (diff & FTDI_RS0_CTS))) {
    return 0;
    }
    /*
    - * Otherwise caller can't care less about what happened,
    - * and so we continue to wait for more events.
    + * Otherwise caller can't care less about what
    + * happened,and so we continue to wait for more
    + * events.
    */
    }
    }
    @@ -2286,8 +2352,8 @@ static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int c
    default:
    break;
    }
    - /* This is not necessarily an error - turns out the higher layers will do
    - * some ioctls itself (see comment above)
    + /* This is not necessarily an error - turns out the higher layers
    + * will do some ioctls themselves (see comment above)
    */
    dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd);
    return -ENOIOCTLCMD;
    @@ -2325,7 +2391,7 @@ static void ftdi_unthrottle(struct tty_struct *tty)
    schedule_delayed_work(&priv->rx_work, 0);
    }

    -static int __init ftdi_init (void)
    +static int __init ftdi_init(void)
    {
    int retval;

    @@ -2355,13 +2421,13 @@ failed_sio_register:
    }


    -static void __exit ftdi_exit (void)
    +static void __exit ftdi_exit(void)
    {

    dbg("%s", __func__);

    - usb_deregister (&ftdi_driver);
    - usb_serial_deregister (&ftdi_sio_device);
    + usb_deregister(&ftdi_driver);
    + usb_serial_deregister(&ftdi_sio_device);

    }

    @@ -2369,8 +2435,8 @@ static void __exit ftdi_exit (void)
    module_init(ftdi_init);
    module_exit(ftdi_exit);

    -MODULE_AUTHOR( DRIVER_AUTHOR );
    -MODULE_DESCRIPTION( DRIVER_DESC );
    +MODULE_AUTHOR(DRIVER_AUTHOR);
    +MODULE_DESCRIPTION(DRIVER_DESC);
    MODULE_LICENSE("GPL");

    module_param(debug, bool, S_IRUGO | S_IWUSR);
    diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
    index 06e0eca..10cc7b1 100644
    --- a/drivers/usb/serial/ftdi_sio.h
    +++ b/drivers/usb/serial/ftdi_sio.h
    @@ -1,20 +1,20 @@
    /*
    - * Definitions for the FTDI USB Single Port Serial Converter -
    - * known as FTDI_SIO (Serial Input/Output application of the chipset)
    + * Definitions for the FTDI USB Single Port Serial Converter -
    + * known as FTDI_SIO (Serial Input/Output application of the chipset)
    *
    * The example I have is known as the USC-1000 which is available from
    * http://www.dse.co.nz - cat no XH4214 It looks similar to this:
    * http://www.dansdata.com/usbser.htm but I can't be sure There are other
    * USC-1000s which don't look like my device though so beware!
    *
    - * The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side,
    + * The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side,
    * USB on the other.
    *
    * Thanx to FTDI (http://www.ftdi.co.uk) for so kindly providing details
    * of the protocol required to talk to the device and ongoing assistence
    * during development.
    *
    - * Bill Ryder - bryder@sgi.com formerly of Silicon Graphics, Inc.- wrote the
    + * Bill Ryder - bryder@sgi.com formerly of Silicon Graphics, Inc.- wrote the
    * FTDI_SIO implementation.
    *
    * Philipp G├╝hring - pg@futureware.at - added the Device ID of the USB relais
    @@ -472,7 +472,7 @@
    /*
    * DSS-20 Sync Station for Sony Ericsson P800
    */
    -#define FTDI_DSS20_PID 0xFC82
    +#define FTDI_DSS20_PID 0xFC82

    /*
    * Home Electronics (www.home-electro.com) USB gadgets
    @@ -881,7 +881,7 @@
    /*
    * BmRequestType: 0100 0000B
    * bRequest: FTDI_SIO_RESET
    - * wValue: Control Value
    + * wValue: Control Value
    * 0 = Reset SIO
    * 1 = Purge RX buffer
    * 2 = Purge TX buffer
    @@ -949,7 +949,7 @@
    * 101 - add .625 to divisor
    * 110 - add .750 to divisor
    * 111 - add .875 to divisor
    - * Bits 15 to 0 of the 17-bit divisor are placed in the urb value. Bit 16 is
    + * Bits 15 to 0 of the 17-bit divisor are placed in the urb value. Bit 16 is
    * placed in bit 0 of the urb index.
    *
    * Note that there are a couple of special cases to support the highest baud
    @@ -968,8 +968,8 @@ typedef enum {
    } ftdi_chip_type_t;

    typedef enum {
    - ftdi_sio_b300 = 0,
    - ftdi_sio_b600 = 1,
    + ftdi_sio_b300 = 0,
    + ftdi_sio_b600 = 1,
    ftdi_sio_b1200 = 2,
    ftdi_sio_b2400 = 3,
    ftdi_sio_b4800 = 4,
    @@ -978,7 +978,7 @@ typedef enum {
    ftdi_sio_b38400 = 7,
    ftdi_sio_b57600 = 8,
    ftdi_sio_b115200 = 9
    -} FTDI_SIO_baudrate_t ;
    +} FTDI_SIO_baudrate_t;

    /*
    * The ftdi_8U232AM_xxMHz_byyy constants have been removed. The encoded divisor values
    @@ -987,19 +987,19 @@ typedef enum {

    #define FTDI_SIO_SET_DATA_REQUEST FTDI_SIO_SET_DATA
    #define FTDI_SIO_SET_DATA_REQUEST_TYPE 0x40
    -#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8 )
    -#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8 )
    -#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8 )
    -#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8 )
    -#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8 )
    -#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11 )
    -#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11 )
    -#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11 )
    +#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8)
    +#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8)
    +#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8)
    +#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8)
    +#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8)
    +#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11)
    +#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11)
    +#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11)
    #define FTDI_SIO_SET_BREAK (0x1 << 14)
    /* FTDI_SIO_SET_DATA */

    /*
    - * BmRequestType: 0100 0000B
    + * BmRequestType: 0100 0000B
    * bRequest: FTDI_SIO_SET_DATA
    * wValue: Data characteristics (see below)
    * wIndex: Port
    @@ -1032,7 +1032,7 @@ typedef enum {
    #define FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE 0x40
    #define FTDI_SIO_SET_MODEM_CTRL_REQUEST FTDI_SIO_MODEM_CTRL

    -/*
    +/*
    * BmRequestType: 0100 0000B
    * bRequest: FTDI_SIO_MODEM_CTRL
    * wValue: ControlValue (see below)
    @@ -1046,11 +1046,11 @@ typedef enum {
    */

    #define FTDI_SIO_SET_DTR_MASK 0x1
    -#define FTDI_SIO_SET_DTR_HIGH ( 1 | ( FTDI_SIO_SET_DTR_MASK << 8))
    -#define FTDI_SIO_SET_DTR_LOW ( 0 | ( FTDI_SIO_SET_DTR_MASK << 8))
    +#define FTDI_SIO_SET_DTR_HIGH (1 | (FTDI_SIO_SET_DTR_MASK << 8))
    +#define FTDI_SIO_SET_DTR_LOW (0 | (FTDI_SIO_SET_DTR_MASK << 8))
    #define FTDI_SIO_SET_RTS_MASK 0x2
    -#define FTDI_SIO_SET_RTS_HIGH ( 2 | ( FTDI_SIO_SET_RTS_MASK << 8 ))
    -#define FTDI_SIO_SET_RTS_LOW ( 0 | ( FTDI_SIO_SET_RTS_MASK << 8 ))
    +#define FTDI_SIO_SET_RTS_HIGH (2 | (FTDI_SIO_SET_RTS_MASK << 8))
    +#define FTDI_SIO_SET_RTS_LOW (0 | (FTDI_SIO_SET_RTS_MASK << 8))

    /*
    * ControlValue
    @@ -1073,7 +1073,7 @@ typedef enum {
    /* FTDI_SIO_SET_FLOW_CTRL */
    #define FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE 0x40
    #define FTDI_SIO_SET_FLOW_CTRL_REQUEST FTDI_SIO_SET_FLOW_CTRL
    -#define FTDI_SIO_DISABLE_FLOW_CTRL 0x0
    +#define FTDI_SIO_DISABLE_FLOW_CTRL 0x0
    #define FTDI_SIO_RTS_CTS_HS (0x1 << 8)
    #define FTDI_SIO_DTR_DSR_HS (0x2 << 8)
    #define FTDI_SIO_XON_XOFF_HS (0x4 << 8)
    @@ -1082,7 +1082,7 @@ typedef enum {
    * bRequest: FTDI_SIO_SET_FLOW_CTRL
    * wValue: Xoff/Xon
    * wIndex: Protocol/Port - hIndex is protocl / lIndex is port
    - * wLength: 0
    + * wLength: 0
    * Data: None
    *
    * hIndex protocol is:
    @@ -1098,10 +1098,10 @@ typedef enum {
    *
    * A value of zero in the hIndex field disables handshaking
    *
    - * If Xon/Xoff handshaking is specified, the hValue field should contain the XOFF character
    + * If Xon/Xoff handshaking is specified, the hValue field should contain the XOFF character
    * and the lValue field contains the XON character.
    - */
    -
    + */
    +
    /*
    * FTDI_SIO_GET_LATENCY_TIMER
    *
    @@ -1115,7 +1115,7 @@ typedef enum {
    #define FTDI_SIO_GET_LATENCY_TIMER_REQUEST FTDI_SIO_GET_LATENCY_TIMER
    #define FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE 0xC0

    -/*
    +/*
    * BmRequestType: 1100 0000b
    * bRequest: FTDI_SIO_GET_LATENCY_TIMER
    * wValue: 0
    @@ -1124,7 +1124,7 @@ typedef enum {
    * Data: latency (on return)
    */

    -/*
    +/*
    * FTDI_SIO_SET_LATENCY_TIMER
    *
    * Set the timeout interval. The FTDI collects data from the slave
    @@ -1137,7 +1137,7 @@ typedef enum {
    #define FTDI_SIO_SET_LATENCY_TIMER_REQUEST FTDI_SIO_SET_LATENCY_TIMER
    #define FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE 0x40

    -/*
    +/*
    * BmRequestType: 0100 0000b
    * bRequest: FTDI_SIO_SET_LATENCY_TIMER
    * wValue: Latency (milliseconds)
    @@ -1152,7 +1152,7 @@ typedef enum {
    */

    /*
    - * FTDI_SIO_SET_EVENT_CHAR
    + * FTDI_SIO_SET_EVENT_CHAR
    *
    * Set the special event character for the specified communications port.
    * If the device sees this character it will immediately return the
    @@ -1165,7 +1165,7 @@ typedef enum {
    #define FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE 0x40


    -/*
    +/*
    * BmRequestType: 0100 0000b
    * bRequest: FTDI_SIO_SET_EVENT_CHAR
    * wValue: EventChar
    @@ -1181,12 +1181,12 @@ typedef enum {
    * B9..15 Reserved
    *
    */
    -
    +
    /* FTDI_SIO_SET_ERROR_CHAR */

    /* Set the parity error replacement character for the specified communications port */

    -/*
    +/*
    * BmRequestType: 0100 0000b
    * bRequest: FTDI_SIO_SET_EVENT_CHAR
    * wValue: Error Char
    @@ -1212,15 +1212,15 @@ typedef enum {
    #define FTDI_SIO_DSR_MASK 0x20
    #define FTDI_SIO_RI_MASK 0x40
    #define FTDI_SIO_RLSD_MASK 0x80
    -/*
    +/*
    * BmRequestType: 1100 0000b
    * bRequest: FTDI_SIO_GET_MODEM_STATUS
    * wValue: zero
    * wIndex: Port
    * wLength: 1
    * Data: Status
    - *
    - * One byte of data is returned
    + *
    + * One byte of data is returned
    * B0..3 0
    * B4 CTS
    * 0 = inactive
    @@ -1233,15 +1233,15 @@ typedef enum {
    * 1 = active
    * B7 Receive Line Signal Detect (RLSD)
    * 0 = inactive
    - * 1 = active
    + * 1 = active
    */



    -/* Descriptors returned by the device
    - *
    +/* Descriptors returned by the device
    + *
    * Device Descriptor
    - *
    + *
    * Offset Field Size Value Description
    * 0 bLength 1 0x12 Size of descriptor in bytes
    * 1 bDescriptorType 1 0x01 DEVICE Descriptor Type
    @@ -1257,9 +1257,9 @@ typedef enum {
    * 15 iProduct 1 0x02 Index of prod string desc
    * 16 iSerialNumber 1 0x02 Index of serial nmr string desc
    * 17 bNumConfigurations 1 0x01 Number of possible configurations
    - *
    + *
    * Configuration Descriptor
    - *
    + *
    * Offset Field Size Value
    * 0 bLength 1 0x09 Size of descriptor in bytes
    * 1 bDescriptorType 1 0x02 CONFIGURATION Descriptor Type
    @@ -1269,9 +1269,9 @@ typedef enum {
    * 6 iConfiguration 1 0x02 Index of config string descriptor
    * 7 bmAttributes 1 0x20 Config characteristics Remote Wakeup
    * 8 MaxPower 1 0x1E Max power consumption
    - *
    + *
    * Interface Descriptor
    - *
    + *
    * Offset Field Size Value
    * 0 bLength 1 0x09 Size of descriptor in bytes
    * 1 bDescriptorType 1 0x04 INTERFACE Descriptor Type
    @@ -1282,9 +1282,9 @@ typedef enum {
    * 6 bInterfaceSubClass 1 0xFF Subclass Code
    * 7 bInterfaceProtocol 1 0xFF Protocol Code
    * 8 iInterface 1 0x02 Index of interface string description
    - *
    + *
    * IN Endpoint Descriptor
    - *
    + *
    * Offset Field Size Value
    * 0 bLength 1 0x07 Size of descriptor in bytes
    * 1 bDescriptorType 1 0x05 ENDPOINT descriptor type
    @@ -1292,9 +1292,9 @@ typedef enum {
    * 3 bmAttributes 1 0x02 Endpoint attributes - Bulk
    * 4 bNumEndpoints 2 0x0040 maximum packet size
    * 5 bInterval 1 0x00 Interval for polling endpoint
    - *
    + *
    * OUT Endpoint Descriptor
    - *
    + *
    * Offset Field Size Value
    * 0 bLength 1 0x07 Size of descriptor in bytes
    * 1 bDescriptorType 1 0x05 ENDPOINT descriptor type
    @@ -1302,17 +1302,17 @@ typedef enum {
    * 3 bmAttributes 1 0x02 Endpoint attributes - Bulk
    * 4 bNumEndpoints 2 0x0040 maximum packet size
    * 5 bInterval 1 0x00 Interval for polling endpoint
    - *
    + *
    * DATA FORMAT
    - *
    + *
    * IN Endpoint
    - *
    + *
    * The device reserves the first two bytes of data on this endpoint to contain the current
    * values of the modem and line status registers. In the absence of data, the device
    * generates a message consisting of these two status bytes every 40 ms
    - *
    + *
    * Byte 0: Modem Status
    - *
    + *
    * Offset Description
    * B0 Reserved - must be 1
    * B1 Reserved - must be 0
    @@ -1322,9 +1322,9 @@ typedef enum {
    * B5 Data Set Ready (DSR)
    * B6 Ring Indicator (RI)
    * B7 Receive Line Signal Detect (RLSD)
    - *
    + *
    * Byte 1: Line Status
    - *
    + *
    * Offset Description
    * B0 Data Ready (DR)
    * B1 Overrun Error (OE)
    @@ -1334,7 +1334,7 @@ typedef enum {
    * B5 Transmitter Holding Register (THRE)
    * B6 Transmitter Empty (TEMT)
    * B7 Error in RCVR FIFO
    - *
    + *
    */
    #define FTDI_RS0_CTS (1 << 4)
    #define FTDI_RS0_DSR (1 << 5)
    @@ -1352,17 +1352,17 @@ typedef enum {

    /*
    * OUT Endpoint
    - *
    + *
    * This device reserves the first bytes of data on this endpoint contain the length
    * and port identifier of the message. For the FTDI USB Serial converter the port
    * identifier is always 1.
    - *
    + *
    * Byte 0: Line Status
    - *
    + *
    * Offset Description
    * B0 Reserved - must be 1
    * B1 Reserved - must be 0
    * B2..7 Length of message - (not including Byte 0)
    - *
    + *
    */


    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  5. [PATCH 58/70] mct_u232: Use flip buffer functions

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/mct_u232.c | 4 +---
    1 files changed, 1 insertions(+), 3 deletions(-)


    diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
    index 7a804d6..0ded8bd 100644
    --- a/drivers/usb/serial/mct_u232.c
    +++ b/drivers/usb/serial/mct_u232.c
    @@ -563,11 +563,9 @@ static void mct_u232_read_int_callback(struct urb *urb)
    * Work-a-round: handle the 'usual' bulk-in pipe here
    */
    if (urb->transfer_buffer_length > 2) {
    - int i;
    tty = port->port.tty;
    if (urb->actual_length) {
    - for (i = 0; i < urb->actual_length ; ++i)
    - tty_insert_flip_char(tty, data[i], 0);
    + tty_insert_flip_string(tty, data, urb->actual_length);
    tty_flip_buffer_push(tty);
    }
    goto exit;

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  6. [PATCH 50/70] tty-usb-keyspan: Coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/keyspan.c | 839 +++++++++++++++++++++---------------------
    1 files changed, 427 insertions(+), 412 deletions(-)


    diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
    index 823ea97..8c7dc40 100644
    --- a/drivers/usb/serial/keyspan.c
    +++ b/drivers/usb/serial/keyspan.c
    @@ -1,29 +1,29 @@
    /*
    Keyspan USB to Serial Converter driver
    -
    +
    (C) Copyright (C) 2000-2001 Hugh Blemings
    (C) Copyright (C) 2002 Greg Kroah-Hartman
    -
    +
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    See http://misc.nu/hugh/keyspan.html for more information.
    -
    +
    Code in this driver inspired by and in a number of places taken
    from Brian Warner's original Keyspan-PDA driver.

    This driver has been put together with the support of Innosys, Inc.
    and Keyspan, Inc the manufacturers of the Keyspan USB-serial products.
    Thanks Guys
    -
    +
    Thanks to Paulus for miscellaneous tidy ups, some largish chunks
    of much nicer and/or completely new code and (perhaps most uniquely)
    having the patience to sit down and explain why and where he'd changed
    - stuff.
    -
    - Tip 'o the hat to IBM (and previously Linuxcare for supporting
    + stuff.
    +
    + Tip 'o the hat to IBM (and previously Linuxcare for supporting
    staff in their work on open source projects.

    Change History
    @@ -70,21 +70,21 @@

    Thu May 31 11:56:42 PDT 2001 gkh
    switched from using spinlock to a semaphore
    -
    +
    (04/08/2001) gb
    Identify version on module load.
    -
    +
    (11/01/2000) Adam J. Richter
    usb_device_id table support.
    -
    +
    Tue Oct 10 23:15:33 EST 2000 Hugh
    Merged Paul's changes with my USA-49W mods. Work in progress
    still...
    -
    +
    Wed Jul 19 14:00:42 EST 2000 gkh
    Added module_init and module_exit functions to handle the fact that
    this driver is a loadable module now.
    -
    +
    Tue Jul 18 16:14:52 EST 2000 Hugh
    Basic character input/output for USA-19 now mostly works,
    fixed at 9600 baud for the moment.
    @@ -105,7 +105,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include
    #include "keyspan.h"
    @@ -130,15 +130,15 @@ struct keyspan_serial_private {
    struct urb *instat_urb;
    char instat_buf[INSTAT_BUFLEN];

    - /* added to support 49wg, where data from all 4 ports comes in on 1 EP */
    - /* and high-speed supported */
    + /* added to support 49wg, where data from all 4 ports comes in
    + on 1 EP and high-speed supported */
    struct urb *indat_urb;
    char indat_buf[INDAT49W_BUFLEN];

    /* XXX this one probably will need a lock */
    struct urb *glocont_urb;
    char glocont_buf[GLOCONT_BUFLEN];
    - char ctrl_buf[8]; // for EP0 control message
    + char ctrl_buf[8]; /* for EP0 control message */
    };

    struct keyspan_port_private {
    @@ -184,19 +184,19 @@ struct keyspan_port_private {
    int resend_cont; /* need to resend control packet */
    };

    -
    /* Include Keyspan message headers. All current Keyspan Adapters
    make use of one of five message formats which are referred
    - to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and within this driver. */
    + to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and
    + within this driver. */
    #include "keyspan_usa26msg.h"
    #include "keyspan_usa28msg.h"
    #include "keyspan_usa49msg.h"
    #include "keyspan_usa90msg.h"
    #include "keyspan_usa67msg.h"
    -
    +

    /* Functions used by new usb-serial code. */
    -static int __init keyspan_init (void)
    +static int __init keyspan_init(void)
    {
    int retval;
    retval = usb_serial_register(&keyspan_pre_device);
    @@ -212,7 +212,7 @@ static int __init keyspan_init (void)
    if (retval)
    goto failed_4port_device_register;
    retval = usb_register(&keyspan_driver);
    - if (retval)
    + if (retval)
    goto failed_usb_register;

    info(DRIVER_VERSION ":" DRIVER_DESC);
    @@ -230,13 +230,13 @@ failed_pre_device_register:
    return retval;
    }

    -static void __exit keyspan_exit (void)
    +static void __exit keyspan_exit(void)
    {
    - usb_deregister (&keyspan_driver);
    - usb_serial_deregister (&keyspan_pre_device);
    - usb_serial_deregister (&keyspan_1port_device);
    - usb_serial_deregister (&keyspan_2port_device);
    - usb_serial_deregister (&keyspan_4port_device);
    + usb_deregister(&keyspan_driver);
    + usb_serial_deregister(&keyspan_pre_device);
    + usb_serial_deregister(&keyspan_1port_device);
    + usb_serial_deregister(&keyspan_2port_device);
    + usb_serial_deregister(&keyspan_4port_device);
    }

    module_init(keyspan_init);
    @@ -247,7 +247,7 @@ static void keyspan_break_ctl(struct tty_struct *tty, int break_state)
    struct usb_serial_port *port = tty->driver_data;
    struct keyspan_port_private *p_priv;

    - dbg("%s", __func__);
    + dbg("%s", __func__);

    p_priv = usb_get_serial_port_data(port);

    @@ -260,7 +260,7 @@ static void keyspan_break_ctl(struct tty_struct *tty, int break_state)
    }


    -static void keyspan_set_termios (struct tty_struct *tty,
    +static void keyspan_set_termios(struct tty_struct *tty,
    struct usb_serial_port *port, struct ktermios *old_termios)
    {
    int baud_rate, device_port;
    @@ -278,7 +278,7 @@ static void keyspan_set_termios (struct tty_struct *tty,
    /* Baud rate calculation takes baud rate as an integer
    so other rates can be generated if desired. */
    baud_rate = tty_get_baud_rate(tty);
    - /* If no match or invalid, don't change */
    + /* If no match or invalid, don't change */
    if (d_details->calculate_baud_rate(baud_rate, d_details->baudclk,
    NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
    /* FIXME - more to do here to ensure rate changes cleanly */
    @@ -303,13 +303,13 @@ static int keyspan_tiocmget(struct tty_struct *tty, struct file *file)
    struct usb_serial_port *port = tty->driver_data;
    struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
    unsigned int value;
    -
    +
    value = ((p_priv->rts_state) ? TIOCM_RTS : 0) |
    ((p_priv->dtr_state) ? TIOCM_DTR : 0) |
    ((p_priv->cts_state) ? TIOCM_CTS : 0) |
    ((p_priv->dsr_state) ? TIOCM_DSR : 0) |
    ((p_priv->dcd_state) ? TIOCM_CAR : 0) |
    - ((p_priv->ri_state) ? TIOCM_RNG : 0);
    + ((p_priv->ri_state) ? TIOCM_RNG : 0);

    return value;
    }
    @@ -319,7 +319,7 @@ static int keyspan_tiocmset(struct tty_struct *tty, struct file *file,
    {
    struct usb_serial_port *port = tty->driver_data;
    struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
    -
    +
    if (set & TIOCM_RTS)
    p_priv->rts_state = 1;
    if (set & TIOCM_DTR)
    @@ -342,19 +342,19 @@ static int keyspan_write(struct tty_struct *tty,
    int flip;
    int left, todo;
    struct urb *this_urb;
    - int err, maxDataLen, dataOffset;
    + int err, maxDataLen, dataOffset;

    p_priv = usb_get_serial_port_data(port);
    d_details = p_priv->device_details;

    if (d_details->msg_format == msg_usa90) {
    - maxDataLen = 64;
    + maxDataLen = 64;
    dataOffset = 0;
    } else {
    maxDataLen = 63;
    dataOffset = 1;
    }
    -
    +
    dbg("%s - for port %d (%d chars), flip=%d",
    __func__, port->number, count, p_priv->out_flip);

    @@ -364,37 +364,40 @@ static int keyspan_write(struct tty_struct *tty,
    todo = maxDataLen;

    flip = p_priv->out_flip;
    -
    +
    /* Check we have a valid urb/endpoint before we use it... */
    - if ((this_urb = p_priv->out_urbs[flip]) == NULL) {
    + this_urb = p_priv->out_urbs[flip];
    + if (this_urb == NULL) {
    /* no bulk out, so return 0 bytes written */
    dbg("%s - no output urb ", __func__);
    return count;
    }

    - dbg("%s - endpoint %d flip %d", __func__, usb_pipeendpoint(this_urb->pipe), flip);
    + dbg("%s - endpoint %d flip %d",
    + __func__, usb_pipeendpoint(this_urb->pipe), flip);

    if (this_urb->status == -EINPROGRESS) {
    - if (time_before(jiffies, p_priv->tx_start_time[flip] + 10 * HZ))
    + if (time_before(jiffies,
    + p_priv->tx_start_time[flip] + 10 * HZ))
    break;
    usb_unlink_urb(this_urb);
    break;
    }

    - /* First byte in buffer is "last flag" (except for usa19hx) - unused so
    - for now so set to zero */
    + /* First byte in buffer is "last flag" (except for usa19hx)
    + - unused so for now so set to zero */
    ((char *)this_urb->transfer_buffer)[0] = 0;

    - memcpy (this_urb->transfer_buffer + dataOffset, buf, todo);
    + memcpy(this_urb->transfer_buffer + dataOffset, buf, todo);
    buf += todo;

    /* send the data out the bulk port */
    this_urb->transfer_buffer_length = todo + dataOffset;

    this_urb->dev = port->serial->dev;
    - if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) {
    + err = usb_submit_urb(this_urb, GFP_ATOMIC);
    + if (err != 0)
    dbg("usb_submit_urb(write bulk) failed (%d)", err);
    - }
    p_priv->tx_start_time[flip] = jiffies;

    /* Flip for next time if usa26 or usa28 interface
    @@ -414,7 +417,7 @@ static void usa26_indat_callback(struct urb *urb)
    unsigned char *data = urb->transfer_buffer;
    int status = urb->status;

    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    endpoint = usb_pipeendpoint(urb->pipe);

    @@ -429,13 +432,14 @@ static void usa26_indat_callback(struct urb *urb)
    if (tty && urb->actual_length) {
    /* 0x80 bit is error flag */
    if ((data[0] & 0x80) == 0) {
    - /* no errors on individual bytes, only possible overrun err*/
    + /* no errors on individual bytes, only
    + possible overrun err */
    if (data[0] & RXERROR_OVERRUN)
    - err = TTY_OVERRUN;
    - else err = 0;
    - for (i = 1; i < urb->actual_length ; ++i) {
    + err = TTY_OVERRUN;
    + else
    + err = 0;
    + for (i = 1; i < urb->actual_length ; ++i)
    tty_insert_flip_char(tty, data[i], err);
    - }
    } else {
    /* some bytes had errors, every byte has status */
    dbg("%s - RX error!!!!", __func__);
    @@ -453,17 +457,19 @@ static void usa26_indat_callback(struct urb *urb)
    }
    tty_flip_buffer_push(tty);
    }
    -
    - /* Resubmit urb so we continue receiving */
    +
    + /* Resubmit urb so we continue receiving */
    urb->dev = port->serial->dev;
    - if (port->port.count)
    - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
    - dbg("%s - resubmit read urb failed. (%d)", __func__, err);
    - }
    + if (port->port.count) {
    + err = usb_submit_urb(urb, GFP_ATOMIC);
    + if (err != 0)
    + dbg("%s - resubmit read urb failed. (%d)",
    + __func__, err);
    + }
    return;
    }

    - /* Outdat handling is common for all devices */
    +/* Outdat handling is common for all devices */
    static void usa2x_outdat_callback(struct urb *urb)
    {
    struct usb_serial_port *port;
    @@ -471,7 +477,7 @@ static void usa2x_outdat_callback(struct urb *urb)

    port = urb->context;
    p_priv = usb_get_serial_port_data(port);
    - dbg ("%s - urb %d", __func__, urb == p_priv->out_urbs[1]);
    + dbg("%s - urb %d", __func__, urb == p_priv->out_urbs[1]);

    if (port->port.count)
    usb_serial_port_softint(port);
    @@ -479,8 +485,8 @@ static void usa2x_outdat_callback(struct urb *urb)

    static void usa26_inack_callback(struct urb *urb)
    {
    - dbg ("%s", __func__);
    -
    + dbg("%s", __func__);
    +
    }

    static void usa26_outcont_callback(struct urb *urb)
    @@ -492,8 +498,9 @@ static void usa26_outcont_callback(struct urb *urb)
    p_priv = usb_get_serial_port_data(port);

    if (p_priv->resend_cont) {
    - dbg ("%s - sending setup", __func__);
    - keyspan_usa26_send_setup(port->serial, port, p_priv->resend_cont - 1);
    + dbg("%s - sending setup", __func__);
    + keyspan_usa26_send_setup(port->serial, port,
    + p_priv->resend_cont - 1);
    }
    }

    @@ -529,14 +536,14 @@ static void usa26_instat_callback(struct urb *urb)
    /* Now do something useful with the data */


    - /* Check port number from message and retrieve private data */
    + /* Check port number from message and retrieve private data */
    if (msg->port >= serial->num_ports) {
    - dbg ("%s - Unexpected port number %d", __func__, msg->port);
    + dbg("%s - Unexpected port number %d", __func__, msg->port);
    goto exit;
    }
    port = serial->port[msg->port];
    p_priv = usb_get_serial_port_data(port);
    -
    +
    /* Update handshaking pin state information */
    old_dcd_state = p_priv->dcd_state;
    p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
    @@ -551,19 +558,18 @@ static void usa26_instat_callback(struct urb *urb)
    /* else */
    /* wake_up_interruptible(&p_priv->open_wait); */
    }
    -
    +
    /* Resubmit urb so we continue receiving */
    urb->dev = serial->dev;
    - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
    + err = usb_submit_urb(urb, GFP_ATOMIC);
    + if (err != 0)
    dbg("%s - resubmit read urb failed. (%d)", __func__, err);
    - }
    exit: ;
    }

    static void usa26_glocont_callback(struct urb *urb)
    {
    - dbg ("%s", __func__);
    -
    + dbg("%s", __func__);
    }


    @@ -576,7 +582,7 @@ static void usa28_indat_callback(struct urb *urb)
    struct keyspan_port_private *p_priv;
    int status = urb->status;

    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    port = urb->context;
    p_priv = usb_get_serial_port_data(port);
    @@ -598,18 +604,19 @@ static void usa28_indat_callback(struct urb *urb)

    tty = port->port.tty;
    if (urb->actual_length) {
    - for (i = 0; i < urb->actual_length ; ++i) {
    + for (i = 0; i < urb->actual_length ; ++i)
    tty_insert_flip_char(tty, data[i], 0);
    - }
    tty_flip_buffer_push(tty);
    }

    /* Resubmit urb so we continue receiving */
    urb->dev = port->serial->dev;
    - if (port->port.count)
    - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
    - dbg("%s - resubmit read urb failed. (%d)", __func__, err);
    - }
    + if (port->port.count) {
    + err = usb_submit_urb(urb, GFP_ATOMIC);
    + if (err != 0)
    + dbg("%s - resubmit read urb failed. (%d)",
    + __func__, err);
    + }
    p_priv->in_flip ^= 1;

    urb = p_priv->in_urbs[p_priv->in_flip];
    @@ -618,7 +625,7 @@ static void usa28_indat_callback(struct urb *urb)

    static void usa28_inack_callback(struct urb *urb)
    {
    - dbg ("%s", __func__);
    + dbg("%s", __func__);
    }

    static void usa28_outcont_callback(struct urb *urb)
    @@ -630,8 +637,9 @@ static void usa28_outcont_callback(struct urb *urb)
    p_priv = usb_get_serial_port_data(port);

    if (p_priv->resend_cont) {
    - dbg ("%s - sending setup", __func__);
    - keyspan_usa28_send_setup(port->serial, port, p_priv->resend_cont - 1);
    + dbg("%s - sending setup", __func__);
    + keyspan_usa28_send_setup(port->serial, port,
    + p_priv->resend_cont - 1);
    }
    }

    @@ -661,19 +669,18 @@ static void usa28_instat_callback(struct urb *urb)
    /*dbg("%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__
    data[0], data[1], data[2], data[3], data[4], data[5],
    data[6], data[7], data[8], data[9], data[10], data[11]);*/
    -
    - /* Now do something useful with the data */
    - msg = (struct keyspan_usa28_portStatusMessage *)data;

    + /* Now do something useful with the data */
    + msg = (struct keyspan_usa28_portStatusMessage *)data;

    - /* Check port number from message and retrieve private data */
    + /* Check port number from message and retrieve private data */
    if (msg->port >= serial->num_ports) {
    - dbg ("%s - Unexpected port number %d", __func__, msg->port);
    + dbg("%s - Unexpected port number %d", __func__, msg->port);
    goto exit;
    }
    port = serial->port[msg->port];
    p_priv = usb_get_serial_port_data(port);
    -
    +
    /* Update handshaking pin state information */
    old_dcd_state = p_priv->dcd_state;
    p_priv->cts_state = ((msg->cts) ? 1 : 0);
    @@ -691,15 +698,15 @@ static void usa28_instat_callback(struct urb *urb)

    /* Resubmit urb so we continue receiving */
    urb->dev = serial->dev;
    - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
    + err = usb_submit_urb(urb, GFP_ATOMIC);
    + if (err != 0)
    dbg("%s - resubmit read urb failed. (%d)", __func__, err);
    - }
    exit: ;
    }

    static void usa28_glocont_callback(struct urb *urb)
    {
    - dbg ("%s", __func__);
    + dbg("%s", __func__);
    }


    @@ -710,7 +717,7 @@ static void usa49_glocont_callback(struct urb *urb)
    struct keyspan_port_private *p_priv;
    int i;

    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    serial = urb->context;
    for (i = 0; i < serial->num_ports; ++i) {
    @@ -718,8 +725,9 @@ static void usa49_glocont_callback(struct urb *urb)
    p_priv = usb_get_serial_port_data(port);

    if (p_priv->resend_cont) {
    - dbg ("%s - sending setup", __func__);
    - keyspan_usa49_send_setup(serial, port, p_priv->resend_cont - 1);
    + dbg("%s - sending setup", __func__);
    + keyspan_usa49_send_setup(serial, port,
    + p_priv->resend_cont - 1);
    break;
    }
    }
    @@ -738,7 +746,7 @@ static void usa49_instat_callback(struct urb *urb)
    int old_dcd_state;
    int status = urb->status;

    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    serial = urb->context;

    @@ -747,7 +755,8 @@ static void usa49_instat_callback(struct urb *urb)
    return;
    }

    - if (urb->actual_length != sizeof(struct keyspan_usa49_portStatusMessage)) {
    + if (urb->actual_length !=
    + sizeof(struct keyspan_usa49_portStatusMessage)) {
    dbg("%s - bad length %d", __func__, urb->actual_length);
    goto exit;
    }
    @@ -755,18 +764,19 @@ static void usa49_instat_callback(struct urb *urb)
    /*dbg(" %x %x %x %x %x %x %x %x %x %x %x", __func__,
    data[0], data[1], data[2], data[3], data[4], data[5],
    data[6], data[7], data[8], data[9], data[10]);*/
    -
    - /* Now do something useful with the data */
    +
    + /* Now do something useful with the data */
    msg = (struct keyspan_usa49_portStatusMessage *)data;

    - /* Check port number from message and retrieve private data */
    + /* Check port number from message and retrieve private data */
    if (msg->portNumber >= serial->num_ports) {
    - dbg ("%s - Unexpected port number %d", __func__, msg->portNumber);
    + dbg("%s - Unexpected port number %d",
    + __func__, msg->portNumber);
    goto exit;
    }
    port = serial->port[msg->portNumber];
    p_priv = usb_get_serial_port_data(port);
    -
    +
    /* Update handshaking pin state information */
    old_dcd_state = p_priv->dcd_state;
    p_priv->cts_state = ((msg->cts) ? 1 : 0);
    @@ -782,18 +792,18 @@ static void usa49_instat_callback(struct urb *urb)
    /* wake_up_interruptible(&p_priv->open_wait); */
    }

    - /* Resubmit urb so we continue receiving */
    + /* Resubmit urb so we continue receiving */
    urb->dev = serial->dev;

    - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
    + err = usb_submit_urb(urb, GFP_ATOMIC);
    + if (err != 0)
    dbg("%s - resubmit read urb failed. (%d)", __func__, err);
    - }
    exit: ;
    }

    static void usa49_inack_callback(struct urb *urb)
    {
    - dbg ("%s", __func__);
    + dbg("%s", __func__);
    }

    static void usa49_indat_callback(struct urb *urb)
    @@ -805,7 +815,7 @@ static void usa49_indat_callback(struct urb *urb)
    unsigned char *data = urb->transfer_buffer;
    int status = urb->status;

    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    endpoint = usb_pipeendpoint(urb->pipe);

    @@ -821,9 +831,8 @@ static void usa49_indat_callback(struct urb *urb)
    /* 0x80 bit is error flag */
    if ((data[0] & 0x80) == 0) {
    /* no error on any byte */
    - for (i = 1; i < urb->actual_length ; ++i) {
    + for (i = 1; i < urb->actual_length ; ++i)
    tty_insert_flip_char(tty, data[i], 0);
    - }
    } else {
    /* some bytes had errors, every byte has status */
    for (i = 0; i + 1 < urb->actual_length; i += 2) {
    @@ -840,13 +849,15 @@ static void usa49_indat_callback(struct urb *urb)
    }
    tty_flip_buffer_push(tty);
    }
    -
    - /* Resubmit urb so we continue receiving */
    +
    + /* Resubmit urb so we continue receiving */
    urb->dev = port->serial->dev;
    - if (port->port.count)
    - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
    - dbg("%s - resubmit read urb failed. (%d)", __func__, err);
    - }
    + if (port->port.count) {
    + err = usb_submit_urb(urb, GFP_ATOMIC);
    + if (err != 0)
    + dbg("%s - resubmit read urb failed. (%d)",
    + __func__, err);
    + }
    }

    static void usa49wg_indat_callback(struct urb *urb)
    @@ -858,7 +869,7 @@ static void usa49wg_indat_callback(struct urb *urb)
    unsigned char *data = urb->transfer_buffer;
    int status = urb->status;

    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    serial = urb->context;

    @@ -876,7 +887,7 @@ static void usa49wg_indat_callback(struct urb *urb)

    /* Check port number from message*/
    if (data[i] >= serial->num_ports) {
    - dbg ("%s - Unexpected port number %d",
    + dbg("%s - Unexpected port number %d",
    __func__, data[i]);
    return;
    }
    @@ -929,7 +940,7 @@ static void usa49wg_indat_callback(struct urb *urb)
    /* not used, usa-49 doesn't have per-port control endpoints */
    static void usa49_outcont_callback(struct urb *urb)
    {
    - dbg ("%s", __func__);
    + dbg("%s", __func__);
    }

    static void usa90_indat_callback(struct urb *urb)
    @@ -942,7 +953,7 @@ static void usa90_indat_callback(struct urb *urb)
    unsigned char *data = urb->transfer_buffer;
    int status = urb->status;

    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    endpoint = usb_pipeendpoint(urb->pipe);

    @@ -957,27 +968,25 @@ static void usa90_indat_callback(struct urb *urb)

    tty = port->port.tty;
    if (urb->actual_length) {
    -
    /* if current mode is DMA, looks like usa28 format
    - otherwise looks like usa26 data format */
    + otherwise looks like usa26 data format */

    if (p_priv->baud > 57600) {
    - for (i = 0; i < urb->actual_length ; ++i)
    + for (i = 0; i < urb->actual_length ; ++i)
    tty_insert_flip_char(tty, data[i], 0);
    - }
    - else {
    -
    + } else {
    /* 0x80 bit is error flag */
    if ((data[0] & 0x80) == 0) {
    - /* no errors on individual bytes, only possible overrun err*/
    + /* no errors on individual bytes, only
    + possible overrun err*/
    if (data[0] & RXERROR_OVERRUN)
    - err = TTY_OVERRUN;
    - else err = 0;
    - for (i = 1; i < urb->actual_length ; ++i)
    - tty_insert_flip_char(tty, data[i], err);
    -
    - }
    - else {
    + err = TTY_OVERRUN;
    + else
    + err = 0;
    + for (i = 1; i < urb->actual_length ; ++i)
    + tty_insert_flip_char(tty, data[i],
    + err);
    + } else {
    /* some bytes had errors, every byte has status */
    dbg("%s - RX error!!!!", __func__);
    for (i = 0; i + 1 < urb->actual_length; i += 2) {
    @@ -989,19 +998,22 @@ static void usa90_indat_callback(struct urb *urb)
    if (stat & RXERROR_PARITY)
    flag |= TTY_PARITY;
    /* XXX should handle break (0x10) */
    - tty_insert_flip_char(tty, data[i+1], flag);
    + tty_insert_flip_char(tty, data[i+1],
    + flag);
    }
    }
    }
    tty_flip_buffer_push(tty);
    }
    -
    +
    /* Resubmit urb so we continue receiving */
    urb->dev = port->serial->dev;
    - if (port->port.count)
    - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
    - dbg("%s - resubmit read urb failed. (%d)", __func__, err);
    - }
    + if (port->port.count) {
    + err = usb_submit_urb(urb, GFP_ATOMIC);
    + if (err != 0)
    + dbg("%s - resubmit read urb failed. (%d)",
    + __func__, err);
    + }
    return;
    }

    @@ -1033,7 +1045,7 @@ static void usa90_instat_callback(struct urb *urb)

    port = serial->port[0];
    p_priv = usb_get_serial_port_data(port);
    -
    +
    /* Update handshaking pin state information */
    old_dcd_state = p_priv->dcd_state;
    p_priv->cts_state = ((msg->cts) ? 1 : 0);
    @@ -1048,12 +1060,12 @@ static void usa90_instat_callback(struct urb *urb)
    /* else */
    /* wake_up_interruptible(&p_priv->open_wait); */
    }
    -
    +
    /* Resubmit urb so we continue receiving */
    urb->dev = serial->dev;
    - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
    + err = usb_submit_urb(urb, GFP_ATOMIC);
    + if (err != 0)
    dbg("%s - resubmit read urb failed. (%d)", __func__, err);
    - }
    exit:
    ;
    }
    @@ -1067,8 +1079,9 @@ static void usa90_outcont_callback(struct urb *urb)
    p_priv = usb_get_serial_port_data(port);

    if (p_priv->resend_cont) {
    - dbg ("%s - sending setup", __func__);
    - keyspan_usa90_send_setup(port->serial, port, p_priv->resend_cont - 1);
    + dbg("%s - sending setup", __func__);
    + keyspan_usa90_send_setup(port->serial, port,
    + p_priv->resend_cont - 1);
    }
    }

    @@ -1084,7 +1097,7 @@ static void usa67_instat_callback(struct urb *urb)
    int old_dcd_state;
    int status = urb->status;

    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    serial = urb->context;

    @@ -1093,7 +1106,8 @@ static void usa67_instat_callback(struct urb *urb)
    return;
    }

    - if (urb->actual_length != sizeof(struct keyspan_usa67_portStatusMessage)) {
    + if (urb->actual_length !=
    + sizeof(struct keyspan_usa67_portStatusMessage)) {
    dbg("%s - bad length %d", __func__, urb->actual_length);
    return;
    }
    @@ -1104,7 +1118,7 @@ static void usa67_instat_callback(struct urb *urb)

    /* Check port number from message and retrieve private data */
    if (msg->port >= serial->num_ports) {
    - dbg ("%s - Unexpected port number %d", __func__, msg->port);
    + dbg("%s - Unexpected port number %d", __func__, msg->port);
    return;
    }

    @@ -1138,7 +1152,7 @@ static void usa67_glocont_callback(struct urb *urb)
    struct keyspan_port_private *p_priv;
    int i;

    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    serial = urb->context;
    for (i = 0; i < serial->num_ports; ++i) {
    @@ -1146,7 +1160,7 @@ static void usa67_glocont_callback(struct urb *urb)
    p_priv = usb_get_serial_port_data(port);

    if (p_priv->resend_cont) {
    - dbg ("%s - sending setup", __func__);
    + dbg("%s - sending setup", __func__);
    keyspan_usa67_send_setup(serial, port,
    p_priv->resend_cont - 1);
    break;
    @@ -1169,20 +1183,23 @@ static int keyspan_write_room(struct tty_struct *tty)

    /* FIXME: locking */
    if (d_details->msg_format == msg_usa90)
    - data_len = 64;
    + data_len = 64;
    else
    data_len = 63;

    flip = p_priv->out_flip;

    /* Check both endpoints to see if any are available. */
    - if ((this_urb = p_priv->out_urbs[flip]) != NULL) {
    + this_urb = p_priv->out_urbs[flip];
    + if (this_urb != NULL) {
    if (this_urb->status != -EINPROGRESS)
    - return (data_len);
    - flip = (flip + 1) & d_details->outdat_endp_flip;
    - if ((this_urb = p_priv->out_urbs[flip]) != NULL)
    + return data_len;
    + flip = (flip + 1) & d_details->outdat_endp_flip;
    + this_urb = p_priv->out_urbs[flip];
    + if (this_urb != NULL) {
    if (this_urb->status != -EINPROGRESS)
    - return (data_len);
    + return data_len;
    + }
    }
    return 0;
    }
    @@ -1220,25 +1237,28 @@ static int keyspan_open(struct tty_struct *tty,

    /* Reset low level data toggle and start reading from endpoints */
    for (i = 0; i < 2; i++) {
    - if ((urb = p_priv->in_urbs[i]) == NULL)
    + urb = p_priv->in_urbs[i];
    + if (urb == NULL)
    continue;
    urb->dev = serial->dev;

    - /* 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);
    -
    - if ((err = usb_submit_urb(urb, GFP_KERNEL)) != 0) {
    - dbg("%s - submit urb %d failed (%d)", __func__, i, err);
    - }
    + err = usb_submit_urb(urb, GFP_KERNEL);
    + if (err != 0)
    + dbg("%s - submit urb %d failed (%d)",
    + __func__, i, err);
    }

    /* Reset low level data toggle on out endpoints */
    for (i = 0; i < 2; i++) {
    - if ((urb = p_priv->out_urbs[i]) == NULL)
    + urb = p_priv->out_urbs[i];
    + if (urb == NULL)
    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); */
    }

    /* get the terminal config for the setup message now so we don't
    @@ -1262,8 +1282,8 @@ static int keyspan_open(struct tty_struct *tty,
    p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none;

    keyspan_send_setup(port, 1);
    - //mdelay(100);
    - //keyspan_set_termios(port, NULL);
    + /* mdelay(100); */
    + /* keyspan_set_termios(port, NULL); */

    return 0;
    }
    @@ -1285,15 +1305,15 @@ static void keyspan_close(struct tty_struct *tty,
    dbg("%s", __func__);
    s_priv = usb_get_serial_data(serial);
    p_priv = usb_get_serial_port_data(port);
    -
    +
    p_priv->rts_state = 0;
    p_priv->dtr_state = 0;
    -
    +
    if (serial->dev) {
    keyspan_send_setup(port, 2);
    /* pilot-xfer seems to work best with this delay */
    mdelay(100);
    - // keyspan_set_termios(port, NULL);
    + /* keyspan_set_termios(port, NULL); */
    }

    /*while (p_priv->outcont_urb->status == -EINPROGRESS) {
    @@ -1316,8 +1336,8 @@ static void keyspan_close(struct tty_struct *tty,
    }


    - /* download the firmware to a pre-renumeration device */
    -static int keyspan_fake_startup (struct usb_serial *serial)
    +/* download the firmware to a pre-renumeration device */
    +static int keyspan_fake_startup(struct usb_serial *serial)
    {
    int response;
    const struct ezusb_hex_record *record;
    @@ -1326,10 +1346,11 @@ static int keyspan_fake_startup (struct usb_serial *serial)
    dbg("Keyspan startup version %04x product %04x",
    le16_to_cpu(serial->dev->descriptor.bcdDevice),
    le16_to_cpu(serial->dev->descriptor.idProduct));
    -
    - if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000) != 0x8000) {
    +
    + if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000)
    + != 0x8000) {
    dbg("Firmware already loaded. Quitting.");
    - return(1);
    + return 1;
    }

    /* Select firmware image on the basis of idProduct */
    @@ -1358,12 +1379,12 @@ static int keyspan_fake_startup (struct usb_serial *serial)
    record = &keyspan_usa19_firmware[0];
    fw_name = "USA19";
    break;
    -
    +
    case keyspan_usa19qi_pre_product_id:
    record = &keyspan_usa19qi_firmware[0];
    fw_name = "USA19QI";
    break;
    -
    +
    case keyspan_mpr_pre_product_id:
    record = &keyspan_mpr_firmware[0];
    fw_name = "MPR";
    @@ -1373,17 +1394,17 @@ static int keyspan_fake_startup (struct usb_serial *serial)
    record = &keyspan_usa19qw_firmware[0];
    fw_name = "USA19QI";
    break;
    -
    +
    case keyspan_usa18x_pre_product_id:
    record = &keyspan_usa18x_firmware[0];
    fw_name = "USA18X";
    break;
    -
    +
    case keyspan_usa19w_pre_product_id:
    record = &keyspan_usa19w_firmware[0];
    fw_name = "USA19W";
    break;
    -
    +
    case keyspan_usa49w_pre_product_id:
    record = &keyspan_usa49w_firmware[0];
    fw_name = "USA49W";
    @@ -1401,8 +1422,10 @@ static int keyspan_fake_startup (struct usb_serial *serial)
    }

    if (record == NULL) {
    - dev_err(&serial->dev->dev, "Required keyspan firmware image (%s) unavailable.\n", fw_name);
    - return(1);
    + dev_err(&serial->dev->dev,
    + "Required keyspan firmware image (%s) unavailable.\n",
    + fw_name);
    + return 1;
    }

    dbg("Uploading Keyspan %s firmware.", fw_name);
    @@ -1410,15 +1433,16 @@ static int keyspan_fake_startup (struct usb_serial *serial)
    /* download the firmware image */
    response = ezusb_set_reset(serial, 1);

    - while(record->address != 0xffff) {
    + while (record->address != 0xffff) {
    response = ezusb_writememory(serial, record->address,
    (unsigned char *)record->data,
    record->data_size, 0xa0);
    if (response < 0) {
    - dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan"
    - "firmware (%d %04X %p %d)\n",
    - response,
    - record->address, record->data, record->data_size);
    + dev_err(&serial->dev->dev,
    + "ezusb_writememory failed for Keyspan firmware (%d %04X %p %d)\n",
    + response,
    + record->address, record->data,
    + record->data_size);
    break;
    }
    record++;
    @@ -1428,7 +1452,7 @@ static int keyspan_fake_startup (struct usb_serial *serial)
    response = ezusb_set_reset(serial, 0);

    /* we don't want this device to have a driver assigned to it. */
    - return (1);
    + return 1;
    }

    /* Helper functions used by keyspan_setup_urbs */
    @@ -1450,7 +1474,7 @@ static struct usb_endpoint_descriptor const *find_ep(struct usb_serial const *se
    return NULL;
    }

    -static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint,
    +static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint,
    int dir, void *ctx, char *buf, int len,
    void (*callback)(struct urb *))
    {
    @@ -1461,10 +1485,10 @@ static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint,
    if (endpoint == -1)
    return NULL; /* endpoint not needed */

    - dbg ("%s - alloc for endpoint %d.", __func__, endpoint);
    + dbg("%s - alloc for endpoint %d.", __func__, endpoint);
    urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
    if (urb == NULL) {
    - dbg ("%s - alloc for endpoint %d failed.", __func__, endpoint);
    + dbg("%s - alloc for endpoint %d failed.", __func__, endpoint);
    return NULL;
    }

    @@ -1537,7 +1561,7 @@ static struct callbacks {
    }, {
    /* msg_usa90 callbacks */
    .instat_callback = usa90_instat_callback,
    - .glocont_callback = usa28_glocont_callback,
    + .glocont_callback = usa28_glocont_callback,
    .indat_callback = usa90_indat_callback,
    .outdat_callback = usa2x_outdat_callback,
    .inack_callback = usa28_inack_callback,
    @@ -1565,16 +1589,16 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
    struct callbacks *cback;
    int endp;

    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    s_priv = usb_get_serial_data(serial);
    d_details = s_priv->device_details;

    - /* Setup values for the various callback routines */
    + /* Setup values for the various callback routines */
    cback = &keyspan_callbacks[d_details->msg_format];

    - /* Allocate and set up urbs for each one that is in use,
    - starting with instat endpoints */
    + /* Allocate and set up urbs for each one that is in use,
    + starting with instat endpoints */
    s_priv->instat_urb = keyspan_setup_urb
    (serial, d_details->instat_endpoint, USB_DIR_IN,
    serial, s_priv->instat_buf, INSTAT_BUFLEN,
    @@ -1590,8 +1614,8 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
    serial, s_priv->glocont_buf, GLOCONT_BUFLEN,
    cback->glocont_callback);

    - /* Setup endpoints for each port specific thing */
    - for (i = 0; i < d_details->num_ports; i ++) {
    + /* Setup endpoints for each port specific thing */
    + for (i = 0; i < d_details->num_ports; i++) {
    port = serial->port[i];
    p_priv = usb_get_serial_port_data(port);

    @@ -1627,8 +1651,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
    (serial, d_details->outcont_endpoints[i], USB_DIR_OUT,
    port, p_priv->outcont_buffer, 64,
    cback->outcont_callback);
    - }
    -
    + }
    }

    /* usa19 function doesn't require prescaler */
    @@ -1636,46 +1659,39 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
    u8 *rate_low, u8 *prescaler, int portnum)
    {
    u32 b16, /* baud rate times 16 (actual rate used internally) */
    - div, /* divisor */
    + div, /* divisor */
    cnt; /* inverse of divisor (programmed into 8051) */
    -
    - dbg ("%s - %d.", __func__, baud_rate);

    - /* prevent divide by zero... */
    - if( (b16 = (baud_rate * 16L)) == 0) {
    - return (KEYSPAN_INVALID_BAUD_RATE);
    - }
    -
    - /* Any "standard" rate over 57k6 is marginal on the USA-19
    - as we run out of divisor resolution. */
    - if (baud_rate > 57600) {
    - return (KEYSPAN_INVALID_BAUD_RATE);
    - }
    -
    - /* calculate the divisor and the counter (its inverse) */
    - if( (div = (baudclk / b16)) == 0) {
    - return (KEYSPAN_INVALID_BAUD_RATE);
    - }
    - else {
    + dbg("%s - %d.", __func__, baud_rate);
    +
    + /* prevent divide by zero... */
    + b16 = baud_rate * 16L
    + if (b16 == 0)
    + return KEYSPAN_INVALID_BAUD_RATE;
    + /* Any "standard" rate over 57k6 is marginal on the USA-19
    + as we run out of divisor resolution. */
    + if (baud_rate > 57600)
    + return KEYSPAN_INVALID_BAUD_RATE;
    +
    + /* calculate the divisor and the counter (its inverse) */
    + div = baudclk / b16;
    + if (div == 0)
    + return KEYSPAN_INVALID_BAUD_RATE;
    + else
    cnt = 0 - div;
    - }

    - if(div > 0xffff) {
    - return (KEYSPAN_INVALID_BAUD_RATE);
    - }
    + if (div > 0xffff)
    + return KEYSPAN_INVALID_BAUD_RATE;

    - /* return the counter values if non-null */
    - if (rate_low) {
    + /* return the counter values if non-null */
    + if (rate_low)
    *rate_low = (u8) (cnt & 0xff);
    - }
    - if (rate_hi) {
    + if (rate_hi)
    *rate_hi = (u8) ((cnt >> 8) & 0xff);
    - }
    - if (rate_low && rate_hi) {
    - dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low);
    - }
    -
    - return (KEYSPAN_BAUD_RATE_OK);
    + if (rate_low && rate_hi)
    + dbg("%s - %d %02x %02x.",
    + __func__, baud_rate, *rate_hi, *rate_low);
    + return KEYSPAN_BAUD_RATE_OK;
    }

    /* usa19hs function doesn't require prescaler */
    @@ -1683,34 +1699,35 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
    u8 *rate_low, u8 *prescaler, int portnum)
    {
    u32 b16, /* baud rate times 16 (actual rate used internally) */
    - div; /* divisor */
    -
    - dbg ("%s - %d.", __func__, baud_rate);
    + div; /* divisor */

    - /* prevent divide by zero... */
    - if( (b16 = (baud_rate * 16L)) == 0)
    - return (KEYSPAN_INVALID_BAUD_RATE);
    -
    + dbg("%s - %d.", __func__, baud_rate);

    + /* prevent divide by zero... */
    + b16 = baud_rate * 16L;
    + if (b16 == 0)
    + return KEYSPAN_INVALID_BAUD_RATE;

    - /* calculate the divisor */
    - if( (div = (baudclk / b16)) == 0)
    - return (KEYSPAN_INVALID_BAUD_RATE);
    + /* calculate the divisor */
    + div = baudclk / b16;
    + if (div == 0)
    + return KEYSPAN_INVALID_BAUD_RATE;

    - if(div > 0xffff)
    - return (KEYSPAN_INVALID_BAUD_RATE);
    + if (div > 0xffff)
    + return KEYSPAN_INVALID_BAUD_RATE;

    - /* return the counter values if non-null */
    - if (rate_low)
    + /* return the counter values if non-null */
    + if (rate_low)
    *rate_low = (u8) (div & 0xff);
    -
    - if (rate_hi)
    +
    + if (rate_hi)
    *rate_hi = (u8) ((div >> 8) & 0xff);
    -
    - if (rate_low && rate_hi)
    - dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low);
    -
    - return (KEYSPAN_BAUD_RATE_OK);
    +
    + if (rate_low && rate_hi)
    + dbg("%s - %d %02x %02x.",
    + __func__, baud_rate, *rate_hi, *rate_low);
    +
    + return KEYSPAN_BAUD_RATE_OK;
    }

    static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
    @@ -1718,64 +1735,61 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
    {
    u32 b16, /* baud rate times 16 (actual rate used internally) */
    clk, /* clock with 13/8 prescaler */
    - div, /* divisor using 13/8 prescaler */
    + div, /* divisor using 13/8 prescaler */
    res, /* resulting baud rate using 13/8 prescaler */
    diff, /* error using 13/8 prescaler */
    smallest_diff;
    u8 best_prescaler;
    int i;

    - dbg ("%s - %d.", __func__, baud_rate);
    + dbg("%s - %d.", __func__, baud_rate);

    - /* prevent divide by zero */
    - if( (b16 = baud_rate * 16L) == 0) {
    - return (KEYSPAN_INVALID_BAUD_RATE);
    - }
    + /* prevent divide by zero */
    + b16 = baud_rate * 16L;
    + if (b16 == 0)
    + return KEYSPAN_INVALID_BAUD_RATE;

    - /* Calculate prescaler by trying them all and looking
    - for best fit */
    -
    - /* start with largest possible difference */
    + /* Calculate prescaler by trying them all and looking
    + for best fit */
    +
    + /* start with largest possible difference */
    smallest_diff = 0xffffffff;

    /* 0 is an invalid prescaler, used as a flag */
    best_prescaler = 0;

    - for(i = 8; i <= 0xff; ++i) {
    + for (i = 8; i <= 0xff; ++i) {
    clk = (baudclk * 8) / (u32) i;
    -
    - if( (div = clk / b16) == 0) {
    +
    + div = clk / b16;
    + if (div == 0)
    continue;
    - }

    res = clk / div;
    - diff= (res > b16) ? (res-b16) : (b16-res);
    + diff = (res > b16) ? (res-b16) : (b16-res);

    - if(diff < smallest_diff) {
    + if (diff < smallest_diff) {
    best_prescaler = i;
    smallest_diff = diff;
    }
    }

    - if(best_prescaler == 0) {
    - return (KEYSPAN_INVALID_BAUD_RATE);
    - }
    + if (best_prescaler == 0)
    + return KEYSPAN_INVALID_BAUD_RATE;

    clk = (baudclk * 8) / (u32) best_prescaler;
    div = clk / b16;

    - /* return the divisor and prescaler if non-null */
    - if (rate_low) {
    + /* return the divisor and prescaler if non-null */
    + if (rate_low)
    *rate_low = (u8) (div & 0xff);
    - }
    - if (rate_hi) {
    + if (rate_hi)
    *rate_hi = (u8) ((div >> 8) & 0xff);
    - }
    if (prescaler) {
    *prescaler = best_prescaler;
    /* dbg("%s - %d %d", __func__, *prescaler, div); */
    }
    - return (KEYSPAN_BAUD_RATE_OK);
    + return KEYSPAN_BAUD_RATE_OK;
    }

    /* USA-28 supports different maximum baud rates on each port */
    @@ -1783,57 +1797,51 @@ static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
    u8 *rate_low, u8 *prescaler, int portnum)
    {
    u32 b16, /* baud rate times 16 (actual rate used internally) */
    - div, /* divisor */
    + div, /* divisor */
    cnt; /* inverse of divisor (programmed into 8051) */

    - dbg ("%s - %d.", __func__, baud_rate);
    + dbg("%s - %d.", __func__, baud_rate);

    /* prevent divide by zero */
    - if ((b16 = baud_rate * 16L) == 0)
    - return (KEYSPAN_INVALID_BAUD_RATE);
    -
    - /* calculate the divisor and the counter (its inverse) */
    - if ((div = (KEYSPAN_USA28_BAUDCLK / b16)) == 0) {
    - return (KEYSPAN_INVALID_BAUD_RATE);
    - }
    - else {
    + b16 = baud_rate * 16L;
    + if (b16 == 0)
    + return KEYSPAN_INVALID_BAUD_RATE;
    +
    + /* calculate the divisor and the counter (its inverse) */
    + div = KEYSPAN_USA28_BAUDCLK / b16;
    + if (div == 0)
    + return KEYSPAN_INVALID_BAUD_RATE;
    + else
    cnt = 0 - div;
    - }

    - /* check for out of range, based on portnum,
    - and return result */
    - if(portnum == 0) {
    - if(div > 0xffff)
    - return (KEYSPAN_INVALID_BAUD_RATE);
    - }
    - else {
    - if(portnum == 1) {
    - if(div > 0xff) {
    - return (KEYSPAN_INVALID_BAUD_RATE);
    - }
    - }
    - else {
    - return (KEYSPAN_INVALID_BAUD_RATE);
    - }
    + /* check for out of range, based on portnum,
    + and return result */
    + if (portnum == 0) {
    + if (div > 0xffff)
    + return KEYSPAN_INVALID_BAUD_RATE;
    + } else {
    + if (portnum == 1) {
    + if (div > 0xff)
    + return KEYSPAN_INVALID_BAUD_RATE;
    + } else
    + return KEYSPAN_INVALID_BAUD_RATE;
    }

    /* return the counter values if not NULL
    (port 1 will ignore retHi) */
    - if (rate_low) {
    + if (rate_low)
    *rate_low = (u8) (cnt & 0xff);
    - }
    - if (rate_hi) {
    + if (rate_hi)
    *rate_hi = (u8) ((cnt >> 8) & 0xff);
    - }
    - dbg ("%s - %d OK.", __func__, baud_rate);
    - return (KEYSPAN_BAUD_RATE_OK);
    + dbg("%s - %d OK.", __func__, baud_rate);
    + return KEYSPAN_BAUD_RATE_OK;
    }

    static int keyspan_usa26_send_setup(struct usb_serial *serial,
    struct usb_serial_port *port,
    int reset_port)
    {
    - struct keyspan_usa26_portControlMessage msg;
    + struct keyspan_usa26_portControlMessage msg;
    struct keyspan_serial_private *s_priv;
    struct keyspan_port_private *p_priv;
    const struct keyspan_device_details *d_details;
    @@ -1841,7 +1849,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
    struct urb *this_urb;
    int device_port, err;

    - dbg ("%s reset=%d", __func__, reset_port);
    + dbg("%s reset=%d", __func__, reset_port);

    s_priv = usb_get_serial_data(serial);
    p_priv = usb_get_serial_port_data(port);
    @@ -1864,22 +1872,22 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
    if ((reset_port + 1) > p_priv->resend_cont)
    p_priv->resend_cont = reset_port + 1;
    if (this_urb->status == -EINPROGRESS) {
    - /* dbg ("%s - already writing", __func__); */
    + /* dbg("%s - already writing", __func__); */
    mdelay(5);
    - return(-1);
    + return -1;
    }

    - memset(&msg, 0, sizeof (struct keyspan_usa26_portControlMessage));
    -
    - /* Only set baud rate if it's changed */
    + memset(&msg, 0, sizeof(struct keyspan_usa26_portControlMessage));
    +
    + /* Only set baud rate if it's changed */
    if (p_priv->old_baud != p_priv->baud) {
    p_priv->old_baud = p_priv->baud;
    msg.setClocking = 0xff;
    if (d_details->calculate_baud_rate
    (p_priv->baud, d_details->baudclk, &msg.baudHi,
    - &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
    - dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
    - p_priv->baud);
    + &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
    + dbg("%s - Invalid baud rate %d requested, using 9600.",
    + __func__, p_priv->baud);
    msg.baudLo = 0;
    msg.baudHi = 125; /* Values for 9600 baud */
    msg.prescaler = 10;
    @@ -1905,7 +1913,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
    if (p_priv->cflag & PARENB) {
    /* note USA_PARITY_NONE == 0 */
    msg.lcr |= (p_priv->cflag & PARODD)?
    - USA_PARITY_ODD: USA_PARITY_EVEN;
    + USA_PARITY_ODD : USA_PARITY_EVEN;
    }
    msg.setLcr = 0xff;

    @@ -1946,7 +1954,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,

    /* Sending intermediate configs */
    else {
    - msg._txOn = (! p_priv->break_on);
    + msg._txOn = (!p_priv->break_on);
    msg._txOff = 0;
    msg.txFlush = 0;
    msg.txBreak = (p_priv->break_on);
    @@ -1958,23 +1966,23 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
    msg.resetDataToggle = 0x0;
    }

    - /* Do handshaking outputs */
    + /* Do handshaking outputs */
    msg.setTxTriState_setRts = 0xff;
    msg.txTriState_rts = p_priv->rts_state;

    msg.setHskoa_setDtr = 0xff;
    msg.hskoa_dtr = p_priv->dtr_state;
    -
    +
    p_priv->resend_cont = 0;
    - memcpy (this_urb->transfer_buffer, &msg, sizeof(msg));
    -
    + memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
    +
    /* send the data out the device on control endpoint */
    this_urb->transfer_buffer_length = sizeof(msg);

    this_urb->dev = serial->dev;
    - if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) {
    + err = usb_submit_urb(this_urb, GFP_ATOMIC);
    + if (err != 0)
    dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err);
    - }
    #if 0
    else {
    dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__
    @@ -1990,14 +1998,14 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
    struct usb_serial_port *port,
    int reset_port)
    {
    - struct keyspan_usa28_portControlMessage msg;
    + struct keyspan_usa28_portControlMessage msg;
    struct keyspan_serial_private *s_priv;
    struct keyspan_port_private *p_priv;
    const struct keyspan_device_details *d_details;
    struct urb *this_urb;
    int device_port, err;

    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    s_priv = usb_get_serial_data(serial);
    p_priv = usb_get_serial_port_data(port);
    @@ -2005,7 +2013,8 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
    device_port = port->number - port->serial->minor;

    /* only do something if we have a bulk out endpoint */
    - if ((this_urb = p_priv->outcont_urb) == NULL) {
    + this_urb = p_priv->outcont_urb;
    + if (this_urb == NULL) {
    dbg("%s - oops no urb.", __func__);
    return -1;
    }
    @@ -2015,17 +2024,18 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
    if ((reset_port + 1) > p_priv->resend_cont)
    p_priv->resend_cont = reset_port + 1;
    if (this_urb->status == -EINPROGRESS) {
    - dbg ("%s already writing", __func__);
    + dbg("%s already writing", __func__);
    mdelay(5);
    - return(-1);
    + return -1;
    }

    - memset(&msg, 0, sizeof (struct keyspan_usa28_portControlMessage));
    + memset(&msg, 0, sizeof(struct keyspan_usa28_portControlMessage));

    msg.setBaudRate = 1;
    if (d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk,
    - &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
    - dbg("%s - Invalid baud rate requested %d.", __func__, p_priv->baud);
    + &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
    + dbg("%s - Invalid baud rate requested %d.",
    + __func__, p_priv->baud);
    msg.baudLo = 0xff;
    msg.baudHi = 0xb2; /* Values for 9600 baud */
    }
    @@ -2036,7 +2046,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
    msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
    msg.xonFlowControl = 0;

    - /* Do handshaking outputs, DTR is inverted relative to RTS */
    + /* Do handshaking outputs, DTR is inverted relative to RTS */
    msg.rts = p_priv->rts_state;
    msg.dtr = p_priv->dtr_state;

    @@ -2078,7 +2088,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
    }
    /* Sending intermediate configs */
    else {
    - msg._txOn = (! p_priv->break_on);
    + msg._txOn = (!p_priv->break_on);
    msg._txOff = 0;
    msg.txFlush = 0;
    msg.txForceXoff = 0;
    @@ -2092,15 +2102,15 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
    }

    p_priv->resend_cont = 0;
    - memcpy (this_urb->transfer_buffer, &msg, sizeof(msg));
    + memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));

    /* send the data out the device on control endpoint */
    this_urb->transfer_buffer_length = sizeof(msg);

    this_urb->dev = serial->dev;
    - if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) {
    + err = usb_submit_urb(this_urb, GFP_ATOMIC);
    + if (err != 0)
    dbg("%s - usb_submit_urb(setup) failed", __func__);
    - }
    #if 0
    else {
    dbg("%s - usb_submit_urb(setup) OK %d bytes", __func__,
    @@ -2123,7 +2133,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
    struct urb *this_urb;
    int err, device_port;

    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    s_priv = usb_get_serial_data(serial);
    p_priv = usb_get_serial_port_data(port);
    @@ -2134,7 +2144,9 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
    /* Work out which port within the device is being setup */
    device_port = port->number - port->serial->minor;

    - dbg("%s - endpoint %d port %d (%d)",__func__, usb_pipeendpoint(this_urb->pipe), port->number, device_port);
    + dbg("%s - endpoint %d port %d (%d)",
    + __func__, usb_pipeendpoint(this_urb->pipe),
    + port->number, device_port);

    /* Make sure we have an urb then send the message */
    if (this_urb == NULL) {
    @@ -2148,30 +2160,30 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
    p_priv->resend_cont = reset_port + 1;

    if (this_urb->status == -EINPROGRESS) {
    - /* dbg ("%s - already writing", __func__); */
    + /* dbg("%s - already writing", __func__); */
    mdelay(5);
    - return(-1);
    + return -1;
    }

    - memset(&msg, 0, sizeof (struct keyspan_usa49_portControlMessage));
    + memset(&msg, 0, sizeof(struct keyspan_usa49_portControlMessage));

    /*msg.portNumber = port->number;*/
    msg.portNumber = device_port;
    -
    - /* Only set baud rate if it's changed */
    +
    + /* Only set baud rate if it's changed */
    if (p_priv->old_baud != p_priv->baud) {
    p_priv->old_baud = p_priv->baud;
    msg.setClocking = 0xff;
    if (d_details->calculate_baud_rate
    (p_priv->baud, d_details->baudclk, &msg.baudHi,
    - &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
    - dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
    - p_priv->baud);
    + &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
    + dbg("%s - Invalid baud rate %d requested, using 9600.",
    + __func__, p_priv->baud);
    msg.baudLo = 0;
    msg.baudHi = 125; /* Values for 9600 baud */
    msg.prescaler = 10;
    }
    - //msg.setPrescaler = 0xff;
    + /* msg.setPrescaler = 0xff; */
    }

    msg.lcr = (p_priv->cflag & CSTOPB)? STOPBITS_678_2: STOPBITS_5678_1;
    @@ -2192,19 +2204,19 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
    if (p_priv->cflag & PARENB) {
    /* note USA_PARITY_NONE == 0 */
    msg.lcr |= (p_priv->cflag & PARODD)?
    - USA_PARITY_ODD: USA_PARITY_EVEN;
    + USA_PARITY_ODD : USA_PARITY_EVEN;
    }
    msg.setLcr = 0xff;

    msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
    msg.xonFlowControl = 0;
    msg.setFlowControl = 0xff;
    -
    +
    msg.forwardingLength = 16;
    msg.xonChar = 17;
    msg.xoffChar = 19;

    - /* Opening port */
    + /* Opening port */
    if (reset_port == 1) {
    msg._txOn = 1;
    msg._txOff = 0;
    @@ -2236,7 +2248,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
    }
    /* Sending intermediate configs */
    else {
    - msg._txOn = (! p_priv->break_on);
    + msg._txOn = (!p_priv->break_on);
    msg._txOff = 0;
    msg.txFlush = 0;
    msg.txBreak = (p_priv->break_on);
    @@ -2250,16 +2262,17 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
    msg.disablePort = 0;
    }

    - /* Do handshaking outputs */
    + /* Do handshaking outputs */
    msg.setRts = 0xff;
    msg.rts = p_priv->rts_state;

    msg.setDtr = 0xff;
    msg.dtr = p_priv->dtr_state;
    -
    +
    p_priv->resend_cont = 0;

    - /* if the device is a 49wg, we send control message on usb control EP 0 */
    + /* if the device is a 49wg, we send control message on usb
    + control EP 0 */

    if (d_details->product_id == keyspan_usa49wg_product_id) {
    dr = (void *)(s_priv->ctrl_buf);
    @@ -2269,23 +2282,24 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
    dr->wIndex = 0;
    dr->wLength = cpu_to_le16(sizeof(msg));

    - memcpy (s_priv->glocont_buf, &msg, sizeof(msg));
    + memcpy(s_priv->glocont_buf, &msg, sizeof(msg));

    - usb_fill_control_urb(this_urb, serial->dev, usb_sndctrlpipe(serial->dev, 0),
    - (unsigned char *)dr, s_priv->glocont_buf, sizeof(msg),
    - usa49_glocont_callback, serial);
    + usb_fill_control_urb(this_urb, serial->dev,
    + usb_sndctrlpipe(serial->dev, 0),
    + (unsigned char *)dr, s_priv->glocont_buf,
    + sizeof(msg), usa49_glocont_callback, serial);

    } else {
    memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
    -
    +
    /* send the data out the device on control endpoint */
    this_urb->transfer_buffer_length = sizeof(msg);

    this_urb->dev = serial->dev;
    }
    - if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) {
    + err = usb_submit_urb(this_urb, GFP_ATOMIC);
    + if (err != 0)
    dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err);
    - }
    #if 0
    else {
    dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__,
    @@ -2301,7 +2315,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
    struct usb_serial_port *port,
    int reset_port)
    {
    - struct keyspan_usa90_portControlMessage msg;
    + struct keyspan_usa90_portControlMessage msg;
    struct keyspan_serial_private *s_priv;
    struct keyspan_port_private *p_priv;
    const struct keyspan_device_details *d_details;
    @@ -2309,14 +2323,15 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
    int err;
    u8 prescaler;

    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    s_priv = usb_get_serial_data(serial);
    p_priv = usb_get_serial_port_data(port);
    d_details = s_priv->device_details;

    /* only do something if we have a bulk out endpoint */
    - if ((this_urb = p_priv->outcont_urb) == NULL) {
    + this_urb = p_priv->outcont_urb;
    + if (this_urb == NULL) {
    dbg("%s - oops no urb.", __func__);
    return -1;
    }
    @@ -2326,24 +2341,24 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
    if ((reset_port + 1) > p_priv->resend_cont)
    p_priv->resend_cont = reset_port + 1;
    if (this_urb->status == -EINPROGRESS) {
    - dbg ("%s already writing", __func__);
    + dbg("%s already writing", __func__);
    mdelay(5);
    - return(-1);
    + return -1;
    }

    - memset(&msg, 0, sizeof (struct keyspan_usa90_portControlMessage));
    + memset(&msg, 0, sizeof(struct keyspan_usa90_portControlMessage));

    - /* Only set baud rate if it's changed */
    + /* Only set baud rate if it's changed */
    if (p_priv->old_baud != p_priv->baud) {
    p_priv->old_baud = p_priv->baud;
    msg.setClocking = 0x01;
    if (d_details->calculate_baud_rate
    (p_priv->baud, d_details->baudclk, &msg.baudHi,
    - &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE ) {
    - dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
    - p_priv->baud);
    + &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE) {
    + dbg("%s - Invalid baud rate %d requested, using 9600.",
    + __func__, p_priv->baud);
    p_priv->baud = 9600;
    - d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk,
    + d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk,
    &msg.baudHi, &msg.baudLo, &prescaler, 0);
    }
    msg.setRxMode = 1;
    @@ -2351,13 +2366,10 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
    }

    /* modes must always be correctly specified */
    - if (p_priv->baud > 57600)
    - {
    + if (p_priv->baud > 57600) {
    msg.rxMode = RXMODE_DMA;
    msg.txMode = TXMODE_DMA;
    - }
    - else
    - {
    + } else {
    msg.rxMode = RXMODE_BYHAND;
    msg.txMode = TXMODE_BYHAND;
    }
    @@ -2380,7 +2392,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
    if (p_priv->cflag & PARENB) {
    /* note USA_PARITY_NONE == 0 */
    msg.lcr |= (p_priv->cflag & PARODD)?
    - USA_PARITY_ODD: USA_PARITY_EVEN;
    + USA_PARITY_ODD : USA_PARITY_EVEN;
    }
    if (p_priv->old_cflag != p_priv->cflag) {
    p_priv->old_cflag = p_priv->cflag;
    @@ -2391,23 +2403,22 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
    msg.txFlowControl = TXFLOW_CTS;
    msg.setTxFlowControl = 0x01;
    msg.setRxFlowControl = 0x01;
    -
    +
    msg.rxForwardingLength = 16;
    - msg.rxForwardingTimeout = 16;
    + msg.rxForwardingTimeout = 16;
    msg.txAckSetting = 0;
    msg.xonChar = 17;
    msg.xoffChar = 19;

    - /* Opening port */
    + /* Opening port */
    if (reset_port == 1) {
    msg.portEnabled = 1;
    msg.rxFlush = 1;
    msg.txBreak = (p_priv->break_on);
    }
    /* Closing port */
    - else if (reset_port == 2) {
    + else if (reset_port == 2)
    msg.portEnabled = 0;
    - }
    /* Sending intermediate configs */
    else {
    if (port->port.count)
    @@ -2415,23 +2426,23 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
    msg.txBreak = (p_priv->break_on);
    }

    - /* Do handshaking outputs */
    + /* Do handshaking outputs */
    msg.setRts = 0x01;
    msg.rts = p_priv->rts_state;

    msg.setDtr = 0x01;
    msg.dtr = p_priv->dtr_state;
    -
    +
    p_priv->resend_cont = 0;
    - memcpy (this_urb->transfer_buffer, &msg, sizeof(msg));
    -
    + memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
    +
    /* send the data out the device on control endpoint */
    this_urb->transfer_buffer_length = sizeof(msg);

    this_urb->dev = serial->dev;
    - if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) {
    + err = usb_submit_urb(this_urb, GFP_ATOMIC);
    + if (err != 0)
    dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err);
    - }
    return 0;
    }

    @@ -2446,7 +2457,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
    struct urb *this_urb;
    int err, device_port;

    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    s_priv = usb_get_serial_data(serial);
    p_priv = usb_get_serial_port_data(port);
    @@ -2469,9 +2480,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
    if ((reset_port + 1) > p_priv->resend_cont)
    p_priv->resend_cont = reset_port + 1;
    if (this_urb->status == -EINPROGRESS) {
    - /* dbg ("%s - already writing", __func__); */
    + /* dbg("%s - already writing", __func__); */
    mdelay(5);
    - return(-1);
    + return -1;
    }

    memset(&msg, 0, sizeof(struct keyspan_usa67_portControlMessage));
    @@ -2484,9 +2495,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
    msg.setClocking = 0xff;
    if (d_details->calculate_baud_rate
    (p_priv->baud, d_details->baudclk, &msg.baudHi,
    - &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
    - dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
    - p_priv->baud);
    + &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
    + dbg("%s - Invalid baud rate %d requested, using 9600.",
    + __func__, p_priv->baud);
    msg.baudLo = 0;
    msg.baudHi = 125; /* Values for 9600 baud */
    msg.prescaler = 10;
    @@ -2512,7 +2523,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
    if (p_priv->cflag & PARENB) {
    /* note USA_PARITY_NONE == 0 */
    msg.lcr |= (p_priv->cflag & PARODD)?
    - USA_PARITY_ODD: USA_PARITY_EVEN;
    + USA_PARITY_ODD : USA_PARITY_EVEN;
    }
    msg.setLcr = 0xff;

    @@ -2549,7 +2560,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
    msg.resetDataToggle = 0;
    } else {
    /* Sending intermediate configs */
    - msg._txOn = (! p_priv->break_on);
    + msg._txOn = (!p_priv->break_on);
    msg._txOff = 0;
    msg.txFlush = 0;
    msg.txBreak = (p_priv->break_on);
    @@ -2589,7 +2600,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
    struct keyspan_serial_private *s_priv;
    const struct keyspan_device_details *d_details;

    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    s_priv = usb_get_serial_data(serial);
    d_details = s_priv->device_details;
    @@ -2616,7 +2627,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)

    /* Gets called by the "real" driver (ie once firmware is loaded
    and renumeration has taken place. */
    -static int keyspan_startup (struct usb_serial *serial)
    +static int keyspan_startup(struct usb_serial *serial)
    {
    int i, err;
    struct usb_serial_port *port;
    @@ -2627,17 +2638,20 @@ static int keyspan_startup (struct usb_serial *serial)
    dbg("%s", __func__);

    for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i)
    - if (d_details->product_id == le16_to_cpu(serial->dev->descriptor.idProduct))
    + if (d_details->product_id ==
    + le16_to_cpu(serial->dev->descriptor.idProduct))
    break;
    if (d_details == NULL) {
    - dev_err(&serial->dev->dev, "%s - unknown product id %x\n", __func__, le16_to_cpu(serial->dev->descriptor.idProduct));
    + dev_err(&serial->dev->dev, "%s - unknown product id %x\n",
    + __func__, le16_to_cpu(serial->dev->descriptor.idProduct));
    return 1;
    }

    /* Setup private data for serial driver */
    s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
    if (!s_priv) {
    - dbg("%s - kmalloc for keyspan_serial_private failed.", __func__);
    + dbg("%s - kmalloc for keyspan_serial_private failed.",
    + __func__);
    return -ENOMEM;
    }

    @@ -2647,10 +2661,11 @@ static int keyspan_startup (struct usb_serial *serial)
    /* Now setup per port private data */
    for (i = 0; i < serial->num_ports; i++) {
    port = serial->port[i];
    - p_priv = kzalloc(sizeof(struct keyspan_port_private), GFP_KERNEL);
    + p_priv = kzalloc(sizeof(struct keyspan_port_private),
    + GFP_KERNEL);
    if (!p_priv) {
    dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __func__, i);
    - return (1);
    + return 1;
    }
    p_priv->device_details = d_details;
    usb_set_serial_port_data(port, p_priv);
    @@ -2672,11 +2687,11 @@ static int keyspan_startup (struct usb_serial *serial)
    dbg("%s - submit indat urb failed %d", __func__,
    err);
    }
    -
    +
    return 0;
    }

    -static void keyspan_shutdown (struct usb_serial *serial)
    +static void keyspan_shutdown(struct usb_serial *serial)
    {
    int i, j;
    struct usb_serial_port *port;
    @@ -2728,8 +2743,8 @@ static void keyspan_shutdown (struct usb_serial *serial)
    }
    }

    -MODULE_AUTHOR( DRIVER_AUTHOR );
    -MODULE_DESCRIPTION( DRIVER_DESC );
    +MODULE_AUTHOR(DRIVER_AUTHOR);
    +MODULE_DESCRIPTION(DRIVER_DESC);
    MODULE_LICENSE("GPL");

    module_param(debug, bool, S_IRUGO | S_IWUSR);

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  7. [PATCH 55/70] tty-usb-kobil-sct: Coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/kl5kusb105.c | 4
    drivers/usb/serial/kobil_sct.c | 557 +++++++++++++++++++++------------------
    2 files changed, 299 insertions(+), 262 deletions(-)


    diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
    index d898dc4..e7e3df6 100644
    --- a/drivers/usb/serial/kl5kusb105.c
    +++ b/drivers/usb/serial/kl5kusb105.c
    @@ -88,7 +88,7 @@ static void klsi_105_set_termios(struct tty_struct *tty,
    struct usb_serial_port *port, struct ktermios *old);
    static void klsi_105_throttle(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 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);

    @@ -433,7 +433,7 @@ static int klsi_105_open(struct tty_struct *tty,
    if (rc >= 0) {
    spin_lock_irqsave(&priv->lock, flags);
    priv->line_state = line_state;
    - spin_unlock_irqrestore*&priv->lock, flags);
    + spin_unlock_irqrestore(&priv->lock, flags);
    dbg("%s - read line state 0x%lx", __func__, line_state);
    retval = 0;
    } else
    diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
    index 40c67f0..f0f8353 100644
    --- a/drivers/usb/serial/kobil_sct.c
    +++ b/drivers/usb/serial/kobil_sct.c
    @@ -1,7 +1,7 @@
    /*
    * KOBIL USB Smart Card Terminal Driver
    *
    - * Copyright (C) 2002 KOBIL Systems GmbH
    + * Copyright (C) 2002 KOBIL Systems GmbH
    * Author: Thomas Wahrenbruch
    *
    * Contact: linuxusb@kobil.de
    @@ -20,7 +20,7 @@
    *
    * Supported readers: USB TWIN, KAAN Standard Plus and SecOVID Reader Plus
    * (Adapter K), B1 Professional and KAAN Professional (Adapter B)
    - *
    + *
    * (21/05/2004) tw
    * Fix bug with P'n'P readers
    *
    @@ -44,7 +44,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include
    #include
    @@ -68,13 +68,13 @@ static int debug;


    /* Function prototypes */
    -static int kobil_startup (struct usb_serial *serial);
    -static void kobil_shutdown (struct usb_serial *serial);
    -static int kobil_open (struct tty_struct *tty,
    +static int kobil_startup(struct usb_serial *serial);
    +static void kobil_shutdown(struct usb_serial *serial);
    +static int kobil_open(struct tty_struct *tty,
    struct usb_serial_port *port, struct file *filp);
    -static void kobil_close (struct tty_struct *tty, struct usb_serial_port *port,
    +static void kobil_close(struct tty_struct *tty, struct usb_serial_port *port,
    struct file *filp);
    -static int kobil_write (struct tty_struct *tty, struct usb_serial_port *port,
    +static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
    const unsigned char *buf, int count);
    static int kobil_write_room(struct tty_struct *tty);
    static int kobil_ioctl(struct tty_struct *tty, struct file *file,
    @@ -82,9 +82,9 @@ static int kobil_ioctl(struct tty_struct *tty, struct file *file,
    static int kobil_tiocmget(struct tty_struct *tty, struct file *file);
    static int kobil_tiocmset(struct tty_struct *tty, struct file *file,
    unsigned int set, unsigned int clear);
    -static void kobil_read_int_callback( struct urb *urb );
    -static void kobil_write_callback( struct urb *purb );
    -static void kobil_set_termios(struct tty_struct *tty,
    +static void kobil_read_int_callback(struct urb *urb);
    +static void kobil_write_callback(struct urb *purb);
    +static void kobil_set_termios(struct tty_struct *tty,
    struct usb_serial_port *port, struct ktermios *old);


    @@ -97,7 +97,7 @@ static struct usb_device_id id_table [] = {
    };


    -MODULE_DEVICE_TABLE (usb, id_table);
    +MODULE_DEVICE_TABLE(usb, id_table);

    static struct usb_driver kobil_driver = {
    .name = "kobil",
    @@ -134,14 +134,14 @@ static struct usb_serial_driver kobil_device = {
    struct kobil_private {
    int write_int_endpoint_address;
    int read_int_endpoint_address;
    - unsigned char buf[KOBIL_BUF_LENGTH]; // buffer for the APDU to send
    - int filled; // index of the last char in buf
    - int cur_pos; // index of the next char to send in buf
    + unsigned char buf[KOBIL_BUF_LENGTH]; /* buffer for the APDU to send */
    + int filled; /* index of the last char in buf */
    + int cur_pos; /* index of the next char to send in buf */
    __u16 device_type;
    };


    -static int kobil_startup (struct usb_serial *serial)
    +static int kobil_startup(struct usb_serial *serial)
    {
    int i;
    struct kobil_private *priv;
    @@ -152,20 +152,20 @@ static int kobil_startup (struct usb_serial *serial)
    struct usb_host_endpoint *endpoint;

    priv = kmalloc(sizeof(struct kobil_private), GFP_KERNEL);
    - if (!priv){
    + if (!priv)
    return -ENOMEM;
    - }

    priv->filled = 0;
    priv->cur_pos = 0;
    priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct);

    - switch (priv->device_type){
    + switch (priv->device_type) {
    case KOBIL_ADAPTER_B_PRODUCT_ID:
    printk(KERN_DEBUG "KOBIL B1 PRO / KAAN PRO detected\n");
    break;
    case KOBIL_ADAPTER_K_PRODUCT_ID:
    - printk(KERN_DEBUG "KOBIL KAAN Standard Plus / SecOVID Reader Plus detected\n");
    + printk(KERN_DEBUG
    + "KOBIL KAAN Standard Plus / SecOVID Reader Plus detected\n");
    break;
    case KOBIL_USBTWIN_PRODUCT_ID:
    printk(KERN_DEBUG "KOBIL USBTWIN detected\n");
    @@ -176,37 +176,40 @@ static int kobil_startup (struct usb_serial *serial)
    }
    usb_set_serial_port_data(serial->port[0], priv);

    - // search for the necessary endpoints
    + /* search for the necessary endpoints */
    pdev = serial->dev;
    - actconfig = pdev->actconfig;
    - interface = actconfig->interface[0];
    + actconfig = pdev->actconfig;
    + interface = actconfig->interface[0];
    altsetting = interface->cur_altsetting;
    - endpoint = altsetting->endpoint;
    -
    - for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
    + endpoint = altsetting->endpoint;
    +
    + for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
    endpoint = &altsetting->endpoint[i];
    if (usb_endpoint_is_int_out(&endpoint->desc)) {
    - dbg("%s Found interrupt out endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress);
    - priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress;
    - }
    + dbg("%s Found interrupt out endpoint. Address: %d",
    + __func__, endpoint->desc.bEndpointAddress);
    + priv->write_int_endpoint_address =
    + endpoint->desc.bEndpointAddress;
    + }
    if (usb_endpoint_is_int_in(&endpoint->desc)) {
    - dbg("%s Found interrupt in endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress);
    - priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress;
    - }
    + dbg("%s Found interrupt in endpoint. Address: %d",
    + __func__, endpoint->desc.bEndpointAddress);
    + priv->read_int_endpoint_address =
    + endpoint->desc.bEndpointAddress;
    + }
    }
    return 0;
    }


    -static void kobil_shutdown (struct usb_serial *serial)
    +static void kobil_shutdown(struct usb_serial *serial)
    {
    int i;
    dbg("%s - port %d", __func__, serial->port[0]->number);

    - for (i=0; i < serial->num_ports; ++i) {
    - while (serial->port[i]->port.count > 0) {
    - kobil_close (NULL, serial->port[i], NULL);
    - }
    + for (i = 0; i < serial->num_ports; ++i) {
    + while (serial->port[i]->port.count > 0)
    + kobil_close(NULL, serial->port[i], NULL);
    kfree(usb_get_serial_port_data(serial->port[i]));
    usb_set_serial_port_data(serial->port[i], NULL);
    }
    @@ -225,7 +228,7 @@ static int kobil_open(struct tty_struct *tty,
    dbg("%s - port %d", __func__, port->number);
    priv = usb_get_serial_port_data(port);

    - // someone sets the dev to 0 if the close method has been called
    + /* someone sets the dev to 0 if the close method has been called */
    port->interrupt_in_urb->dev = port->serial->dev;


    @@ -238,96 +241,110 @@ static int kobil_open(struct tty_struct *tty,

    /* Default to echo off and other sane device settings */
    tty->termios->c_lflag = 0;
    - tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE);
    + tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN |
    + XCASE);
    tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF;
    - tty->termios->c_oflag &= ~ONLCR; // do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D)
    - }
    - // allocate memory for transfer buffer
    + /* do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) */
    + tty->termios->c_oflag &= ~ONLCR;
    + }
    + /* allocate memory for transfer buffer */
    transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);
    - if (! transfer_buffer) {
    + if (!transfer_buffer)
    return -ENOMEM;
    - }
    -
    - // allocate write_urb
    - if (!port->write_urb) {
    - dbg("%s - port %d Allocating port->write_urb", __func__, port->number);
    - port->write_urb = usb_alloc_urb(0, GFP_KERNEL);
    +
    + /* allocate write_urb */
    + if (!port->write_urb) {
    + dbg("%s - port %d Allocating port->write_urb",
    + __func__, port->number);
    + port->write_urb = usb_alloc_urb(0, GFP_KERNEL);
    if (!port->write_urb) {
    - dbg("%s - port %d usb_alloc_urb failed", __func__, port->number);
    + dbg("%s - port %d usb_alloc_urb failed",
    + __func__, port->number);
    kfree(transfer_buffer);
    return -ENOMEM;
    }
    }

    - // allocate memory for write_urb transfer buffer
    - port->write_urb->transfer_buffer = kmalloc(write_urb_transfer_buffer_length, GFP_KERNEL);
    - if (! port->write_urb->transfer_buffer) {
    + /* allocate memory for write_urb transfer buffer */
    + port->write_urb->transfer_buffer =
    + kmalloc(write_urb_transfer_buffer_length, GFP_KERNEL);
    + if (!port->write_urb->transfer_buffer) {
    kfree(transfer_buffer);
    usb_free_urb(port->write_urb);
    port->write_urb = NULL;
    return -ENOMEM;
    - }
    -
    - // get hardware version
    - result = usb_control_msg( port->serial->dev,
    - usb_rcvctrlpipe(port->serial->dev, 0 ),
    - SUSBCRequest_GetMisc,
    - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN,
    - SUSBCR_MSC_GetHWVersion,
    - 0,
    - transfer_buffer,
    - transfer_buffer_length,
    - KOBIL_TIMEOUT
    + }
    +
    + /* get hardware version */
    + result = usb_control_msg(port->serial->dev,
    + usb_rcvctrlpipe(port->serial->dev, 0),
    + SUSBCRequest_GetMisc,
    + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN,
    + SUSBCR_MSC_GetHWVersion,
    + 0,
    + transfer_buffer,
    + transfer_buffer_length,
    + KOBIL_TIMEOUT
    + );
    + dbg("%s - port %d Send get_HW_version URB returns: %i",
    + __func__, port->number, result);
    + dbg("Harware version: %i.%i.%i",
    + transfer_buffer[0], transfer_buffer[1], transfer_buffer[2]);
    +
    + /* get firmware version */
    + result = usb_control_msg(port->serial->dev,
    + usb_rcvctrlpipe(port->serial->dev, 0),
    + SUSBCRequest_GetMisc,
    + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN,
    + SUSBCR_MSC_GetFWVersion,
    + 0,
    + transfer_buffer,
    + transfer_buffer_length,
    + KOBIL_TIMEOUT
    + );
    + dbg("%s - port %d Send get_FW_version URB returns: %i",
    + __func__, port->number, result);
    + dbg("Firmware version: %i.%i.%i",
    + transfer_buffer[0], transfer_buffer[1], transfer_buffer[2]);
    +
    + if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID ||
    + priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) {
    + /* Setting Baudrate, Parity and Stopbits */
    + result = usb_control_msg(port->serial->dev,
    + usb_rcvctrlpipe(port->serial->dev, 0),
    + SUSBCRequest_SetBaudRateParityAndStopBits,
    + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
    + SUSBCR_SBR_9600 | SUSBCR_SPASB_EvenParity |
    + SUSBCR_SPASB_1StopBit,
    + 0,
    + transfer_buffer,
    + 0,
    + KOBIL_TIMEOUT
    );
    - dbg("%s - port %d Send get_HW_version URB returns: %i", __func__, port->number, result);
    - dbg("Harware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] );
    -
    - // get firmware version
    - result = usb_control_msg( port->serial->dev,
    - usb_rcvctrlpipe(port->serial->dev, 0 ),
    - SUSBCRequest_GetMisc,
    - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN,
    - SUSBCR_MSC_GetFWVersion,
    - 0,
    - transfer_buffer,
    - transfer_buffer_length,
    - KOBIL_TIMEOUT
    + dbg("%s - port %d Send set_baudrate URB returns: %i",
    + __func__, port->number, result);
    +
    + /* reset all queues */
    + result = usb_control_msg(port->serial->dev,
    + usb_rcvctrlpipe(port->serial->dev, 0),
    + SUSBCRequest_Misc,
    + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
    + SUSBCR_MSC_ResetAllQueues,
    + 0,
    + transfer_buffer,
    + 0,
    + KOBIL_TIMEOUT
    );
    - dbg("%s - port %d Send get_FW_version URB returns: %i", __func__, port->number, result);
    - dbg("Firmware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] );
    -
    - if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) {
    - // Setting Baudrate, Parity and Stopbits
    - result = usb_control_msg( port->serial->dev,
    - usb_rcvctrlpipe(port->serial->dev, 0 ),
    - SUSBCRequest_SetBaudRateParityAndStopBits,
    - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
    - SUSBCR_SBR_9600 | SUSBCR_SPASB_EvenParity | SUSBCR_SPASB_1StopBit,
    - 0,
    - transfer_buffer,
    - 0,
    - KOBIL_TIMEOUT
    - );
    - dbg("%s - port %d Send set_baudrate URB returns: %i", __func__, port->number, result);
    -
    - // reset all queues
    - result = usb_control_msg( port->serial->dev,
    - usb_rcvctrlpipe(port->serial->dev, 0 ),
    - SUSBCRequest_Misc,
    - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
    - SUSBCR_MSC_ResetAllQueues,
    - 0,
    - transfer_buffer,
    - 0,
    - KOBIL_TIMEOUT
    - );
    - dbg("%s - port %d Send reset_all_queues URB returns: %i", __func__, port->number, result);
    + dbg("%s - port %d Send reset_all_queues URB returns: %i",
    + __func__, port->number, result);
    }
    - if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID ||
    + if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID ||
    + priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID ||
    priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) {
    - // start reading (Adapter B 'cause PNP string)
    - result = usb_submit_urb( port->interrupt_in_urb, GFP_ATOMIC );
    - dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result);
    + /* start reading (Adapter B 'cause PNP string) */
    + result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
    + dbg("%s - port %d Send read URB returns: %i",
    + __func__, port->number, result);
    }

    kfree(transfer_buffer);
    @@ -342,7 +359,7 @@ static void kobil_close(struct tty_struct *tty,

    if (port->write_urb) {
    usb_kill_urb(port->write_urb);
    - usb_free_urb( port->write_urb );
    + usb_free_urb(port->write_urb);
    port->write_urb = NULL;
    }
    usb_kill_urb(port->interrupt_in_urb);
    @@ -356,7 +373,7 @@ static void kobil_read_int_callback(struct urb *urb)
    struct tty_struct *tty;
    unsigned char *data = urb->transfer_buffer;
    int status = urb->status;
    -// char *dbg_data;
    +/* char *dbg_data; */

    dbg("%s - port %d", __func__, port->number);

    @@ -369,48 +386,50 @@ static void kobil_read_int_callback(struct urb *urb)
    tty = port->port.tty;
    if (urb->actual_length) {

    - // BEGIN DEBUG
    + /* BEGIN DEBUG */
    /*
    - dbg_data = kzalloc((3 * purb->actual_length + 10) * sizeof(char), GFP_KERNEL);
    + dbg_data = kzalloc((3 * purb->actual_length + 10)
    + * sizeof(char), GFP_KERNEL);
    if (! dbg_data) {
    - return;
    + return;
    }
    - for (i = 0; i < purb->actual_length; i++) {
    - sprintf(dbg_data +3*i, "%02X ", data[i]);
    + for (i = 0; i < purb->actual_length; i++) {
    + sprintf(dbg_data +3*i, "%02X ", data[i]);
    }
    - dbg(" <-- %s", dbg_data );
    + dbg(" <-- %s", dbg_data);
    kfree(dbg_data);
    */
    - // END DEBUG
    + /* END DEBUG */

    tty_buffer_request_room(tty, urb->actual_length);
    tty_insert_flip_string(tty, data, urb->actual_length);
    tty_flip_buffer_push(tty);
    }
    -
    - // someone sets the dev to 0 if the close method has been called
    + /* someone sets the dev to 0 if the close method has been called */
    port->interrupt_in_urb->dev = port->serial->dev;

    result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
    - dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result);
    + dbg("%s - port %d Send read URB returns: %i",
    + __func__, port->number, result);
    }


    -static void kobil_write_callback( struct urb *purb )
    +static void kobil_write_callback(struct urb *purb)
    {
    }


    -static int kobil_write (struct tty_struct *tty, struct usb_serial_port *port,
    +static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
    const unsigned char *buf, int count)
    {
    int length = 0;
    int result = 0;
    int todo = 0;
    - struct kobil_private * priv;
    + struct kobil_private *priv;

    if (count == 0) {
    - dbg("%s - port %d write request of 0 bytes", __func__, port->number);
    + dbg("%s - port %d write request of 0 bytes",
    + __func__, port->number);
    return 0;
    }

    @@ -421,69 +440,77 @@ static int kobil_write (struct tty_struct *tty, struct usb_serial_port *port,
    return -ENOMEM;
    }

    - // Copy data to buffer
    - memcpy (priv->buf + priv->filled, buf, count);
    - usb_serial_debug_data(debug, &port->dev, __func__, count, priv->buf + priv->filled);
    + /* Copy data to buffer */
    + memcpy(priv->buf + priv->filled, buf, count);
    + usb_serial_debug_data(debug, &port->dev, __func__, count,
    + priv->buf + priv->filled);
    priv->filled = priv->filled + count;

    - // only send complete block. TWIN, KAAN SIM and adapter K use the same protocol.
    - if ( ((priv->device_type != KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 2) && (priv->filled >= (priv->buf[1] + 3))) ||
    - ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4))) ) {
    -
    - // stop reading (except TWIN and KAAN SIM)
    - if ( (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) )
    + /* only send complete block. TWIN, KAAN SIM and adapter K
    + use the same protocol. */
    + if (((priv->device_type != KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 2) && (priv->filled >= (priv->buf[1] + 3))) ||
    + ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4)))) {
    + /* stop reading (except TWIN and KAAN SIM) */
    + if ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID)
    + || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID))
    usb_kill_urb(port->interrupt_in_urb);

    todo = priv->filled - priv->cur_pos;

    - while(todo > 0) {
    - // max 8 byte in one urb (endpoint size)
    + while (todo > 0) {
    + /* max 8 byte in one urb (endpoint size) */
    length = (todo < 8) ? todo : 8;
    - // copy data to transfer buffer
    - memcpy(port->write_urb->transfer_buffer, priv->buf + priv->cur_pos, length );
    - usb_fill_int_urb( port->write_urb,
    - port->serial->dev,
    - usb_sndintpipe(port->serial->dev, priv->write_int_endpoint_address),
    - port->write_urb->transfer_buffer,
    - length,
    - kobil_write_callback,
    - port,
    - 8
    - );
    + /* copy data to transfer buffer */
    + memcpy(port->write_urb->transfer_buffer,
    + priv->buf + priv->cur_pos, length);
    + usb_fill_int_urb(port->write_urb,
    + port->serial->dev,
    + usb_sndintpipe(port->serial->dev,
    + priv->write_int_endpoint_address),
    + port->write_urb->transfer_buffer,
    + length,
    + kobil_write_callback,
    + port,
    + 8
    + );

    priv->cur_pos = priv->cur_pos + length;
    - result = usb_submit_urb( port->write_urb, GFP_NOIO );
    - dbg("%s - port %d Send write URB returns: %i", __func__, port->number, result);
    + result = usb_submit_urb(port->write_urb, GFP_NOIO);
    + dbg("%s - port %d Send write URB returns: %i",
    + __func__, port->number, result);
    todo = priv->filled - priv->cur_pos;

    - if (todo > 0) {
    + if (todo > 0)
    msleep(24);
    - }
    + }

    - } // end while
    -
    priv->filled = 0;
    priv->cur_pos = 0;

    - // someone sets the dev to 0 if the close method has been called
    + /* someone sets the dev to 0 if the close method
    + has been called */
    port->interrupt_in_urb->dev = port->serial->dev;
    -
    - // start reading (except TWIN and KAAN SIM)
    - if ( (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) ) {
    - // someone sets the dev to 0 if the close method has been called
    +
    + /* start reading (except TWIN and KAAN SIM) */
    + if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID ||
    + priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) {
    + /* someone sets the dev to 0 if the close method has
    + been called */
    port->interrupt_in_urb->dev = port->serial->dev;
    -
    - result = usb_submit_urb( port->interrupt_in_urb, GFP_NOIO );
    - dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result);
    +
    + result = usb_submit_urb(port->interrupt_in_urb,
    + GFP_NOIO);
    + dbg("%s - port %d Send read URB returns: %i",
    + __func__, port->number, result);
    }
    }
    return count;
    }


    -static int kobil_write_room (struct tty_struct *tty)
    +static int kobil_write_room(struct tty_struct *tty)
    {
    - //dbg("%s - port %d", __func__, port->number);
    + /* dbg("%s - port %d", __func__, port->number); */
    /* FIXME */
    return 8;
    }
    @@ -492,34 +519,34 @@ static int kobil_write_room (struct tty_struct *tty)
    static int kobil_tiocmget(struct tty_struct *tty, struct file *file)
    {
    struct usb_serial_port *port = tty->driver_data;
    - struct kobil_private * priv;
    + struct kobil_private *priv;
    int result;
    unsigned char *transfer_buffer;
    int transfer_buffer_length = 8;

    priv = usb_get_serial_port_data(port);
    - if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) {
    - // This device doesn't support ioctl calls
    + if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID
    + || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) {
    + /* This device doesn't support ioctl calls */
    return -EINVAL;
    }

    - // allocate memory for transfer buffer
    + /* allocate memory for transfer buffer */
    transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);
    - if (!transfer_buffer) {
    + if (!transfer_buffer)
    return -ENOMEM;
    - }

    - result = usb_control_msg( port->serial->dev,
    - usb_rcvctrlpipe(port->serial->dev, 0 ),
    - SUSBCRequest_GetStatusLineState,
    - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN,
    - 0,
    - 0,
    - transfer_buffer,
    - transfer_buffer_length,
    - KOBIL_TIMEOUT);
    -
    - dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x",
    + result = usb_control_msg(port->serial->dev,
    + usb_rcvctrlpipe(port->serial->dev, 0),
    + SUSBCRequest_GetStatusLineState,
    + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN,
    + 0,
    + 0,
    + transfer_buffer,
    + transfer_buffer_length,
    + KOBIL_TIMEOUT);
    +
    + dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x",
    __func__, port->number, result, transfer_buffer[0]);

    result = 0;
    @@ -533,7 +560,7 @@ static int kobil_tiocmset(struct tty_struct *tty, struct file *file,
    unsigned int set, unsigned int clear)
    {
    struct usb_serial_port *port = tty->driver_data;
    - struct kobil_private * priv;
    + struct kobil_private *priv;
    int result;
    int dtr = 0;
    int rts = 0;
    @@ -542,16 +569,16 @@ static int kobil_tiocmset(struct tty_struct *tty, struct file *file,

    /* FIXME: locking ? */
    priv = usb_get_serial_port_data(port);
    - if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) {
    - // This device doesn't support ioctl calls
    + if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID
    + || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) {
    + /* This device doesn't support ioctl calls */
    return -EINVAL;
    }

    - // allocate memory for transfer buffer
    + /* allocate memory for transfer buffer */
    transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);
    - if (! transfer_buffer) {
    + if (!transfer_buffer)
    return -ENOMEM;
    - }

    if (set & TIOCM_RTS)
    rts = 1;
    @@ -564,34 +591,39 @@ static int kobil_tiocmset(struct tty_struct *tty, struct file *file,

    if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) {
    if (dtr != 0)
    - dbg("%s - port %d Setting DTR", __func__, port->number);
    + dbg("%s - port %d Setting DTR",
    + __func__, port->number);
    else
    - dbg("%s - port %d Clearing DTR", __func__, port->number);
    - result = usb_control_msg( port->serial->dev,
    - usb_rcvctrlpipe(port->serial->dev, 0 ),
    - SUSBCRequest_SetStatusLinesOrQueues,
    - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
    - ((dtr != 0) ? SUSBCR_SSL_SETDTR : SUSBCR_SSL_CLRDTR),
    - 0,
    - transfer_buffer,
    - 0,
    - KOBIL_TIMEOUT);
    + dbg("%s - port %d Clearing DTR",
    + __func__, port->number);
    + result = usb_control_msg(port->serial->dev,
    + usb_rcvctrlpipe(port->serial->dev, 0),
    + SUSBCRequest_SetStatusLinesOrQueues,
    + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
    + ((dtr != 0) ? SUSBCR_SSL_SETDTR : SUSBCR_SSL_CLRDTR),
    + 0,
    + transfer_buffer,
    + 0,
    + KOBIL_TIMEOUT);
    } else {
    if (rts != 0)
    - dbg("%s - port %d Setting RTS", __func__, port->number);
    + dbg("%s - port %d Setting RTS",
    + __func__, port->number);
    else
    - dbg("%s - port %d Clearing RTS", __func__, port->number);
    - result = usb_control_msg( port->serial->dev,
    - usb_rcvctrlpipe(port->serial->dev, 0 ),
    - SUSBCRequest_SetStatusLinesOrQueues,
    - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
    - ((rts != 0) ? SUSBCR_SSL_SETRTS : SUSBCR_SSL_CLRRTS),
    - 0,
    - transfer_buffer,
    - 0,
    - KOBIL_TIMEOUT);
    + dbg("%s - port %d Clearing RTS",
    + __func__, port->number);
    + result = usb_control_msg(port->serial->dev,
    + usb_rcvctrlpipe(port->serial->dev, 0),
    + SUSBCRequest_SetStatusLinesOrQueues,
    + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
    + ((rts != 0) ? SUSBCR_SSL_SETRTS : SUSBCR_SSL_CLRRTS),
    + 0,
    + transfer_buffer,
    + 0,
    + KOBIL_TIMEOUT);
    }
    - dbg("%s - port %d Send set_status_line URB returns: %i", __func__, port->number, result);
    + dbg("%s - port %d Send set_status_line URB returns: %i",
    + __func__, port->number, result);
    kfree(transfer_buffer);
    return (result < 0) ? result : 0;
    }
    @@ -599,32 +631,35 @@ static int kobil_tiocmset(struct tty_struct *tty, struct file *file,
    static void kobil_set_termios(struct tty_struct *tty,
    struct usb_serial_port *port, struct ktermios *old)
    {
    - struct kobil_private * priv;
    + struct kobil_private *priv;
    int result;
    unsigned short urb_val = 0;
    int c_cflag = tty->termios->c_cflag;
    speed_t speed;
    - void * settings;
    + void *settings;

    priv = usb_get_serial_port_data(port);
    - if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)
    - // This device doesn't support ioctl calls
    + if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID ||
    + priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)
    + /* This device doesn't support ioctl calls */
    return;

    - switch (speed = tty_get_baud_rate(tty)) {
    - case 1200:
    - urb_val = SUSBCR_SBR_1200;
    - break;
    - default:
    - speed = 9600;
    - case 9600:
    - urb_val = SUSBCR_SBR_9600;
    - break;
    + speed = tty_get_baud_rate(tty);
    + switch (speed) {
    + case 1200:
    + urb_val = SUSBCR_SBR_1200;
    + break;
    + default:
    + speed = 9600;
    + case 9600:
    + urb_val = SUSBCR_SBR_9600;
    + break;
    }
    - urb_val |= (c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits : SUSBCR_SPASB_1StopBit;
    + urb_val |= (c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits :
    + SUSBCR_SPASB_1StopBit;

    settings = kzalloc(50, GFP_KERNEL);
    - if (! settings)
    + if (!settings)
    return;

    sprintf(settings, "%d ", speed);
    @@ -644,48 +679,50 @@ static void kobil_set_termios(struct tty_struct *tty,
    tty->termios->c_cflag &= ~CMSPAR;
    tty_encode_baud_rate(tty, speed, speed);

    - result = usb_control_msg( port->serial->dev,
    - usb_rcvctrlpipe(port->serial->dev, 0 ),
    - SUSBCRequest_SetBaudRateParityAndStopBits,
    - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
    - urb_val,
    - 0,
    - settings,
    - 0,
    - KOBIL_TIMEOUT
    + result = usb_control_msg(port->serial->dev,
    + usb_rcvctrlpipe(port->serial->dev, 0),
    + SUSBCRequest_SetBaudRateParityAndStopBits,
    + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
    + urb_val,
    + 0,
    + settings,
    + 0,
    + KOBIL_TIMEOUT
    );
    kfree(settings);
    }

    -static int kobil_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg)
    +static int kobil_ioctl(struct tty_struct *tty, struct file *file,
    + unsigned int cmd, unsigned long arg)
    {
    struct usb_serial_port *port = tty->driver_data;
    - struct kobil_private * priv = usb_get_serial_port_data(port);
    + struct kobil_private *priv = usb_get_serial_port_data(port);
    unsigned char *transfer_buffer;
    int transfer_buffer_length = 8;
    int result;

    - if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)
    - // This device doesn't support ioctl calls
    + if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID ||
    + priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)
    + /* This device doesn't support ioctl calls */
    return 0;

    switch (cmd) {
    case TCFLSH:
    transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL);
    - if (! transfer_buffer)
    - return -ENOBUFS;
    -
    - result = usb_control_msg( port->serial->dev,
    - usb_rcvctrlpipe(port->serial->dev, 0 ),
    - SUSBCRequest_Misc,
    - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
    - SUSBCR_MSC_ResetAllQueues,
    - 0,
    - NULL,//transfer_buffer,
    - 0,
    - KOBIL_TIMEOUT
    + if (!transfer_buffer)
    + return -ENOBUFS;
    +
    + result = usb_control_msg(port->serial->dev,
    + usb_rcvctrlpipe(port->serial->dev, 0),
    + SUSBCRequest_Misc,
    + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
    + SUSBCR_MSC_ResetAllQueues,
    + 0,
    + NULL, /* transfer_buffer, */
    + 0,
    + KOBIL_TIMEOUT
    );
    -
    +
    dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result);
    kfree(transfer_buffer);
    return (result < 0) ? -EIO: 0;
    @@ -694,14 +731,14 @@ static int kobil_ioctl(struct tty_struct *tty, struct file * file, unsigned int
    }
    }

    -static int __init kobil_init (void)
    +static int __init kobil_init(void)
    {
    int retval;
    retval = usb_serial_register(&kobil_device);
    if (retval)
    goto failed_usb_serial_register;
    retval = usb_register(&kobil_driver);
    - if (retval)
    + if (retval)
    goto failed_usb_register;

    info(DRIVER_VERSION " " DRIVER_AUTHOR);
    @@ -715,18 +752,18 @@ failed_usb_serial_register:
    }


    -static void __exit kobil_exit (void)
    +static void __exit kobil_exit(void)
    {
    - usb_deregister (&kobil_driver);
    - usb_serial_deregister (&kobil_device);
    + usb_deregister(&kobil_driver);
    + usb_serial_deregister(&kobil_device);
    }

    module_init(kobil_init);
    module_exit(kobil_exit);

    -MODULE_AUTHOR( DRIVER_AUTHOR );
    -MODULE_DESCRIPTION( DRIVER_DESC );
    -MODULE_LICENSE( "GPL" );
    +MODULE_AUTHOR(DRIVER_AUTHOR);
    +MODULE_DESCRIPTION(DRIVER_DESC);
    +MODULE_LICENSE("GPL");

    module_param(debug, bool, S_IRUGO | S_IWUSR);
    MODULE_PARM_DESC(debug, "Debug enabled or not");

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  8. [PATCH 44/70] usb-serial: Coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/usb-serial.c | 311 +++++++++++++++++++++------------------
    1 files changed, 168 insertions(+), 143 deletions(-)


    diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
    index 6a1146a..8882f95 100644
    --- a/drivers/usb/serial/usb-serial.c
    +++ b/drivers/usb/serial/usb-serial.c
    @@ -12,7 +12,8 @@
    * This driver was originally based on the ACM driver by Armin Fuerst (which was
    * based on a driver by Brad Keryan)
    *
    - * See Documentation/usb/usb-serial.txt for more information on using this driver
    + * See Documentation/usb/usb-serial.txt for more information on using this
    + * driver
    *
    */

    @@ -28,7 +29,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include
    #include "pl2303.h"
    @@ -59,7 +60,8 @@ static struct usb_driver usb_serial_driver = {
    */

    static int debug;
    -static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; /* initially all NULL */
    +/* initially all NULL */
    +static struct usb_serial *serial_table[SERIAL_TTY_MINORS];
    static DEFINE_MUTEX(table_lock);
    static LIST_HEAD(usb_serial_driver_list);

    @@ -76,7 +78,8 @@ struct usb_serial *usb_serial_get_by_index(unsigned index)
    return serial;
    }

    -static struct usb_serial *get_free_serial (struct usb_serial *serial, int num_ports, unsigned int *minor)
    +static struct usb_serial *get_free_serial(struct usb_serial *serial,
    + int num_ports, unsigned int *minor)
    {
    unsigned int i, j;
    int good_spot;
    @@ -122,9 +125,8 @@ static void return_serial(struct usb_serial *serial)
    if (serial == NULL)
    return;

    - for (i = 0; i < serial->num_ports; ++i) {
    + for (i = 0; i < serial->num_ports; ++i)
    serial_table[serial->minor + i] = NULL;
    - }
    }

    static void destroy_serial(struct kref *kref)
    @@ -156,7 +158,8 @@ static void destroy_serial(struct kref *kref)
    * not get cleaned up in port_release() as it was never registered with
    * the driver core */
    if (serial->num_ports < serial->num_port_pointers) {
    - for (i = serial->num_ports; i < serial->num_port_pointers; ++i) {
    + for (i = serial->num_ports;
    + i < serial->num_port_pointers; ++i) {
    port = serial->port[i];
    if (!port)
    continue;
    @@ -167,7 +170,7 @@ static void destroy_serial(struct kref *kref)
    usb_put_dev(serial->dev);

    /* free up any memory that we allocated */
    - kfree (serial);
    + kfree(serial);
    }

    void usb_serial_put(struct usb_serial *serial)
    @@ -180,13 +183,13 @@ void usb_serial_put(struct usb_serial *serial)
    /************************************************** ***************************
    * Driver tty interface functions
    ************************************************** ***************************/
    -static int serial_open (struct tty_struct *tty, struct file * filp)
    +static int serial_open (struct tty_struct *tty, struct file *filp)
    {
    struct usb_serial *serial;
    struct usb_serial_port *port;
    unsigned int portNumber;
    int retval;
    -
    +
    dbg("%s", __func__);

    /* get the serial object associated with this tty pointer */
    @@ -207,7 +210,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
    retval = -ERESTARTSYS;
    goto bailout_kref_put;
    }
    -
    +
    ++port->port.count;

    /* set up our port structure making the tty driver
    @@ -228,7 +231,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
    retval = usb_autopm_get_interface(serial->interface);
    if (retval)
    goto bailout_module_put;
    - /* only call the device specific open if this
    + /* only call the device specific open if this
    * is the first time the port is opened */
    retval = serial->type->open(tty, port, filp);
    if (retval)
    @@ -252,7 +255,7 @@ bailout_kref_put:
    return retval;
    }

    -static void serial_close(struct tty_struct *tty, struct file * filp)
    +static void serial_close(struct tty_struct *tty, struct file *filp)
    {
    struct usb_serial_port *port = tty->driver_data;

    @@ -270,7 +273,7 @@ static void serial_close(struct tty_struct *tty, struct file * filp)

    --port->port.count;
    if (port->port.count == 0)
    - /* only call the device specific close if this
    + /* only call the device specific close if this
    * port is being closed by the last owner */
    port->serial->type->close(tty, port, filp);

    @@ -291,7 +294,8 @@ static void serial_close(struct tty_struct *tty, struct file * filp)
    usb_serial_put(port->serial);
    }

    -static int serial_write (struct tty_struct * tty, const unsigned char *buf, int count)
    +static int serial_write(struct tty_struct *tty, const unsigned char *buf,
    + int count)
    {
    struct usb_serial_port *port = tty->driver_data;
    int retval = -ENODEV;
    @@ -302,7 +306,7 @@ static int serial_write (struct tty_struct * tty, const unsigned char *buf, int
    dbg("%s - port %d, %d byte(s)", __func__, port->number, count);

    /* count is managed under the mutex lock for the tty so cannot
    - drop to zero until after the last close completes */
    + drop to zero until after the last close completes */
    WARN_ON(!port->port.count);

    /* pass on to the driver specific version of this function */
    @@ -312,7 +316,7 @@ exit:
    return retval;
    }

    -static int serial_write_room (struct tty_struct *tty)
    +static int serial_write_room(struct tty_struct *tty)
    {
    struct usb_serial_port *port = tty->driver_data;
    dbg("%s - port %d", __func__, port->number);
    @@ -321,7 +325,7 @@ static int serial_write_room (struct tty_struct *tty)
    return port->serial->type->write_room(tty);
    }

    -static int serial_chars_in_buffer (struct tty_struct *tty)
    +static int serial_chars_in_buffer(struct tty_struct *tty)
    {
    struct usb_serial_port *port = tty->driver_data;
    dbg("%s = port %d", __func__, port->number);
    @@ -331,7 +335,7 @@ static int serial_chars_in_buffer (struct tty_struct *tty)
    return port->serial->type->chars_in_buffer(tty);
    }

    -static void serial_throttle (struct tty_struct * tty)
    +static void serial_throttle(struct tty_struct *tty)
    {
    struct usb_serial_port *port = tty->driver_data;
    dbg("%s - port %d", __func__, port->number);
    @@ -342,7 +346,7 @@ static void serial_throttle (struct tty_struct * tty)
    port->serial->type->throttle(tty);
    }

    -static void serial_unthrottle (struct tty_struct * tty)
    +static void serial_unthrottle(struct tty_struct *tty)
    {
    struct usb_serial_port *port = tty->driver_data;
    dbg("%s - port %d", __func__, port->number);
    @@ -353,7 +357,8 @@ static void serial_unthrottle (struct tty_struct * tty)
    port->serial->type->unthrottle(tty);
    }

    -static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg)
    +static int serial_ioctl(struct tty_struct *tty, struct file *file,
    + unsigned int cmd, unsigned long arg)
    {
    struct usb_serial_port *port = tty->driver_data;
    int retval = -ENODEV;
    @@ -362,38 +367,40 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in

    WARN_ON(!port->port.count);

    - /* pass on to the driver specific version of this function if it is available */
    + /* pass on to the driver specific version of this function
    + if it is available */
    if (port->serial->type->ioctl) {
    lock_kernel();
    retval = port->serial->type->ioctl(tty, file, cmd, arg);
    unlock_kernel();
    - }
    - else
    + } else
    retval = -ENOIOCTLCMD;
    return retval;
    }

    -static void serial_set_termios (struct tty_struct *tty, struct ktermios * old)
    +static void serial_set_termios(struct tty_struct *tty, struct ktermios *old)
    {
    struct usb_serial_port *port = tty->driver_data;
    dbg("%s - port %d", __func__, port->number);

    WARN_ON(!port->port.count);
    - /* pass on to the driver specific version of this function if it is available */
    + /* pass on to the driver specific version of this function
    + if it is available */
    if (port->serial->type->set_termios)
    port->serial->type->set_termios(tty, port, old);
    else
    tty_termios_copy_hw(tty->termios, old);
    }

    -static void serial_break (struct tty_struct *tty, int break_state)
    +static void serial_break(struct tty_struct *tty, int break_state)
    {
    struct usb_serial_port *port = tty->driver_data;

    dbg("%s - port %d", __func__, port->number);

    WARN_ON(!port->port.count);
    - /* pass on to the driver specific version of this function if it is available */
    + /* pass on to the driver specific version of this function
    + if it is available */
    if (port->serial->type->break_ctl) {
    lock_kernel();
    port->serial->type->break_ctl(tty, break_state);
    @@ -401,7 +408,8 @@ static void serial_break (struct tty_struct *tty, int break_state)
    }
    }

    -static int serial_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data)
    +static int serial_read_proc(char *page, char **start, off_t off, int count,
    + int *eof, void *data)
    {
    struct usb_serial *serial;
    int length = 0;
    @@ -410,26 +418,29 @@ static int serial_read_proc (char *page, char **start, off_t off, int count, int
    char tmp[40];

    dbg("%s", __func__);
    - length += sprintf (page, "usbserinfo:1.0 driver:2.0\n");
    + length += sprintf(page, "usbserinfo:1.0 driver:2.0\n");
    for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) {
    serial = usb_serial_get_by_index(i);
    if (serial == NULL)
    continue;

    - length += sprintf (page+length, "%d:", i);
    + length += sprintf(page+length, "%d:", i);
    if (serial->type->driver.owner)
    - length += sprintf (page+length, " module:%s", module_name(serial->type->driver.owner));
    - length += sprintf (page+length, " name:\"%s\"", serial->type->description);
    - length += sprintf (page+length, " vendor:%04x product:%04x",
    - le16_to_cpu(serial->dev->descriptor.idVendor),
    - le16_to_cpu(serial->dev->descriptor.idProduct));
    - length += sprintf (page+length, " num_ports:%d", serial->num_ports);
    - length += sprintf (page+length, " port:%d", i - serial->minor + 1);
    -
    + length += sprintf(page+length, " module:%s",
    + module_name(serial->type->driver.owner));
    + length += sprintf(page+length, " name:\"%s\"",
    + serial->type->description);
    + length += sprintf(page+length, " vendor:%04x product:%04x",
    + le16_to_cpu(serial->dev->descriptor.idVendor),
    + le16_to_cpu(serial->dev->descriptor.idProduct));
    + length += sprintf(page+length, " num_ports:%d",
    + serial->num_ports);
    + length += sprintf(page+length, " port:%d",
    + i - serial->minor + 1);
    usb_make_path(serial->dev, tmp, sizeof(tmp));
    - length += sprintf (page+length, " path:%s", tmp);
    -
    - length += sprintf (page+length, "\n");
    + length += sprintf(page+length, " path:%s", tmp);
    +
    + length += sprintf(page+length, "\n");
    if ((length + begin) > (off + count)) {
    usb_serial_put(serial);
    goto done;
    @@ -445,10 +456,10 @@ done:
    if (off >= (length + begin))
    return 0;
    *start = page + (off-begin);
    - return ((count < begin+length-off) ? count : begin+length-off);
    + return (count < begin+length-off) ? count : begin+length-off;
    }

    -static int serial_tiocmget (struct tty_struct *tty, struct file *file)
    +static int serial_tiocmget(struct tty_struct *tty, struct file *file)
    {
    struct usb_serial_port *port = tty->driver_data;

    @@ -460,7 +471,7 @@ static int serial_tiocmget (struct tty_struct *tty, struct file *file)
    return -EINVAL;
    }

    -static int serial_tiocmset (struct tty_struct *tty, struct file *file,
    +static int serial_tiocmset(struct tty_struct *tty, struct file *file,
    unsigned int set, unsigned int clear)
    {
    struct usb_serial_port *port = tty->driver_data;
    @@ -482,6 +493,7 @@ void usb_serial_port_softint(struct usb_serial_port *port)
    {
    schedule_work(&port->work);
    }
    +EXPORT_SYMBOL_GPL(usb_serial_port_softint);

    static void usb_serial_port_work(struct work_struct *work)
    {
    @@ -490,7 +502,7 @@ static void usb_serial_port_work(struct work_struct *work)
    struct tty_struct *tty;

    dbg("%s - port %d", __func__, port->number);
    -
    +
    if (!port)
    return;

    @@ -505,7 +517,7 @@ static void port_release(struct device *dev)
    {
    struct usb_serial_port *port = to_usb_serial_port(dev);

    - dbg ("%s - %s", __func__, dev->bus_id);
    + dbg("%s - %s", __func__, dev->bus_id);
    port_free(port);
    }

    @@ -543,9 +555,9 @@ static void port_free(struct usb_serial_port *port)
    kfree(port);
    }

    -static struct usb_serial * create_serial (struct usb_device *dev,
    - struct usb_interface *interface,
    - struct usb_serial_driver *driver)
    +static struct usb_serial *create_serial(struct usb_device *dev,
    + struct usb_interface *interface,
    + struct usb_serial_driver *driver)
    {
    struct usb_serial *serial;

    @@ -564,7 +576,7 @@ static struct usb_serial * create_serial (struct usb_device *dev,
    }

    static const struct usb_device_id *match_dynamic_id(struct usb_interface *intf,
    - struct usb_serial_driver *drv)
    + struct usb_serial_driver *drv)
    {
    struct usb_dynid *dynid;

    @@ -596,7 +608,8 @@ exit:
    return id;
    }

    -static struct usb_serial_driver *search_serial_device(struct usb_interface *iface)
    +static struct usb_serial_driver *search_serial_device(
    + struct usb_interface *iface)
    {
    const struct usb_device_id *id;
    struct usb_serial_driver *drv;
    @@ -614,7 +627,7 @@ static struct usb_serial_driver *search_serial_device(struct usb_interface *ifac
    int usb_serial_probe(struct usb_interface *interface,
    const struct usb_device_id *id)
    {
    - struct usb_device *dev = interface_to_usbdev (interface);
    + struct usb_device *dev = interface_to_usbdev(interface);
    struct usb_serial *serial = NULL;
    struct usb_serial_port *port;
    struct usb_host_interface *iface_desc;
    @@ -643,7 +656,7 @@ int usb_serial_probe(struct usb_interface *interface,
    return -ENODEV;
    }

    - serial = create_serial (dev, interface, type);
    + serial = create_serial(dev, interface, type);
    if (!serial) {
    unlock_kernel();
    dev_err(&interface->dev, "%s - out of memory\n", __func__);
    @@ -656,8 +669,9 @@ int usb_serial_probe(struct usb_interface *interface,

    if (!try_module_get(type->driver.owner)) {
    unlock_kernel();
    - dev_err(&interface->dev, "module get failed, exiting\n");
    - kfree (serial);
    + dev_err(&interface->dev,
    + "module get failed, exiting\n");
    + kfree(serial);
    return -EIO;
    }

    @@ -667,8 +681,8 @@ int usb_serial_probe(struct usb_interface *interface,

    if (retval) {
    unlock_kernel();
    - dbg ("sub driver rejected device");
    - kfree (serial);
    + dbg("sub driver rejected device");
    + kfree(serial);
    return retval;
    }
    }
    @@ -709,7 +723,7 @@ int usb_serial_probe(struct usb_interface *interface,
    }

    #if defined(CONFIG_USB_SERIAL_PL2303) || defined(CONFIG_USB_SERIAL_PL2303_MODULE)
    - /* BEGIN HORRIBLE HACK FOR PL2303 */
    + /* BEGIN HORRIBLE HACK FOR PL2303 */
    /* this is needed due to the looney way its endpoints are set up */
    if (((le16_to_cpu(dev->descriptor.idVendor) == PL2303_VENDOR_ID) &&
    (le16_to_cpu(dev->descriptor.idProduct) == PL2303_PRODUCT_ID)) ||
    @@ -738,7 +752,7 @@ int usb_serial_probe(struct usb_interface *interface,
    if (num_bulk_in == 0 || num_bulk_out == 0) {
    unlock_kernel();
    dev_info(&interface->dev, "PL-2303 hack: descriptors matched but endpoints did not\n");
    - kfree (serial);
    + kfree(serial);
    return -ENODEV;
    }
    }
    @@ -750,8 +764,9 @@ int usb_serial_probe(struct usb_interface *interface,
    num_ports = num_bulk_out;
    if (num_ports == 0) {
    unlock_kernel();
    - dev_err(&interface->dev, "Generic device with no bulk out, not allowed.\n");
    - kfree (serial);
    + dev_err(&interface->dev,
    + "Generic device with no bulk out, not allowed.\n");
    + kfree(serial);
    return -EIO;
    }
    }
    @@ -761,11 +776,12 @@ int usb_serial_probe(struct usb_interface *interface,
    if (type->calc_num_ports) {
    if (!try_module_get(type->driver.owner)) {
    unlock_kernel();
    - dev_err(&interface->dev, "module get failed, exiting\n");
    - kfree (serial);
    + dev_err(&interface->dev,
    + "module get failed, exiting\n");
    + kfree(serial);
    return -EIO;
    }
    - num_ports = type->calc_num_ports (serial);
    + num_ports = type->calc_num_ports(serial);
    module_put(type->driver.owner);
    }
    if (!num_ports)
    @@ -783,7 +799,8 @@ int usb_serial_probe(struct usb_interface *interface,
    type->description);

    /* create our ports, we need as many as the max endpoints */
    - /* we don't use num_ports here cauz some devices have more endpoint pairs than ports */
    + /* we don't use num_ports here because some devices have more
    + endpoint pairs than ports */
    max_endpoints = max(num_bulk_in, num_bulk_out);
    max_endpoints = max(max_endpoints, num_interrupt_in);
    max_endpoints = max(max_endpoints, num_interrupt_out);
    @@ -791,7 +808,8 @@ int usb_serial_probe(struct usb_interface *interface,
    serial->num_port_pointers = max_endpoints;
    unlock_kernel();

    - dbg("%s - setting up %d port structures for this device", __func__, max_endpoints);
    + dbg("%s - setting up %d port structures for this device",
    + __func__, max_endpoints);
    for (i = 0; i < max_endpoints; ++i) {
    port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL);
    if (!port)
    @@ -807,7 +825,7 @@ int usb_serial_probe(struct usb_interface *interface,
    for (i = 0; i < num_bulk_in; ++i) {
    endpoint = bulk_in_endpoint[i];
    port = serial->port[i];
    - port->read_urb = usb_alloc_urb (0, GFP_KERNEL);
    + port->read_urb = usb_alloc_urb(0, GFP_KERNEL);
    if (!port->read_urb) {
    dev_err(&interface->dev, "No free urbs available\n");
    goto probe_error;
    @@ -815,17 +833,17 @@ int usb_serial_probe(struct usb_interface *interface,
    buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
    port->bulk_in_size = buffer_size;
    port->bulk_in_endpointAddress = endpoint->bEndpointAddress;
    - port->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
    + port->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
    if (!port->bulk_in_buffer) {
    - dev_err(&interface->dev, "Couldn't allocate bulk_in_buffer\n");
    + dev_err(&interface->dev,
    + "Couldn't allocate bulk_in_buffer\n");
    goto probe_error;
    }
    - usb_fill_bulk_urb (port->read_urb, dev,
    - usb_rcvbulkpipe (dev,
    - endpoint->bEndpointAddress),
    - port->bulk_in_buffer, buffer_size,
    - serial->type->read_bulk_callback,
    - port);
    + usb_fill_bulk_urb(port->read_urb, dev,
    + usb_rcvbulkpipe(dev,
    + endpoint->bEndpointAddress),
    + port->bulk_in_buffer, buffer_size,
    + serial->type->read_bulk_callback, port);
    }

    for (i = 0; i < num_bulk_out; ++i) {
    @@ -839,17 +857,17 @@ int usb_serial_probe(struct usb_interface *interface,
    buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
    port->bulk_out_size = buffer_size;
    port->bulk_out_endpointAddress = endpoint->bEndpointAddress;
    - port->bulk_out_buffer = kmalloc (buffer_size, GFP_KERNEL);
    + port->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL);
    if (!port->bulk_out_buffer) {
    - dev_err(&interface->dev, "Couldn't allocate bulk_out_buffer\n");
    + dev_err(&interface->dev,
    + "Couldn't allocate bulk_out_buffer\n");
    goto probe_error;
    }
    - usb_fill_bulk_urb (port->write_urb, dev,
    - usb_sndbulkpipe (dev,
    - endpoint->bEndpointAddress),
    - port->bulk_out_buffer, buffer_size,
    - serial->type->write_bulk_callback,
    - port);
    + usb_fill_bulk_urb(port->write_urb, dev,
    + usb_sndbulkpipe(dev,
    + endpoint->bEndpointAddress),
    + port->bulk_out_buffer, buffer_size,
    + serial->type->write_bulk_callback, port);
    }

    if (serial->type->read_int_callback) {
    @@ -858,73 +876,82 @@ int usb_serial_probe(struct usb_interface *interface,
    port = serial->port[i];
    port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
    if (!port->interrupt_in_urb) {
    - dev_err(&interface->dev, "No free urbs available\n");
    + dev_err(&interface->dev,
    + "No free urbs available\n");
    goto probe_error;
    }
    buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
    - port->interrupt_in_endpointAddress = endpoint->bEndpointAddress;
    - port->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
    + port->interrupt_in_endpointAddress =
    + endpoint->bEndpointAddress;
    + port->interrupt_in_buffer = kmalloc(buffer_size,
    + GFP_KERNEL);
    if (!port->interrupt_in_buffer) {
    - dev_err(&interface->dev, "Couldn't allocate interrupt_in_buffer\n");
    + dev_err(&interface->dev,
    + "Couldn't allocate interrupt_in_buffer\n");
    goto probe_error;
    }
    - usb_fill_int_urb (port->interrupt_in_urb, dev,
    - usb_rcvintpipe (dev,
    - endpoint->bEndpointAddress),
    - port->interrupt_in_buffer, buffer_size,
    - serial->type->read_int_callback, port,
    - endpoint->bInterval);
    + usb_fill_int_urb(port->interrupt_in_urb, dev,
    + usb_rcvintpipe(dev,
    + endpoint->bEndpointAddress),
    + port->interrupt_in_buffer, buffer_size,
    + serial->type->read_int_callback, port,
    + endpoint->bInterval);
    }
    } else if (num_interrupt_in) {
    dbg("the device claims to support interrupt in transfers, but read_int_callback is not defined");
    }
    -
    +
    if (serial->type->write_int_callback) {
    for (i = 0; i < num_interrupt_out; ++i) {
    endpoint = interrupt_out_endpoint[i];
    port = serial->port[i];
    port->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
    if (!port->interrupt_out_urb) {
    - dev_err(&interface->dev, "No free urbs available\n");
    + dev_err(&interface->dev,
    + "No free urbs available\n");
    goto probe_error;
    }
    buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
    port->interrupt_out_size = buffer_size;
    - port->interrupt_out_endpointAddress = endpoint->bEndpointAddress;
    - port->interrupt_out_buffer = kmalloc (buffer_size, GFP_KERNEL);
    + port->interrupt_out_endpointAddress =
    + endpoint->bEndpointAddress;
    + port->interrupt_out_buffer = kmalloc(buffer_size,
    + GFP_KERNEL);
    if (!port->interrupt_out_buffer) {
    - dev_err(&interface->dev, "Couldn't allocate interrupt_out_buffer\n");
    + dev_err(&interface->dev,
    + "Couldn't allocate interrupt_out_buffer\n");
    goto probe_error;
    }
    - usb_fill_int_urb (port->interrupt_out_urb, dev,
    - usb_sndintpipe (dev,
    - endpoint->bEndpointAddress),
    - port->interrupt_out_buffer, buffer_size,
    - serial->type->write_int_callback, port,
    - endpoint->bInterval);
    + usb_fill_int_urb(port->interrupt_out_urb, dev,
    + usb_sndintpipe(dev,
    + endpoint->bEndpointAddress),
    + port->interrupt_out_buffer, buffer_size,
    + serial->type->write_int_callback, port,
    + endpoint->bInterval);
    }
    } else if (num_interrupt_out) {
    dbg("the device claims to support interrupt out transfers, but write_int_callback is not defined");
    }
    -
    +
    /* if this device type has an attach function, call it */
    if (type->attach) {
    if (!try_module_get(type->driver.owner)) {
    - dev_err(&interface->dev, "module get failed, exiting\n");
    + dev_err(&interface->dev,
    + "module get failed, exiting\n");
    goto probe_error;
    }
    - retval = type->attach (serial);
    + retval = type->attach(serial);
    module_put(type->driver.owner);
    if (retval < 0)
    goto probe_error;
    if (retval > 0) {
    - /* quietly accept this device, but don't bind to a serial port
    - * as it's about to disappear */
    + /* quietly accept this device, but don't bind to a
    + serial port as it's about to disappear */
    goto exit;
    }
    }

    - if (get_free_serial (serial, num_ports, &minor) == NULL) {
    + if (get_free_serial(serial, num_ports, &minor) == NULL) {
    dev_err(&interface->dev, "No more free serial devices\n");
    goto probe_error;
    }
    @@ -938,19 +965,20 @@ int usb_serial_probe(struct usb_interface *interface,
    port->dev.bus = &usb_serial_bus_type;
    port->dev.release = &port_release;

    - snprintf (&port->dev.bus_id[0], sizeof(port->dev.bus_id), "ttyUSB%d", port->number);
    - dbg ("%s - registering %s", __func__, port->dev.bus_id);
    + snprintf(&port->dev.bus_id[0], sizeof(port->dev.bus_id),
    + "ttyUSB%d", port->number);
    + dbg("%s - registering %s", __func__, port->dev.bus_id);
    retval = device_register(&port->dev);
    if (retval)
    dev_err(&port->dev, "Error registering port device, "
    "continuing\n");
    }

    - usb_serial_console_init (debug, minor);
    + usb_serial_console_init(debug, minor);

    exit:
    /* success */
    - usb_set_intfdata (interface, serial);
    + usb_set_intfdata(interface, serial);
    return 0;

    probe_error:
    @@ -986,22 +1014,23 @@ probe_error:
    /* free up any memory that we allocated */
    for (i = 0; i < serial->num_port_pointers; ++i)
    kfree(serial->port[i]);
    - kfree (serial);
    + kfree(serial);
    return -EIO;
    }
    +EXPORT_SYMBOL_GPL(usb_serial_probe);

    void usb_serial_disconnect(struct usb_interface *interface)
    {
    int i;
    - struct usb_serial *serial = usb_get_intfdata (interface);
    + struct usb_serial *serial = usb_get_intfdata(interface);
    struct device *dev = &interface->dev;
    struct usb_serial_port *port;

    usb_serial_console_disconnect(serial);
    - dbg ("%s", __func__);
    + dbg("%s", __func__);

    mutex_lock(&serial->disc_mutex);
    - usb_set_intfdata (interface, NULL);
    + usb_set_intfdata(interface, NULL);
    /* must set a flag, to signal subdrivers */
    serial->disconnected = 1;
    for (i = 0; i < serial->num_ports; ++i) {
    @@ -1018,6 +1047,7 @@ void usb_serial_disconnect(struct usb_interface *interface)
    usb_serial_put(serial);
    dev_info(dev, "device disconnected\n");
    }
    +EXPORT_SYMBOL_GPL(usb_serial_disconnect);

    int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
    {
    @@ -1076,9 +1106,8 @@ static int __init usb_serial_init(void)
    return -ENOMEM;

    /* Initialize our global data */
    - for (i = 0; i < SERIAL_TTY_MINORS; ++i) {
    + for (i = 0; i < SERIAL_TTY_MINORS; ++i)
    serial_table[i] = NULL;
    - }

    result = bus_register(&usb_serial_bus_type);
    if (result) {
    @@ -1093,9 +1122,11 @@ static int __init usb_serial_init(void)
    usb_serial_tty_driver->minor_start = 0;
    usb_serial_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
    usb_serial_tty_driver->subtype = SERIAL_TYPE_NORMAL;
    - usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
    + usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW |
    + TTY_DRIVER_DYNAMIC_DEV;
    usb_serial_tty_driver->init_termios = tty_std_termios;
    - usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
    + usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD
    + | HUPCL | CLOCAL;
    usb_serial_tty_driver->init_termios.c_ispeed = 9600;
    usb_serial_tty_driver->init_termios.c_ospeed = 9600;
    tty_set_operations(usb_serial_tty_driver, &serial_ops);
    @@ -1133,7 +1164,7 @@ exit_reg_driver:
    bus_unregister(&usb_serial_bus_type);

    exit_bus:
    - err ("%s - returning with error %d", __func__, result);
    + err("%s - returning with error %d", __func__, result);
    put_tty_driver(usb_serial_tty_driver);
    return result;
    }
    @@ -1160,7 +1191,7 @@ module_exit(usb_serial_exit);
    if (!type->function) { \
    type->function = usb_serial_generic_##function; \
    dbg("Had to override the " #function \
    - " usb serial operation with the generic one.");\
    + " usb serial operation with the generic one.");\
    } \
    } while (0)

    @@ -1177,8 +1208,9 @@ static void fixup_generic(struct usb_serial_driver *device)
    set_to_generic_if_null(device, resume);
    }

    -int usb_serial_register(struct usb_serial_driver *driver) /* must be called with BKL held */
    +int usb_serial_register(struct usb_serial_driver *driver)
    {
    + /* must be called with BKL held */
    int retval;

    fixup_generic(driver);
    @@ -1191,37 +1223,30 @@ int usb_serial_register(struct usb_serial_driver *driver) /* must be called with

    retval = usb_serial_bus_register(driver);
    if (retval) {
    - err("problem %d when registering driver %s", retval, driver->description);
    + err("problem %d when registering driver %s",
    + retval, driver->description);
    list_del(&driver->driver_list);
    - }
    - else
    - info("USB Serial support registered for %s", driver->description);
    + } else
    + info("USB Serial support registered for %s",
    + driver->description);

    return retval;
    }
    +EXPORT_SYMBOL_GPL(usb_serial_register);


    -void usb_serial_deregister(struct usb_serial_driver *device) /* must be called with BKL held */
    +void usb_serial_deregister(struct usb_serial_driver *device)
    {
    + /* must be called with BKL held */
    info("USB Serial deregistering driver %s", device->description);
    list_del(&device->driver_list);
    usb_serial_bus_deregister(device);
    }
    -
    -
    -
    -/* If the usb-serial core is built into the core, the usb-serial drivers
    - need these symbols to load properly as modules. */
    -EXPORT_SYMBOL_GPL(usb_serial_register);
    EXPORT_SYMBOL_GPL(usb_serial_deregister);
    -EXPORT_SYMBOL_GPL(usb_serial_probe);
    -EXPORT_SYMBOL_GPL(usb_serial_disconnect);
    -EXPORT_SYMBOL_GPL(usb_serial_port_softint);
    -

    /* Module information */
    -MODULE_AUTHOR( DRIVER_AUTHOR );
    -MODULE_DESCRIPTION( DRIVER_DESC );
    +MODULE_AUTHOR(DRIVER_AUTHOR);
    +MODULE_DESCRIPTION(DRIVER_DESC);
    MODULE_LICENSE("GPL");

    module_param(debug, bool, S_IRUGO | S_IWUSR);

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  9. [PATCH 39/70] tty-usb-generic: Code cleanup

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/generic.c | 87 ++++++++++++++++++++++++------------------
    1 files changed, 49 insertions(+), 38 deletions(-)


    diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
    index 5128018..fe84c88 100644
    --- a/drivers/usb/serial/generic.c
    +++ b/drivers/usb/serial/generic.c
    @@ -18,7 +18,7 @@
    #include
    #include
    #include
    -#include
    +#include


    static int debug;
    @@ -81,7 +81,7 @@ static int generic_probe(struct usb_interface *interface,
    }
    #endif

    -int usb_serial_generic_register (int _debug)
    +int usb_serial_generic_register(int _debug)
    {
    int retval = 0;

    @@ -89,10 +89,11 @@ int usb_serial_generic_register (int _debug)
    #ifdef CONFIG_USB_SERIAL_GENERIC
    generic_device_ids[0].idVendor = vendor;
    generic_device_ids[0].idProduct = product;
    - generic_device_ids[0].match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT;
    + generic_device_ids[0].match_flags =
    + USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT;

    /* register our generic driver with ourselves */
    - retval = usb_serial_register (&usb_serial_generic_device);
    + retval = usb_serial_register(&usb_serial_generic_device);
    if (retval)
    goto exit;
    retval = usb_register(&generic_driver);
    @@ -103,12 +104,12 @@ exit:
    return retval;
    }

    -void usb_serial_generic_deregister (void)
    +void usb_serial_generic_deregister(void)
    {
    #ifdef CONFIG_USB_SERIAL_GENERIC
    /* remove our generic driver */
    usb_deregister(&generic_driver);
    - usb_serial_deregister (&usb_serial_generic_device);
    + usb_serial_deregister(&usb_serial_generic_device);
    #endif
    }

    @@ -121,9 +122,9 @@ int usb_serial_generic_open(struct tty_struct *tty,

    dbg("%s - port %d", __func__, port->number);

    - /* force low_latency on so that our tty_push actually forces the data through,
    - otherwise it is scheduled, and with high data rates (like with OHCI) data
    - can get lost. */
    + /* force low_latency on so that our tty_push actually forces the data
    + through, otherwise it is scheduled, and with high data rates (like
    + with OHCI) data can get lost. */
    if (tty)
    tty->low_latency = 1;

    @@ -136,8 +137,9 @@ int usb_serial_generic_open(struct tty_struct *tty,
    /* if we have a bulk endpoint, start reading from it */
    if (serial->num_bulk_in) {
    /* Start reading from the device */
    - usb_fill_bulk_urb (port->read_urb, serial->dev,
    - usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
    + usb_fill_bulk_urb(port->read_urb, serial->dev,
    + usb_rcvbulkpipe(serial->dev,
    + port->bulk_in_endpointAddress),
    port->read_urb->transfer_buffer,
    port->read_urb->transfer_buffer_length,
    ((serial->type->read_bulk_callback) ?
    @@ -146,7 +148,9 @@ int usb_serial_generic_open(struct tty_struct *tty,
    port);
    result = usb_submit_urb(port->read_urb, GFP_KERNEL);
    if (result)
    - dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
    + dev_err(&port->dev,
    + "%s - failed resubmitting read urb, error %d\n",
    + __func__, result);
    }

    return result;
    @@ -194,10 +198,10 @@ int usb_serial_generic_resume(struct usb_serial *serial)
    }

    void usb_serial_generic_close(struct tty_struct *tty,
    - struct usb_serial_port *port, struct file * filp)
    + struct usb_serial_port *port, struct file *filp)
    {
    dbg("%s - port %d", __func__, port->number);
    - generic_cleanup (port);
    + generic_cleanup(port);
    }

    int usb_serial_generic_write(struct tty_struct *tty,
    @@ -211,7 +215,7 @@ int usb_serial_generic_write(struct tty_struct *tty,

    if (count == 0) {
    dbg("%s - write request of 0 bytes", __func__);
    - return (0);
    + return 0;
    }

    /* only do something if we have a bulk out endpoint */
    @@ -226,27 +230,32 @@ int usb_serial_generic_write(struct tty_struct *tty,
    port->write_urb_busy = 1;
    spin_unlock_irqrestore(&port->lock, flags);

    - count = (count > port->bulk_out_size) ? port->bulk_out_size : count;
    + count = (count > port->bulk_out_size) ?
    + port->bulk_out_size : count;

    - memcpy (port->write_urb->transfer_buffer, buf, count);
    + memcpy(port->write_urb->transfer_buffer, buf, count);
    data = port->write_urb->transfer_buffer;
    usb_serial_debug_data(debug, &port->dev, __func__, count, data);

    /* set up our urb */
    - usb_fill_bulk_urb (port->write_urb, serial->dev,
    - usb_sndbulkpipe (serial->dev,
    - port->bulk_out_endpointAddress),
    + usb_fill_bulk_urb(port->write_urb, serial->dev,
    + usb_sndbulkpipe(serial->dev,
    + port->bulk_out_endpointAddress),
    port->write_urb->transfer_buffer, count,
    - ((serial->type->write_bulk_callback) ?
    + ((serial->type->write_bulk_callback) ?
    serial->type->write_bulk_callback :
    - usb_serial_generic_write_bulk_callback), port);
    + usb_serial_generic_write_bulk_callback),
    + port);

    /* send the data out the bulk port */
    port->write_urb_busy = 1;
    result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
    if (result) {
    - dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result);
    - /* don't have to grab the lock here, as we will retry if != 0 */
    + dev_err(&port->dev,
    + "%s - failed submitting write urb, error %d\n",
    + __func__, result);
    + /* don't have to grab the lock here, as we will
    + retry if != 0 */
    port->write_urb_busy = 0;
    } else
    result = count;
    @@ -258,7 +267,7 @@ int usb_serial_generic_write(struct tty_struct *tty,
    return 0;
    }

    -int usb_serial_generic_write_room (struct tty_struct *tty)
    +int usb_serial_generic_write_room(struct tty_struct *tty)
    {
    struct usb_serial_port *port = tty->driver_data;
    struct usb_serial *serial = port->serial;
    @@ -302,17 +311,19 @@ static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags)
    int result;

    /* Continue reading from device */
    - usb_fill_bulk_urb (urb, serial->dev,
    - usb_rcvbulkpipe (serial->dev,
    - port->bulk_in_endpointAddress),
    + usb_fill_bulk_urb(urb, serial->dev,
    + usb_rcvbulkpipe(serial->dev,
    + port->bulk_in_endpointAddress),
    urb->transfer_buffer,
    urb->transfer_buffer_length,
    - ((serial->type->read_bulk_callback) ?
    - serial->type->read_bulk_callback :
    + ((serial->type->read_bulk_callback) ?
    + serial->type->read_bulk_callback :
    usb_serial_generic_read_bulk_callback), port);
    result = usb_submit_urb(urb, mem_flags);
    if (result)
    - dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
    + dev_err(&port->dev,
    + "%s - failed resubmitting read urb, error %d\n",
    + __func__, result);
    }

    /* Push data to tty layer and resubmit the bulk read URB */
    @@ -349,16 +360,17 @@ void usb_serial_generic_read_bulk_callback(struct urb *urb)
    return;
    }

    - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
    + usb_serial_debug_data(debug, &port->dev, __func__,
    + urb->actual_length, data);

    /* Throttle the device if requested by tty */
    spin_lock_irqsave(&port->lock, flags);
    - if (!(port->throttled = port->throttle_req)) {
    + port->throttled = port->throttle_req;
    + if (!port->throttled) {
    spin_unlock_irqrestore(&port->lock, flags);
    flush_and_resubmit_read_urb(port);
    - } else {
    + } else
    spin_unlock_irqrestore(&port->lock, flags);
    - }
    }
    EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_cal lback);

    @@ -413,15 +425,14 @@ void usb_serial_generic_unthrottle(struct tty_struct *tty)
    }
    }

    -void usb_serial_generic_shutdown (struct usb_serial *serial)
    +void usb_serial_generic_shutdown(struct usb_serial *serial)
    {
    int i;

    dbg("%s", __func__);

    /* stop reads and writes on all ports */
    - for (i=0; i < serial->num_ports; ++i) {
    + for (i = 0; i < serial->num_ports; ++i)
    generic_cleanup(serial->port[i]);
    - }
    }


    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  10. [PATCH 45/70] io_ti: Minor coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/io_ti.c | 6 +++---
    1 files changed, 3 insertions(+), 3 deletions(-)


    diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
    index 808e285..c6a6444 100644
    --- a/drivers/usb/serial/io_ti.c
    +++ b/drivers/usb/serial/io_ti.c
    @@ -2402,7 +2402,7 @@ static void change_port_settings(struct tty_struct *tty,
    return;
    }

    -static void edge_set_termios(struct tty_struct *tty,
    +static void edge_set_termios(struct tty_struct *tty,
    struct usb_serial_port *port, struct ktermios *old_termios)
    {
    struct edgeport_port *edge_port = usb_get_serial_port_data(port);
    @@ -2771,7 +2771,7 @@ static unsigned int edge_buf_data_avail(struct edge_buf *eb)
    {
    if (eb == NULL)
    return 0;
    - return ((eb->buf_size + eb->buf_put - eb->buf_get) % eb->buf_size);
    + return (eb->buf_size + eb->buf_put - eb->buf_get) % eb->buf_size;
    }


    @@ -2786,7 +2786,7 @@ static unsigned int edge_buf_space_avail(struct edge_buf *eb)
    {
    if (eb == NULL)
    return 0;
    - return ((eb->buf_size + eb->buf_get - eb->buf_put - 1) % eb->buf_size);
    + return (eb->buf_size + eb->buf_get - eb->buf_put - 1) % eb->buf_size;
    }



    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  11. [PATCH 46/70] ipaq: Coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/ipaq.c | 97 ++++++++++++++++++++++++---------------------
    1 files changed, 52 insertions(+), 45 deletions(-)


    diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
    index 437982a..5f07f62 100644
    --- a/drivers/usb/serial/ipaq.c
    +++ b/drivers/usb/serial/ipaq.c
    @@ -53,7 +53,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include
    #include "ipaq.h"
    @@ -82,10 +82,10 @@ static int ipaq_startup(struct usb_serial *serial);
    static void ipaq_shutdown(struct usb_serial *serial);
    static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port,
    const unsigned char *buf, int count);
    -static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf,
    - int count);
    +static int ipaq_write_bulk(struct usb_serial_port *port,
    + const unsigned char *buf, int count);
    static void ipaq_write_gather(struct usb_serial_port *port);
    -static void ipaq_read_bulk_callback (struct urb *urb);
    +static void ipaq_read_bulk_callback(struct urb *urb);
    static void ipaq_write_bulk_callback(struct urb *urb);
    static int ipaq_write_room(struct tty_struct *tty);
    static int ipaq_chars_in_buffer(struct tty_struct *tty);
    @@ -552,7 +552,7 @@ static struct usb_device_id ipaq_id_table [] = {
    { } /* Terminating entry */
    };

    -MODULE_DEVICE_TABLE (usb, ipaq_id_table);
    +MODULE_DEVICE_TABLE(usb, ipaq_id_table);

    static struct usb_driver ipaq_driver = {
    .name = "ipaq",
    @@ -615,9 +615,9 @@ static int ipaq_open(struct tty_struct *tty,

    for (i = 0; i < URBDATA_QUEUE_MAX / PACKET_SIZE; i++) {
    pkt = kmalloc(sizeof(struct ipaq_packet), GFP_KERNEL);
    - if (pkt == NULL) {
    + if (pkt == NULL)
    goto enomem;
    - }
    +
    pkt->data = kmalloc(PACKET_SIZE, GFP_KERNEL);
    if (pkt->data == NULL) {
    kfree(pkt);
    @@ -661,8 +661,9 @@ static int ipaq_open(struct tty_struct *tty,
    port->read_urb->transfer_buffer = port->bulk_in_buffer;
    port->write_urb->transfer_buffer = port->bulk_out_buffer;
    port->read_urb->transfer_buffer_length = URBDATA_SIZE;
    - port->bulk_out_size = port->write_urb->transfer_buffer_length = URBDATA_SIZE;
    -
    + port->bulk_out_size = port->write_urb->transfer_buffer_length
    + = URBDATA_SIZE;
    +
    msleep(1000*initial_wait);

    /*
    @@ -691,13 +692,15 @@ static int ipaq_open(struct tty_struct *tty,

    /* Start reading from the device */
    usb_fill_bulk_urb(port->read_urb, serial->dev,
    - usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
    - port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
    - ipaq_read_bulk_callback, port);
    + usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
    + port->read_urb->transfer_buffer,
    + port->read_urb->transfer_buffer_length,
    + ipaq_read_bulk_callback, port);

    result = usb_submit_urb(port->read_urb, GFP_KERNEL);
    if (result) {
    - err("%s - failed submitting read urb, error %d", __func__, result);
    + err("%s - failed submitting read urb, error %d",
    + __func__, result);
    goto error;
    }

    @@ -719,7 +722,7 @@ static void ipaq_close(struct tty_struct *tty,
    struct ipaq_private *priv = usb_get_serial_port_data(port);

    dbg("%s - port %d", __func__, port->number);
    -
    +
    /*
    * shut down bulk read and write
    */
    @@ -729,7 +732,8 @@ static void ipaq_close(struct tty_struct *tty,
    kfree(priv);
    usb_set_serial_port_data(port, NULL);

    - /* Uncomment the following line if you want to see some statistics in your syslog */
    + /* Uncomment the following line if you want to see some statistics
    + * in your syslog */
    /* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */
    }

    @@ -749,7 +753,8 @@ static void ipaq_read_bulk_callback(struct urb *urb)
    return;
    }

    - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
    + usb_serial_debug_data(debug, &port->dev, __func__,
    + urb->actual_length, data);

    tty = port->port.tty;
    if (tty && urb->actual_length) {
    @@ -760,13 +765,15 @@ static void ipaq_read_bulk_callback(struct urb *urb)
    }

    /* Continue trying to always read */
    - usb_fill_bulk_urb(port->read_urb, port->serial->dev,
    - usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
    - port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
    - ipaq_read_bulk_callback, port);
    + usb_fill_bulk_urb(port->read_urb, port->serial->dev,
    + usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
    + port->read_urb->transfer_buffer,
    + port->read_urb->transfer_buffer_length,
    + ipaq_read_bulk_callback, port);
    result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
    if (result)
    - err("%s - failed resubmitting read urb, error %d", __func__, result);
    + err("%s - failed resubmitting read urb, error %d",
    + __func__, result);
    return;
    }

    @@ -781,9 +788,8 @@ static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port,

    while (count > 0) {
    transfer_size = min(count, PACKET_SIZE);
    - if (ipaq_write_bulk(port, current_position, transfer_size)) {
    + if (ipaq_write_bulk(port, current_position, transfer_size))
    break;
    - }
    current_position += transfer_size;
    bytes_sent += transfer_size;
    count -= transfer_size;
    @@ -791,10 +797,10 @@ static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port,
    }

    return bytes_sent;
    -}
    +}

    -static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf,
    - int count)
    +static int ipaq_write_bulk(struct usb_serial_port *port,
    + const unsigned char *buf, int count)
    {
    struct ipaq_private *priv = usb_get_serial_port_data(port);
    struct ipaq_packet *pkt = NULL;
    @@ -831,9 +837,9 @@ static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *bu
    ipaq_write_gather(port);
    spin_unlock_irqrestore(&write_list_lock, flags);
    result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
    - if (result) {
    - err("%s - failed submitting write urb, error %d", __func__, result);
    - }
    + if (result)
    + err("%s - failed submitting write urb, error %d",
    + __func__, result);
    } else {
    spin_unlock_irqrestore(&write_list_lock, flags);
    }
    @@ -860,16 +866,15 @@ static void ipaq_write_gather(struct usb_serial_port *port)
    list_move(&pkt->list, &priv->freelist);
    priv->free_len += PACKET_SIZE;
    }
    - if (room == 0) {
    + if (room == 0)
    break;
    - }
    }

    count = URBDATA_SIZE - room;
    - usb_fill_bulk_urb(port->write_urb, serial->dev,
    - usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress),
    - port->write_urb->transfer_buffer, count, ipaq_write_bulk_callback,
    - port);
    + usb_fill_bulk_urb(port->write_urb, serial->dev,
    + usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress),
    + port->write_urb->transfer_buffer, count,
    + ipaq_write_bulk_callback, port);
    return;
    }

    @@ -894,9 +899,9 @@ static void ipaq_write_bulk_callback(struct urb *urb)
    ipaq_write_gather(port);
    spin_unlock_irqrestore(&write_list_lock, flags);
    result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
    - if (result) {
    - err("%s - failed submitting write urb, error %d", __func__, result);
    - }
    + if (result)
    + err("%s - failed submitting write urb, error %d",
    + __func__, result);
    } else {
    priv->active = 0;
    spin_unlock_irqrestore(&write_list_lock, flags);
    @@ -947,7 +952,7 @@ static int ipaq_startup(struct usb_serial *serial)
    serial->dev->actconfig->desc.bConfigurationValue);
    return -ENODEV;
    }
    - return usb_reset_configuration (serial->dev);
    + return usb_reset_configuration(serial->dev);
    }

    static void ipaq_shutdown(struct usb_serial *serial)
    @@ -960,7 +965,7 @@ static int __init ipaq_init(void)
    int retval;
    spin_lock_init(&write_list_lock);
    retval = usb_serial_register(&ipaq_device);
    - if (retval)
    + if (retval)
    goto failed_usb_serial_register;
    info(DRIVER_DESC " " DRIVER_VERSION);
    if (vendor) {
    @@ -970,7 +975,7 @@ static int __init ipaq_init(void)
    retval = usb_register(&ipaq_driver);
    if (retval)
    goto failed_usb_register;
    -
    +
    return 0;
    failed_usb_register:
    usb_serial_deregister(&ipaq_device);
    @@ -989,8 +994,8 @@ static void __exit ipaq_exit(void)
    module_init(ipaq_init);
    module_exit(ipaq_exit);

    -MODULE_AUTHOR( DRIVER_AUTHOR );
    -MODULE_DESCRIPTION( DRIVER_DESC );
    +MODULE_AUTHOR(DRIVER_AUTHOR);
    +MODULE_DESCRIPTION(DRIVER_DESC);
    MODULE_LICENSE("GPL");

    module_param(debug, bool, S_IRUGO | S_IWUSR);
    @@ -1003,7 +1008,9 @@ module_param(product, ushort, 0);
    MODULE_PARM_DESC(product, "User specified USB idProduct");

    module_param(connect_retries, int, S_IRUGO|S_IWUSR);
    -MODULE_PARM_DESC(connect_retries, "Maximum number of connect retries (one second each)");
    +MODULE_PARM_DESC(connect_retries,
    + "Maximum number of connect retries (one second each)");

    module_param(initial_wait, int, S_IRUGO|S_IWUSR);
    -MODULE_PARM_DESC(initial_wait, "Time to wait before attempting a connection (in seconds)");
    +MODULE_PARM_DESC(initial_wait,
    + "Time to wait before attempting a connection (in seconds)");

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  12. [PATCH 41/70] tty-usb-visor: Coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/visor.c | 340 +++++++++++++++++++++++++-------------------
    1 files changed, 191 insertions(+), 149 deletions(-)


    diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
    index 373a3c7..cf8924f 100644
    --- a/drivers/usb/serial/visor.c
    +++ b/drivers/usb/serial/visor.c
    @@ -9,7 +9,8 @@
    * modify it under the terms of the GNU General Public License version
    * 2 as published by the Free Software Foundation.
    *
    - * See Documentation/usb/usb-serial.txt for more information on using this driver
    + * See Documentation/usb/usb-serial.txt for more information on using this
    + * driver
    *
    */

    @@ -23,7 +24,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include
    #include "visor.h"
    @@ -35,23 +36,29 @@
    #define DRIVER_DESC "USB HandSpring Visor / Palm OS driver"

    /* function prototypes for a handspring visor */
    -static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
    -static void visor_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
    -static int visor_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
    -static int visor_write_room (struct tty_struct *tty);
    -static void visor_throttle (struct tty_struct *tty);
    -static void visor_unthrottle (struct tty_struct *tty);
    -static int visor_probe (struct usb_serial *serial, const struct usb_device_id *id);
    +static int visor_open(struct tty_struct *tty, struct usb_serial_port *port,
    + struct file *filp);
    +static void visor_close(struct tty_struct *tty, struct usb_serial_port *port,
    + struct file *filp);
    +static int visor_write(struct tty_struct *tty, struct usb_serial_port *port,
    + const unsigned char *buf, int count);
    +static int visor_write_room(struct tty_struct *tty);
    +static void visor_throttle(struct tty_struct *tty);
    +static void visor_unthrottle(struct tty_struct *tty);
    +static int visor_probe(struct usb_serial *serial,
    + const struct usb_device_id *id);
    static int visor_calc_num_ports(struct usb_serial *serial);
    -static void visor_shutdown (struct usb_serial *serial);
    -static void visor_write_bulk_callback (struct urb *urb);
    -static void visor_read_bulk_callback (struct urb *urb);
    -static void visor_read_int_callback (struct urb *urb);
    -static int clie_3_5_startup (struct usb_serial *serial);
    -static int treo_attach (struct usb_serial *serial);
    -static int clie_5_attach (struct usb_serial *serial);
    -static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id);
    -static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_id *id);
    +static void visor_shutdown(struct usb_serial *serial);
    +static void visor_write_bulk_callback(struct urb *urb);
    +static void visor_read_bulk_callback(struct urb *urb);
    +static void visor_read_int_callback(struct urb *urb);
    +static int clie_3_5_startup(struct usb_serial *serial);
    +static int treo_attach(struct usb_serial *serial);
    +static int clie_5_attach(struct usb_serial *serial);
    +static int palm_os_3_probe(struct usb_serial *serial,
    + const struct usb_device_id *id);
    +static int palm_os_4_probe(struct usb_serial *serial,
    + const struct usb_device_id *id);

    /* Parameters that may be passed into the module. */
    static int debug;
    @@ -103,13 +110,13 @@ static struct usb_device_id id_table [] = {
    .driver_info = (kernel_ulong_t)&palm_os_4_probe },
    { USB_DEVICE(ACER_VENDOR_ID, ACER_S10_ID),
    .driver_info = (kernel_ulong_t)&palm_os_4_probe },
    - { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID),
    + { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID),
    .driver_info = (kernel_ulong_t)&palm_os_4_probe },
    - { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID),
    + { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID),
    .driver_info = (kernel_ulong_t)&palm_os_4_probe },
    { USB_DEVICE(TAPWAVE_VENDOR_ID, TAPWAVE_ZODIAC_ID),
    .driver_info = (kernel_ulong_t)&palm_os_4_probe },
    - { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID),
    + { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID),
    .driver_info = (kernel_ulong_t)&palm_os_4_probe },
    { USB_DEVICE(ACEECA_VENDOR_ID, ACEECA_MEZ1000_ID),
    .driver_info = (kernel_ulong_t)&palm_os_4_probe },
    @@ -168,7 +175,7 @@ static struct usb_device_id id_table_combined [] = {
    { } /* Terminating entry */
    };

    -MODULE_DEVICE_TABLE (usb, id_table_combined);
    +MODULE_DEVICE_TABLE(usb, id_table_combined);

    static struct usb_driver visor_driver = {
    .name = "visor",
    @@ -178,7 +185,8 @@ static struct usb_driver visor_driver = {
    .no_dynamic_id = 1,
    };

    -/* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */
    +/* All of the device info needed for the Handspring Visor,
    + and Palm 4.0 devices */
    static struct usb_serial_driver handspring_device = {
    .driver = {
    .owner = THIS_MODULE,
    @@ -266,7 +274,8 @@ static int stats;
    /************************************************** ****************************
    * Handspring Visor specific driver functions
    ************************************************** ****************************/
    -static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp)
    +static int visor_open(struct tty_struct *tty, struct usb_serial_port *port,
    + struct file *filp)
    {
    struct usb_serial *serial = port->serial;
    struct visor_private *priv = usb_get_serial_port_data(port);
    @@ -296,39 +305,41 @@ static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, str
    tty->low_latency = 1;

    /* Start reading from the device */
    - usb_fill_bulk_urb (port->read_urb, serial->dev,
    - usb_rcvbulkpipe (serial->dev,
    + usb_fill_bulk_urb(port->read_urb, serial->dev,
    + usb_rcvbulkpipe(serial->dev,
    port->bulk_in_endpointAddress),
    port->read_urb->transfer_buffer,
    port->read_urb->transfer_buffer_length,
    visor_read_bulk_callback, port);
    result = usb_submit_urb(port->read_urb, GFP_KERNEL);
    if (result) {
    - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n",
    - __func__, result);
    + dev_err(&port->dev,
    + "%s - failed submitting read urb, error %d\n",
    + __func__, result);
    goto exit;
    }
    -
    +
    if (port->interrupt_in_urb) {
    dbg("%s - adding interrupt input for treo", __func__);
    result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
    if (result)
    - dev_err(&port->dev, "%s - failed submitting interrupt urb, error %d\n",
    - __func__, result);
    + dev_err(&port->dev,
    + "%s - failed submitting interrupt urb, error %d\n",
    + __func__, result);
    }
    -exit:
    +exit:
    return result;
    }


    static void visor_close(struct tty_struct *tty,
    - struct usb_serial_port *port, struct file * filp)
    + struct usb_serial_port *port, struct file *filp)
    {
    struct visor_private *priv = usb_get_serial_port_data(port);
    unsigned char *transfer_buffer;

    dbg("%s - port %d", __func__, port->number);
    -
    +
    /* shutdown our urbs */
    usb_kill_urb(port->read_urb);
    usb_kill_urb(port->interrupt_in_urb);
    @@ -336,14 +347,14 @@ static void visor_close(struct tty_struct *tty,
    mutex_lock(&port->serial->disc_mutex);
    if (!port->serial->disconnected) {
    /* Try to send shutdown message, unless the device is gone */
    - transfer_buffer = kmalloc (0x12, GFP_KERNEL);
    + transfer_buffer = kmalloc(0x12, GFP_KERNEL);
    if (transfer_buffer) {
    - usb_control_msg (port->serial->dev,
    + usb_control_msg(port->serial->dev,
    usb_rcvctrlpipe(port->serial->dev, 0),
    VISOR_CLOSE_NOTIFICATION, 0xc2,
    0x0000, 0x0000,
    transfer_buffer, 0x12, 300);
    - kfree (transfer_buffer);
    + kfree(transfer_buffer);
    }
    }
    mutex_unlock(&port->serial->disc_mutex);
    @@ -375,7 +386,7 @@ static int visor_write(struct tty_struct *tty, struct usb_serial_port *port,
    priv->outstanding_urbs++;
    spin_unlock_irqrestore(&priv->lock, flags);

    - buffer = kmalloc (count, GFP_ATOMIC);
    + buffer = kmalloc(count, GFP_ATOMIC);
    if (!buffer) {
    dev_err(&port->dev, "out of memory\n");
    count = -ENOMEM;
    @@ -389,21 +400,22 @@ static int visor_write(struct tty_struct *tty, struct usb_serial_port *port,
    goto error_no_urb;
    }

    - memcpy (buffer, buf, count);
    + memcpy(buffer, buf, count);

    usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);

    - usb_fill_bulk_urb (urb, serial->dev,
    - usb_sndbulkpipe (serial->dev,
    + usb_fill_bulk_urb(urb, serial->dev,
    + usb_sndbulkpipe(serial->dev,
    port->bulk_out_endpointAddress),
    - buffer, count,
    + buffer, count,
    visor_write_bulk_callback, port);

    /* send it down the pipe */
    status = usb_submit_urb(urb, GFP_ATOMIC);
    if (status) {
    - dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n",
    - __func__, status);
    + dev_err(&port->dev,
    + "%s - usb_submit_urb(write bulk) failed with status = %d\n",
    + __func__, status);
    count = status;
    goto error;
    } else {
    @@ -429,7 +441,7 @@ error_no_buffer:
    }


    -static int visor_write_room (struct tty_struct *tty)
    +static int visor_write_room(struct tty_struct *tty)
    {
    struct usb_serial_port *port = tty->driver_data;
    struct visor_private *priv = usb_get_serial_port_data(port);
    @@ -455,7 +467,7 @@ static int visor_write_room (struct tty_struct *tty)
    }


    -static void visor_write_bulk_callback (struct urb *urb)
    +static void visor_write_bulk_callback(struct urb *urb)
    {
    struct usb_serial_port *port = urb->context;
    struct visor_private *priv = usb_get_serial_port_data(port);
    @@ -463,7 +475,7 @@ static void visor_write_bulk_callback (struct urb *urb)
    unsigned long flags;

    /* free up the transfer buffer, as usb_free_urb() does not do this */
    - kfree (urb->transfer_buffer);
    + kfree(urb->transfer_buffer);

    dbg("%s - port %d", __func__, port->number);

    @@ -479,7 +491,7 @@ static void visor_write_bulk_callback (struct urb *urb)
    }


    -static void visor_read_bulk_callback (struct urb *urb)
    +static void visor_read_bulk_callback(struct urb *urb)
    {
    struct usb_serial_port *port = urb->context;
    struct visor_private *priv = usb_get_serial_port_data(port);
    @@ -497,11 +509,13 @@ static void visor_read_bulk_callback (struct urb *urb)
    return;
    }

    - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
    + usb_serial_debug_data(debug, &port->dev, __func__,
    + urb->actual_length, data);

    tty = port->port.tty;
    if (tty && urb->actual_length) {
    - available_room = tty_buffer_request_room(tty, urb->actual_length);
    + available_room = tty_buffer_request_room(tty,
    + urb->actual_length);
    if (available_room) {
    tty_insert_flip_string(tty, data, available_room);
    tty_flip_buffer_push(tty);
    @@ -515,22 +529,23 @@ static void visor_read_bulk_callback (struct urb *urb)

    /* Continue trying to always read if we should */
    if (!priv->throttled) {
    - usb_fill_bulk_urb (port->read_urb, port->serial->dev,
    + usb_fill_bulk_urb(port->read_urb, port->serial->dev,
    usb_rcvbulkpipe(port->serial->dev,
    - port->bulk_in_endpointAddress),
    + port->bulk_in_endpointAddress),
    port->read_urb->transfer_buffer,
    port->read_urb->transfer_buffer_length,
    visor_read_bulk_callback, port);
    result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
    if (result)
    - dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
    - } else {
    + dev_err(&port->dev,
    + "%s - failed resubmitting read urb, error %d\n",
    + __func__, result);
    + } else
    priv->actually_throttled = 1;
    - }
    spin_unlock(&priv->lock);
    }

    -static void visor_read_int_callback (struct urb *urb)
    +static void visor_read_int_callback(struct urb *urb)
    {
    struct usb_serial_port *port = urb->context;
    int status = urb->status;
    @@ -564,13 +579,14 @@ static void visor_read_int_callback (struct urb *urb)
    urb->actual_length, urb->transfer_buffer);

    exit:
    - result = usb_submit_urb (urb, GFP_ATOMIC);
    + result = usb_submit_urb(urb, GFP_ATOMIC);
    if (result)
    - dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n",
    - __func__, result);
    + dev_err(&urb->dev->dev,
    + "%s - Error %d submitting interrupt urb\n",
    + __func__, result);
    }

    -static void visor_throttle (struct tty_struct *tty)
    +static void visor_throttle(struct tty_struct *tty)
    {
    struct usb_serial_port *port = tty->driver_data;
    struct visor_private *priv = usb_get_serial_port_data(port);
    @@ -583,7 +599,7 @@ static void visor_throttle (struct tty_struct *tty)
    }


    -static void visor_unthrottle (struct tty_struct *tty)
    +static void visor_unthrottle(struct tty_struct *tty)
    {
    struct usb_serial_port *port = tty->driver_data;
    struct visor_private *priv = usb_get_serial_port_data(port);
    @@ -599,10 +615,13 @@ static void visor_unthrottle (struct tty_struct *tty)
    port->read_urb->dev = port->serial->dev;
    result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
    if (result)
    - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result);
    + dev_err(&port->dev,
    + "%s - failed submitting read urb, error %d\n",
    + __func__, result);
    }

    -static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id)
    +static int palm_os_3_probe(struct usb_serial *serial,
    + const struct usb_device_id *id)
    {
    struct device *dev = &serial->dev->dev;
    struct visor_connection_info *connection_info;
    @@ -614,7 +633,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i

    dbg("%s", __func__);

    - transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL);
    + transfer_buffer = kmalloc(sizeof(*connection_info), GFP_KERNEL);
    if (!transfer_buffer) {
    dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __func__,
    sizeof(*connection_info));
    @@ -622,7 +641,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
    }

    /* send a get connection info request */
    - retval = usb_control_msg (serial->dev,
    + retval = usb_control_msg(serial->dev,
    usb_rcvctrlpipe(serial->dev, 0),
    VISOR_GET_CONNECTION_INFORMATION,
    0xc2, 0x0000, 0x0000, transfer_buffer,
    @@ -634,29 +653,31 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
    }

    if (retval == sizeof(*connection_info)) {
    - connection_info = (struct visor_connection_info *)transfer_buffer;
    + connection_info = (struct visor_connection_info *)
    + transfer_buffer;

    num_ports = le16_to_cpu(connection_info->num_ports);
    for (i = 0; i < num_ports; ++i) {
    - switch (connection_info->connections[i].port_function_id) {
    - case VISOR_FUNCTION_GENERIC:
    - string = "Generic";
    - break;
    - case VISOR_FUNCTION_DEBUGGER:
    - string = "Debugger";
    - break;
    - case VISOR_FUNCTION_HOTSYNC:
    - string = "HotSync";
    - break;
    - case VISOR_FUNCTION_CONSOLE:
    - string = "Console";
    - break;
    - case VISOR_FUNCTION_REMOTE_FILE_SYS:
    - string = "Remote File System";
    - break;
    - default:
    - string = "unknown";
    - break;
    + switch (
    + connection_info->connections[i].port_function_id) {
    + case VISOR_FUNCTION_GENERIC:
    + string = "Generic";
    + break;
    + case VISOR_FUNCTION_DEBUGGER:
    + string = "Debugger";
    + break;
    + case VISOR_FUNCTION_HOTSYNC:
    + string = "HotSync";
    + break;
    + case VISOR_FUNCTION_CONSOLE:
    + string = "Console";
    + break;
    + case VISOR_FUNCTION_REMOTE_FILE_SYS:
    + string = "Remote File System";
    + break;
    + default:
    + string = "unknown";
    + break;
    }
    dev_info(dev, "%s: port %d, is for %s use\n",
    serial->type->description,
    @@ -667,11 +688,11 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
    * Handle devices that report invalid stuff here.
    */
    if (num_ports == 0 || num_ports > 2) {
    - dev_warn (dev, "%s: No valid connect info available\n",
    + dev_warn(dev, "%s: No valid connect info available\n",
    serial->type->description);
    num_ports = 2;
    }
    -
    +
    dev_info(dev, "%s: Number of ports: %d\n", serial->type->description,
    num_ports);

    @@ -681,8 +702,9 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
    */
    usb_set_serial_data(serial, (void *)(long)num_ports);

    - /* ask for the number of bytes available, but ignore the response as it is broken */
    - retval = usb_control_msg (serial->dev,
    + /* ask for the number of bytes available, but ignore the
    + response as it is broken */
    + retval = usb_control_msg(serial->dev,
    usb_rcvctrlpipe(serial->dev, 0),
    VISOR_REQUEST_BYTES_AVAILABLE,
    0xc2, 0x0000, 0x0005, transfer_buffer,
    @@ -693,12 +715,13 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
    retval = 0;

    exit:
    - kfree (transfer_buffer);
    + kfree(transfer_buffer);

    return retval;
    }

    -static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_id *id)
    +static int palm_os_4_probe(struct usb_serial *serial,
    + const struct usb_device_id *id)
    {
    struct device *dev = &serial->dev->dev;
    struct palm_ext_connection_info *connection_info;
    @@ -707,18 +730,18 @@ static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_i

    dbg("%s", __func__);

    - transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL);
    + transfer_buffer = kmalloc(sizeof(*connection_info), GFP_KERNEL);
    if (!transfer_buffer) {
    dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __func__,
    sizeof(*connection_info));
    return -ENOMEM;
    }

    - retval = usb_control_msg (serial->dev,
    - usb_rcvctrlpipe(serial->dev, 0),
    + retval = usb_control_msg(serial->dev,
    + usb_rcvctrlpipe(serial->dev, 0),
    PALM_GET_EXT_CONNECTION_INFORMATION,
    0xc2, 0x0000, 0x0000, transfer_buffer,
    - sizeof (*connection_info), 300);
    + sizeof(*connection_info), 300);
    if (retval < 0)
    dev_err(dev, "%s - error %d getting connection info\n",
    __func__, retval);
    @@ -726,15 +749,17 @@ static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_i
    usb_serial_debug_data(debug, &serial->dev->dev, __func__,
    retval, transfer_buffer);

    - kfree (transfer_buffer);
    + kfree(transfer_buffer);
    return 0;
    }


    -static int visor_probe (struct usb_serial *serial, const struct usb_device_id *id)
    +static int visor_probe(struct usb_serial *serial,
    + const struct usb_device_id *id)
    {
    int retval = 0;
    - int (*startup) (struct usb_serial *serial, const struct usb_device_id *id);
    + int (*startup)(struct usb_serial *serial,
    + const struct usb_device_id *id);

    dbg("%s", __func__);

    @@ -752,7 +777,7 @@ static int visor_probe (struct usb_serial *serial, const struct usb_device_id *i
    return retval;
    }

    -static int visor_calc_num_ports (struct usb_serial *serial)
    +static int visor_calc_num_ports(struct usb_serial *serial)
    {
    int num_ports = (int)(long)(usb_get_serial_data(serial));

    @@ -769,7 +794,7 @@ static int generic_startup(struct usb_serial *serial)
    int i;

    for (i = 0; i < serial->num_ports; ++i) {
    - priv = kzalloc (sizeof(*priv), GFP_KERNEL);
    + priv = kzalloc(sizeof(*priv), GFP_KERNEL);
    if (!priv) {
    while (i-- != 0) {
    priv = usb_get_serial_port_data(ports[i]);
    @@ -784,7 +809,7 @@ static int generic_startup(struct usb_serial *serial)
    return 0;
    }

    -static int clie_3_5_startup (struct usb_serial *serial)
    +static int clie_3_5_startup(struct usb_serial *serial)
    {
    struct device *dev = &serial->dev->dev;
    int result;
    @@ -797,62 +822,72 @@ static int clie_3_5_startup (struct usb_serial *serial)
    */

    /* get the config number */
    - result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0),
    + result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
    USB_REQ_GET_CONFIGURATION, USB_DIR_IN,
    0, 0, &data, 1, 3000);
    if (result < 0) {
    - dev_err(dev, "%s: get config number failed: %d\n", __func__, result);
    + dev_err(dev, "%s: get config number failed: %d\n",
    + __func__, result);
    return result;
    }
    if (result != 1) {
    - dev_err(dev, "%s: get config number bad return length: %d\n", __func__, result);
    + dev_err(dev, "%s: get config number bad return length: %d\n",
    + __func__, result);
    return -EIO;
    }

    /* get the interface number */
    - result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0),
    - USB_REQ_GET_INTERFACE,
    + result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
    + USB_REQ_GET_INTERFACE,
    USB_DIR_IN | USB_RECIP_INTERFACE,
    0, 0, &data, 1, 3000);
    if (result < 0) {
    - dev_err(dev, "%s: get interface number failed: %d\n", __func__, result);
    + dev_err(dev, "%s: get interface number failed: %d\n",
    + __func__, result);
    return result;
    }
    if (result != 1) {
    - dev_err(dev, "%s: get interface number bad return length: %d\n", __func__, result);
    + dev_err(dev,
    + "%s: get interface number bad return length: %d\n",
    + __func__, result);
    return -EIO;
    }

    return generic_startup(serial);
    }
    -
    -static int treo_attach (struct usb_serial *serial)
    +
    +static int treo_attach(struct usb_serial *serial)
    {
    struct usb_serial_port *swap_port;

    /* Only do this endpoint hack for the Handspring devices with
    * interrupt in endpoints, which for now are the Treo devices. */
    - if (!((le16_to_cpu(serial->dev->descriptor.idVendor) == HANDSPRING_VENDOR_ID) ||
    - (le16_to_cpu(serial->dev->descriptor.idVendor) == KYOCERA_VENDOR_ID)) ||
    - (serial->num_interrupt_in == 0))
    + if (!((le16_to_cpu(serial->dev->descriptor.idVendor)
    + == HANDSPRING_VENDOR_ID) ||
    + (le16_to_cpu(serial->dev->descriptor.idVendor)
    + == KYOCERA_VENDOR_ID)) ||
    + (serial->num_interrupt_in == 0))
    goto generic_startup;

    dbg("%s", __func__);

    /*
    - * It appears that Treos and Kyoceras want to use the
    - * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint,
    - * so let's swap the 1st and 2nd bulk in and interrupt endpoints.
    - * Note that swapping the bulk out endpoints would break lots of
    + * It appears that Treos and Kyoceras want to use the
    + * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint,
    + * so let's swap the 1st and 2nd bulk in and interrupt endpoints.
    + * Note that swapping the bulk out endpoints would break lots of
    * apps that want to communicate on the second port.
    */
    #define COPY_PORT(dest, src) \
    - dest->read_urb = src->read_urb; \
    - dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress; \
    - dest->bulk_in_buffer = src->bulk_in_buffer; \
    - dest->interrupt_in_urb = src->interrupt_in_urb; \
    - dest->interrupt_in_endpointAddress = src->interrupt_in_endpointAddress; \
    - dest->interrupt_in_buffer = src->interrupt_in_buffer;
    + do { \
    + dest->read_urb = src->read_urb; \
    + dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress;\
    + dest->bulk_in_buffer = src->bulk_in_buffer; \
    + dest->interrupt_in_urb = src->interrupt_in_urb; \
    + dest->interrupt_in_endpointAddress = \
    + src->interrupt_in_endpointAddress;\
    + dest->interrupt_in_buffer = src->interrupt_in_buffer; \
    + } while (0);

    swap_port = kmalloc(sizeof(*swap_port), GFP_KERNEL);
    if (!swap_port)
    @@ -866,28 +901,30 @@ generic_startup:
    return generic_startup(serial);
    }

    -static int clie_5_attach (struct usb_serial *serial)
    +static int clie_5_attach(struct usb_serial *serial)
    {
    dbg("%s", __func__);

    - /* TH55 registers 2 ports.
    - Communication in from the UX50/TH55 uses bulk_in_endpointAddress from port 0
    - Communication out to the UX50/TH55 uses bulk_out_endpointAddress from port 1
    -
    + /* TH55 registers 2 ports.
    + Communication in from the UX50/TH55 uses bulk_in_endpointAddress
    + from port 0. Communication out to the UX50/TH55 uses
    + bulk_out_endpointAddress from port 1
    +
    Lets do a quick and dirty mapping
    */
    -
    +
    /* some sanity check */
    if (serial->num_ports < 2)
    return -1;
    -
    +
    /* port 0 now uses the modified endpoint Address */
    - serial->port[0]->bulk_out_endpointAddress = serial->port[1]->bulk_out_endpointAddress;
    + serial->port[0]->bulk_out_endpointAddress =
    + serial->port[1]->bulk_out_endpointAddress;

    return generic_startup(serial);
    }

    -static void visor_shutdown (struct usb_serial *serial)
    +static void visor_shutdown(struct usb_serial *serial)
    {
    struct visor_private *priv;
    int i;
    @@ -903,30 +940,35 @@ static void visor_shutdown (struct usb_serial *serial)
    }
    }

    -static int __init visor_init (void)
    +static int __init visor_init(void)
    {
    int i, retval;
    /* Only if parameters were passed to us */
    - if ((vendor>0) && (product>0)) {
    - struct usb_device_id usb_dev_temp[]=
    - {{USB_DEVICE(vendor, product),
    - .driver_info = (kernel_ulong_t)&palm_os_4_probe }};
    + if (vendor > 0 && product > 0) {
    + struct usb_device_id usb_dev_temp[] = {
    + {
    + USB_DEVICE(vendor, product),
    + .driver_info =
    + (kernel_ulong_t) &palm_os_4_probe
    + }
    + };

    /* Find the last entry in id_table */
    - for (i=0; ; i++) {
    - if (id_table[i].idVendor==0) {
    + for (i = 0;; i++) {
    + if (id_table[i].idVendor == 0) {
    id_table[i] = usb_dev_temp[0];
    break;
    }
    }
    /* Find the last entry in id_table_combined */
    - for (i=0; ; i++) {
    - if (id_table_combined[i].idVendor==0) {
    + for (i = 0;; i++) {
    + if (id_table_combined[i].idVendor == 0) {
    id_table_combined[i] = usb_dev_temp[0];
    break;
    }
    }
    - info("Untested USB device specified at time of module insertion");
    + info(
    + "Untested USB device specified at time of module insertion");
    info("Warning: This is not guaranteed to work");
    info("Using a newer kernel is preferred to this method");
    info("Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x",
    @@ -942,7 +984,7 @@ static int __init visor_init (void)
    if (retval)
    goto failed_clie_5_register;
    retval = usb_register(&visor_driver);
    - if (retval)
    + if (retval)
    goto failed_usb_register;
    info(DRIVER_DESC);

    @@ -960,18 +1002,18 @@ failed_handspring_register:

    static void __exit visor_exit (void)
    {
    - usb_deregister (&visor_driver);
    - usb_serial_deregister (&handspring_device);
    - usb_serial_deregister (&clie_3_5_device);
    - usb_serial_deregister (&clie_5_device);
    + usb_deregister(&visor_driver);
    + usb_serial_deregister(&handspring_device);
    + usb_serial_deregister(&clie_3_5_device);
    + usb_serial_deregister(&clie_5_device);
    }


    module_init(visor_init);
    module_exit(visor_exit);

    -MODULE_AUTHOR( DRIVER_AUTHOR );
    -MODULE_DESCRIPTION( DRIVER_DESC );
    +MODULE_AUTHOR(DRIVER_AUTHOR);
    +MODULE_DESCRIPTION(DRIVER_DESC);
    MODULE_LICENSE("GPL");

    module_param(debug, bool, S_IRUGO | S_IWUSR);

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  13. [PATCH 53/70] tty-usb-kl5kusb105: Coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/kl5kusb105.c | 389 +++++++++++++++++++--------------------
    1 files changed, 188 insertions(+), 201 deletions(-)


    diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
    index 4c27ccc..d898dc4 100644
    --- a/drivers/usb/serial/kl5kusb105.c
    +++ b/drivers/usb/serial/kl5kusb105.c
    @@ -15,12 +15,12 @@
    * Neither Palm, nor their contractor (MCCI) or their supplier (KLSI) provided
    * information that was not already available.
    *
    - * It seems that KLSI bought some silicon-design information from ScanLogic,
    + * It seems that KLSI bought some silicon-design information from ScanLogic,
    * whose SL11R processor is at the core of the KL5KUSB chipset from KLSI.
    * KLSI has firmware available for their devices; it is probable that the
    * firmware differs from that used by KLSI in their products. If you have an
    - * original KLSI device and can provide some information on it, I would be
    - * most interested in adding support for it here. If you have any information
    + * original KLSI device and can provide some information on it, I would be
    + * most interested in adding support for it here. If you have any information
    * on the protocol used (or find errors in my reverse-engineered stuff), please
    * let me know.
    *
    @@ -40,7 +40,7 @@
    * 0.2 - TIOCMGET works, so autopilot(1) can be used!
    * 0.1 - can be used to to pilot-xfer -p /dev/ttyUSB0 -l
    *
    - * The driver skeleton is mainly based on mct_u232.c and various other
    + * The driver skeleton is mainly based on mct_u232.c and various other
    * pieces of code shamelessly copied from the drivers/usb/serial/ directory.
    */

    @@ -53,7 +53,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include
    #include
    @@ -72,37 +72,25 @@ static int debug;
    /*
    * Function prototypes
    */
    -static int klsi_105_startup (struct usb_serial *serial);
    -static void klsi_105_shutdown (struct usb_serial *serial);
    -static int klsi_105_open (struct tty_struct *tty,
    - struct usb_serial_port *port,
    - struct file *filp);
    -static void klsi_105_close (struct tty_struct *tty,
    - struct usb_serial_port *port,
    - struct file *filp);
    -static int klsi_105_write (struct tty_struct *tty,
    - struct usb_serial_port *port,
    - const unsigned char *buf,
    - int count);
    -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_write_room (struct tty_struct *tty);
    -
    -static void klsi_105_read_bulk_callback (struct urb *urb);
    -static void klsi_105_set_termios (struct tty_struct *tty,
    - struct usb_serial_port *port,
    - struct ktermios *old);
    -static void klsi_105_throttle (struct tty_struct *tty);
    -static void klsi_105_unthrottle (struct tty_struct *tty);
    -/*
    -static void klsi_105_break_ctl (struct tty_struct *tty,
    - int break_state );
    - */
    -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);
    +static int klsi_105_startup(struct usb_serial *serial);
    +static void klsi_105_shutdown(struct usb_serial *serial);
    +static int klsi_105_open(struct tty_struct *tty,
    + struct usb_serial_port *port, struct file *filp);
    +static void klsi_105_close(struct tty_struct *tty,
    + struct usb_serial_port *port, struct file *filp);
    +static int klsi_105_write(struct tty_struct *tty,
    + struct usb_serial_port *port, const unsigned char *buf, int count);
    +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_write_room(struct tty_struct *tty);
    +static void klsi_105_read_bulk_callback(struct urb *urb);
    +static void klsi_105_set_termios(struct tty_struct *tty,
    + struct usb_serial_port *port, struct ktermios *old);
    +static void klsi_105_throttle(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 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.
    @@ -113,7 +101,7 @@ static struct usb_device_id id_table [] = {
    { } /* Terminating entry */
    };

    -MODULE_DEVICE_TABLE (usb, id_table);
    +MODULE_DEVICE_TABLE(usb, id_table);

    static struct usb_driver kl5kusb105d_driver = {
    .name = "kl5kusb105d",
    @@ -138,7 +126,7 @@ static struct usb_serial_driver kl5kusb105d_device = {
    .write_bulk_callback = klsi_105_write_bulk_callback,
    .chars_in_buffer = klsi_105_chars_in_buffer,
    .write_room = klsi_105_write_room,
    - .read_bulk_callback =klsi_105_read_bulk_callback,
    + .read_bulk_callback = klsi_105_read_bulk_callback,
    .set_termios = klsi_105_set_termios,
    /*.break_ctl = klsi_105_break_ctl,*/
    .tiocmget = klsi_105_tiocmget,
    @@ -165,7 +153,7 @@ struct klsi_105_private {
    struct ktermios termios;
    unsigned long line_state; /* modem line settings */
    /* write pool */
    - struct urb * write_urb_pool[NUM_URBS];
    + struct urb *write_urb_pool[NUM_URBS];
    spinlock_t lock;
    unsigned long bytes_in;
    unsigned long bytes_out;
    @@ -184,15 +172,15 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port,
    {
    int rc;

    - rc = usb_control_msg(port->serial->dev,
    - usb_sndctrlpipe(port->serial->dev, 0),
    - KL5KUSB105A_SIO_SET_DATA,
    - USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_INTERFACE,
    - 0, /* value */
    - 0, /* index */
    - settings,
    - sizeof(struct klsi_105_port_settings),
    - KLSI_TIMEOUT);
    + rc = usb_control_msg(port->serial->dev,
    + usb_sndctrlpipe(port->serial->dev, 0),
    + KL5KUSB105A_SIO_SET_DATA,
    + USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_INTERFACE,
    + 0, /* value */
    + 0, /* index */
    + settings,
    + sizeof(struct klsi_105_port_settings),
    + KLSI_TIMEOUT);
    if (rc < 0)
    err("Change port settings failed (error = %d)", rc);
    info("%s - %d byte block, baudrate %x, databits %d, u1 %d, u2 %d",
    @@ -200,7 +188,7 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port,
    settings->pktlen,
    settings->baudrate, settings->databits,
    settings->unknown1, settings->unknown2);
    - return rc;
    + return rc;
    } /* klsi_105_chg_port_settings */

    /* translate a 16-bit status value from the device to linux's TIO bits */
    @@ -214,9 +202,9 @@ static unsigned long klsi_105_status2linestate(const __u16 status)

    return res;
    }
    -/*
    +/*
    * Read line control via vendor command and return result through
    - * *line_state_p
    + * *line_state_p
    */
    /* It seems that the status buffer has always only 2 bytes length */
    #define KLSI_STATUSBUF_LEN 2
    @@ -224,14 +212,14 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
    unsigned long *line_state_p)
    {
    int rc;
    - __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1,-1};
    + __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1, -1};
    __u16 status;

    info("%s - sending SIO Poll request", __func__);
    - rc = usb_control_msg(port->serial->dev,
    + rc = usb_control_msg(port->serial->dev,
    usb_rcvctrlpipe(port->serial->dev, 0),
    KL5KUSB105A_SIO_POLL,
    - USB_TYPE_VENDOR | USB_DIR_IN,
    + USB_TYPE_VENDOR | USB_DIR_IN,
    0, /* value */
    0, /* index */
    status_buf, KLSI_STATUSBUF_LEN,
    @@ -247,8 +235,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,

    *line_state_p = klsi_105_status2linestate(status);
    }
    -
    - return rc;
    + return rc;
    }


    @@ -256,7 +243,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
    * Driver's tty interface functions
    */

    -static int klsi_105_startup (struct usb_serial *serial)
    +static int klsi_105_startup(struct usb_serial *serial)
    {
    struct klsi_105_private *priv;
    int i, j;
    @@ -266,7 +253,7 @@ static int klsi_105_startup (struct usb_serial *serial)
    */

    /* allocate the private data structure */
    - for (i=0; inum_ports; i++) {
    + for (i = 0; i < serial->num_ports; i++) {
    priv = kmalloc(sizeof(struct klsi_105_private),
    GFP_KERNEL);
    if (!priv) {
    @@ -287,9 +274,9 @@ static int klsi_105_startup (struct usb_serial *serial)
    priv->bytes_out = 0;
    usb_set_serial_port_data(serial->port[i], priv);

    - spin_lock_init (&priv->lock);
    - for (j=0; j - struct urb* urb = usb_alloc_urb(0, GFP_KERNEL);
    + spin_lock_init(&priv->lock);
    + for (j = 0; j < NUM_URBS; j++) {
    + struct urb *urb = usb_alloc_urb(0, GFP_KERNEL);

    priv->write_urb_pool[j] = urb;
    if (urb == NULL) {
    @@ -297,10 +284,11 @@ static int klsi_105_startup (struct usb_serial *serial)
    goto err_cleanup;
    }

    - urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE,
    - GFP_KERNEL);
    + urb->transfer_buffer =
    + kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
    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;
    }
    }
    @@ -308,13 +296,13 @@ static int klsi_105_startup (struct usb_serial *serial)
    /* priv->termios is left uninitalized until port opening */
    init_waitqueue_head(&serial->port[i]->write_wait);
    }
    -
    +
    return 0;

    err_cleanup:
    for (; i >= 0; i--) {
    priv = usb_get_serial_port_data(serial->port[i]);
    - for (j=0; j < NUM_URBS; j++) {
    + for (j = 0; j < NUM_URBS; j++) {
    if (priv->write_urb_pool[j]) {
    kfree(priv->write_urb_pool[j]->transfer_buffer);
    usb_free_urb(priv->write_urb_pool[j]);
    @@ -326,22 +314,23 @@ err_cleanup:
    } /* klsi_105_startup */


    -static void klsi_105_shutdown (struct usb_serial *serial)
    +static void klsi_105_shutdown(struct usb_serial *serial)
    {
    int i;
    -
    +
    dbg("%s", __func__);

    /* stop reads and writes on all ports */
    - for (i=0; i < serial->num_ports; ++i) {
    - struct klsi_105_private *priv = usb_get_serial_port_data(serial->port[i]);
    + for (i = 0; i < serial->num_ports; ++i) {
    + struct klsi_105_private *priv =
    + usb_get_serial_port_data(serial->port[i]);
    unsigned long flags;

    if (priv) {
    /* kill our write urb pool */
    int j;
    struct urb **write_urbs = priv->write_urb_pool;
    - spin_lock_irqsave(&priv->lock,flags);
    + spin_lock_irqsave(&priv->lock, flags);

    for (j = 0; j < NUM_URBS; j++) {
    if (write_urbs[j]) {
    @@ -353,12 +342,10 @@ static void klsi_105_shutdown (struct usb_serial *serial)
    * oopses. */
    /* usb_kill_urb(write_urbs[j]); */
    kfree(write_urbs[j]->transfer_buffer);
    - 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);
    usb_set_serial_port_data(serial->port[i], NULL);
    }
    @@ -384,7 +371,7 @@ static int klsi_105_open(struct tty_struct *tty,

    /* Do a defined restart:
    * Set up sane default baud rate and send the 'READ_ON'
    - * vendor command.
    + * vendor command.
    * FIXME: set modem line control (how?)
    * Then read the modem line control and store values in
    * priv->line_state.
    @@ -395,24 +382,24 @@ static int klsi_105_open(struct tty_struct *tty,
    cfg.unknown1 = 0;
    cfg.unknown2 = 1;
    klsi_105_chg_port_settings(port, &cfg);
    -
    +
    /* set up termios structure */
    - spin_lock_irqsave (&priv->lock, flags);
    + spin_lock_irqsave(&priv->lock, flags);
    priv->termios.c_iflag = tty->termios->c_iflag;
    priv->termios.c_oflag = tty->termios->c_oflag;
    priv->termios.c_cflag = tty->termios->c_cflag;
    priv->termios.c_lflag = tty->termios->c_lflag;
    - for (i=0; i + for (i = 0; i < NCCS; i++)
    priv->termios.c_cc[i] = tty->termios->c_cc[i];
    priv->cfg.pktlen = cfg.pktlen;
    priv->cfg.baudrate = cfg.baudrate;
    priv->cfg.databits = cfg.databits;
    priv->cfg.unknown1 = cfg.unknown1;
    priv->cfg.unknown2 = cfg.unknown2;
    - spin_unlock_irqrestore (&priv->lock, flags);
    + spin_unlock_irqrestore(&priv->lock, flags);

    /* READ_ON and urb submission */
    - usb_fill_bulk_urb(port->read_urb, port->serial->dev,
    + usb_fill_bulk_urb(port->read_urb, port->serial->dev,
    usb_rcvbulkpipe(port->serial->dev,
    port->bulk_in_endpointAddress),
    port->read_urb->transfer_buffer,
    @@ -428,7 +415,7 @@ static int klsi_105_open(struct tty_struct *tty,
    }

    rc = usb_control_msg(port->serial->dev,
    - usb_sndctrlpipe(port->serial->dev,0),
    + usb_sndctrlpipe(port->serial->dev, 0),
    KL5KUSB105A_SIO_CONFIGURE,
    USB_TYPE_VENDOR|USB_DIR_OUT|USB_RECIP_INTERFACE,
    KL5KUSB105A_SIO_CONFIGURE_READ_ON,
    @@ -439,14 +426,14 @@ static int klsi_105_open(struct tty_struct *tty,
    if (rc < 0) {
    err("Enabling read failed (error = %d)", rc);
    retval = rc;
    - } else
    + } else
    dbg("%s - enabled reading", __func__);

    rc = klsi_105_get_line_state(port, &line_state);
    if (rc >= 0) {
    - spin_lock_irqsave (&priv->lock, flags);
    + spin_lock_irqsave(&priv->lock, flags);
    priv->line_state = line_state;
    - spin_unlock_irqrestore (&priv->lock, flags);
    + spin_unlock_irqrestore*&priv->lock, flags);
    dbg("%s - read line state 0x%lx", __func__, line_state);
    retval = 0;
    } else
    @@ -468,14 +455,14 @@ static void klsi_105_close(struct tty_struct *tty,
    mutex_lock(&port->serial->disc_mutex);
    if (!port->serial->disconnected) {
    /* send READ_OFF */
    - rc = usb_control_msg (port->serial->dev,
    - usb_sndctrlpipe(port->serial->dev, 0),
    - KL5KUSB105A_SIO_CONFIGURE,
    - USB_TYPE_VENDOR | USB_DIR_OUT,
    - KL5KUSB105A_SIO_CONFIGURE_READ_OFF,
    - 0, /* index */
    - NULL, 0,
    - KLSI_TIMEOUT);
    + rc = usb_control_msg(port->serial->dev,
    + usb_sndctrlpipe(port->serial->dev, 0),
    + KL5KUSB105A_SIO_CONFIGURE,
    + USB_TYPE_VENDOR | USB_DIR_OUT,
    + KL5KUSB105A_SIO_CONFIGURE_READ_OFF,
    + 0, /* index */
    + NULL, 0,
    + KLSI_TIMEOUT);
    if (rc < 0)
    err("Disabling read failed (error = %d)", rc);
    }
    @@ -488,12 +475,13 @@ static void klsi_105_close(struct tty_struct *tty,
    /* FIXME */
    /* wgg - do I need this? I think so. */
    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 */


    /* We need to write a complete 64-byte data block and encode the
    - * number actually sent in the first double-byte, LSB-order. That
    + * number actually sent in the first double-byte, LSB-order. That
    * leaves at most 62 bytes of payload.
    */
    #define KLSI_105_DATA_OFFSET 2 /* in the bulk urb data block */
    @@ -504,7 +492,7 @@ static int klsi_105_write(struct tty_struct *tty,
    {
    struct klsi_105_private *priv = usb_get_serial_port_data(port);
    int result, size;
    - int bytes_sent=0;
    + int bytes_sent = 0;

    dbg("%s - port %d", __func__, port->number);

    @@ -513,34 +501,37 @@ static int klsi_105_write(struct tty_struct *tty,
    struct urb *urb = NULL;
    unsigned long flags;
    int i;
    - /* since the pool is per-port we might not need the spin lock !? */
    - spin_lock_irqsave (&priv->lock, flags);
    - for (i=0; i + /* since the pool is per-port we might not need
    + the spin lock !? */
    + spin_lock_irqsave(&priv->lock, flags);
    + for (i = 0; i < NUM_URBS; i++) {
    if (priv->write_urb_pool[i]->status != -EINPROGRESS) {
    urb = priv->write_urb_pool[i];
    dbg("%s - using pool URB %d", __func__, i);
    break;
    }
    }
    - spin_unlock_irqrestore (&priv->lock, flags);
    + spin_unlock_irqrestore(&priv->lock, flags);

    - if (urb==NULL) {
    + if (urb == NULL) {
    dbg("%s - no more free urbs", __func__);
    goto exit;
    }

    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) {
    err("%s - no more kernel memory...", __func__);
    goto exit;
    }
    }

    - size = min (count, port->bulk_out_size - KLSI_105_DATA_OFFSET);
    - size = min (size, URB_TRANSFER_BUFFER_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);

    - memcpy (urb->transfer_buffer + KLSI_105_DATA_OFFSET, buf, size);
    + memcpy(urb->transfer_buffer + KLSI_105_DATA_OFFSET, buf, size);

    /* write payload size into transfer buffer */
    ((__u8 *)urb->transfer_buffer)[0] = (__u8) (size & 0xFF);
    @@ -558,7 +549,8 @@ static int klsi_105_write(struct tty_struct *tty,
    /* send the data out the bulk port */
    result = usb_submit_urb(urb, GFP_ATOMIC);
    if (result) {
    - err("%s - failed submitting write urb, error %d", __func__, result);
    + err("%s - failed submitting write urb, error %d",
    + __func__, result);
    goto exit;
    }
    buf += size;
    @@ -567,12 +559,12 @@ static int klsi_105_write(struct tty_struct *tty,
    }
    exit:
    /* lockless, but it's for debug info only... */
    - priv->bytes_out+=bytes_sent;
    + priv->bytes_out += bytes_sent;

    return bytes_sent; /* that's how much we wrote */
    } /* klsi_105_write */

    -static void klsi_105_write_bulk_callback ( struct urb *urb)
    +static void klsi_105_write_bulk_callback(struct urb *urb)
    {
    struct usb_serial_port *port = urb->context;
    int status = urb->status;
    @@ -590,7 +582,7 @@ static void klsi_105_write_bulk_callback ( struct urb *urb)


    /* return number of characters currently in the writing process */
    -static int klsi_105_chars_in_buffer (struct tty_struct *tty)
    +static int klsi_105_chars_in_buffer(struct tty_struct *tty)
    {
    struct usb_serial_port *port = tty->driver_data;
    int chars = 0;
    @@ -598,21 +590,20 @@ static int klsi_105_chars_in_buffer (struct tty_struct *tty)
    unsigned long flags;
    struct klsi_105_private *priv = usb_get_serial_port_data(port);

    - spin_lock_irqsave (&priv->lock, flags);
    + spin_lock_irqsave(&priv->lock, flags);

    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;
    - }
    }

    - spin_unlock_irqrestore (&priv->lock, flags);
    + spin_unlock_irqrestore(&priv->lock, flags);

    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)
    {
    struct usb_serial_port *port = tty->driver_data;
    unsigned long flags;
    @@ -620,22 +611,21 @@ static int klsi_105_write_room (struct tty_struct *tty)
    int room = 0;
    struct klsi_105_private *priv = usb_get_serial_port_data(port);

    - spin_lock_irqsave (&priv->lock, flags);
    + spin_lock_irqsave(&priv->lock, flags);
    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;
    - }
    }

    - spin_unlock_irqrestore (&priv->lock, flags);
    + spin_unlock_irqrestore(&priv->lock, flags);

    dbg("%s - returns %d", __func__, room);
    - return (room);
    + return room;
    }



    -static void klsi_105_read_bulk_callback (struct urb *urb)
    +static void klsi_105_read_bulk_callback(struct urb *urb)
    {
    struct usb_serial_port *port = urb->context;
    struct klsi_105_private *priv = usb_get_serial_port_data(port);
    @@ -674,7 +664,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
    * against re-entry an then mixed-up data because of
    * intermixed tty_flip_buffer_push()s
    * FIXME
    - */
    + */
    usb_serial_debug_data(debug, &port->dev, __func__,
    urb->actual_length, data);

    @@ -694,7 +684,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
    priv->bytes_in += bytes_sent;
    }
    /* Continue trying to always read */
    - usb_fill_bulk_urb(port->read_urb, port->serial->dev,
    + usb_fill_bulk_urb(port->read_urb, port->serial->dev,
    usb_rcvbulkpipe(port->serial->dev,
    port->bulk_in_endpointAddress),
    port->read_urb->transfer_buffer,
    @@ -703,13 +693,14 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
    port);
    rc = usb_submit_urb(port->read_urb, GFP_ATOMIC);
    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 */


    -static void klsi_105_set_termios (struct tty_struct *tty,
    - struct usb_serial_port *port,
    - struct ktermios *old_termios)
    +static void klsi_105_set_termios(struct tty_struct *tty,
    + struct usb_serial_port *port,
    + struct ktermios *old_termios)
    {
    struct klsi_105_private *priv = usb_get_serial_port_data(port);
    unsigned int iflag = tty->termios->c_iflag;
    @@ -719,65 +710,63 @@ static void klsi_105_set_termios (struct tty_struct *tty,
    struct klsi_105_port_settings cfg;
    unsigned long flags;
    speed_t baud;
    -
    +
    /* lock while we are modifying the settings */
    - spin_lock_irqsave (&priv->lock, flags);
    -
    + spin_lock_irqsave(&priv->lock, flags);
    +
    /*
    * Update baud rate
    */
    baud = tty_get_baud_rate(tty);

    - if( (cflag & CBAUD) != (old_cflag & CBAUD) ) {
    - /* reassert DTR and (maybe) RTS on transition from B0 */
    - if( (old_cflag & CBAUD) == B0 ) {
    + if ((cflag & CBAUD) != (old_cflag & CBAUD)) {
    + /* reassert DTR and (maybe) RTS on transition from B0 */
    + if ((old_cflag & CBAUD) == B0) {
    dbg("%s: baud was B0", __func__);
    #if 0
    priv->control_state |= TIOCM_DTR;
    /* don't set RTS if using hardware flow control */
    - if (!(old_cflag & CRTSCTS)) {
    + if (!(old_cflag & CRTSCTS))
    priv->control_state |= TIOCM_RTS;
    - }
    mct_u232_set_modem_ctrl(serial, priv->control_state);
    #endif
    }
    }
    - switch(baud) {
    - case 0: /* handled below */
    - break;
    - case 1200:
    - priv->cfg.baudrate = kl5kusb105a_sio_b1200;
    - break;
    - case 2400:
    - priv->cfg.baudrate = kl5kusb105a_sio_b2400;
    - break;
    - case 4800:
    - priv->cfg.baudrate = kl5kusb105a_sio_b4800;
    - break;
    - case 9600:
    + switch (baud) {
    + case 0: /* handled below */
    + break;
    + case 1200:
    + priv->cfg.baudrate = kl5kusb105a_sio_b1200;
    + break;
    + case 2400:
    + priv->cfg.baudrate = kl5kusb105a_sio_b2400;
    + break;
    + case 4800:
    + priv->cfg.baudrate = kl5kusb105a_sio_b4800;
    + break;
    + case 9600:
    + priv->cfg.baudrate = kl5kusb105a_sio_b9600;
    + break;
    + case 19200:
    + priv->cfg.baudrate = kl5kusb105a_sio_b19200;
    + break;
    + case 38400:
    + priv->cfg.baudrate = kl5kusb105a_sio_b38400;
    + break;
    + case 57600:
    + priv->cfg.baudrate = kl5kusb105a_sio_b57600;
    + break;
    + case 115200:
    + priv->cfg.baudrate = kl5kusb105a_sio_b115200;
    + break;
    + default:
    + dbg("KLSI USB->Serial converter:"
    + " unsupported baudrate request, using default of 9600");
    priv->cfg.baudrate = kl5kusb105a_sio_b9600;
    - break;
    - case 19200:
    - priv->cfg.baudrate = kl5kusb105a_sio_b19200;
    - break;
    - case 38400:
    - priv->cfg.baudrate = kl5kusb105a_sio_b38400;
    - break;
    - case 57600:
    - priv->cfg.baudrate = kl5kusb105a_sio_b57600;
    - break;
    - case 115200:
    - priv->cfg.baudrate = kl5kusb105a_sio_b115200;
    - break;
    - default:
    - dbg("KLSI USB->Serial converter:"
    - " unsupported baudrate request, using default"
    - " of 9600");
    - priv->cfg.baudrate = kl5kusb105a_sio_b9600;
    - baud = 9600;
    - break;
    + baud = 9600;
    + break;
    }
    - if ((cflag & CBAUD) == B0 ) {
    + if ((cflag & CBAUD) == B0) {
    dbg("%s: baud is B0", __func__);
    /* Drop RTS and DTR */
    /* maybe this should be simulated by sending read
    @@ -786,7 +775,7 @@ static void klsi_105_set_termios (struct tty_struct *tty,
    ;
    #if 0
    priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
    - mct_u232_set_modem_ctrl(serial, priv->control_state);
    + mct_u232_set_modem_ctrl(serial, priv->control_state);
    #endif
    }
    tty_encode_baud_rate(tty, baud, baud);
    @@ -796,11 +785,11 @@ static void klsi_105_set_termios (struct tty_struct *tty,
    switch (cflag & CSIZE) {
    case CS5:
    dbg("%s - 5 bits/byte not supported", __func__);
    - spin_unlock_irqrestore (&priv->lock, flags);
    + spin_unlock_irqrestore(&priv->lock, flags);
    return ;
    case CS6:
    dbg("%s - 6 bits/byte not supported", __func__);
    - spin_unlock_irqrestore (&priv->lock, flags);
    + spin_unlock_irqrestore(&priv->lock, flags);
    return ;
    case CS7:
    priv->cfg.databits = kl5kusb105a_dtb_7;
    @@ -819,8 +808,7 @@ static void klsi_105_set_termios (struct tty_struct *tty,
    * Update line control register (LCR)
    */
    if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD))
    - || (cflag & CSTOPB) != (old_cflag & CSTOPB) ) {
    -
    + || (cflag & CSTOPB) != (old_cflag & CSTOPB)) {
    /* Not currently supported */
    tty->termios->c_cflag &= ~(PARENB|PARODD|CSTOPB);
    #if 0
    @@ -841,20 +829,18 @@ static void klsi_105_set_termios (struct tty_struct *tty,
    #endif
    ;
    }
    -
    /*
    * Set flow control: well, I do not really now how to handle DTR/RTS.
    * Just do what we have seen with SniffUSB on Win98.
    */
    - if( (iflag & IXOFF) != (old_iflag & IXOFF)
    + if ((iflag & IXOFF) != (old_iflag & IXOFF)
    || (iflag & IXON) != (old_iflag & IXON)
    - || (cflag & CRTSCTS) != (old_cflag & CRTSCTS) ) {
    -
    + || (cflag & CRTSCTS) != (old_cflag & CRTSCTS)) {
    /* Not currently supported */
    tty->termios->c_cflag &= ~CRTSCTS;
    /* Drop DTR/RTS if no flow control otherwise assert */
    #if 0
    - if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS) )
    + if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS))
    priv->control_state |= TIOCM_DTR | TIOCM_RTS;
    else
    priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
    @@ -862,20 +848,21 @@ static void klsi_105_set_termios (struct tty_struct *tty,
    #endif
    ;
    }
    - memcpy (&cfg, &priv->cfg, sizeof(cfg));
    - spin_unlock_irqrestore (&priv->lock, flags);
    -
    + memcpy(&cfg, &priv->cfg, sizeof(cfg));
    + spin_unlock_irqrestore(&priv->lock, flags);
    +
    /* now commit changes to device */
    klsi_105_chg_port_settings(port, &cfg);
    } /* klsi_105_set_termios */


    #if 0
    -static void mct_u232_break_ctl( struct tty_struct *tty, int break_state )
    +static void mct_u232_break_ctl(struct tty_struct *tty, int break_state)
    {
    struct usb_serial_port *port = tty->driver_data;
    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;

    dbg("%sstate=%d", __func__, break_state);
    @@ -887,7 +874,7 @@ static void mct_u232_break_ctl( struct tty_struct *tty, int break_state )
    } /* mct_u232_break_ctl */
    #endif

    -static int klsi_105_tiocmget (struct tty_struct *tty, struct file *file)
    +static int klsi_105_tiocmget(struct tty_struct *tty, struct file *file)
    {
    struct usb_serial_port *port = tty->driver_data;
    struct klsi_105_private *priv = usb_get_serial_port_data(port);
    @@ -903,18 +890,18 @@ static int klsi_105_tiocmget (struct tty_struct *tty, struct file *file)
    return rc;
    }

    - spin_lock_irqsave (&priv->lock, flags);
    + spin_lock_irqsave(&priv->lock, flags);
    priv->line_state = line_state;
    - spin_unlock_irqrestore (&priv->lock, flags);
    + spin_unlock_irqrestore(&priv->lock, flags);
    dbg("%s - read line state 0x%lx", __func__, line_state);
    return (int)line_state;
    }

    -static int klsi_105_tiocmset (struct tty_struct *tty, struct file *file,
    - unsigned int set, unsigned int clear)
    +static int klsi_105_tiocmset(struct tty_struct *tty, struct file *file,
    + unsigned int set, unsigned int clear)
    {
    int retval = -EINVAL;
    -
    +
    dbg("%s", __func__);

    /* if this ever gets implemented, it should be done something like this:
    @@ -939,14 +926,14 @@ static int klsi_105_tiocmset (struct tty_struct *tty, struct file *file,
    return retval;
    }

    -static void klsi_105_throttle (struct tty_struct *tty)
    +static void klsi_105_throttle(struct tty_struct *tty)
    {
    struct usb_serial_port *port = tty->driver_data;
    dbg("%s - port %d", __func__, port->number);
    usb_kill_urb(port->read_urb);
    }

    -static void klsi_105_unthrottle (struct tty_struct *tty)
    +static void klsi_105_unthrottle(struct tty_struct *tty)
    {
    struct usb_serial_port *port = tty->driver_data;
    int result;
    @@ -962,7 +949,7 @@ static void klsi_105_unthrottle (struct tty_struct *tty)



    -static int __init klsi_105_init (void)
    +static int __init klsi_105_init(void)
    {
    int retval;
    retval = usb_serial_register(&kl5kusb105d_device);
    @@ -981,19 +968,19 @@ failed_usb_serial_register:
    }


    -static void __exit klsi_105_exit (void)
    +static void __exit klsi_105_exit(void)
    {
    - usb_deregister (&kl5kusb105d_driver);
    - usb_serial_deregister (&kl5kusb105d_device);
    + usb_deregister(&kl5kusb105d_driver);
    + usb_serial_deregister(&kl5kusb105d_device);
    }


    -module_init (klsi_105_init);
    -module_exit (klsi_105_exit);
    +module_init(klsi_105_init);
    +module_exit(klsi_105_exit);

    -MODULE_AUTHOR( DRIVER_AUTHOR );
    -MODULE_DESCRIPTION( DRIVER_DESC );
    -MODULE_LICENSE("GPL");
    +MODULE_AUTHOR(DRIVER_AUTHOR);
    +MODULE_DESCRIPTION(DRIVER_DESC);
    +MODULE_LICENSE("GPL");


    module_param(debug, bool, S_IRUGO | S_IWUSR);

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  14. [PATCH 51/70] keyspan: Use string flip functions when possible

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/keyspan.c | 18 ++++++++----------
    1 files changed, 8 insertions(+), 10 deletions(-)


    diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
    index 8c7dc40..a90098a 100644
    --- a/drivers/usb/serial/keyspan.c
    +++ b/drivers/usb/serial/keyspan.c
    @@ -575,7 +575,7 @@ static void usa26_glocont_callback(struct urb *urb)

    static void usa28_indat_callback(struct urb *urb)
    {
    - int i, err;
    + int err;
    struct usb_serial_port *port;
    struct tty_struct *tty;
    unsigned char *data;
    @@ -604,8 +604,7 @@ static void usa28_indat_callback(struct urb *urb)

    tty = port->port.tty;
    if (urb->actual_length) {
    - for (i = 0; i < urb->actual_length ; ++i)
    - tty_insert_flip_char(tty, data[i], 0);
    + tty_insert_flip_string(tty, data, urb->actual_length);
    tty_flip_buffer_push(tty);
    }

    @@ -831,8 +830,8 @@ static void usa49_indat_callback(struct urb *urb)
    /* 0x80 bit is error flag */
    if ((data[0] & 0x80) == 0) {
    /* no error on any byte */
    - for (i = 1; i < urb->actual_length ; ++i)
    - tty_insert_flip_char(tty, data[i], 0);
    + tty_insert_flip_string(tty, data + 1,
    + urb->actual_length - 1);
    } else {
    /* some bytes had errors, every byte has status */
    for (i = 0; i + 1 < urb->actual_length; i += 2) {
    @@ -971,10 +970,9 @@ static void usa90_indat_callback(struct urb *urb)
    /* if current mode is DMA, looks like usa28 format
    otherwise looks like usa26 data format */

    - if (p_priv->baud > 57600) {
    - for (i = 0; i < urb->actual_length ; ++i)
    - tty_insert_flip_char(tty, data[i], 0);
    - } else {
    + if (p_priv->baud > 57600)
    + tty_insert_flip_string(tty, data, urb->actual_length);
    + else {
    /* 0x80 bit is error flag */
    if ((data[0] & 0x80) == 0) {
    /* no errors on individual bytes, only
    @@ -1665,7 +1663,7 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
    dbg("%s - %d.", __func__, baud_rate);

    /* prevent divide by zero... */
    - b16 = baud_rate * 16L
    + b16 = baud_rate * 16L;
    if (b16 == 0)
    return KEYSPAN_INVALID_BAUD_RATE;
    /* Any "standard" rate over 57k6 is marginal on the USA-19

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  15. [PATCH 54/70] keyspan_pda: Use string flip functions

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/keyspan_pda.c | 5 ++---
    1 files changed, 2 insertions(+), 3 deletions(-)


    diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
    index 928f545..b11329e 100644
    --- a/drivers/usb/serial/keyspan_pda.c
    +++ b/drivers/usb/serial/keyspan_pda.c
    @@ -220,7 +220,6 @@ static void keyspan_pda_rx_interrupt(struct urb *urb)
    struct usb_serial_port *port = urb->context;
    struct tty_struct *tty = port->port.tty;
    unsigned char *data = urb->transfer_buffer;
    - int i;
    int retval;
    int status = urb->status;
    struct keyspan_pda_private *priv;
    @@ -248,8 +247,8 @@ static void keyspan_pda_rx_interrupt(struct urb *urb)
    case 0:
    /* rest of message is rx data */
    if (urb->actual_length) {
    - for (i = 1; i < urb->actual_length ; ++i)
    - tty_insert_flip_char(tty, data[i], 0);
    + tty_insert_flip_string(tty, data + 1,
    + urb->actual_length - 1);
    tty_flip_buffer_push(tty);
    }
    break;

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  16. [PATCH 42/70] tty-usb-io_edgeport: Coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/io_edgeport.c | 1965 +++++++++++++++++++++-----------------
    drivers/usb/serial/io_tables.h | 6
    2 files changed, 1107 insertions(+), 864 deletions(-)


    diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
    index 1d8d130..3cb2511 100644
    --- a/drivers/usb/serial/io_edgeport.c
    +++ b/drivers/usb/serial/io_edgeport.c
    @@ -42,7 +42,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include
    #include "io_edgeport.h"
    @@ -59,14 +59,17 @@
    /* First, the latest boot code - for first generation edgeports */
    #define IMAGE_ARRAY_NAME BootCodeImage_GEN1
    #define IMAGE_VERSION_NAME BootCodeImageVersion_GEN1
    -#include "io_fw_boot.h" /* the bootloader firmware to download to a device, if it needs it */
    +#include "io_fw_boot.h" /* the bootloader firmware to download to
    + a device, if it needs it */

    /* for second generation edgeports */
    #define IMAGE_ARRAY_NAME BootCodeImage_GEN2
    #define IMAGE_VERSION_NAME BootCodeImageVersion_GEN2
    -#include "io_fw_boot2.h" /* the bootloader firmware to download to a device, if it needs it */
    +#include "io_fw_boot2.h" /* the bootloader firmware to download to
    + a device, if it needs it */

    -/* Then finally the main run-time operational code - for first generation edgeports */
    +/* Then finally the main run-time operational code - for first generation
    + edgeports */
    #define IMAGE_ARRAY_NAME OperationalCodeImage_GEN1
    #define IMAGE_VERSION_NAME OperationalCodeImageVersion_GEN1
    #include "io_fw_down.h" /* Define array OperationalCodeImage[] */
    @@ -84,16 +87,16 @@

    /* receive port state */
    enum RXSTATE {
    - EXPECT_HDR1 = 0, /* Expect header byte 1 */
    - EXPECT_HDR2 = 1, /* Expect header byte 2 */
    - EXPECT_DATA = 2, /* Expect 'RxBytesRemaining' data */
    - EXPECT_HDR3 = 3, /* Expect header byte 3 (for status hdrs only) */
    + EXPECT_HDR1 = 0, /* Expect header byte 1 */
    + EXPECT_HDR2 = 1, /* Expect header byte 2 */
    + EXPECT_DATA = 2, /* Expect 'RxBytesRemaining' data */
    + EXPECT_HDR3 = 3, /* Expect header byte 3 (for status hdrs only) */
    };


    -/* Transmit Fifo
    - * This Transmit queue is an extension of the edgeport Rx buffer.
    - * The maximum amount of data buffered in both the edgeport
    +/* Transmit Fifo
    + * This Transmit queue is an extension of the edgeport Rx buffer.
    + * The maximum amount of data buffered in both the edgeport
    * Rx buffer (maxTxCredits) and this buffer will never exceed maxTxCredits.
    */
    struct TxFifo {
    @@ -150,12 +153,12 @@ struct edgeport_serial {
    int is_epic; /* flag if EPiC device or not */

    __u8 interrupt_in_endpoint; /* the interrupt endpoint handle */
    - unsigned char * interrupt_in_buffer; /* the buffer we use for the interrupt endpoint */
    - struct urb * interrupt_read_urb; /* our interrupt urb */
    + unsigned char *interrupt_in_buffer; /* the buffer we use for the interrupt endpoint */
    + struct urb *interrupt_read_urb; /* our interrupt urb */

    __u8 bulk_in_endpoint; /* the bulk in endpoint handle */
    - unsigned char * bulk_in_buffer; /* the buffer we use for the bulk in endpoint */
    - struct urb * read_urb; /* our bulk read urb */
    + unsigned char *bulk_in_buffer; /* the buffer we use for the bulk in endpoint */
    + struct urb *read_urb; /* our bulk read urb */
    bool read_in_progress;
    spinlock_t es_lock;

    @@ -180,16 +183,17 @@ struct divisor_table_entry {
    __u16 Divisor;
    };

    -//
    -// Define table of divisors for Rev A EdgePort/4 hardware
    -// These assume a 3.6864MHz crystal, the standard /16, and
    -// MCR.7 = 0.
    -//
    +/*
    + * Define table of divisors for Rev A EdgePort/4 hardware
    + * These assume a 3.6864MHz crystal, the standard /16, and
    + * MCR.7 = 0.
    + */
    +
    static const struct divisor_table_entry divisor_table[] = {
    - { 50, 4608},
    - { 75, 3072},
    - { 110, 2095}, /* 2094.545455 => 230450 => .0217 % over */
    - { 134, 1713}, /* 1713.011152 => 230398.5 => .00065% under */
    + { 50, 4608},
    + { 75, 3072},
    + { 110, 2095}, /* 2094.545455 => 230450 => .0217 % over */
    + { 134, 1713}, /* 1713.011152 => 230398.5 => .00065% under */
    { 150, 1536},
    { 300, 768},
    { 600, 384},
    @@ -212,65 +216,86 @@ static int debug;

    static int low_latency = 1; /* tty low latency flag, on by default */

    -static atomic_t CmdUrbs; /* Number of outstanding Command Write Urbs */
    +static atomic_t CmdUrbs; /* Number of outstanding Command Write Urbs */


    /* local function prototypes */

    /* function prototypes for all URB callbacks */
    -static void edge_interrupt_callback (struct urb *urb);
    -static void edge_bulk_in_callback (struct urb *urb);
    -static void edge_bulk_out_data_callback (struct urb *urb);
    -static void edge_bulk_out_cmd_callback (struct urb *urb);
    +static void edge_interrupt_callback(struct urb *urb);
    +static void edge_bulk_in_callback(struct urb *urb);
    +static void edge_bulk_out_data_callback(struct urb *urb);
    +static void edge_bulk_out_cmd_callback(struct urb *urb);

    /* function prototypes for the usbserial callbacks */
    -static int edge_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
    -static void edge_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
    -static int edge_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
    -static int edge_write_room (struct tty_struct *tty);
    -static int edge_chars_in_buffer (struct tty_struct *tty);
    -static void edge_throttle (struct tty_struct *tty);
    -static void edge_unthrottle (struct tty_struct *tty);
    -static void edge_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios);
    -static int edge_ioctl (struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg);
    -static void edge_break (struct tty_struct *tty, int break_state);
    -static int edge_tiocmget (struct tty_struct *tty, struct file *file);
    -static int edge_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear);
    -static int edge_startup (struct usb_serial *serial);
    -static void edge_shutdown (struct usb_serial *serial);
    +static int edge_open(struct tty_struct *tty, struct usb_serial_port *port,
    + struct file *filp);
    +static void edge_close(struct tty_struct *tty, struct usb_serial_port *port,
    + struct file *filp);
    +static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
    + const unsigned char *buf, int count);
    +static int edge_write_room(struct tty_struct *tty);
    +static int edge_chars_in_buffer(struct tty_struct *tty);
    +static void edge_throttle(struct tty_struct *tty);
    +static void edge_unthrottle(struct tty_struct *tty);
    +static void edge_set_termios(struct tty_struct *tty,
    + struct usb_serial_port *port,
    + struct ktermios *old_termios);
    +static int edge_ioctl(struct tty_struct *tty, struct file *file,
    + unsigned int cmd, unsigned long arg);
    +static void edge_break(struct tty_struct *tty, int break_state);
    +static int edge_tiocmget(struct tty_struct *tty, struct file *file);
    +static int edge_tiocmset(struct tty_struct *tty, struct file *file,
    + unsigned int set, unsigned int clear);
    +static int edge_startup(struct usb_serial *serial);
    +static void edge_shutdown(struct usb_serial *serial);


    #include "io_tables.h" /* all of the devices that this driver supports */

    /* function prototypes for all of our local functions */
    -static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned char *buffer, __u16 bufferLength);
    -static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2, __u8 byte3);
    -static void edge_tty_recv (struct device *dev, struct tty_struct *tty, unsigned char *data, int length);
    -static void handle_new_msr (struct edgeport_port *edge_port, __u8 newMsr);
    -static void handle_new_lsr (struct edgeport_port *edge_port, __u8 lsrData, __u8 lsr, __u8 data);
    -static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u8 param);
    -static int calc_baud_rate_divisor (int baud_rate, int *divisor);
    -static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRate);
    -static void change_port_settings (struct tty_struct *tty, struct edgeport_port *edge_port,
    - struct ktermios *old_termios);
    -static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 regNum, __u8 regValue);
    -static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer, int writeLength);
    -static void send_more_port_data (struct edgeport_serial *edge_serial, struct edgeport_port *edge_port);
    -
    -static int sram_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, __u8 *data);
    -static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, __u8 *data);
    -static int rom_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, __u8 *data);
    -static void get_manufacturing_desc (struct edgeport_serial *edge_serial);
    -static void get_boot_desc (struct edgeport_serial *edge_serial);
    -static void load_application_firmware (struct edgeport_serial *edge_serial);
    -
    -static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unicode_size);
    -
    -
    -// ************************************************** **********************
    -// ************************************************** **********************
    -// ************************************************** **********************
    -// ************************************************** **********************
    +static void process_rcvd_data(struct edgeport_serial *edge_serial,
    + unsigned char *buffer, __u16 bufferLength);
    +static void process_rcvd_status(struct edgeport_serial *edge_serial,
    + __u8 byte2, __u8 byte3);
    +static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
    + unsigned char *data, int length);
    +static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr);
    +static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData,
    + __u8 lsr, __u8 data);
    +static int send_iosp_ext_cmd(struct edgeport_port *edge_port, __u8 command,
    + __u8 param);
    +static int calc_baud_rate_divisor(int baud_rate, int *divisor);
    +static int send_cmd_write_baud_rate(struct edgeport_port *edge_port,
    + int baudRate);
    +static void change_port_settings(struct tty_struct *tty,
    + struct edgeport_port *edge_port,
    + struct ktermios *old_termios);
    +static int send_cmd_write_uart_register(struct edgeport_port *edge_port,
    + __u8 regNum, __u8 regValue);
    +static int write_cmd_usb(struct edgeport_port *edge_port,
    + unsigned char *buffer, int writeLength);
    +static void send_more_port_data(struct edgeport_serial *edge_serial,
    + struct edgeport_port *edge_port);
    +
    +static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr,
    + __u16 length, __u8 *data);
    +static int rom_read(struct usb_serial *serial, __u16 extAddr, __u16 addr,
    + __u16 length, __u8 *data);
    +static int rom_write(struct usb_serial *serial, __u16 extAddr, __u16 addr,
    + __u16 length, __u8 *data);
    +static void get_manufacturing_desc(struct edgeport_serial *edge_serial);
    +static void get_boot_desc(struct edgeport_serial *edge_serial);
    +static void load_application_firmware(struct edgeport_serial *edge_serial);
    +
    +static void unicode_to_ascii(char *string, int buflen,
    + __le16 *unicode, int unicode_size);
    +
    +
    +/* ************************************************** ********************** */
    +/* ************************************************** ********************** */
    +/* ************************************************** ********************** */
    +/* ************************************************** ********************** */

    /************************************************** **********************
    * *
    @@ -280,42 +305,43 @@ static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unic
    * embedded in this driver *
    * *
    ************************************************** **********************/
    -static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial)
    +static void update_edgeport_E2PROM(struct edgeport_serial *edge_serial)
    {
    __u32 BootCurVer;
    __u32 BootNewVer;
    - __u8 BootMajorVersion;
    - __u8 BootMinorVersion;
    + __u8 BootMajorVersion;
    + __u8 BootMinorVersion;
    __le16 BootBuildNumber;
    - __u8 *BootImage;
    + __u8 *BootImage;
    __u32 BootSize;
    struct edge_firmware_image_record *record;
    unsigned char *firmware;
    int response;

    -
    switch (edge_serial->product_info.iDownloadFile) {
    - case EDGE_DOWNLOAD_FILE_I930:
    - BootMajorVersion = BootCodeImageVersion_GEN1.MajorVersion;
    - BootMinorVersion = BootCodeImageVersion_GEN1.MinorVersion;
    - BootBuildNumber = cpu_to_le16(BootCodeImageVersion_GEN1.BuildNumber) ;
    - BootImage = &BootCodeImage_GEN1[0];
    - BootSize = sizeof( BootCodeImage_GEN1 );
    - break;
    + case EDGE_DOWNLOAD_FILE_I930:
    + BootMajorVersion = BootCodeImageVersion_GEN1.MajorVersion;
    + BootMinorVersion = BootCodeImageVersion_GEN1.MinorVersion;
    + BootBuildNumber =
    + cpu_to_le16(BootCodeImageVersion_GEN1.BuildNumber) ;
    + BootImage = &BootCodeImage_GEN1[0];
    + BootSize = sizeof(BootCodeImage_GEN1);
    + break;

    - case EDGE_DOWNLOAD_FILE_80251:
    - BootMajorVersion = BootCodeImageVersion_GEN2.MajorVersion;
    - BootMinorVersion = BootCodeImageVersion_GEN2.MinorVersion;
    - BootBuildNumber = cpu_to_le16(BootCodeImageVersion_GEN2.BuildNumber) ;
    - BootImage = &BootCodeImage_GEN2[0];
    - BootSize = sizeof( BootCodeImage_GEN2 );
    - break;
    + case EDGE_DOWNLOAD_FILE_80251:
    + BootMajorVersion = BootCodeImageVersion_GEN2.MajorVersion;
    + BootMinorVersion = BootCodeImageVersion_GEN2.MinorVersion;
    + BootBuildNumber =
    + cpu_to_le16(BootCodeImageVersion_GEN2.BuildNumber) ;
    + BootImage = &BootCodeImage_GEN2[0];
    + BootSize = sizeof(BootCodeImage_GEN2);
    + break;

    - default:
    - return;
    + default:
    + return;
    }

    - // Check Boot Image Version
    + /* Check Boot Image Version */
    BootCurVer = (edge_serial->boot_descriptor.MajorVersion << 24) +
    (edge_serial->boot_descriptor.MinorVersion << 16) +
    le16_to_cpu(edge_serial->boot_descriptor.BuildNumber);
    @@ -346,19 +372,26 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial)

    for (; {
    record = (struct edge_firmware_image_record *)firmware;
    - response = rom_write (edge_serial->serial, le16_to_cpu(record->ExtAddr), le16_to_cpu(record->Addr), le16_to_cpu(record->Len), &record->Data[0]);
    + response = rom_write(edge_serial->serial,
    + le16_to_cpu(record->ExtAddr),
    + le16_to_cpu(record->Addr),
    + le16_to_cpu(record->Len),
    + &record->Data[0]);
    if (response < 0) {
    - dev_err(&edge_serial->serial->dev->dev, "rom_write failed (%x, %x, %d)\n", le16_to_cpu(record->ExtAddr), le16_to_cpu(record->Addr), le16_to_cpu(record->Len));
    + dev_err(&edge_serial->serial->dev->dev,
    + "rom_write failed (%x, %x, %d)\n",
    + le16_to_cpu(record->ExtAddr),
    + le16_to_cpu(record->Addr),
    + le16_to_cpu(record->Len));
    break;
    }
    - firmware += sizeof (struct edge_firmware_image_record) + le16_to_cpu(record->Len);
    - if (firmware >= &BootImage[BootSize]) {
    + firmware += sizeof(struct edge_firmware_image_record)
    + + le16_to_cpu(record->Len);
    + if (firmware >= &BootImage[BootSize])
    break;
    - }
    }
    - } else {
    + } else
    dbg("Boot Image -- already up to date");
    - }
    }


    @@ -367,29 +400,29 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial)
    * Get string descriptor from device *
    * *
    ************************************************** **********************/
    -static int get_string (struct usb_device *dev, int Id, char *string, int buflen)
    +static int get_string(struct usb_device *dev, int Id, char *string, int buflen)
    {
    struct usb_string_descriptor StringDesc;
    struct usb_string_descriptor *pStringDesc;

    - dbg("%s - USB String ID = %d", __func__, Id );
    + dbg("%s - USB String ID = %d", __func__, Id);

    - if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, sizeof(StringDesc))) {
    + if (!usb_get_descriptor(dev, USB_DT_STRING, Id,
    + &StringDesc, sizeof(StringDesc)))
    return 0;
    - }
    -
    - pStringDesc = kmalloc (StringDesc.bLength, GFP_KERNEL);

    - if (!pStringDesc) {
    + pStringDesc = kmalloc(StringDesc.bLength, GFP_KERNEL);
    + if (!pStringDesc)
    return 0;
    - }

    - if (!usb_get_descriptor(dev, USB_DT_STRING, Id, pStringDesc, StringDesc.bLength )) {
    + if (!usb_get_descriptor(dev, USB_DT_STRING, Id,
    + pStringDesc, StringDesc.bLength)) {
    kfree(pStringDesc);
    return 0;
    }

    - unicode_to_ascii(string, buflen, pStringDesc->wData, pStringDesc->bLength/2);
    + unicode_to_ascii(string, buflen,
    + pStringDesc->wData, pStringDesc->bLength/2);

    kfree(pStringDesc);
    dbg("%s - USB String %s", __func__, string);
    @@ -403,24 +436,24 @@ static int get_string (struct usb_device *dev, int Id, char *string, int buflen)
    * Get string descriptor from device
    *
    ************************************************** **********************/
    -static int get_string_desc (struct usb_device *dev, int Id, struct usb_string_descriptor **pRetDesc)
    +static int get_string_desc(struct usb_device *dev, int Id,
    + struct usb_string_descriptor **pRetDesc)
    {
    struct usb_string_descriptor StringDesc;
    struct usb_string_descriptor *pStringDesc;

    - dbg("%s - USB String ID = %d", __func__, Id );
    + dbg("%s - USB String ID = %d", __func__, Id);

    - if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, sizeof(StringDesc))) {
    + if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc,
    + sizeof(StringDesc)))
    return 0;
    - }
    -
    - pStringDesc = kmalloc (StringDesc.bLength, GFP_KERNEL);

    - if (!pStringDesc) {
    + pStringDesc = kmalloc(StringDesc.bLength, GFP_KERNEL);
    + if (!pStringDesc)
    return -1;
    - }

    - if (!usb_get_descriptor(dev, USB_DT_STRING, Id, pStringDesc, StringDesc.bLength )) {
    + if (!usb_get_descriptor(dev, USB_DT_STRING, Id, pStringDesc,
    + StringDesc.bLength)) {
    kfree(pStringDesc);
    return -1;
    }
    @@ -432,28 +465,30 @@ static int get_string_desc (struct usb_device *dev, int Id, struct usb_string_de

    static void dump_product_info(struct edgeport_product_info *product_info)
    {
    - // Dump Product Info structure
    + /* Dump Product Info structure */
    dbg("**Product Information:");
    - dbg(" ProductId %x", product_info->ProductId );
    - dbg(" NumPorts %d", product_info->NumPorts );
    - dbg(" ProdInfoVer %d", product_info->ProdInfoVer );
    + dbg(" ProductId %x", product_info->ProductId);
    + dbg(" NumPorts %d", product_info->NumPorts);
    + dbg(" ProdInfoVer %d", product_info->ProdInfoVer);
    dbg(" IsServer %d", product_info->IsServer);
    - dbg(" IsRS232 %d", product_info->IsRS232 );
    - dbg(" IsRS422 %d", product_info->IsRS422 );
    - dbg(" IsRS485 %d", product_info->IsRS485 );
    - dbg(" RomSize %d", product_info->RomSize );
    - dbg(" RamSize %d", product_info->RamSize );
    - dbg(" CpuRev %x", product_info->CpuRev );
    + dbg(" IsRS232 %d", product_info->IsRS232);
    + dbg(" IsRS422 %d", product_info->IsRS422);
    + dbg(" IsRS485 %d", product_info->IsRS485);
    + dbg(" RomSize %d", product_info->RomSize);
    + dbg(" RamSize %d", product_info->RamSize);
    + dbg(" CpuRev %x", product_info->CpuRev);
    dbg(" BoardRev %x", product_info->BoardRev);
    dbg(" BootMajorVersion %d.%d.%d", product_info->BootMajorVersion,
    product_info->BootMinorVersion,
    le16_to_cpu(product_info->BootBuildNumber));
    - dbg(" FirmwareMajorVersion %d.%d.%d", product_info->FirmwareMajorVersion,
    - product_info->FirmwareMinorVersion,
    - le16_to_cpu(product_info->FirmwareBuildNumber));
    - dbg(" ManufactureDescDate %d/%d/%d", product_info->ManufactureDescDate[0],
    - product_info->ManufactureDescDate[1],
    - product_info->ManufactureDescDate[2]+1900);
    + dbg(" FirmwareMajorVersion %d.%d.%d",
    + product_info->FirmwareMajorVersion,
    + product_info->FirmwareMinorVersion,
    + le16_to_cpu(product_info->FirmwareBuildNumber));
    + dbg(" ManufactureDescDate %d/%d/%d",
    + product_info->ManufactureDescDate[0],
    + product_info->ManufactureDescDate[1],
    + product_info->ManufactureDescDate[2]+1900);
    dbg(" iDownloadFile 0x%x", product_info->iDownloadFile);
    dbg(" EpicVer %d", product_info->EpicVer);
    }
    @@ -462,61 +497,73 @@ static void get_product_info(struct edgeport_serial *edge_serial)
    {
    struct edgeport_product_info *product_info = &edge_serial->product_info;

    - memset (product_info, 0, sizeof(struct edgeport_product_info));
    -
    - product_info->ProductId = (__u16)(le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct) & ~ION_DEVICE_ID_80251_NETCHIP);
    - product_info->NumPorts = edge_serial->manuf_descriptor.NumPorts;
    - product_info->ProdInfoVer = 0;
    -
    - product_info->RomSize = edge_serial->manuf_descriptor.RomSize;
    - product_info->RamSize = edge_serial->manuf_descriptor.RamSize;
    - product_info->CpuRev = edge_serial->manuf_descriptor.CpuRev;
    - product_info->BoardRev = edge_serial->manuf_descriptor.BoardRev;
    -
    - product_info->BootMajorVersion = edge_serial->boot_descriptor.MajorVersion;
    - product_info->BootMinorVersion = edge_serial->boot_descriptor.MinorVersion;
    - product_info->BootBuildNumber = edge_serial->boot_descriptor.BuildNumber;
    -
    - memcpy(product_info->ManufactureDescDate, edge_serial->manuf_descriptor.DescDate, sizeof(edge_serial->manuf_descriptor.DescDate));
    -
    - // check if this is 2nd generation hardware
    - if (le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct) & ION_DEVICE_ID_80251_NETCHIP) {
    - product_info->FirmwareMajorVersion = OperationalCodeImageVersion_GEN2.MajorVersion;
    - product_info->FirmwareMinorVersion = OperationalCodeImageVersion_GEN2.MinorVersion;
    - product_info->FirmwareBuildNumber = cpu_to_le16(OperationalCodeImageVersion_GEN2.Build Number);
    - product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_80251;
    + memset(product_info, 0, sizeof(struct edgeport_product_info));
    +
    + product_info->ProductId = (__u16)(le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct) & ~ION_DEVICE_ID_80251_NETCHIP);
    + product_info->NumPorts = edge_serial->manuf_descriptor.NumPorts;
    + product_info->ProdInfoVer = 0;
    +
    + product_info->RomSize = edge_serial->manuf_descriptor.RomSize;
    + product_info->RamSize = edge_serial->manuf_descriptor.RamSize;
    + product_info->CpuRev = edge_serial->manuf_descriptor.CpuRev;
    + product_info->BoardRev = edge_serial->manuf_descriptor.BoardRev;
    +
    + product_info->BootMajorVersion =
    + edge_serial->boot_descriptor.MajorVersion;
    + product_info->BootMinorVersion =
    + edge_serial->boot_descriptor.MinorVersion;
    + product_info->BootBuildNumber =
    + edge_serial->boot_descriptor.BuildNumber;
    +
    + memcpy(product_info->ManufactureDescDate,
    + edge_serial->manuf_descriptor.DescDate,
    + sizeof(edge_serial->manuf_descriptor.DescDate));
    +
    + /* check if this is 2nd generation hardware */
    + if (le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct)
    + & ION_DEVICE_ID_80251_NETCHIP) {
    + product_info->FirmwareMajorVersion =
    + OperationalCodeImageVersion_GEN2.MajorVersion;
    + product_info->FirmwareMinorVersion =
    + OperationalCodeImageVersion_GEN2.MinorVersion;
    + product_info->FirmwareBuildNumber =
    + cpu_to_le16(OperationalCodeImageVersion_GEN2.Build Number);
    + product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_80251;
    } else {
    - product_info->FirmwareMajorVersion = OperationalCodeImageVersion_GEN1.MajorVersion;
    - product_info->FirmwareMinorVersion = OperationalCodeImageVersion_GEN1.MinorVersion;
    - product_info->FirmwareBuildNumber = cpu_to_le16(OperationalCodeImageVersion_GEN1.Build Number);
    - product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_I930;
    + product_info->FirmwareMajorVersion =
    + OperationalCodeImageVersion_GEN1.MajorVersion;
    + product_info->FirmwareMinorVersion =
    + OperationalCodeImageVersion_GEN1.MinorVersion;
    + product_info->FirmwareBuildNumber =
    + cpu_to_le16(OperationalCodeImageVersion_GEN1.Build Number);
    + product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_I930;
    }

    - // Determine Product type and set appropriate flags
    + /* Determine Product type and set appropriate flags */
    switch (DEVICE_ID_FROM_USB_PRODUCT_ID(product_info->ProductId)) {
    - case ION_DEVICE_ID_EDGEPORT_COMPATIBLE:
    - case ION_DEVICE_ID_EDGEPORT_4T:
    - case ION_DEVICE_ID_EDGEPORT_4:
    - case ION_DEVICE_ID_EDGEPORT_2:
    - case ION_DEVICE_ID_EDGEPORT_8_DUAL_CPU:
    - case ION_DEVICE_ID_EDGEPORT_8:
    - case ION_DEVICE_ID_EDGEPORT_421:
    - case ION_DEVICE_ID_EDGEPORT_21:
    - case ION_DEVICE_ID_EDGEPORT_2_DIN:
    - case ION_DEVICE_ID_EDGEPORT_4_DIN:
    - case ION_DEVICE_ID_EDGEPORT_16_DUAL_CPU:
    - product_info->IsRS232 = 1;
    - break;
    + case ION_DEVICE_ID_EDGEPORT_COMPATIBLE:
    + case ION_DEVICE_ID_EDGEPORT_4T:
    + case ION_DEVICE_ID_EDGEPORT_4:
    + case ION_DEVICE_ID_EDGEPORT_2:
    + case ION_DEVICE_ID_EDGEPORT_8_DUAL_CPU:
    + case ION_DEVICE_ID_EDGEPORT_8:
    + case ION_DEVICE_ID_EDGEPORT_421:
    + case ION_DEVICE_ID_EDGEPORT_21:
    + case ION_DEVICE_ID_EDGEPORT_2_DIN:
    + case ION_DEVICE_ID_EDGEPORT_4_DIN:
    + case ION_DEVICE_ID_EDGEPORT_16_DUAL_CPU:
    + product_info->IsRS232 = 1;
    + break;

    - case ION_DEVICE_ID_EDGEPORT_2I: // Edgeport/2 RS422/RS485
    - product_info->IsRS422 = 1;
    - product_info->IsRS485 = 1;
    - break;
    + case ION_DEVICE_ID_EDGEPORT_2I: /* Edgeport/2 RS422/RS485 */
    + product_info->IsRS422 = 1;
    + product_info->IsRS485 = 1;
    + break;

    - case ION_DEVICE_ID_EDGEPORT_8I: // Edgeport/4 RS422
    - case ION_DEVICE_ID_EDGEPORT_4I: // Edgeport/4 RS422
    - product_info->IsRS422 = 1;
    - break;
    + case ION_DEVICE_ID_EDGEPORT_8I: /* Edgeport/4 RS422 */
    + case ION_DEVICE_ID_EDGEPORT_4I: /* Edgeport/4 RS422 */
    + product_info->IsRS422 = 1;
    + break;
    }

    dump_product_info(product_info);
    @@ -544,32 +591,32 @@ static int get_epic_descriptor(struct edgeport_serial *ep)
    ep->is_epic = 1;
    memset(product_info, 0, sizeof(struct edgeport_product_info));

    - product_info->NumPorts = epic->NumPorts;
    - product_info->ProdInfoVer = 0;
    - product_info->FirmwareMajorVersion = epic->MajorVersion;
    - product_info->FirmwareMinorVersion = epic->MinorVersion;
    - product_info->FirmwareBuildNumber = epic->BuildNumber;
    - product_info->iDownloadFile = epic->iDownloadFile;
    - product_info->EpicVer = epic->EpicVer;
    - product_info->Epic = epic->Supports;
    - product_info->ProductId = ION_DEVICE_ID_EDGEPORT_COMPATIBLE;
    + product_info->NumPorts = epic->NumPorts;
    + product_info->ProdInfoVer = 0;
    + product_info->FirmwareMajorVersion = epic->MajorVersion;
    + product_info->FirmwareMinorVersion = epic->MinorVersion;
    + product_info->FirmwareBuildNumber = epic->BuildNumber;
    + product_info->iDownloadFile = epic->iDownloadFile;
    + product_info->EpicVer = epic->EpicVer;
    + product_info->Epic = epic->Supports;
    + product_info->ProductId = ION_DEVICE_ID_EDGEPORT_COMPATIBLE;
    dump_product_info(product_info);

    bits = &ep->epic_descriptor.Supports;
    dbg("**EPIC descriptor:");
    dbg(" VendEnableSuspend: %s", bits->VendEnableSuspend ? "TRUE": "FALSE");
    - dbg(" IOSPOpen : %s", bits->IOSPOpen ? "TRUE": "FALSE" );
    - dbg(" IOSPClose : %s", bits->IOSPClose ? "TRUE": "FALSE" );
    - dbg(" IOSPChase : %s", bits->IOSPChase ? "TRUE": "FALSE" );
    - dbg(" IOSPSetRxFlow : %s", bits->IOSPSetRxFlow ? "TRUE": "FALSE" );
    - dbg(" IOSPSetTxFlow : %s", bits->IOSPSetTxFlow ? "TRUE": "FALSE" );
    - dbg(" IOSPSetXChar : %s", bits->IOSPSetXChar ? "TRUE": "FALSE" );
    - dbg(" IOSPRxCheck : %s", bits->IOSPRxCheck ? "TRUE": "FALSE" );
    - dbg(" IOSPSetClrBreak : %s", bits->IOSPSetClrBreak ? "TRUE": "FALSE" );
    - dbg(" IOSPWriteMCR : %s", bits->IOSPWriteMCR ? "TRUE": "FALSE" );
    - dbg(" IOSPWriteLCR : %s", bits->IOSPWriteLCR ? "TRUE": "FALSE" );
    - dbg(" IOSPSetBaudRate : %s", bits->IOSPSetBaudRate ? "TRUE": "FALSE" );
    - dbg(" TrueEdgeport : %s", bits->TrueEdgeport ? "TRUE": "FALSE" );
    + dbg(" IOSPOpen : %s", bits->IOSPOpen ? "TRUE": "FALSE");
    + dbg(" IOSPClose : %s", bits->IOSPClose ? "TRUE": "FALSE");
    + dbg(" IOSPChase : %s", bits->IOSPChase ? "TRUE": "FALSE");
    + dbg(" IOSPSetRxFlow : %s", bits->IOSPSetRxFlow ? "TRUE": "FALSE");
    + dbg(" IOSPSetTxFlow : %s", bits->IOSPSetTxFlow ? "TRUE": "FALSE");
    + dbg(" IOSPSetXChar : %s", bits->IOSPSetXChar ? "TRUE": "FALSE");
    + dbg(" IOSPRxCheck : %s", bits->IOSPRxCheck ? "TRUE": "FALSE");
    + dbg(" IOSPSetClrBreak : %s", bits->IOSPSetClrBreak ? "TRUE": "FALSE");
    + dbg(" IOSPWriteMCR : %s", bits->IOSPWriteMCR ? "TRUE": "FALSE");
    + dbg(" IOSPWriteLCR : %s", bits->IOSPWriteLCR ? "TRUE": "FALSE");
    + dbg(" IOSPSetBaudRate : %s", bits->IOSPSetBaudRate ? "TRUE": "FALSE");
    + dbg(" TrueEdgeport : %s", bits->TrueEdgeport ? "TRUE": "FALSE");
    }

    return result;
    @@ -585,10 +632,10 @@ static int get_epic_descriptor(struct edgeport_serial *ep)

    /************************************************** ***************************
    * edge_interrupt_callback
    - * this is the callback function for when we have received data on the
    + * this is the callback function for when we have received data on the
    * interrupt endpoint.
    ************************************************** ***************************/
    -static void edge_interrupt_callback (struct urb *urb)
    +static void edge_interrupt_callback(struct urb *urb)
    {
    struct edgeport_serial *edge_serial = urb->context;
    struct edgeport_port *edge_port;
    @@ -613,17 +660,17 @@ static void edge_interrupt_callback (struct urb *urb)
    case -ESHUTDOWN:
    /* this urb is terminated, clean up */
    dbg("%s - urb shutting down with status: %d",
    - __func__, status);
    + __func__, status);
    return;
    default:
    - dbg("%s - nonzero urb status received: %d",
    - __func__, status);
    + dbg("%s - nonzero urb status received: %d", __func__, status);
    goto exit;
    }

    - // process this interrupt-read even if there are no ports open
    + /* process this interrupt-read even if there are no ports open */
    if (length) {
    - usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __func__, length, data);
    + usb_serial_debug_data(debug, &edge_serial->serial->dev->dev,
    + __func__, length, data);

    if (length > 1) {
    bytes_avail = data[0] | (data[1] << 8);
    @@ -637,7 +684,8 @@ static void edge_interrupt_callback (struct urb *urb)
    dbg("%s - posting a read", __func__);
    edge_serial->read_in_progress = true;

    - /* we have pending bytes on the bulk in pipe, send a request */
    + /* we have pending bytes on the
    + bulk in pipe, send a request */
    edge_serial->read_urb->dev = edge_serial->serial->dev;
    result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC);
    if (result) {
    @@ -651,7 +699,8 @@ static void edge_interrupt_callback (struct urb *urb)
    /* grab the txcredits for the ports if available */
    position = 2;
    portNumber = 0;
    - while ((position < length) && (portNumber < edge_serial->serial->num_ports)) {
    + while ((position < length) &&
    + (portNumber < edge_serial->serial->num_ports)) {
    txCredits = data[position] | (data[position+1] << 8);
    if (txCredits) {
    port = edge_serial->serial->port[portNumber];
    @@ -660,14 +709,19 @@ static void edge_interrupt_callback (struct urb *urb)
    spin_lock(&edge_port->ep_lock);
    edge_port->txCredits += txCredits;
    spin_unlock(&edge_port->ep_lock);
    - dbg("%s - txcredits for port%d = %d", __func__, portNumber, edge_port->txCredits);
    + dbg("%s - txcredits for port%d = %d",
    + __func__, portNumber,
    + edge_port->txCredits);

    - /* tell the tty driver that something has changed */
    + /* tell the tty driver that something
    + has changed */
    if (edge_port->port->port.tty)
    tty_wakeup(edge_port->port->port.tty);

    - // Since we have more credit, check if more data can be sent
    - send_more_port_data(edge_serial, edge_port);
    + /* Since we have more credit, check
    + if more data can be sent */
    + send_more_port_data(edge_serial,
    + edge_port);
    }
    }
    position += 2;
    @@ -676,19 +730,20 @@ static void edge_interrupt_callback (struct urb *urb)
    }

    exit:
    - result = usb_submit_urb (urb, GFP_ATOMIC);
    - if (result) {
    - dev_err(&urb->dev->dev, "%s - Error %d submitting control urb\n", __func__, result);
    - }
    + result = usb_submit_urb(urb, GFP_ATOMIC);
    + if (result)
    + dev_err(&urb->dev->dev,
    + "%s - Error %d submitting control urb\n",
    + __func__, result);
    }


    /************************************************** ***************************
    * edge_bulk_in_callback
    - * this is the callback function for when we have received data on the
    + * this is the callback function for when we have received data on the
    * bulk in endpoint.
    ************************************************** ***************************/
    -static void edge_bulk_in_callback (struct urb *urb)
    +static void edge_bulk_in_callback(struct urb *urb)
    {
    struct edgeport_serial *edge_serial = urb->context;
    unsigned char *data = urb->transfer_buffer;
    @@ -713,16 +768,18 @@ static void edge_bulk_in_callback (struct urb *urb)

    raw_data_length = urb->actual_length;

    - usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __func__, raw_data_length, data);
    + usb_serial_debug_data(debug, &edge_serial->serial->dev->dev,
    + __func__, raw_data_length, data);

    spin_lock(&edge_serial->es_lock);

    /* decrement our rxBytes available by the number that we just got */
    edge_serial->rxBytesAvail -= raw_data_length;

    - dbg("%s - Received = %d, rxBytesAvail %d", __func__, raw_data_length, edge_serial->rxBytesAvail);
    + dbg("%s - Received = %d, rxBytesAvail %d", __func__,
    + raw_data_length, edge_serial->rxBytesAvail);

    - process_rcvd_data (edge_serial, data, urb->actual_length);
    + process_rcvd_data(edge_serial, data, urb->actual_length);

    /* check to see if there's any more data for us to read */
    if (edge_serial->rxBytesAvail > 0) {
    @@ -745,10 +802,10 @@ static void edge_bulk_in_callback (struct urb *urb)

    /************************************************** ***************************
    * edge_bulk_out_data_callback
    - * this is the callback function for when we have finished sending serial data
    - * on the bulk out endpoint.
    + * this is the callback function for when we have finished sending
    + * serial data on the bulk out endpoint.
    ************************************************** ***************************/
    -static void edge_bulk_out_data_callback (struct urb *urb)
    +static void edge_bulk_out_data_callback(struct urb *urb)
    {
    struct edgeport_port *edge_port = urb->context;
    struct tty_struct *tty;
    @@ -764,24 +821,26 @@ static void edge_bulk_out_data_callback (struct urb *urb)
    tty = edge_port->port->port.tty;

    if (tty && edge_port->open) {
    - /* let the tty driver wakeup if it has a special write_wakeup function */
    + /* let the tty driver wakeup if it has a special
    + write_wakeup function */
    tty_wakeup(tty);
    }

    - // Release the Write URB
    + /* Release the Write URB */
    edge_port->write_in_progress = false;

    - // Check if more data needs to be sent
    - send_more_port_data((struct edgeport_serial *)(usb_get_serial_data(edge_port->port->serial)), edge_port);
    + /* Check if more data needs to be sent */
    + send_more_port_data((struct edgeport_serial *)
    + (usb_get_serial_data(edge_port->port->serial)), edge_port);
    }


    /************************************************** ***************************
    * BulkOutCmdCallback
    - * this is the callback function for when we have finished sending a command
    - * on the bulk out endpoint.
    + * this is the callback function for when we have finished sending a
    + * command on the bulk out endpoint.
    ************************************************** ***************************/
    -static void edge_bulk_out_cmd_callback (struct urb *urb)
    +static void edge_bulk_out_cmd_callback(struct urb *urb)
    {
    struct edgeport_port *edge_port = urb->context;
    struct tty_struct *tty;
    @@ -790,17 +849,19 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)
    dbg("%s", __func__);

    atomic_dec(&CmdUrbs);
    - dbg("%s - FREE URB %p (outstanding %d)", __func__, urb, atomic_read(&CmdUrbs));
    + dbg("%s - FREE URB %p (outstanding %d)", __func__,
    + urb, atomic_read(&CmdUrbs));


    /* clean up the transfer buffer */
    kfree(urb->transfer_buffer);

    /* Free the command urb */
    - usb_free_urb (urb);
    + usb_free_urb(urb);

    if (status) {
    - dbg("%s - nonzero write bulk status received: %d", __func__, status);
    + dbg("%s - nonzero write bulk status received: %d",
    + __func__, status);
    return;
    }

    @@ -828,7 +889,7 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)
    * Otherwise we return a negative error number.
    ************************************************** ***************************/
    static int edge_open(struct tty_struct *tty,
    - struct usb_serial_port *port, struct file * filp)
    + struct usb_serial_port *port, struct file *filp)
    {
    struct edgeport_port *edge_port = usb_get_serial_port_data(port);
    struct usb_serial *serial;
    @@ -843,51 +904,59 @@ static int edge_open(struct tty_struct *tty,
    if (tty)
    tty->low_latency = low_latency;

    - /* see if we've set up our endpoint info yet (can't set it up in edge_startup
    - as the structures were not set up at that time.) */
    + /* see if we've set up our endpoint info yet (can't set it up
    + in edge_startup as the structures were not set up at that time.) */
    serial = port->serial;
    edge_serial = usb_get_serial_data(serial);
    if (edge_serial == NULL)
    return -ENODEV;
    if (edge_serial->interrupt_in_buffer == NULL) {
    struct usb_serial_port *port0 = serial->port[0];
    -
    +
    /* not set up yet, so do it now */
    - edge_serial->interrupt_in_buffer = port0->interrupt_in_buffer;
    - edge_serial->interrupt_in_endpoint = port0->interrupt_in_endpointAddress;
    + edge_serial->interrupt_in_buffer =
    + port0->interrupt_in_buffer;
    + edge_serial->interrupt_in_endpoint =
    + port0->interrupt_in_endpointAddress;
    edge_serial->interrupt_read_urb = port0->interrupt_in_urb;
    edge_serial->bulk_in_buffer = port0->bulk_in_buffer;
    - edge_serial->bulk_in_endpoint = port0->bulk_in_endpointAddress;
    + edge_serial->bulk_in_endpoint =
    + port0->bulk_in_endpointAddress;
    edge_serial->read_urb = port0->read_urb;
    - edge_serial->bulk_out_endpoint = port0->bulk_out_endpointAddress;
    -
    + edge_serial->bulk_out_endpoint =
    + port0->bulk_out_endpointAddress;
    +
    /* set up our interrupt urb */
    usb_fill_int_urb(edge_serial->interrupt_read_urb,
    - serial->dev,
    - usb_rcvintpipe(serial->dev,
    - port0->interrupt_in_endpointAddress),
    - port0->interrupt_in_buffer,
    - edge_serial->interrupt_read_urb->transfer_buffer_length,
    - edge_interrupt_callback, edge_serial,
    - edge_serial->interrupt_read_urb->interval);
    -
    + serial->dev,
    + usb_rcvintpipe(serial->dev,
    + port0->interrupt_in_endpointAddress),
    + port0->interrupt_in_buffer,
    + edge_serial->interrupt_read_urb->transfer_buffer_length,
    + edge_interrupt_callback, edge_serial,
    + edge_serial->interrupt_read_urb->interval);
    +
    /* set up our bulk in urb */
    usb_fill_bulk_urb(edge_serial->read_urb, serial->dev,
    - usb_rcvbulkpipe(serial->dev,
    - port0->bulk_in_endpointAddress),
    - port0->bulk_in_buffer,
    - edge_serial->read_urb->transfer_buffer_length,
    - edge_bulk_in_callback, edge_serial);
    + usb_rcvbulkpipe(serial->dev,
    + port0->bulk_in_endpointAddress),
    + port0->bulk_in_buffer,
    + edge_serial->read_urb->transfer_buffer_length,
    + edge_bulk_in_callback, edge_serial);
    edge_serial->read_in_progress = false;

    /* start interrupt read for this edgeport
    - * this interrupt will continue as long as the edgeport is connected */
    - response = usb_submit_urb (edge_serial->interrupt_read_urb, GFP_KERNEL);
    + * this interrupt will continue as long
    + * as the edgeport is connected */
    + response = usb_submit_urb(edge_serial->interrupt_read_urb,
    + GFP_KERNEL);
    if (response) {
    - dev_err(&port->dev, "%s - Error %d submitting control urb\n", __func__, response);
    + dev_err(&port->dev,
    + "%s - Error %d submitting control urb\n",
    + __func__, response);
    }
    }
    -
    +
    /* initialize our wait queues */
    init_waitqueue_head(&edge_port->wait_open);
    init_waitqueue_head(&edge_port->wait_chase);
    @@ -895,26 +964,29 @@ static int edge_open(struct tty_struct *tty,
    init_waitqueue_head(&edge_port->wait_command);

    /* initialize our icount structure */
    - memset (&(edge_port->icount), 0x00, sizeof(edge_port->icount));
    + memset(&(edge_port->icount), 0x00, sizeof(edge_port->icount));

    /* initialize our port settings */
    - edge_port->txCredits = 0; /* Can't send any data yet */
    - edge_port->shadowMCR = MCR_MASTER_IE; /* Must always set this bit to enable ints! */
    + edge_port->txCredits = 0; /* Can't send any data yet */
    + /* Must always set this bit to enable ints! */
    + edge_port->shadowMCR = MCR_MASTER_IE;
    edge_port->chaseResponsePending = false;

    /* send a open port command */
    edge_port->openPending = true;
    edge_port->open = false;
    - response = send_iosp_ext_cmd (edge_port, IOSP_CMD_OPEN_PORT, 0);
    + response = send_iosp_ext_cmd(edge_port, IOSP_CMD_OPEN_PORT, 0);

    if (response < 0) {
    - dev_err(&port->dev, "%s - error sending open port command\n", __func__);
    + dev_err(&port->dev, "%s - error sending open port command\n",
    + __func__);
    edge_port->openPending = false;
    return -ENODEV;
    }

    /* now wait for the port to be completely opened */
    - wait_event_timeout(edge_port->wait_open, !edge_port->openPending, OPEN_TIMEOUT);
    + wait_event_timeout(edge_port->wait_open, !edge_port->openPending,
    + OPEN_TIMEOUT);

    if (!edge_port->open) {
    /* open timed out */
    @@ -928,25 +1000,26 @@ static int edge_open(struct tty_struct *tty,
    edge_port->txfifo.tail = 0;
    edge_port->txfifo.count = 0;
    edge_port->txfifo.size = edge_port->maxTxCredits;
    - edge_port->txfifo.fifo = kmalloc (edge_port->maxTxCredits, GFP_KERNEL);
    + edge_port->txfifo.fifo = kmalloc(edge_port->maxTxCredits, GFP_KERNEL);

    if (!edge_port->txfifo.fifo) {
    dbg("%s - no memory", __func__);
    - edge_close (tty, port, filp);
    + edge_close(tty, port, filp);
    return -ENOMEM;
    }

    /* Allocate a URB for the write */
    - edge_port->write_urb = usb_alloc_urb (0, GFP_KERNEL);
    + edge_port->write_urb = usb_alloc_urb(0, GFP_KERNEL);
    edge_port->write_in_progress = false;

    if (!edge_port->write_urb) {
    dbg("%s - no memory", __func__);
    - edge_close (tty, port, filp);
    + edge_close(tty, port, filp);
    return -ENOMEM;
    }

    - dbg("%s(%d) - Initialize TX fifo to %d bytes", __func__, port->number, edge_port->maxTxCredits);
    + dbg("%s(%d) - Initialize TX fifo to %d bytes",
    + __func__, port->number, edge_port->maxTxCredits);

    dbg("%s exited", __func__);

    @@ -972,27 +1045,28 @@ static void block_until_chase_response(struct edgeport_port *edge_port)
    int loop = 10;

    while (1) {
    - // Save Last credits
    + /* Save Last credits */
    lastCredits = edge_port->txCredits;

    - // Did we get our Chase response
    + /* Did we get our Chase response */
    if (!edge_port->chaseResponsePending) {
    dbg("%s - Got Chase Response", __func__);

    - // did we get all of our credit back?
    - if (edge_port->txCredits == edge_port->maxTxCredits ) {
    + /* did we get all of our credit back? */
    + if (edge_port->txCredits == edge_port->maxTxCredits) {
    dbg("%s - Got all credits", __func__);
    return;
    }
    }

    - // Block the thread for a while
    - prepare_to_wait(&edge_port->wait_chase, &wait, TASK_UNINTERRUPTIBLE);
    + /* Block the thread for a while */
    + prepare_to_wait(&edge_port->wait_chase, &wait,
    + TASK_UNINTERRUPTIBLE);
    schedule_timeout(timeout);
    finish_wait(&edge_port->wait_chase, &wait);

    if (lastCredits == edge_port->txCredits) {
    - // No activity.. count down.
    + /* No activity.. count down. */
    loop--;
    if (loop == 0) {
    edge_port->chaseResponsePending = false;
    @@ -1000,8 +1074,9 @@ static void block_until_chase_response(struct edgeport_port *edge_port)
    return;
    }
    } else {
    - // Reset timeout value back to 10 seconds
    - dbg("%s - Last %d, Current %d", __func__, lastCredits, edge_port->txCredits);
    + /* Reset timeout value back to 10 seconds */
    + dbg("%s - Last %d, Current %d", __func__,
    + lastCredits, edge_port->txCredits);
    loop = 10;
    }
    }
    @@ -1018,7 +1093,7 @@ static void block_until_chase_response(struct edgeport_port *edge_port)
    * 3. A timeout of 3 seconds without activity has expired
    *
    ************************************************** **********************/
    -static void block_until_tx_empty (struct edgeport_port *edge_port)
    +static void block_until_tx_empty(struct edgeport_port *edge_port)
    {
    DEFINE_WAIT(wait);
    struct TxFifo *fifo = &edge_port->txfifo;
    @@ -1027,31 +1102,32 @@ static void block_until_tx_empty (struct edgeport_port *edge_port)
    int loop = 30;

    while (1) {
    - // Save Last count
    + /* Save Last count */
    lastCount = fifo->count;

    - // Is the Edgeport Buffer empty?
    + /* Is the Edgeport Buffer empty? */
    if (lastCount == 0) {
    dbg("%s - TX Buffer Empty", __func__);
    return;
    }

    - // Block the thread for a while
    - prepare_to_wait (&edge_port->wait_chase, &wait, TASK_UNINTERRUPTIBLE);
    + /* Block the thread for a while */
    + prepare_to_wait(&edge_port->wait_chase, &wait,
    + TASK_UNINTERRUPTIBLE);
    schedule_timeout(timeout);
    finish_wait(&edge_port->wait_chase, &wait);

    dbg("%s wait", __func__);

    if (lastCount == fifo->count) {
    - // No activity.. count down.
    + /* No activity.. count down. */
    loop--;
    if (loop == 0) {
    dbg("%s - TIMEOUT", __func__);
    return;
    }
    } else {
    - // Reset timeout value back to seconds
    + /* Reset timeout value back to seconds */
    loop = 30;
    }
    }
    @@ -1063,20 +1139,20 @@ static void block_until_tx_empty (struct edgeport_port *edge_port)
    * this function is called by the tty driver when a port is closed
    ************************************************** ***************************/
    static void edge_close(struct tty_struct *tty,
    - struct usb_serial_port *port, struct file * filp)
    + struct usb_serial_port *port, struct file *filp)
    {
    struct edgeport_serial *edge_serial;
    struct edgeport_port *edge_port;
    int status;

    dbg("%s - port %d", __func__, port->number);
    -
    +
    edge_serial = usb_get_serial_data(port->serial);
    edge_port = usb_get_serial_port_data(port);
    - if ((edge_serial == NULL) || (edge_port == NULL))
    + if (edge_serial == NULL || edge_port == NULL)
    return;
    -
    - // block until tx is empty
    +
    + /* block until tx is empty */
    block_until_tx_empty(edge_port);

    edge_port->closePending = true;
    @@ -1088,13 +1164,12 @@ static void edge_close(struct tty_struct *tty,
    edge_port->chaseResponsePending = true;

    dbg("%s - Sending IOSP_CMD_CHASE_PORT", __func__);
    - status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0);
    - if (status == 0) {
    - // block until chase finished
    + status = send_iosp_ext_cmd(edge_port, IOSP_CMD_CHASE_PORT, 0);
    + if (status == 0)
    + /* block until chase finished */
    block_until_chase_response(edge_port);
    - } else {
    + else
    edge_port->chaseResponsePending = false;
    - }
    }

    if ((!edge_serial->is_epic) ||
    @@ -1102,10 +1177,10 @@ static void edge_close(struct tty_struct *tty,
    (edge_serial->epic_descriptor.Supports.IOSPClose))) {
    /* close the port */
    dbg("%s - Sending IOSP_CMD_CLOSE_PORT", __func__);
    - send_iosp_ext_cmd (edge_port, IOSP_CMD_CLOSE_PORT, 0);
    + send_iosp_ext_cmd(edge_port, IOSP_CMD_CLOSE_PORT, 0);
    }

    - //port->close = true;
    + /* port->close = true; */
    edge_port->closePending = false;
    edge_port->open = false;
    edge_port->openPending = false;
    @@ -1113,7 +1188,8 @@ static void edge_close(struct tty_struct *tty,
    usb_kill_urb(edge_port->write_urb);

    if (edge_port->write_urb) {
    - /* if this urb had a transfer buffer already (old transfer) free it */
    + /* if this urb had a transfer buffer already
    + (old transfer) free it */
    kfree(edge_port->write_urb->transfer_buffer);
    usb_free_urb(edge_port->write_urb);
    edge_port->write_urb = NULL;
    @@ -1122,14 +1198,14 @@ static void edge_close(struct tty_struct *tty,
    edge_port->txfifo.fifo = NULL;

    dbg("%s exited", __func__);
    -}
    +}

    /************************************************** ***************************
    * SerialWrite
    - * this function is called by the tty driver when data should be written to
    - * the port.
    - * If successful, we return the number of bytes written, otherwise we return
    - * a negative error number.
    + * this function is called by the tty driver when data should be written
    + * to the port.
    + * If successful, we return the number of bytes written, otherwise we
    + * return a negative error number.
    ************************************************** ***************************/
    static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
    const unsigned char *data, int count)
    @@ -1147,66 +1223,76 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
    if (edge_port == NULL)
    return -ENODEV;

    - // get a pointer to the Tx fifo
    + /* get a pointer to the Tx fifo */
    fifo = &edge_port->txfifo;

    spin_lock_irqsave(&edge_port->ep_lock, flags);

    - // calculate number of bytes to put in fifo
    - copySize = min ((unsigned int)count, (edge_port->txCredits - fifo->count));
    + /* calculate number of bytes to put in fifo */
    + copySize = min((unsigned int)count,
    + (edge_port->txCredits - fifo->count));

    - dbg("%s(%d) of %d byte(s) Fifo room %d -- will copy %d bytes", __func__,
    - port->number, count, edge_port->txCredits - fifo->count, copySize);
    + dbg("%s(%d) of %d byte(s) Fifo room %d -- will copy %d bytes",
    + __func__, port->number, count,
    + edge_port->txCredits - fifo->count, copySize);

    - /* catch writes of 0 bytes which the tty driver likes to give us, and when txCredits is empty */
    + /* catch writes of 0 bytes which the tty driver likes to give us,
    + and when txCredits is empty */
    if (copySize == 0) {
    dbg("%s - copySize = Zero", __func__);
    goto finish_write;
    }

    - // queue the data
    - // since we can never overflow the buffer we do not have to check for full condition
    -
    - // the copy is done is two parts -- first fill to the end of the buffer
    - // then copy the reset from the start of the buffer
    -
    + /* queue the data
    + * since we can never overflow the buffer we do not have to check for a
    + * full condition
    + *
    + * the copy is done is two parts -- first fill to the end of the buffer
    + * then copy the reset from the start of the buffer
    + */
    bytesleft = fifo->size - fifo->head;
    - firsthalf = min (bytesleft, copySize);
    - dbg("%s - copy %d bytes of %d into fifo ", __func__, firsthalf, bytesleft);
    + firsthalf = min(bytesleft, copySize);
    + dbg("%s - copy %d bytes of %d into fifo ", __func__,
    + firsthalf, bytesleft);

    /* now copy our data */
    memcpy(&fifo->fifo[fifo->head], data, firsthalf);
    - usb_serial_debug_data(debug, &port->dev, __func__, firsthalf, &fifo->fifo[fifo->head]);
    + usb_serial_debug_data(debug, &port->dev, __func__,
    + firsthalf, &fifo->fifo[fifo->head]);

    - // update the index and size
    + /* update the index and size */
    fifo->head += firsthalf;
    fifo->count += firsthalf;

    - // wrap the index
    - if (fifo->head == fifo->size) {
    + /* wrap the index */
    + if (fifo->head == fifo->size)
    fifo->head = 0;
    - }

    secondhalf = copySize-firsthalf;

    if (secondhalf) {
    dbg("%s - copy rest of data %d", __func__, secondhalf);
    memcpy(&fifo->fifo[fifo->head], &data[firsthalf], secondhalf);
    - usb_serial_debug_data(debug, &port->dev, __func__, secondhalf, &fifo->fifo[fifo->head]);
    - // update the index and size
    + usb_serial_debug_data(debug, &port->dev, __func__,
    + secondhalf, &fifo->fifo[fifo->head]);
    + /* update the index and size */
    fifo->count += secondhalf;
    fifo->head += secondhalf;
    - // No need to check for wrap since we can not get to end of fifo in this part
    + /* No need to check for wrap since we can not get to end of
    + * the fifo in this part
    + */
    }

    finish_write:
    spin_unlock_irqrestore(&edge_port->ep_lock, flags);

    - send_more_port_data((struct edgeport_serial *)usb_get_serial_data(port->serial), edge_port);
    + send_more_port_data((struct edgeport_serial *)
    + usb_get_serial_data(port->serial), edge_port);

    - dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __func__, copySize, edge_port->txCredits, fifo->count);
    + dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __func__,
    + copySize, edge_port->txCredits, fifo->count);

    - return copySize;
    + return copySize;
    }


    @@ -1223,7 +1309,8 @@ finish_write:
    * can transmit more.
    *
    ************************************************** **********************/
    -static void send_more_port_data(struct edgeport_serial *edge_serial, struct edgeport_port *edge_port)
    +static void send_more_port_data(struct edgeport_serial *edge_serial,
    + struct edgeport_port *edge_port)
    {
    struct TxFifo *fifo = &edge_port->txfifo;
    struct urb *urb;
    @@ -1242,67 +1329,78 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
    if (edge_port->write_in_progress ||
    !edge_port->open ||
    (fifo->count == 0)) {
    - dbg("%s(%d) EXIT - fifo %d, PendingWrite = %d", __func__, edge_port->port->number, fifo->count, edge_port->write_in_progress);
    + dbg("%s(%d) EXIT - fifo %d, PendingWrite = %d",
    + __func__, edge_port->port->number,
    + fifo->count, edge_port->write_in_progress);
    goto exit_send;
    }

    - // since the amount of data in the fifo will always fit into the
    - // edgeport buffer we do not need to check the write length
    -
    - // Do we have enough credits for this port to make it worthwhile
    - // to bother queueing a write. If it's too small, say a few bytes,
    - // it's better to wait for more credits so we can do a larger
    - // write.
    - if (edge_port->txCredits < EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(edge_port->maxTxCredits,EDGE_FW_BULK_MAX_PACKET_SIZE)) {
    - dbg("%s(%d) Not enough credit - fifo %d TxCredit %d", __func__, edge_port->port->number, fifo->count, edge_port->txCredits );
    + /* since the amount of data in the fifo will always fit into the
    + * edgeport buffer we do not need to check the write length
    + *
    + * Do we have enough credits for this port to make it worthwhile
    + * to bother queueing a write. If it's too small, say a few bytes,
    + * it's better to wait for more credits so we can do a larger write.
    + */
    + if (edge_port->txCredits < EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(edge_port->maxTxCredits, EDGE_FW_BULK_MAX_PACKET_SIZE)) {
    + dbg("%s(%d) Not enough credit - fifo %d TxCredit %d",
    + __func__, edge_port->port->number, fifo->count,
    + edge_port->txCredits);
    goto exit_send;
    }

    - // lock this write
    + /* lock this write */
    edge_port->write_in_progress = true;

    - // get a pointer to the write_urb
    + /* get a pointer to the write_urb */
    urb = edge_port->write_urb;

    /* make sure transfer buffer is freed */
    kfree(urb->transfer_buffer);
    urb->transfer_buffer = NULL;

    - /* build the data header for the buffer and port that we are about to send out */
    + /* build the data header for the buffer and port that we are about
    + to send out */
    count = fifo->count;
    - buffer = kmalloc (count+2, GFP_ATOMIC);
    + buffer = kmalloc(count+2, GFP_ATOMIC);
    if (buffer == NULL) {
    - dev_err(&edge_port->port->dev, "%s - no more kernel memory...\n", __func__);
    + dev_err(&edge_port->port->dev,
    + "%s - no more kernel memory...\n", __func__);
    edge_port->write_in_progress = false;
    goto exit_send;
    }
    - buffer[0] = IOSP_BUILD_DATA_HDR1 (edge_port->port->number - edge_port->port->serial->minor, count);
    - buffer[1] = IOSP_BUILD_DATA_HDR2 (edge_port->port->number - edge_port->port->serial->minor, count);
    + buffer[0] = IOSP_BUILD_DATA_HDR1(edge_port->port->number
    + - edge_port->port->serial->minor, count);
    + buffer[1] = IOSP_BUILD_DATA_HDR2(edge_port->port->number
    + - edge_port->port->serial->minor, count);

    /* now copy our data */
    bytesleft = fifo->size - fifo->tail;
    - firsthalf = min (bytesleft, count);
    + firsthalf = min(bytesleft, count);
    memcpy(&buffer[2], &fifo->fifo[fifo->tail], firsthalf);
    fifo->tail += firsthalf;
    fifo->count -= firsthalf;
    - if (fifo->tail == fifo->size) {
    + if (fifo->tail == fifo->size)
    fifo->tail = 0;
    - }

    secondhalf = count-firsthalf;
    if (secondhalf) {
    - memcpy(&buffer[2+firsthalf], &fifo->fifo[fifo->tail], secondhalf);
    + memcpy(&buffer[2+firsthalf], &fifo->fifo[fifo->tail],
    + secondhalf);
    fifo->tail += secondhalf;
    fifo->count -= secondhalf;
    }

    if (count)
    - usb_serial_debug_data(debug, &edge_port->port->dev, __func__, count, &buffer[2]);
    + usb_serial_debug_data(debug, &edge_port->port->dev,
    + __func__, count, &buffer[2]);

    /* fill up the urb with all of our data and submit it */
    - usb_fill_bulk_urb (urb, edge_serial->serial->dev,
    - usb_sndbulkpipe(edge_serial->serial->dev, edge_serial->bulk_out_endpoint),
    - buffer, count+2, edge_bulk_out_data_callback, edge_port);
    + usb_fill_bulk_urb(urb, edge_serial->serial->dev,
    + usb_sndbulkpipe(edge_serial->serial->dev,
    + edge_serial->bulk_out_endpoint),
    + buffer, count+2,
    + edge_bulk_out_data_callback, edge_port);

    /* decrement the number of credits we have by the number we just sent */
    edge_port->txCredits -= count;
    @@ -1312,14 +1410,17 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
    status = usb_submit_urb(urb, GFP_ATOMIC);
    if (status) {
    /* something went wrong */
    - dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", __func__, status);
    + dev_err(&edge_port->port->dev,
    + "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n",
    + __func__, status);
    edge_port->write_in_progress = false;

    /* revert the credits as something bad happened. */
    edge_port->txCredits += count;
    edge_port->icount.tx -= count;
    }
    - dbg("%s wrote %d byte(s) TxCredit %d, Fifo %d", __func__, count, edge_port->txCredits, fifo->count);
    + dbg("%s wrote %d byte(s) TxCredit %d, Fifo %d",
    + __func__, count, edge_port->txCredits, fifo->count);

    exit_send:
    spin_unlock_irqrestore(&edge_port->ep_lock, flags);
    @@ -1328,11 +1429,10 @@ exit_send:

    /************************************************** ***************************
    * edge_write_room
    - * this function is called by the tty driver when it wants to know how many
    - * bytes of data we can accept for a specific port.
    - * If successful, we return the amount of room that we have for this port
    - * (the txCredits),
    - * Otherwise we return a negative error number.
    + * this function is called by the tty driver when it wants to know how
    + * many bytes of data we can accept for a specific port. If successful,
    + * we return the amount of room that we have for this port (the txCredits)
    + * otherwise we return a negative error number.
    ************************************************** ***************************/
    static int edge_write_room(struct tty_struct *tty)
    {
    @@ -1355,7 +1455,7 @@ static int edge_write_room(struct tty_struct *tty)
    return -EINVAL;
    }

    - // total of both buffers is still txCredit
    + /* total of both buffers is still txCredit */
    spin_lock_irqsave(&edge_port->ep_lock, flags);
    room = edge_port->txCredits - edge_port->txfifo.count;
    spin_unlock_irqrestore(&edge_port->ep_lock, flags);
    @@ -1367,11 +1467,11 @@ static int edge_write_room(struct tty_struct *tty)

    /************************************************** ***************************
    * edge_chars_in_buffer
    - * this function is called by the tty driver when it wants to know how many
    - * bytes of data we currently have outstanding in the port (data that has
    - * been written, but hasn't made it out the port yet)
    - * If successful, we return the number of bytes left to be written in the
    - * system,
    + * this function is called by the tty driver when it wants to know how
    + * many bytes of data we currently have outstanding in the port (data that
    + * has been written, but hasn't made it out the port yet)
    + * If successful, we return the number of bytes left to be written in the
    + * system,
    * Otherwise we return a negative error number.
    ************************************************** ***************************/
    static int edge_chars_in_buffer(struct tty_struct *tty)
    @@ -1394,10 +1494,12 @@ static int edge_chars_in_buffer(struct tty_struct *tty)
    }

    spin_lock_irqsave(&edge_port->ep_lock, flags);
    - num_chars = edge_port->maxTxCredits - edge_port->txCredits + edge_port->txfifo.count;
    + num_chars = edge_port->maxTxCredits - edge_port->txCredits +
    + edge_port->txfifo.count;
    spin_unlock_irqrestore(&edge_port->ep_lock, flags);
    if (num_chars) {
    - dbg("%s(port %d) - returns %d", __func__, port->number, num_chars);
    + dbg("%s(port %d) - returns %d", __func__,
    + port->number, num_chars);
    }

    return num_chars;
    @@ -1428,19 +1530,18 @@ static void edge_throttle(struct tty_struct *tty)
    /* if we are implementing XON/XOFF, send the stop character */
    if (I_IXOFF(tty)) {
    unsigned char stop_char = STOP_CHAR(tty);
    - status = edge_write (tty, port, &stop_char, 1);
    - if (status <= 0) {
    + status = edge_write(tty, port, &stop_char, 1);
    + if (status <= 0)
    return;
    - }
    }

    /* if we are implementing RTS/CTS, toggle that line */
    if (tty->termios->c_cflag & CRTSCTS) {
    edge_port->shadowMCR &= ~MCR_RTS;
    - status = send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR);
    - if (status != 0) {
    + status = send_cmd_write_uart_register(edge_port, MCR,
    + edge_port->shadowMCR);
    + if (status != 0)
    return;
    - }
    }

    return;
    @@ -1449,8 +1550,8 @@ static void edge_throttle(struct tty_struct *tty)

    /************************************************** ***************************
    * edge_unthrottle
    - * this function is called by the tty driver when it wants to resume the data
    - * being read from the port (called after SerialThrottle is called)
    + * this function is called by the tty driver when it wants to resume the
    + * data being read from the port (called after SerialThrottle is called)
    ************************************************** ***************************/
    static void edge_unthrottle(struct tty_struct *tty)
    {
    @@ -1478,14 +1579,16 @@ static void edge_unthrottle(struct tty_struct *tty)
    /* if we are implementing RTS/CTS, toggle that line */
    if (tty->termios->c_cflag & CRTSCTS) {
    edge_port->shadowMCR |= MCR_RTS;
    - send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR);
    + send_cmd_write_uart_register(edge_port, MCR,
    + edge_port->shadowMCR);
    }
    }


    /************************************************** ***************************
    * SerialSetTermios
    - * this function is called by the tty driver when it wants to change the termios structure
    + * this function is called by the tty driver when it wants to change
    + * the termios structure
    ************************************************** ***************************/
    static void edge_set_termios(struct tty_struct *tty,
    struct usb_serial_port *port, struct ktermios *old_termios)
    @@ -1522,9 +1625,10 @@ static void edge_set_termios(struct tty_struct *tty,
    * release the bus after transmitting. This must be done when
    * the transmit shift register is empty, not be done when the
    * transmit holding register is empty. This functionality
    - * allows an RS485 driver to be written in user space.
    + * allows an RS485 driver to be written in user space.
    ************************************************** ***************************/
    -static int get_lsr_info(struct edgeport_port *edge_port, unsigned int __user *value)
    +static int get_lsr_info(struct edgeport_port *edge_port,
    + unsigned int __user *value)
    {
    unsigned int result = 0;
    unsigned long flags;
    @@ -1542,7 +1646,8 @@ static int get_lsr_info(struct edgeport_port *edge_port, unsigned int __user *va
    return 0;
    }

    -static int edge_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear)
    +static int edge_tiocmset(struct tty_struct *tty, struct file *file,
    + unsigned int set, unsigned int clear)
    {
    struct usb_serial_port *port = tty->driver_data;
    struct edgeport_port *edge_port = usb_get_serial_port_data(port);
    @@ -1597,7 +1702,8 @@ static int edge_tiocmget(struct tty_struct *tty, struct file *file)
    return result;
    }

    -static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct __user *retinfo)
    +static int get_serial_info(struct edgeport_port *edge_port,
    + struct serial_struct __user *retinfo)
    {
    struct serial_struct tmp;

    @@ -1640,60 +1746,61 @@ static int edge_ioctl(struct tty_struct *tty, struct file *file,
    dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);

    switch (cmd) {
    - case TIOCSERGETLSR:
    - dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
    - return get_lsr_info(edge_port, (unsigned int __user *) arg);
    -
    - case TIOCGSERIAL:
    - dbg("%s (%d) TIOCGSERIAL", __func__, port->number);
    - return get_serial_info(edge_port, (struct serial_struct __user *) arg);
    -
    - case TIOCMIWAIT:
    - dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
    - cprev = edge_port->icount;
    - while (1) {
    - prepare_to_wait(&edge_port->delta_msr_wait, &wait, TASK_INTERRUPTIBLE);
    - schedule();
    - finish_wait(&edge_port->delta_msr_wait, &wait);
    - /* see if a signal did it */
    - if (signal_pending(current))
    - return -ERESTARTSYS;
    - cnow = edge_port->icount;
    - if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
    - cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
    - return -EIO; /* no change => error */
    - if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
    - ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
    - ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
    - ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
    - return 0;
    - }
    - cprev = cnow;
    + case TIOCSERGETLSR:
    + dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
    + return get_lsr_info(edge_port, (unsigned int __user *) arg);
    +
    + case TIOCGSERIAL:
    + dbg("%s (%d) TIOCGSERIAL", __func__, port->number);
    + return get_serial_info(edge_port, (struct serial_struct __user *) arg);
    +
    + case TIOCMIWAIT:
    + dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
    + cprev = edge_port->icount;
    + while (1) {
    + prepare_to_wait(&edge_port->delta_msr_wait,
    + &wait, TASK_INTERRUPTIBLE);
    + schedule();
    + finish_wait(&edge_port->delta_msr_wait, &wait);
    + /* see if a signal did it */
    + if (signal_pending(current))
    + return -ERESTARTSYS;
    + cnow = edge_port->icount;
    + if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
    + cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
    + return -EIO; /* no change => error */
    + if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
    + ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
    + ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
    + ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) {
    + return 0;
    }
    - /* NOTREACHED */
    - break;
    + cprev = cnow;
    + }
    + /* NOTREACHED */
    + break;

    - case TIOCGICOUNT:
    - cnow = edge_port->icount;
    - memset(&icount, 0, sizeof(icount));
    - icount.cts = cnow.cts;
    - icount.dsr = cnow.dsr;
    - icount.rng = cnow.rng;
    - icount.dcd = cnow.dcd;
    - icount.rx = cnow.rx;
    - icount.tx = cnow.tx;
    - icount.frame = cnow.frame;
    - icount.overrun = cnow.overrun;
    - icount.parity = cnow.parity;
    - icount.brk = cnow.brk;
    - icount.buf_overrun = cnow.buf_overrun;
    -
    - dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, port->number, icount.rx, icount.tx );
    - if (copy_to_user((void __user *)arg, &icount, sizeof(icount)))
    - return -EFAULT;
    - return 0;
    + case TIOCGICOUNT:
    + cnow = edge_port->icount;
    + memset(&icount, 0, sizeof(icount));
    + icount.cts = cnow.cts;
    + icount.dsr = cnow.dsr;
    + icount.rng = cnow.rng;
    + icount.dcd = cnow.dcd;
    + icount.rx = cnow.rx;
    + icount.tx = cnow.tx;
    + icount.frame = cnow.frame;
    + icount.overrun = cnow.overrun;
    + icount.parity = cnow.parity;
    + icount.brk = cnow.brk;
    + icount.buf_overrun = cnow.buf_overrun;
    +
    + dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d",
    + __func__, port->number, icount.rx, icount.tx);
    + if (copy_to_user((void __user *)arg, &icount, sizeof(icount)))
    + return -EFAULT;
    + return 0;
    }
    -
    return -ENOIOCTLCMD;
    }

    @@ -1702,7 +1809,7 @@ static int edge_ioctl(struct tty_struct *tty, struct file *file,
    * SerialBreak
    * this function sends a break to the port
    ************************************************** ***************************/
    -static void edge_break (struct tty_struct *tty, int break_state)
    +static void edge_break(struct tty_struct *tty, int break_state)
    {
    struct usb_serial_port *port = tty->driver_data;
    struct edgeport_port *edge_port = usb_get_serial_port_data(port);
    @@ -1716,9 +1823,9 @@ static void edge_break (struct tty_struct *tty, int break_state)
    edge_port->chaseResponsePending = true;

    dbg("%s - Sending IOSP_CMD_CHASE_PORT", __func__);
    - status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0);
    + status = send_iosp_ext_cmd(edge_port, IOSP_CMD_CHASE_PORT, 0);
    if (status == 0) {
    - // block until chase finished
    + /* block until chase finished */
    block_until_chase_response(edge_port);
    } else {
    edge_port->chaseResponsePending = false;
    @@ -1730,14 +1837,16 @@ static void edge_break (struct tty_struct *tty, int break_state)
    (edge_serial->epic_descriptor.Supports.IOSPSetClrBreak))) {
    if (break_state == -1) {
    dbg("%s - Sending IOSP_CMD_SET_BREAK", __func__);
    - status = send_iosp_ext_cmd (edge_port, IOSP_CMD_SET_BREAK, 0);
    + status = send_iosp_ext_cmd(edge_port,
    + IOSP_CMD_SET_BREAK, 0);
    } else {
    dbg("%s - Sending IOSP_CMD_CLEAR_BREAK", __func__);
    - status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CLEAR_BREAK, 0);
    - }
    - if (status) {
    - dbg("%s - error sending break set/clear command.", __func__);
    + status = send_iosp_ext_cmd(edge_port,
    + IOSP_CMD_CLEAR_BREAK, 0);
    }
    + if (status)
    + dbg("%s - error sending break set/clear command.",
    + __func__);
    }

    return;
    @@ -1748,7 +1857,8 @@ static void edge_break (struct tty_struct *tty, int break_state)
    * process_rcvd_data
    * this function handles the data received on the bulk in pipe.
    ************************************************** ***************************/
    -static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned char * buffer, __u16 bufferLength)
    +static void process_rcvd_data(struct edgeport_serial *edge_serial,
    + unsigned char *buffer, __u16 bufferLength)
    {
    struct usb_serial_port *port;
    struct edgeport_port *edge_port;
    @@ -1769,105 +1879,123 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha
    lastBufferLength = bufferLength;

    switch (edge_serial->rxState) {
    - case EXPECT_HDR1:
    - edge_serial->rxHeader1 = *buffer;
    - ++buffer;
    - --bufferLength;
    + case EXPECT_HDR1:
    + edge_serial->rxHeader1 = *buffer;
    + ++buffer;
    + --bufferLength;

    - if (bufferLength == 0) {
    - edge_serial->rxState = EXPECT_HDR2;
    + if (bufferLength == 0) {
    + edge_serial->rxState = EXPECT_HDR2;
    + break;
    + }
    + /* otherwise, drop on through */
    + case EXPECT_HDR2:
    + edge_serial->rxHeader2 = *buffer;
    + ++buffer;
    + --bufferLength;
    +
    + dbg("%s - Hdr1=%02X Hdr2=%02X", __func__,
    + edge_serial->rxHeader1, edge_serial->rxHeader2);
    + /* Process depending on whether this header is
    + * data or status */
    +
    + if (IS_CMD_STAT_HDR(edge_serial->rxHeader1)) {
    + /* Decode this status header and go to
    + * EXPECT_HDR1 (if we can process the status
    + * with only 2 bytes), or go to EXPECT_HDR3 to
    + * get the third byte. */
    + edge_serial->rxPort =
    + IOSP_GET_HDR_PORT(edge_serial->rxHeader1);
    + edge_serial->rxStatusCode =
    + IOSP_GET_STATUS_CODE(
    + edge_serial->rxHeader1);
    +
    + if (!IOSP_STATUS_IS_2BYTE(
    + edge_serial->rxStatusCode)) {
    + /* This status needs additional bytes.
    + * Save what we have and then wait for
    + * more data.
    + */
    + edge_serial->rxStatusParam
    + = edge_serial->rxHeader2;
    + edge_serial->rxState = EXPECT_HDR3;
    break;
    }
    - /* otherwise, drop on through */
    -
    - case EXPECT_HDR2:
    - edge_serial->rxHeader2 = *buffer;
    - ++buffer;
    - --bufferLength;
    -
    - dbg("%s - Hdr1=%02X Hdr2=%02X", __func__, edge_serial->rxHeader1, edge_serial->rxHeader2);
    -
    - // Process depending on whether this header is
    - // data or status
    -
    - if (IS_CMD_STAT_HDR(edge_serial->rxHeader1)) {
    - // Decode this status header and goto EXPECT_HDR1 (if we
    - // can process the status with only 2 bytes), or goto
    - // EXPECT_HDR3 to get the third byte.
    -
    - edge_serial->rxPort = IOSP_GET_HDR_PORT(edge_serial->rxHeader1);
    - edge_serial->rxStatusCode = IOSP_GET_STATUS_CODE(edge_serial->rxHeader1);
    -
    - if (!IOSP_STATUS_IS_2BYTE(edge_serial->rxStatusCode)) {
    - // This status needs additional bytes. Save what we have
    - // and then wait for more data.
    - edge_serial->rxStatusParam = edge_serial->rxHeader2;
    -
    - edge_serial->rxState = EXPECT_HDR3;
    - break;
    - }
    + /* We have all the header bytes, process the
    + status now */
    + process_rcvd_status(edge_serial,
    + edge_serial->rxHeader2, 0);
    + edge_serial->rxState = EXPECT_HDR1;
    + break;
    + } else {
    + edge_serial->rxPort =
    + IOSP_GET_HDR_PORT(edge_serial->rxHeader1);
    + edge_serial->rxBytesRemaining =
    + IOSP_GET_HDR_DATA_LEN(
    + edge_serial->rxHeader1,
    + edge_serial->rxHeader2);
    + dbg("%s - Data for Port %u Len %u",
    + __func__,
    + edge_serial->rxPort,
    + edge_serial->rxBytesRemaining);
    +
    + /* ASSERT(DevExt->RxPort < DevExt->NumPorts);
    + * ASSERT(DevExt->RxBytesRemaining <
    + * IOSP_MAX_DATA_LENGTH);
    + */

    - // We have all the header bytes, process the status now
    - process_rcvd_status (edge_serial, edge_serial->rxHeader2, 0);
    - edge_serial->rxState = EXPECT_HDR1;
    + if (bufferLength == 0) {
    + edge_serial->rxState = EXPECT_DATA;
    break;
    - } else {
    - edge_serial->rxPort = IOSP_GET_HDR_PORT(edge_serial->rxHeader1);
    - edge_serial->rxBytesRemaining = IOSP_GET_HDR_DATA_LEN(edge_serial->rxHeader1, edge_serial->rxHeader2);
    -
    - dbg("%s - Data for Port %u Len %u", __func__, edge_serial->rxPort, edge_serial->rxBytesRemaining);
    -
    - //ASSERT( DevExt->RxPort < DevExt->NumPorts );
    - //ASSERT( DevExt->RxBytesRemaining < IOSP_MAX_DATA_LENGTH );
    -
    - if (bufferLength == 0 ) {
    - edge_serial->rxState = EXPECT_DATA;
    - break;
    - }
    - // Else, drop through
    }
    + /* Else, drop through */
    + }
    + case EXPECT_DATA: /* Expect data */
    + if (bufferLength < edge_serial->rxBytesRemaining) {
    + rxLen = bufferLength;
    + /* Expect data to start next buffer */
    + edge_serial->rxState = EXPECT_DATA;
    + } else {
    + /* BufLen >= RxBytesRemaining */
    + rxLen = edge_serial->rxBytesRemaining;
    + /* Start another header next time */
    + edge_serial->rxState = EXPECT_HDR1;
    + }

    - case EXPECT_DATA: // Expect data
    -
    - if (bufferLength < edge_serial->rxBytesRemaining) {
    - rxLen = bufferLength;
    - edge_serial->rxState = EXPECT_DATA; // Expect data to start next buffer
    - } else {
    - // BufLen >= RxBytesRemaining
    - rxLen = edge_serial->rxBytesRemaining;
    - edge_serial->rxState = EXPECT_HDR1; // Start another header next time
    - }
    + bufferLength -= rxLen;
    + edge_serial->rxBytesRemaining -= rxLen;

    - bufferLength -= rxLen;
    - edge_serial->rxBytesRemaining -= rxLen;
    -
    - /* spit this data back into the tty driver if this port is open */
    - if (rxLen) {
    - port = edge_serial->serial->port[edge_serial->rxPort];
    - edge_port = usb_get_serial_port_data(port);
    - if (edge_port->open) {
    - tty = edge_port->port->port.tty;
    - if (tty) {
    - dbg("%s - Sending %d bytes to TTY for port %d", __func__, rxLen, edge_serial->rxPort);
    - edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen);
    - }
    - edge_port->icount.rx += rxLen;
    + /* spit this data back into the tty driver if this
    + port is open */
    + if (rxLen) {
    + port = edge_serial->serial->port[
    + edge_serial->rxPort];
    + edge_port = usb_get_serial_port_data(port);
    + if (edge_port->open) {
    + tty = edge_port->port->port.tty;
    + if (tty) {
    + dbg("%s - Sending %d bytes to TTY for port %d",
    + __func__, rxLen, edge_serial->rxPort);
    + edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen);
    }
    - buffer += rxLen;
    + edge_port->icount.rx += rxLen;
    }
    + buffer += rxLen;
    + }
    + break;

    - break;
    -
    - case EXPECT_HDR3: // Expect 3rd byte of status header
    - edge_serial->rxHeader3 = *buffer;
    - ++buffer;
    - --bufferLength;
    -
    - // We have all the header bytes, process the status now
    - process_rcvd_status (edge_serial, edge_serial->rxStatusParam, edge_serial->rxHeader3);
    - edge_serial->rxState = EXPECT_HDR1;
    - break;
    -
    + case EXPECT_HDR3: /* Expect 3rd byte of status header */
    + edge_serial->rxHeader3 = *buffer;
    + ++buffer;
    + --bufferLength;
    +
    + /* We have all the header bytes, process the
    + status now */
    + process_rcvd_status(edge_serial,
    + edge_serial->rxStatusParam,
    + edge_serial->rxHeader3);
    + edge_serial->rxState = EXPECT_HDR1;
    + break;
    }
    }
    }
    @@ -1875,9 +2003,11 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha

    /************************************************** ***************************
    * process_rcvd_status
    - * this function handles the any status messages received on the bulk in pipe.
    + * this function handles the any status messages received on the
    + * bulk in pipe.
    ************************************************** ***************************/
    -static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2, __u8 byte3)
    +static void process_rcvd_status(struct edgeport_serial *edge_serial,
    + __u8 byte2, __u8 byte3)
    {
    struct usb_serial_port *port;
    struct edgeport_port *edge_port;
    @@ -1887,7 +2017,9 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
    port = edge_serial->serial->port[edge_serial->rxPort];
    edge_port = usb_get_serial_port_data(port);
    if (edge_port == NULL) {
    - dev_err(&edge_serial->serial->dev->dev, "%s - edge_port == NULL for port %d\n", __func__, edge_serial->rxPort);
    + dev_err(&edge_serial->serial->dev->dev,
    + "%s - edge_port == NULL for port %d\n",
    + __func__, edge_serial->rxPort);
    return;
    }

    @@ -1895,22 +2027,28 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2

    if (code == IOSP_EXT_STATUS) {
    switch (byte2) {
    - case IOSP_EXT_STATUS_CHASE_RSP:
    - // we want to do EXT status regardless of port open/closed
    - dbg("%s - Port %u EXT CHASE_RSP Data = %02x", __func__, edge_serial->rxPort, byte3 );
    - // Currently, the only EXT_STATUS is Chase, so process here instead of one more call
    - // to one more subroutine. If/when more EXT_STATUS, there'll be more work to do.
    - // Also, we currently clear flag and close the port regardless of content of above's Byte3.
    - // We could choose to do something else when Byte3 says Timeout on Chase from Edgeport,
    - // like wait longer in block_until_chase_response, but for now we don't.
    - edge_port->chaseResponsePending = false;
    - wake_up (&edge_port->wait_chase);
    - return;
    + case IOSP_EXT_STATUS_CHASE_RSP:
    + /* we want to do EXT status regardless of port
    + * open/closed */
    + dbg("%s - Port %u EXT CHASE_RSP Data = %02x",
    + __func__, edge_serial->rxPort, byte3);
    + /* Currently, the only EXT_STATUS is Chase, so process
    + * here instead of one more call to one more subroutine
    + * If/when more EXT_STATUS, there'll be more work to do
    + * Also, we currently clear flag and close the port
    + * regardless of content of above's Byte3.
    + * We could choose to do something else when Byte3 says
    + * Timeout on Chase from Edgeport, like wait longer in
    + * block_until_chase_response, but for now we don't.
    + */
    + edge_port->chaseResponsePending = false;
    + wake_up(&edge_port->wait_chase);
    + return;

    - case IOSP_EXT_STATUS_RX_CHECK_RSP:
    - dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n", __func__, edge_serial->rxPort, byte3 );
    - //Port->RxCheckRsp = true;
    - return;
    + case IOSP_EXT_STATUS_RX_CHECK_RSP:
    + dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n", __func__, edge_serial->rxPort, byte3);
    + /* Port->RxCheckRsp = true; */
    + return;
    }
    }

    @@ -1918,12 +2056,14 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
    edge_port->txCredits = GET_TX_BUFFER_SIZE(byte3);
    edge_port->maxTxCredits = edge_port->txCredits;
    dbg("%s - Port %u Open Response Inital MSR = %02x TxBufferSize = %d", __func__, edge_serial->rxPort, byte2, edge_port->txCredits);
    - handle_new_msr (edge_port, byte2);
    + handle_new_msr(edge_port, byte2);

    - /* send the current line settings to the port so we are in sync with any further termios calls */
    + /* send the current line settings to the port so we are
    + in sync with any further termios calls */
    /* FIXME: locking on tty */
    if (edge_port->port->port.tty)
    - change_port_settings(edge_port->port->port.tty, edge_port, edge_port->port->port.tty->termios);
    + change_port_settings(edge_port->port->port.tty,
    + edge_port, edge_port->port->port.tty->termios);

    /* we have completed the open */
    edge_port->openPending = false;
    @@ -1932,45 +2072,49 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
    return;
    }

    - // If port is closed, silently discard all rcvd status. We can
    - // have cases where buffered status is received AFTER the close
    - // port command is sent to the Edgeport.
    - if (!edge_port->open || edge_port->closePending) {
    + /* If port is closed, silently discard all rcvd status. We can
    + * have cases where buffered status is received AFTER the close
    + * port command is sent to the Edgeport.
    + */
    + if (!edge_port->open || edge_port->closePending)
    return;
    - }

    switch (code) {
    - // Not currently sent by Edgeport
    - case IOSP_STATUS_LSR:
    - dbg("%s - Port %u LSR Status = %02x", __func__, edge_serial->rxPort, byte2);
    - handle_new_lsr(edge_port, false, byte2, 0);
    - break;
    + /* Not currently sent by Edgeport */
    + case IOSP_STATUS_LSR:
    + dbg("%s - Port %u LSR Status = %02x",
    + __func__, edge_serial->rxPort, byte2);
    + handle_new_lsr(edge_port, false, byte2, 0);
    + break;

    - case IOSP_STATUS_LSR_DATA:
    - dbg("%s - Port %u LSR Status = %02x, Data = %02x", __func__, edge_serial->rxPort, byte2, byte3);
    - // byte2 is LSR Register
    - // byte3 is broken data byte
    - handle_new_lsr(edge_port, true, byte2, byte3);
    - break;
    - //
    - // case IOSP_EXT_4_STATUS:
    - // dbg("%s - Port %u LSR Status = %02x Data = %02x", __func__, edge_serial->rxPort, byte2, byte3);
    - // break;
    - //
    - case IOSP_STATUS_MSR:
    - dbg("%s - Port %u MSR Status = %02x", __func__, edge_serial->rxPort, byte2);
    -
    - // Process this new modem status and generate appropriate
    - // events, etc, based on the new status. This routine
    - // also saves the MSR in Port->ShadowMsr.
    - handle_new_msr(edge_port, byte2);
    - break;
    + case IOSP_STATUS_LSR_DATA:
    + dbg("%s - Port %u LSR Status = %02x, Data = %02x",
    + __func__, edge_serial->rxPort, byte2, byte3);
    + /* byte2 is LSR Register */
    + /* byte3 is broken data byte */
    + handle_new_lsr(edge_port, true, byte2, byte3);
    + break;
    + /*
    + * case IOSP_EXT_4_STATUS:
    + * dbg("%s - Port %u LSR Status = %02x Data = %02x",
    + * __func__, edge_serial->rxPort, byte2, byte3);
    + * break;
    + */
    + case IOSP_STATUS_MSR:
    + dbg("%s - Port %u MSR Status = %02x",
    + __func__, edge_serial->rxPort, byte2);
    + /*
    + * Process this new modem status and generate appropriate
    + * events, etc, based on the new status. This routine
    + * also saves the MSR in Port->ShadowMsr.
    + */
    + handle_new_msr(edge_port, byte2);
    + break;

    - default:
    - dbg("%s - Unrecognized IOSP status code %u\n", __func__, code);
    - break;
    + default:
    + dbg("%s - Unrecognized IOSP status code %u\n", __func__, code);
    + break;
    }
    -
    return;
    }

    @@ -1979,7 +2123,8 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
    * edge_tty_recv
    * this function passes data on to the tty flip buffer
    ************************************************** ***************************/
    -static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned char *data, int length)
    +static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
    + unsigned char *data, int length)
    {
    int cnt;

    @@ -1988,7 +2133,7 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned c
    if (cnt < length) {
    dev_err(dev, "%s - dropping data, %d bytes lost\n",
    __func__, length - cnt);
    - if(cnt == 0)
    + if (cnt == 0)
    break;
    }
    tty_insert_flip_string(tty, data, cnt);
    @@ -2010,22 +2155,19 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr)

    dbg("%s %02x", __func__, newMsr);

    - if (newMsr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) {
    + if (newMsr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR |
    + EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) {
    icount = &edge_port->icount;

    /* update input line counters */
    - if (newMsr & EDGEPORT_MSR_DELTA_CTS) {
    + if (newMsr & EDGEPORT_MSR_DELTA_CTS)
    icount->cts++;
    - }
    - if (newMsr & EDGEPORT_MSR_DELTA_DSR) {
    + if (newMsr & EDGEPORT_MSR_DELTA_DSR)
    icount->dsr++;
    - }
    - if (newMsr & EDGEPORT_MSR_DELTA_CD) {
    + if (newMsr & EDGEPORT_MSR_DELTA_CD)
    icount->dcd++;
    - }
    - if (newMsr & EDGEPORT_MSR_DELTA_RI) {
    + if (newMsr & EDGEPORT_MSR_DELTA_RI)
    icount->rng++;
    - }
    wake_up_interruptible(&edge_port->delta_msr_wait);
    }

    @@ -2040,42 +2182,41 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr)
    * handle_new_lsr
    * this function handles any change to the lsr register for a port.
    ************************************************** ***************************/
    -static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, __u8 lsr, __u8 data)
    +static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData,
    + __u8 lsr, __u8 data)
    {
    - __u8 newLsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK));
    - struct async_icount *icount;
    + __u8 newLsr = (__u8) (lsr & (__u8)
    + (LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK));
    + struct async_icount *icount;

    dbg("%s - %02x", __func__, newLsr);

    edge_port->shadowLSR = lsr;

    if (newLsr & LSR_BREAK) {
    - //
    - // Parity and Framing errors only count if they
    - // occur exclusive of a break being
    - // received.
    - //
    + /*
    + * Parity and Framing errors only count if they
    + * occur exclusive of a break being
    + * received.
    + */
    newLsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK);
    }

    /* Place LSR data byte into Rx buffer */
    if (lsrData && edge_port->port->port.tty)
    - edge_tty_recv(&edge_port->port->dev, edge_port->port->port.tty, &data, 1);
    + edge_tty_recv(&edge_port->port->dev,
    + edge_port->port->port.tty, &data, 1);

    /* update input line counters */
    icount = &edge_port->icount;
    - if (newLsr & LSR_BREAK) {
    + if (newLsr & LSR_BREAK)
    icount->brk++;
    - }
    - if (newLsr & LSR_OVER_ERR) {
    + if (newLsr & LSR_OVER_ERR)
    icount->overrun++;
    - }
    - if (newLsr & LSR_PAR_ERR) {
    + if (newLsr & LSR_PAR_ERR)
    icount->parity++;
    - }
    - if (newLsr & LSR_FRM_ERR) {
    + if (newLsr & LSR_FRM_ERR)
    icount->frame++;
    - }

    return;
    }
    @@ -2083,12 +2224,13 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, __u8 l

    /************************************************** **************************
    * sram_write
    - * writes a number of bytes to the Edgeport device's sram starting at the
    + * writes a number of bytes to the Edgeport device's sram starting at the
    * given address.
    * If successful returns the number of bytes written, otherwise it returns
    * a negative error number of the problem.
    ************************************************** **************************/
    -static int sram_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, __u8 *data)
    +static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr,
    + __u16 length, __u8 *data)
    {
    int result;
    __u16 current_length;
    @@ -2096,32 +2238,37 @@ static int sram_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u

    dbg("%s - %x, %x, %d", __func__, extAddr, addr, length);

    - transfer_buffer = kmalloc (64, GFP_KERNEL);
    + transfer_buffer = kmalloc(64, GFP_KERNEL);
    if (!transfer_buffer) {
    - dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, 64);
    + dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n",
    + __func__, 64);
    return -ENOMEM;
    }

    /* need to split these writes up into 64 byte chunks */
    result = 0;
    while (length > 0) {
    - if (length > 64) {
    + if (length > 64)
    current_length = 64;
    - } else {
    + else
    current_length = length;
    - }
    -// dbg("%s - writing %x, %x, %d", __func__, extAddr, addr, current_length);
    - memcpy (transfer_buffer, data, current_length);
    - result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), USB_REQUEST_ION_WRITE_RAM,
    - 0x40, addr, extAddr, transfer_buffer, current_length, 300);
    +
    +/* dbg("%s - writing %x, %x, %d", __func__,
    + extAddr, addr, current_length); */
    + memcpy(transfer_buffer, data, current_length);
    + result = usb_control_msg(serial->dev,
    + usb_sndctrlpipe(serial->dev, 0),
    + USB_REQUEST_ION_WRITE_RAM,
    + 0x40, addr, extAddr, transfer_buffer,
    + current_length, 300);
    if (result < 0)
    break;
    length -= current_length;
    addr += current_length;
    data += current_length;
    - }
    + }

    - kfree (transfer_buffer);
    + kfree(transfer_buffer);
    return result;
    }

    @@ -2133,40 +2280,46 @@ static int sram_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u
    * If successful returns the number of bytes written, otherwise it returns
    * a negative error number of the problem.
    ************************************************** **************************/
    -static int rom_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, __u8 *data)
    +static int rom_write(struct usb_serial *serial, __u16 extAddr, __u16 addr,
    + __u16 length, __u8 *data)
    {
    int result;
    __u16 current_length;
    unsigned char *transfer_buffer;

    -// dbg("%s - %x, %x, %d", __func__, extAddr, addr, length);
    +/* dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); */

    - transfer_buffer = kmalloc (64, GFP_KERNEL);
    + transfer_buffer = kmalloc(64, GFP_KERNEL);
    if (!transfer_buffer) {
    - dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, 64);
    + dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n",
    + __func__, 64);
    return -ENOMEM;
    }

    /* need to split these writes up into 64 byte chunks */
    result = 0;
    while (length > 0) {
    - if (length > 64) {
    + if (length > 64)
    current_length = 64;
    - } else {
    + else
    current_length = length;
    - }
    -// dbg("%s - writing %x, %x, %d", __func__, extAddr, addr, current_length);
    - memcpy (transfer_buffer, data, current_length);
    - result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), USB_REQUEST_ION_WRITE_ROM,
    - 0x40, addr, extAddr, transfer_buffer, current_length, 300);
    +
    +/* dbg("%s - writing %x, %x, %d", __func__,
    + extAddr, addr, current_length); */
    + memcpy(transfer_buffer, data, current_length);
    + result = usb_control_msg(serial->dev,
    + usb_sndctrlpipe(serial->dev, 0),
    + USB_REQUEST_ION_WRITE_ROM, 0x40,
    + addr, extAddr,
    + transfer_buffer, current_length, 300);
    if (result < 0)
    break;
    length -= current_length;
    addr += current_length;
    data += current_length;
    - }
    + }

    - kfree (transfer_buffer);
    + kfree(transfer_buffer);
    return result;
    }

    @@ -2178,7 +2331,8 @@ static int rom_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u1
    * If successful returns the number of bytes read, otherwise it returns
    * a negative error number of the problem.
    ************************************************** **************************/
    -static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, __u8 *data)
    +static int rom_read(struct usb_serial *serial, __u16 extAddr,
    + __u16 addr, __u16 length, __u8 *data)
    {
    int result;
    __u16 current_length;
    @@ -2186,32 +2340,36 @@ static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16

    dbg("%s - %x, %x, %d", __func__, extAddr, addr, length);

    - transfer_buffer = kmalloc (64, GFP_KERNEL);
    + transfer_buffer = kmalloc(64, GFP_KERNEL);
    if (!transfer_buffer) {
    - dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, 64);
    + dev_err(&serial->dev->dev,
    + "%s - kmalloc(%d) failed.\n", __func__, 64);
    return -ENOMEM;
    }

    /* need to split these reads up into 64 byte chunks */
    result = 0;
    while (length > 0) {
    - if (length > 64) {
    + if (length > 64)
    current_length = 64;
    - } else {
    + else
    current_length = length;
    - }
    -// dbg("%s - %x, %x, %d", __func__, extAddr, addr, current_length);
    - result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0), USB_REQUEST_ION_READ_ROM,
    - 0xC0, addr, extAddr, transfer_buffer, current_length, 300);
    +/* dbg("%s - %x, %x, %d", __func__,
    + extAddr, addr, current_length); */
    + result = usb_control_msg(serial->dev,
    + usb_rcvctrlpipe(serial->dev, 0),
    + USB_REQUEST_ION_READ_ROM,
    + 0xC0, addr, extAddr, transfer_buffer,
    + current_length, 300);
    if (result < 0)
    break;
    - memcpy (data, transfer_buffer, current_length);
    + memcpy(data, transfer_buffer, current_length);
    length -= current_length;
    addr += current_length;
    data += current_length;
    - }
    + }

    - kfree (transfer_buffer);
    + kfree(transfer_buffer);
    return result;
    }

    @@ -2220,7 +2378,8 @@ static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16
    * send_iosp_ext_cmd
    * Is used to send a IOSP message to the Edgeport device
    ************************************************** **************************/
    -static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u8 param)
    +static int send_iosp_ext_cmd(struct edgeport_port *edge_port,
    + __u8 command, __u8 param)
    {
    unsigned char *buffer;
    unsigned char *currentCommand;
    @@ -2229,19 +2388,20 @@ static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u

    dbg("%s - %d, %d", __func__, command, param);

    - buffer = kmalloc (10, GFP_ATOMIC);
    + buffer = kmalloc(10, GFP_ATOMIC);
    if (!buffer) {
    - dev_err(&edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __func__, 10);
    + dev_err(&edge_port->port->dev,
    + "%s - kmalloc(%d) failed.\n", __func__, 10);
    return -ENOMEM;
    }

    currentCommand = buffer;

    - MAKE_CMD_EXT_CMD (&currentCommand, &length,
    - edge_port->port->number - edge_port->port->serial->minor,
    - command, param);
    + MAKE_CMD_EXT_CMD(&currentCommand, &length,
    + edge_port->port->number - edge_port->port->serial->minor,
    + command, param);

    - status = write_cmd_usb (edge_port, buffer, length);
    + status = write_cmd_usb(edge_port, buffer, length);
    if (status) {
    /* something bad happened, let's free up the memory */
    kfree(buffer);
    @@ -2255,43 +2415,50 @@ static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u
    * write_cmd_usb
    * this function writes the given buffer out to the bulk write endpoint.
    ************************************************** ***************************/
    -static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer, int length)
    +static int write_cmd_usb(struct edgeport_port *edge_port,
    + unsigned char *buffer, int length)
    {
    - struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial);
    + struct edgeport_serial *edge_serial =
    + usb_get_serial_data(edge_port->port->serial);
    int status = 0;
    struct urb *urb;
    int timeout;

    - usb_serial_debug_data(debug, &edge_port->port->dev, __func__, length, buffer);
    + usb_serial_debug_data(debug, &edge_port->port->dev,
    + __func__, length, buffer);

    /* Allocate our next urb */
    - urb = usb_alloc_urb (0, GFP_ATOMIC);
    + urb = usb_alloc_urb(0, GFP_ATOMIC);
    if (!urb)
    return -ENOMEM;

    atomic_inc(&CmdUrbs);
    - dbg("%s - ALLOCATE URB %p (outstanding %d)", __func__, urb, atomic_read(&CmdUrbs));
    + dbg("%s - ALLOCATE URB %p (outstanding %d)",
    + __func__, urb, atomic_read(&CmdUrbs));

    - usb_fill_bulk_urb (urb, edge_serial->serial->dev,
    - usb_sndbulkpipe(edge_serial->serial->dev, edge_serial->bulk_out_endpoint),
    - buffer, length, edge_bulk_out_cmd_callback, edge_port);
    + usb_fill_bulk_urb(urb, edge_serial->serial->dev,
    + usb_sndbulkpipe(edge_serial->serial->dev,
    + edge_serial->bulk_out_endpoint),
    + buffer, length, edge_bulk_out_cmd_callback, edge_port);

    edge_port->commandPending = true;
    status = usb_submit_urb(urb, GFP_ATOMIC);

    if (status) {
    /* something went wrong */
    - dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write command) failed, status = %d\n", __func__, status);
    + dev_err(&edge_port->port->dev,
    + "%s - usb_submit_urb(write command) failed, status = %d\n",
    + __func__, status);
    usb_kill_urb(urb);
    usb_free_urb(urb);
    atomic_dec(&CmdUrbs);
    return status;
    }

    - // wait for command to finish
    + /* wait for command to finish */
    timeout = COMMAND_TIMEOUT;
    #if 0
    - wait_event (&edge_port->wait_command, !edge_port->commandPending);
    + wait_event(&edge_port->wait_command, !edge_port->commandPending);

    if (edge_port->commandPending) {
    /* command timed out */
    @@ -2308,15 +2475,18 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer
    * this function sends the proper command to change the baud rate of the
    * specified port.
    ************************************************** ***************************/
    -static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRate)
    +static int send_cmd_write_baud_rate(struct edgeport_port *edge_port,
    + int baudRate)
    {
    - struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial);
    + struct edgeport_serial *edge_serial =
    + usb_get_serial_data(edge_port->port->serial);
    unsigned char *cmdBuffer;
    unsigned char *currCmd;
    int cmdLen = 0;
    int divisor;
    int status;
    - unsigned char number = edge_port->port->number - edge_port->port->serial->minor;
    + unsigned char number =
    + edge_port->port->number - edge_port->port->serial->minor;

    if (edge_serial->is_epic &&
    !edge_serial->epic_descriptor.Supports.IOSPSetBaudRate) {
    @@ -2325,36 +2495,40 @@ static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRa
    return 0;
    }

    - dbg("%s - port = %d, baud = %d", __func__, edge_port->port->number, baudRate);
    + dbg("%s - port = %d, baud = %d", __func__,
    + edge_port->port->number, baudRate);

    - status = calc_baud_rate_divisor (baudRate, &divisor);
    + status = calc_baud_rate_divisor(baudRate, &divisor);
    if (status) {
    - dev_err(&edge_port->port->dev, "%s - bad baud rate\n", __func__);
    + dev_err(&edge_port->port->dev, "%s - bad baud rate\n",
    + __func__);
    return status;
    }

    - // Alloc memory for the string of commands.
    - cmdBuffer = kmalloc (0x100, GFP_ATOMIC);
    + /* Alloc memory for the string of commands. */
    + cmdBuffer = kmalloc(0x100, GFP_ATOMIC);
    if (!cmdBuffer) {
    - dev_err(&edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __func__, 0x100);
    + dev_err(&edge_port->port->dev,
    + "%s - kmalloc(%d) failed.\n", __func__, 0x100);
    return -ENOMEM;
    }
    currCmd = cmdBuffer;

    - // Enable access to divisor latch
    - MAKE_CMD_WRITE_REG( &currCmd, &cmdLen, number, LCR, LCR_DL_ENABLE );
    + /* Enable access to divisor latch */
    + MAKE_CMD_WRITE_REG(&currCmd, &cmdLen, number, LCR, LCR_DL_ENABLE);

    - // Write the divisor itself
    - MAKE_CMD_WRITE_REG( &currCmd, &cmdLen, number, DLL, LOW8 (divisor) );
    - MAKE_CMD_WRITE_REG( &currCmd, &cmdLen, number, DLM, HIGH8(divisor) );
    + /* Write the divisor itself */
    + MAKE_CMD_WRITE_REG(&currCmd, &cmdLen, number, DLL, LOW8(divisor));
    + MAKE_CMD_WRITE_REG(&currCmd, &cmdLen, number, DLM, HIGH8(divisor));

    - // Restore original value to disable access to divisor latch
    - MAKE_CMD_WRITE_REG( &currCmd, &cmdLen, number, LCR, edge_port->shadowLCR);
    + /* Restore original value to disable access to divisor latch */
    + MAKE_CMD_WRITE_REG(&currCmd, &cmdLen, number, LCR,
    + edge_port->shadowLCR);

    - status = write_cmd_usb(edge_port, cmdBuffer, cmdLen );
    + status = write_cmd_usb(edge_port, cmdBuffer, cmdLen);
    if (status) {
    /* something bad happened, let's free up the memory */
    - kfree (cmdBuffer);
    + kfree(cmdBuffer);
    }

    return status;
    @@ -2366,7 +2540,7 @@ static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRa
    * this function calculates the proper baud rate divisor for the specified
    * baud rate.
    ************************************************** ***************************/
    -static int calc_baud_rate_divisor (int baudrate, int *divisor)
    +static int calc_baud_rate_divisor(int baudrate, int *divisor)
    {
    int i;
    __u16 custom;
    @@ -2375,17 +2549,17 @@ static int calc_baud_rate_divisor (int baudrate, int *divisor)
    dbg("%s - %d", __func__, baudrate);

    for (i = 0; i < ARRAY_SIZE(divisor_table); i++) {
    - if ( divisor_table[i].BaudRate == baudrate ) {
    + if (divisor_table[i].BaudRate == baudrate) {
    *divisor = divisor_table[i].Divisor;
    return 0;
    }
    }

    - // We have tried all of the standard baud rates
    - // lets try to calculate the divisor for this baud rate
    - // Make sure the baud rate is reasonable
    + /* We have tried all of the standard baud rates
    + * lets try to calculate the divisor for this baud rate
    + * Make sure the baud rate is reasonable */
    if (baudrate > 50 && baudrate < 230400) {
    - // get divisor
    + /* get divisor */
    custom = (__u16)((230400L + baudrate/2) / baudrate);

    *divisor = custom;
    @@ -2400,17 +2574,20 @@ static int calc_baud_rate_divisor (int baudrate, int *divisor)

    /************************************************** ***************************
    * send_cmd_write_uart_register
    - * this function builds up a uart register message and sends to to the device.
    + * this function builds up a uart register message and sends to to the device.
    ************************************************** ***************************/
    -static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 regNum, __u8 regValue)
    +static int send_cmd_write_uart_register(struct edgeport_port *edge_port,
    + __u8 regNum, __u8 regValue)
    {
    - struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial);
    + struct edgeport_serial *edge_serial =
    + usb_get_serial_data(edge_port->port->serial);
    unsigned char *cmdBuffer;
    unsigned char *currCmd;
    unsigned long cmdLen = 0;
    int status;

    - dbg("%s - write to %s register 0x%02x", (regNum == MCR) ? "MCR" : "LCR", __func__, regValue);
    + dbg("%s - write to %s register 0x%02x",
    + (regNum == MCR) ? "MCR" : "LCR", __func__, regValue);

    if (edge_serial->is_epic &&
    !edge_serial->epic_descriptor.Supports.IOSPWriteMCR &&
    @@ -2422,27 +2599,26 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r
    if (edge_serial->is_epic &&
    !edge_serial->epic_descriptor.Supports.IOSPWriteLCR &&
    regNum == LCR) {
    - dbg ("SendCmdWriteUartReg - Not writing to LCR Register");
    + dbg("SendCmdWriteUartReg - Not writing to LCR Register");
    return 0;
    }

    - // Alloc memory for the string of commands.
    - cmdBuffer = kmalloc (0x10, GFP_ATOMIC);
    - if (cmdBuffer == NULL ) {
    + /* Alloc memory for the string of commands. */
    + cmdBuffer = kmalloc(0x10, GFP_ATOMIC);
    + if (cmdBuffer == NULL)
    return -ENOMEM;
    - }

    currCmd = cmdBuffer;

    - // Build a cmd in the buffer to write the given register
    - MAKE_CMD_WRITE_REG (&currCmd, &cmdLen,
    - edge_port->port->number - edge_port->port->serial->minor,
    - regNum, regValue);
    + /* Build a cmd in the buffer to write the given register */
    + MAKE_CMD_WRITE_REG(&currCmd, &cmdLen,
    + edge_port->port->number - edge_port->port->serial->minor,
    + regNum, regValue);

    status = write_cmd_usb(edge_port, cmdBuffer, cmdLen);
    if (status) {
    /* something bad happened, let's free up the memory */
    - kfree (cmdBuffer);
    + kfree(cmdBuffer);
    }

    return status;
    @@ -2451,14 +2627,15 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r

    /************************************************** ***************************
    * change_port_settings
    - * This routine is called to set the UART on the device to match the specified
    - * new settings.
    + * This routine is called to set the UART on the device to match the
    + * specified new settings.
    ************************************************** ***************************/

    static void change_port_settings(struct tty_struct *tty,
    struct edgeport_port *edge_port, struct ktermios *old_termios)
    {
    - struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial);
    + struct edgeport_serial *edge_serial =
    + usb_get_serial_data(edge_port->port->serial);
    int baud;
    unsigned cflag;
    __u8 mask = 0xff;
    @@ -2480,11 +2657,23 @@ static void change_port_settings(struct tty_struct *tty,
    cflag = tty->termios->c_cflag;

    switch (cflag & CSIZE) {
    - case CS5: lData = LCR_BITS_5; mask = 0x1f; dbg("%s - data bits = 5", __func__); break;
    - case CS6: lData = LCR_BITS_6; mask = 0x3f; dbg("%s - data bits = 6", __func__); break;
    - case CS7: lData = LCR_BITS_7; mask = 0x7f; dbg("%s - data bits = 7", __func__); break;
    - default:
    - case CS8: lData = LCR_BITS_8; dbg("%s - data bits = 8", __func__); break;
    + case CS5:
    + lData = LCR_BITS_5; mask = 0x1f;
    + dbg("%s - data bits = 5", __func__);
    + break;
    + case CS6:
    + lData = LCR_BITS_6; mask = 0x3f;
    + dbg("%s - data bits = 6", __func__);
    + break;
    + case CS7:
    + lData = LCR_BITS_7; mask = 0x7f;
    + dbg("%s - data bits = 7", __func__);
    + break;
    + default:
    + case CS8:
    + lData = LCR_BITS_8;
    + dbg("%s - data bits = 8", __func__);
    + break;
    }

    lParity = LCR_PAR_NONE;
    @@ -2526,7 +2715,8 @@ static void change_port_settings(struct tty_struct *tty,
    dbg("%s - RTS/CTS is disabled", __func__);
    }

    - /* if we are implementing XON/XOFF, set the start and stop character in the device */
    + /* if we are implementing XON/XOFF, set the start and stop character
    + in the device */
    if (I_IXOFF(tty) || I_IXON(tty)) {
    unsigned char stop_char = STOP_CHAR(tty);
    unsigned char start_char = START_CHAR(tty);
    @@ -2534,14 +2724,17 @@ static void change_port_settings(struct tty_struct *tty,
    if ((!edge_serial->is_epic) ||
    ((edge_serial->is_epic) &&
    (edge_serial->epic_descriptor.Supports.IOSPSetXChar))) {
    - send_iosp_ext_cmd(edge_port, IOSP_CMD_SET_XON_CHAR, start_char);
    - send_iosp_ext_cmd(edge_port, IOSP_CMD_SET_XOFF_CHAR, stop_char);
    + send_iosp_ext_cmd(edge_port,
    + IOSP_CMD_SET_XON_CHAR, start_char);
    + send_iosp_ext_cmd(edge_port,
    + IOSP_CMD_SET_XOFF_CHAR, stop_char);
    }

    /* if we are implementing INBOUND XON/XOFF */
    if (I_IXOFF(tty)) {
    rxFlow |= IOSP_RX_FLOW_XON_XOFF;
    - dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", __func__, start_char, stop_char);
    + dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x",
    + __func__, start_char, stop_char);
    } else {
    dbg("%s - INBOUND XON/XOFF is disabled", __func__);
    }
    @@ -2549,7 +2742,8 @@ static void change_port_settings(struct tty_struct *tty,
    /* if we are implementing OUTBOUND XON/XOFF */
    if (I_IXON(tty)) {
    txFlow |= IOSP_TX_FLOW_XON_XOFF;
    - dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", __func__, start_char, stop_char);
    + dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x",
    + __func__, start_char, stop_char);
    } else {
    dbg("%s - OUTBOUND XON/XOFF is disabled", __func__);
    }
    @@ -2572,20 +2766,20 @@ static void change_port_settings(struct tty_struct *tty,
    edge_port->validDataMask = mask;

    /* Send the updated LCR value to the EdgePort */
    - status = send_cmd_write_uart_register(edge_port, LCR, edge_port->shadowLCR);
    - if (status != 0) {
    + status = send_cmd_write_uart_register(edge_port, LCR,
    + edge_port->shadowLCR);
    + if (status != 0)
    return;
    - }

    /* set up the MCR register and send it to the EdgePort */
    edge_port->shadowMCR = MCR_MASTER_IE;
    - if (cflag & CBAUD) {
    + if (cflag & CBAUD)
    edge_port->shadowMCR |= (MCR_DTR | MCR_RTS);
    - }
    - status = send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR);
    - if (status != 0) {
    +
    + status = send_cmd_write_uart_register(edge_port, MCR,
    + edge_port->shadowMCR);
    + if (status != 0)
    return;
    - }

    /* Determine divisor based on baud rate */
    baud = tty_get_baud_rate(tty);
    @@ -2595,7 +2789,7 @@ static void change_port_settings(struct tty_struct *tty,
    }

    dbg("%s - baud rate = %d", __func__, baud);
    - status = send_cmd_write_baud_rate (edge_port, baud);
    + status = send_cmd_write_baud_rate(edge_port, baud);
    if (status == -1) {
    /* Speed change was not possible - put back the old speed */
    baud = tty_termios_baud_rate(old_termios);
    @@ -2612,7 +2806,8 @@ static void change_port_settings(struct tty_struct *tty,
    * ASCII range, but it's only for debugging...
    * NOTE: expects the unicode in LE format
    ************************************************** **************************/
    -static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unicode_size)
    +static void unicode_to_ascii(char *string, int buflen,
    + __le16 *unicode, int unicode_size)
    {
    int i;

    @@ -2631,75 +2826,99 @@ static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unic

    /************************************************** **************************
    * get_manufacturing_desc
    - * reads in the manufacturing descriptor and stores it into the serial
    + * reads in the manufacturing descriptor and stores it into the serial
    * structure.
    ************************************************** **************************/
    -static void get_manufacturing_desc (struct edgeport_serial *edge_serial)
    +static void get_manufacturing_desc(struct edgeport_serial *edge_serial)
    {
    int response;

    dbg("getting manufacturer descriptor");

    - response = rom_read (edge_serial->serial, (EDGE_MANUF_DESC_ADDR & 0xffff0000) >> 16,
    - (__u16)(EDGE_MANUF_DESC_ADDR & 0x0000ffff), EDGE_MANUF_DESC_LEN,
    - (__u8 *)(&edge_serial->manuf_descriptor));
    + response = rom_read(edge_serial->serial,
    + (EDGE_MANUF_DESC_ADDR & 0xffff0000) >> 16,
    + (__u16)(EDGE_MANUF_DESC_ADDR & 0x0000ffff),
    + EDGE_MANUF_DESC_LEN,
    + (__u8 *)(&edge_serial->manuf_descriptor));

    - if (response < 1) {
    - dev_err(&edge_serial->serial->dev->dev, "error in getting manufacturer descriptor\n");
    - } else {
    + if (response < 1)
    + dev_err(&edge_serial->serial->dev->dev,
    + "error in getting manufacturer descriptor\n");
    + else {
    char string[30];
    dbg("**Manufacturer Descriptor");
    - dbg(" RomSize: %dK", edge_serial->manuf_descriptor.RomSize);
    - dbg(" RamSize: %dK", edge_serial->manuf_descriptor.RamSize);
    - dbg(" CpuRev: %d", edge_serial->manuf_descriptor.CpuRev);
    - dbg(" BoardRev: %d", edge_serial->manuf_descriptor.BoardRev);
    - dbg(" NumPorts: %d", edge_serial->manuf_descriptor.NumPorts);
    - dbg(" DescDate: %d/%d/%d", edge_serial->manuf_descriptor.DescDate[0], edge_serial->manuf_descriptor.DescDate[1], edge_serial->manuf_descriptor.DescDate[2]+1900);
    + dbg(" RomSize: %dK",
    + edge_serial->manuf_descriptor.RomSize);
    + dbg(" RamSize: %dK",
    + edge_serial->manuf_descriptor.RamSize);
    + dbg(" CpuRev: %d",
    + edge_serial->manuf_descriptor.CpuRev);
    + dbg(" BoardRev: %d",
    + edge_serial->manuf_descriptor.BoardRev);
    + dbg(" NumPorts: %d",
    + edge_serial->manuf_descriptor.NumPorts);
    + dbg(" DescDate: %d/%d/%d",
    + edge_serial->manuf_descriptor.DescDate[0],
    + edge_serial->manuf_descriptor.DescDate[1],
    + edge_serial->manuf_descriptor.DescDate[2]+1900);
    unicode_to_ascii(string, sizeof(string),
    - edge_serial->manuf_descriptor.SerialNumber,
    - edge_serial->manuf_descriptor.SerNumLength/2);
    + edge_serial->manuf_descriptor.SerialNumber,
    + edge_serial->manuf_descriptor.SerNumLength/2);
    dbg(" SerialNumber: %s", string);
    unicode_to_ascii(string, sizeof(string),
    - edge_serial->manuf_descriptor.AssemblyNumber,
    - edge_serial->manuf_descriptor.AssemblyNumLength/2);
    + edge_serial->manuf_descriptor.AssemblyNumber,
    + edge_serial->manuf_descriptor.AssemblyNumLength/2);
    dbg(" AssemblyNumber: %s", string);
    unicode_to_ascii(string, sizeof(string),
    edge_serial->manuf_descriptor.OemAssyNumber,
    edge_serial->manuf_descriptor.OemAssyNumLength/2);
    dbg(" OemAssyNumber: %s", string);
    - dbg(" UartType: %d", edge_serial->manuf_descriptor.UartType);
    - dbg(" IonPid: %d", edge_serial->manuf_descriptor.IonPid);
    - dbg(" IonConfig: %d", edge_serial->manuf_descriptor.IonConfig);
    + dbg(" UartType: %d",
    + edge_serial->manuf_descriptor.UartType);
    + dbg(" IonPid: %d",
    + edge_serial->manuf_descriptor.IonPid);
    + dbg(" IonConfig: %d",
    + edge_serial->manuf_descriptor.IonConfig);
    }
    }


    /************************************************** **************************
    * get_boot_desc
    - * reads in the bootloader descriptor and stores it into the serial
    + * reads in the bootloader descriptor and stores it into the serial
    * structure.
    ************************************************** **************************/
    -static void get_boot_desc (struct edgeport_serial *edge_serial)
    +static void get_boot_desc(struct edgeport_serial *edge_serial)
    {
    int response;

    dbg("getting boot descriptor");

    - response = rom_read (edge_serial->serial, (EDGE_BOOT_DESC_ADDR & 0xffff0000) >> 16,
    - (__u16)(EDGE_BOOT_DESC_ADDR & 0x0000ffff), EDGE_BOOT_DESC_LEN,
    - (__u8 *)(&edge_serial->boot_descriptor));
    + response = rom_read(edge_serial->serial,
    + (EDGE_BOOT_DESC_ADDR & 0xffff0000) >> 16,
    + (__u16)(EDGE_BOOT_DESC_ADDR & 0x0000ffff),
    + EDGE_BOOT_DESC_LEN,
    + (__u8 *)(&edge_serial->boot_descriptor));

    - if (response < 1) {
    - dev_err(&edge_serial->serial->dev->dev, "error in getting boot descriptor\n");
    - } else {
    + if (response < 1)
    + dev_err(&edge_serial->serial->dev->dev,
    + "error in getting boot descriptor\n");
    + else {
    dbg("**Boot Descriptor:");
    - dbg(" BootCodeLength: %d", le16_to_cpu(edge_serial->boot_descriptor.BootCodeLength));
    - dbg(" MajorVersion: %d", edge_serial->boot_descriptor.MajorVersion);
    - dbg(" MinorVersion: %d", edge_serial->boot_descriptor.MinorVersion);
    - dbg(" BuildNumber: %d", le16_to_cpu(edge_serial->boot_descriptor.BuildNumber));
    - dbg(" Capabilities: 0x%x", le16_to_cpu(edge_serial->boot_descriptor.Capabilities));
    - dbg(" UConfig0: %d", edge_serial->boot_descriptor.UConfig0);
    - dbg(" UConfig1: %d", edge_serial->boot_descriptor.UConfig1);
    + dbg(" BootCodeLength: %d",
    + le16_to_cpu(edge_serial->boot_descriptor.BootCodeLength));
    + dbg(" MajorVersion: %d",
    + edge_serial->boot_descriptor.MajorVersion);
    + dbg(" MinorVersion: %d",
    + edge_serial->boot_descriptor.MinorVersion);
    + dbg(" BuildNumber: %d",
    + le16_to_cpu(edge_serial->boot_descriptor.BuildNumber));
    + dbg(" Capabilities: 0x%x",
    + le16_to_cpu(edge_serial->boot_descriptor.Capabilities));
    + dbg(" UConfig0: %d",
    + edge_serial->boot_descriptor.UConfig0);
    + dbg(" UConfig1: %d",
    + edge_serial->boot_descriptor.UConfig1);
    }
    }

    @@ -2708,7 +2927,7 @@ static void get_boot_desc (struct edgeport_serial *edge_serial)
    * load_application_firmware
    * This is called to load the application firmware to the device
    ************************************************** **************************/
    -static void load_application_firmware (struct edgeport_serial *edge_serial)
    +static void load_application_firmware(struct edgeport_serial *edge_serial)
    {
    struct edge_firmware_image_record *record;
    unsigned char *firmware;
    @@ -2718,53 +2937,60 @@ static void load_application_firmware (struct edgeport_serial *edge_serial)


    switch (edge_serial->product_info.iDownloadFile) {
    - case EDGE_DOWNLOAD_FILE_I930:
    - dbg("downloading firmware version (930) %d.%d.%d",
    - OperationalCodeImageVersion_GEN1.MajorVersion,
    - OperationalCodeImageVersion_GEN1.MinorVersion,
    - OperationalCodeImageVersion_GEN1.BuildNumber);
    - firmware = &OperationalCodeImage_GEN1[0];
    - FirmwareImage = &OperationalCodeImage_GEN1[0];
    - ImageSize = sizeof(OperationalCodeImage_GEN1);
    - break;
    + case EDGE_DOWNLOAD_FILE_I930:
    + dbg("downloading firmware version (930) %d.%d.%d",
    + OperationalCodeImageVersion_GEN1.MajorVersion,
    + OperationalCodeImageVersion_GEN1.MinorVersion,
    + OperationalCodeImageVersion_GEN1.BuildNumber);
    + firmware = &OperationalCodeImage_GEN1[0];
    + FirmwareImage = &OperationalCodeImage_GEN1[0];
    + ImageSize = sizeof(OperationalCodeImage_GEN1);
    + break;

    - case EDGE_DOWNLOAD_FILE_80251:
    - dbg("downloading firmware version (80251) %d.%d.%d",
    - OperationalCodeImageVersion_GEN2.MajorVersion,
    - OperationalCodeImageVersion_GEN2.MinorVersion,
    - OperationalCodeImageVersion_GEN2.BuildNumber);
    - firmware = &OperationalCodeImage_GEN2[0];
    - FirmwareImage = &OperationalCodeImage_GEN2[0];
    - ImageSize = sizeof(OperationalCodeImage_GEN2);
    - break;
    + case EDGE_DOWNLOAD_FILE_80251:
    + dbg("downloading firmware version (80251) %d.%d.%d",
    + OperationalCodeImageVersion_GEN2.MajorVersion,
    + OperationalCodeImageVersion_GEN2.MinorVersion,
    + OperationalCodeImageVersion_GEN2.BuildNumber);
    + firmware = &OperationalCodeImage_GEN2[0];
    + FirmwareImage = &OperationalCodeImage_GEN2[0];
    + ImageSize = sizeof(OperationalCodeImage_GEN2);
    + break;

    - case EDGE_DOWNLOAD_FILE_NONE:
    - dbg ("No download file specified, skipping download\n");
    - return;
    + case EDGE_DOWNLOAD_FILE_NONE:
    + dbg("No download file specified, skipping download\n");
    + return;

    - default:
    - return;
    + default:
    + return;
    }

    -
    for (; {
    record = (struct edge_firmware_image_record *)firmware;
    - response = sram_write (edge_serial->serial, le16_to_cpu(record->ExtAddr), le16_to_cpu(record->Addr), le16_to_cpu(record->Len), &record->Data[0]);
    + response = sram_write(edge_serial->serial,
    + le16_to_cpu(record->ExtAddr),
    + le16_to_cpu(record->Addr),
    + le16_to_cpu(record->Len),
    + &record->Data[0]);
    if (response < 0) {
    - dev_err(&edge_serial->serial->dev->dev, "sram_write failed (%x, %x, %d)\n", le16_to_cpu(record->ExtAddr), le16_to_cpu(record->Addr), le16_to_cpu(record->Len));
    + dev_err(&edge_serial->serial->dev->dev,
    + "sram_write failed (%x, %x, %d)\n",
    + le16_to_cpu(record->ExtAddr),
    + le16_to_cpu(record->Addr),
    + le16_to_cpu(record->Len));
    break;
    }
    - firmware += sizeof (struct edge_firmware_image_record) + le16_to_cpu(record->Len);
    - if (firmware >= &FirmwareImage[ImageSize]) {
    + firmware += sizeof(struct edge_firmware_image_record)
    + + le16_to_cpu(record->Len);
    + if (firmware >= &FirmwareImage[ImageSize])
    break;
    - }
    }

    dbg("sending exec_dl_code");
    - response = usb_control_msg (edge_serial->serial->dev,
    - usb_sndctrlpipe(edge_serial->serial->dev, 0),
    - USB_REQUEST_ION_EXEC_DL_CODE,
    - 0x40, 0x4000, 0x0001, NULL, 0, 3000);
    + response = usb_control_msg(edge_serial->serial->dev,
    + usb_sndctrlpipe(edge_serial->serial->dev, 0),
    + USB_REQUEST_ION_EXEC_DL_CODE,
    + 0x40, 0x4000, 0x0001, NULL, 0, 3000);

    return;
    }
    @@ -2773,7 +2999,7 @@ static void load_application_firmware (struct edgeport_serial *edge_serial)
    /************************************************** **************************
    * edge_startup
    ************************************************** **************************/
    -static int edge_startup (struct usb_serial *serial)
    +static int edge_startup(struct usb_serial *serial)
    {
    struct edgeport_serial *edge_serial;
    struct edgeport_port *edge_port;
    @@ -2815,10 +3041,10 @@ static int edge_startup (struct usb_serial *serial)
    sizeof(struct edge_compatibility_bits));

    /* get the manufacturing descriptor for this device */
    - get_manufacturing_desc (edge_serial);
    + get_manufacturing_desc(edge_serial);

    /* get the boot descriptor */
    - get_boot_desc (edge_serial);
    + get_boot_desc(edge_serial);

    get_product_info(edge_serial);
    }
    @@ -2839,37 +3065,40 @@ static int edge_startup (struct usb_serial *serial)
    /* If not an EPiC device */
    if (!edge_serial->is_epic) {
    /* now load the application firmware into this device */
    - load_application_firmware (edge_serial);
    + load_application_firmware(edge_serial);

    dbg("%s - time 2 %ld", __func__, jiffies);

    /* Check current Edgeport EEPROM and update if necessary */
    - update_edgeport_E2PROM (edge_serial);
    + update_edgeport_E2PROM(edge_serial);

    dbg("%s - time 3 %ld", __func__, jiffies);

    /* set the configuration to use #1 */
    -// dbg("set_configuration 1");
    -// usb_set_configuration (dev, 1);
    +/* dbg("set_configuration 1"); */
    +/* usb_set_configuration (dev, 1); */
    }

    - /* we set up the pointers to the endpoints in the edge_open function,
    + /* we set up the pointers to the endpoints in the edge_open function,
    * as the structures aren't created yet. */

    /* set up our port private structures */
    for (i = 0; i < serial->num_ports; ++i) {
    - edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL);
    + edge_port = kmalloc(sizeof(struct edgeport_port), GFP_KERNEL);
    if (edge_port == NULL) {
    - dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__);
    + dev_err(&serial->dev->dev,
    + "%s - Out of memory\n", __func__);
    for (j = 0; j < i; ++j) {
    - kfree (usb_get_serial_port_data(serial->port[j]));
    - usb_set_serial_port_data(serial->port[j], NULL);
    + kfree(usb_get_serial_port_data(
    + serial->port[j]));
    + usb_set_serial_port_data(serial->port[j],
    + NULL);
    }
    usb_set_serial_data(serial, NULL);
    kfree(edge_serial);
    return -ENOMEM;
    }
    - memset (edge_port, 0, sizeof(struct edgeport_port));
    + memset(edge_port, 0, sizeof(struct edgeport_port));
    spin_lock_init(&edge_port->ep_lock);
    edge_port->port = serial->port[i];
    usb_set_serial_port_data(serial->port[i], edge_port);
    @@ -2878,14 +3107,16 @@ static int edge_startup (struct usb_serial *serial)
    response = 0;

    if (edge_serial->is_epic) {
    - /* EPIC thing, set up our interrupt polling now and our read urb, so
    - * that the device knows it really is connected. */
    + /* EPIC thing, set up our interrupt polling now and our read
    + * urb, so that the device knows it really is connected. */
    interrupt_in_found = bulk_in_found = bulk_out_found = false;
    - for (i = 0; i < serial->interface->altsetting[0].desc.bNumEndpoints; ++i) {
    + for (i = 0; i < serial->interface->altsetting[0]
    + .desc.bNumEndpoints; ++i) {
    struct usb_endpoint_descriptor *endpoint;
    int buffer_size;

    - endpoint = &serial->interface->altsetting[0].endpoint[i].desc;
    + endpoint = &serial->interface->altsetting[0].
    + endpoint[i].desc;
    buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
    if (!interrupt_in_found &&
    (usb_endpoint_is_int_in(endpoint))) {
    @@ -2893,58 +3124,67 @@ static int edge_startup (struct usb_serial *serial)
    dbg("found interrupt in");

    /* not set up yet, so do it now */
    - edge_serial->interrupt_read_urb = usb_alloc_urb(0, GFP_KERNEL);
    + edge_serial->interrupt_read_urb =
    + usb_alloc_urb(0, GFP_KERNEL);
    if (!edge_serial->interrupt_read_urb) {
    err("out of memory");
    return -ENOMEM;
    }
    - edge_serial->interrupt_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
    + edge_serial->interrupt_in_buffer =
    + kmalloc(buffer_size, GFP_KERNEL);
    if (!edge_serial->interrupt_in_buffer) {
    err("out of memory");
    usb_free_urb(edge_serial->interrupt_read_urb);
    return -ENOMEM;
    }
    - edge_serial->interrupt_in_endpoint = endpoint->bEndpointAddress;
    + edge_serial->interrupt_in_endpoint =
    + endpoint->bEndpointAddress;

    /* set up our interrupt urb */
    - usb_fill_int_urb(edge_serial->interrupt_read_urb,
    - dev,
    - usb_rcvintpipe(dev, endpoint->bEndpointAddress),
    - edge_serial->interrupt_in_buffer,
    - buffer_size,
    - edge_interrupt_callback,
    - edge_serial,
    - endpoint->bInterval);
    + usb_fill_int_urb(
    + edge_serial->interrupt_read_urb,
    + dev,
    + usb_rcvintpipe(dev,
    + endpoint->bEndpointAddress),
    + edge_serial->interrupt_in_buffer,
    + buffer_size,
    + edge_interrupt_callback,
    + edge_serial,
    + endpoint->bInterval);

    interrupt_in_found = true;
    }

    if (!bulk_in_found &&
    - (usb_endpoint_is_bulk_in(endpoint))) {
    + (usb_endpoint_is_bulk_in(endpoint))) {
    /* we found a bulk in endpoint */
    dbg("found bulk in");

    /* not set up yet, so do it now */
    - edge_serial->read_urb = usb_alloc_urb(0, GFP_KERNEL);
    + edge_serial->read_urb =
    + usb_alloc_urb(0, GFP_KERNEL);
    if (!edge_serial->read_urb) {
    err("out of memory");
    return -ENOMEM;
    }
    - edge_serial->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
    + edge_serial->bulk_in_buffer =
    + kmalloc(buffer_size, GFP_KERNEL);
    if (!edge_serial->bulk_in_buffer) {
    - err ("out of memory");
    + err("out of memory");
    usb_free_urb(edge_serial->read_urb);
    return -ENOMEM;
    }
    - edge_serial->bulk_in_endpoint = endpoint->bEndpointAddress;
    + edge_serial->bulk_in_endpoint =
    + endpoint->bEndpointAddress;

    /* set up our bulk in urb */
    usb_fill_bulk_urb(edge_serial->read_urb, dev,
    - usb_rcvbulkpipe(dev, endpoint->bEndpointAddress),
    - edge_serial->bulk_in_buffer,
    - le16_to_cpu(endpoint->wMaxPacketSize),
    - edge_bulk_in_callback,
    - edge_serial);
    + usb_rcvbulkpipe(dev,
    + endpoint->bEndpointAddress),
    + edge_serial->bulk_in_buffer,
    + le16_to_cpu(endpoint->wMaxPacketSize),
    + edge_bulk_in_callback,
    + edge_serial);
    bulk_in_found = true;
    }

    @@ -2952,21 +3192,24 @@ static int edge_startup (struct usb_serial *serial)
    (usb_endpoint_is_bulk_out(endpoint))) {
    /* we found a bulk out endpoint */
    dbg("found bulk out");
    - edge_serial->bulk_out_endpoint = endpoint->bEndpointAddress;
    + edge_serial->bulk_out_endpoint =
    + endpoint->bEndpointAddress;
    bulk_out_found = true;
    }
    }

    if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) {
    - err ("Error - the proper endpoints were not found!");
    + err("Error - the proper endpoints were not found!");
    return -ENODEV;
    }

    /* start interrupt read for this edgeport this interrupt will
    * continue as long as the edgeport is connected */
    - response = usb_submit_urb(edge_serial->interrupt_read_urb, GFP_KERNEL);
    + response = usb_submit_urb(edge_serial->interrupt_read_urb,
    + GFP_KERNEL);
    if (response)
    - err("%s - Error %d submitting control urb", __func__, response);
    + err("%s - Error %d submitting control urb",
    + __func__, response);
    }
    return response;
    }
    @@ -2976,7 +3219,7 @@ static int edge_startup (struct usb_serial *serial)
    * edge_shutdown
    * This function is called whenever the device is removed from the usb bus.
    ************************************************** **************************/
    -static void edge_shutdown (struct usb_serial *serial)
    +static void edge_shutdown(struct usb_serial *serial)
    {
    struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
    int i;
    @@ -2984,8 +3227,8 @@ static void edge_shutdown (struct usb_serial *serial)
    dbg("%s", __func__);

    /* stop reads and writes on all ports */
    - for (i=0; i < serial->num_ports; ++i) {
    - kfree (usb_get_serial_port_data(serial->port[i]));
    + for (i = 0; i < serial->num_ports; ++i) {
    + kfree(usb_get_serial_port_data(serial->port[i]));
    usb_set_serial_port_data(serial->port[i], NULL);
    }
    /* free up our endpoint stuff */
    @@ -3025,7 +3268,7 @@ static int __init edgeport_init(void)
    if (retval)
    goto failed_epic_device_register;
    retval = usb_register(&io_driver);
    - if (retval)
    + if (retval)
    goto failed_usb_register;
    atomic_set(&CmdUrbs, 0);
    info(DRIVER_DESC " " DRIVER_VERSION);
    @@ -3050,19 +3293,19 @@ failed_2port_device_register:
    ************************************************** **************************/
    static void __exit edgeport_exit (void)
    {
    - usb_deregister (&io_driver);
    - usb_serial_deregister (&edgeport_2port_device);
    - usb_serial_deregister (&edgeport_4port_device);
    - usb_serial_deregister (&edgeport_8port_device);
    - usb_serial_deregister (&epic_device);
    + usb_deregister(&io_driver);
    + usb_serial_deregister(&edgeport_2port_device);
    + usb_serial_deregister(&edgeport_4port_device);
    + usb_serial_deregister(&edgeport_8port_device);
    + usb_serial_deregister(&epic_device);
    }

    module_init(edgeport_init);
    module_exit(edgeport_exit);

    /* Module information */
    -MODULE_AUTHOR( DRIVER_AUTHOR );
    -MODULE_DESCRIPTION( DRIVER_DESC );
    +MODULE_AUTHOR(DRIVER_AUTHOR);
    +MODULE_DESCRIPTION(DRIVER_DESC);
    MODULE_LICENSE("GPL");

    module_param(debug, bool, S_IRUGO | S_IWUSR);
    diff --git a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h
    index 2ec8589..7eb9d67 100644
    --- a/drivers/usb/serial/io_tables.h
    +++ b/drivers/usb/serial/io_tables.h
    @@ -8,7 +8,7 @@
    * it under the terms of the GNU General Public License as published by
    * the Free Software Foundation; either version 2 of the License, or
    * (at your option) any later version.
    - *
    + *
    */

    #ifndef IO_TABLES_H
    @@ -90,10 +90,10 @@ static struct usb_device_id id_table_combined [] = {
    { USB_DEVICE(USB_VENDOR_ID_AXIOHM, AXIOHM_DEVICE_ID_EPIC_A758) },
    { USB_DEVICE(USB_VENDOR_ID_AXIOHM, AXIOHM_DEVICE_ID_EPIC_A794) },
    { USB_DEVICE(USB_VENDOR_ID_AXIOHM, AXIOHM_DEVICE_ID_EPIC_A225) },
    - { } /* Terminating entry */
    + { } /* Terminating entry */
    };

    -MODULE_DEVICE_TABLE (usb, id_table_combined);
    +MODULE_DEVICE_TABLE(usb, id_table_combined);

    static struct usb_driver io_driver = {
    .name = "io_edgeport",

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  17. [PATCH 40/70] tty-usb-hp4x: Fix overlong line

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/hp4x.c | 3 ++-
    1 files changed, 2 insertions(+), 1 deletions(-)


    diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c
    index 75b88b3..ab90586 100644
    --- a/drivers/usb/serial/hp4x.c
    +++ b/drivers/usb/serial/hp4x.c
    @@ -9,7 +9,8 @@
    * the Free Software Foundation; either version 2 of the License, or
    * (at your option) any later version.
    *
    - * See Documentation/usb/usb-serial.txt for more information on using this driver
    + * See Documentation/usb/usb-serial.txt for more information on using this
    + * driver
    */

    #include

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  18. [PATCH 60/70] tty-usb-sierra: Coding style - minor

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/sierra.c | 2 +-
    1 files changed, 1 insertions(+), 1 deletions(-)


    diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
    index 892020d..2f6f152 100644
    --- a/drivers/usb/serial/sierra.c
    +++ b/drivers/usb/serial/sierra.c
    @@ -757,7 +757,7 @@ failed_device_register:

    static void __exit sierra_exit(void)
    {
    - usb_deregister (&sierra_driver);
    + usb_deregister(&sierra_driver);
    usb_serial_deregister(&sierra_device);
    }


    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  19. [PATCH 61/70] tty-usb-spcp8x5: Minor coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/spcp8x5.c | 4 ++--
    1 files changed, 2 insertions(+), 2 deletions(-)


    diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
    index 58495f5..283cf6b 100644
    --- a/drivers/usb/serial/spcp8x5.c
    +++ b/drivers/usb/serial/spcp8x5.c
    @@ -208,7 +208,7 @@ static inline unsigned int ringbuf_avail_data(struct ringbuf *pb)
    {
    if (pb == NULL)
    return 0;
    - return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size);
    + return (pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size;
    }

    /* get the number of space in the pipo */
    @@ -216,7 +216,7 @@ static inline unsigned int ringbuf_avail_space(struct ringbuf *pb)
    {
    if (pb == NULL)
    return 0;
    - return ((pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size);
    + return (pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size;
    }

    /* put count data into pipo */

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  20. [PATCH 70/70] tty-usb-mos7720: Coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/mos7720.c | 227 +++++++++++++++++++++---------------------
    1 files changed, 116 insertions(+), 111 deletions(-)


    diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
    index d47f081..7c4917d 100644
    --- a/drivers/usb/serial/mos7720.c
    +++ b/drivers/usb/serial/mos7720.c
    @@ -33,7 +33,7 @@
    #include
    #include
    #include
    -#include
    +#include


    /*
    @@ -64,8 +64,7 @@
    #define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */

    /* This structure holds all of the local port information */
    -struct moschip_port
    -{
    +struct moschip_port {
    __u8 shadowLCR; /* last LCR value received */
    __u8 shadowMCR; /* last MCR value received */
    __u8 shadowMSR; /* last MSR value received */
    @@ -76,8 +75,7 @@ struct moschip_port
    };

    /* This structure holds all of the individual serial device information */
    -struct moschip_serial
    -{
    +struct moschip_serial {
    int interrupt_started;
    };

    @@ -88,7 +86,7 @@ static int debug;
    #define MOSCHIP_DEVICE_ID_7715 0x7715

    static struct usb_device_id moschip_port_id_table [] = {
    - { USB_DEVICE(USB_VENDOR_ID_MOSCHIP,MOSCHIP_DEVICE_ID _7720) },
    + { USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7720) },
    { } /* terminating entry */
    };
    MODULE_DEVICE_TABLE(usb, moschip_port_id_table);
    @@ -108,7 +106,7 @@ static void mos7720_interrupt_callback(struct urb *urb)
    __u8 sp1;
    __u8 sp2;

    - dbg("%s"," : Entering\n");
    + dbg("%s", " : Entering\n");

    switch (status) {
    case 0:
    @@ -208,7 +206,7 @@ static void mos7720_bulk_in_callback(struct urb *urb)

    mos7720_port = urb->context;
    if (!mos7720_port) {
    - dbg("%s","NULL mos7720_port pointer \n");
    + dbg("%s", "NULL mos7720_port pointer \n");
    return ;
    }

    @@ -284,17 +282,16 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value,
    __u16 size = 0x0000;

    if (value < MOS_MAX_PORT) {
    - if (product == MOSCHIP_DEVICE_ID_7715) {
    + if (product == MOSCHIP_DEVICE_ID_7715)
    value = value*0x100+0x100;
    - } else {
    + else
    value = value*0x100+0x200;
    - }
    } else {
    value = 0x0000;
    if ((product == MOSCHIP_DEVICE_ID_7715) &&
    (index != 0x08)) {
    dbg("serial->product== MOSCHIP_DEVICE_ID_7715");
    - //index = 0x01 ;
    + /* index = 0x01 ; */
    }
    }

    @@ -308,20 +305,20 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value,
    request = (__u8)MOS_READ;
    requesttype = (__u8)0xC0;
    size = 0x01;
    - pipe = usb_rcvctrlpipe(serial->dev,0);
    + pipe = usb_rcvctrlpipe(serial->dev, 0);
    }

    status = usb_control_msg(serial->dev, pipe, request, requesttype,
    value, index, data, size, MOS_WDR_TIMEOUT);

    if (status < 0)
    - dbg("Command Write failed Value %x index %x\n",value,index);
    + dbg("Command Write failed Value %x index %x\n", value, index);

    return status;
    }

    static int mos7720_open(struct tty_struct *tty,
    - struct usb_serial_port *port, struct file * filp)
    + struct usb_serial_port *port, struct file *filp)
    {
    struct usb_serial *serial;
    struct usb_serial_port *port0;
    @@ -352,7 +349,7 @@ static int mos7720_open(struct tty_struct *tty,

    /* Initialising the write urb pool */
    for (j = 0; j < NUM_URBS; ++j) {
    - urb = usb_alloc_urb(0,GFP_KERNEL);
    + urb = usb_alloc_urb(0, GFP_KERNEL);
    mos7720_port->write_urb_pool[j] = urb;

    if (urb == NULL) {
    @@ -386,7 +383,7 @@ static int mos7720_open(struct tty_struct *tty,
    */
    port_number = port->number - port->serial->minor;
    send_mos_cmd(port->serial, MOS_READ, port_number, UART_LSR, &data);
    - dbg("SS::%p LSR:%x\n",mos7720_port, data);
    + dbg("SS::%p LSR:%x\n", mos7720_port, data);

    dbg("Check:Sending Command ..........");

    @@ -403,10 +400,10 @@ static int mos7720_open(struct tty_struct *tty,
    data = 0xCF;
    send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data);
    data = 0x03;
    - mos7720_port->shadowLCR = data;
    + mos7720_port->shadowLCR = data;
    send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
    data = 0x0b;
    - mos7720_port->shadowMCR = data;
    + mos7720_port->shadowMCR = data;
    send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
    data = 0x0b;
    send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
    @@ -421,7 +418,8 @@ static int mos7720_open(struct tty_struct *tty,
    data = 0x03;
    send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data);
    data = 0x00;
    - send_mos_cmd(port->serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data);
    + send_mos_cmd(port->serial, MOS_WRITE, MOS_MAX_PORT,
    + port_number + 1, &data);
    */
    data = 0x00;
    send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
    @@ -430,14 +428,14 @@ static int mos7720_open(struct tty_struct *tty,
    send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);

    data = 0x83;
    - mos7720_port->shadowLCR = data;
    + mos7720_port->shadowLCR = data;
    send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
    data = 0x0c;
    send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data);
    data = 0x00;
    send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
    data = 0x03;
    - mos7720_port->shadowLCR = data;
    + mos7720_port->shadowLCR = data;
    send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
    data = 0x0c;
    send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
    @@ -464,15 +462,15 @@ static int mos7720_open(struct tty_struct *tty,

    /* set up our interrupt urb */
    usb_fill_int_urb(port0->interrupt_in_urb, serial->dev,
    - usb_rcvintpipe(serial->dev,
    - port->interrupt_in_endpointAddress),
    - port0->interrupt_in_buffer,
    - port0->interrupt_in_urb->transfer_buffer_length,
    - mos7720_interrupt_callback, mos7720_port,
    - port0->interrupt_in_urb->interval);
    + usb_rcvintpipe(serial->dev,
    + port->interrupt_in_endpointAddress),
    + port0->interrupt_in_buffer,
    + port0->interrupt_in_urb->transfer_buffer_length,
    + mos7720_interrupt_callback, mos7720_port,
    + port0->interrupt_in_urb->interval);

    /* start interrupt read for this mos7720 this interrupt *
    - * will continue as long as the mos7720 is connected */
    + * will continue as long as the mos7720 is connected */
    dbg("Submit URB over !!!");
    response = usb_submit_urb(port0->interrupt_in_urb, GFP_KERNEL);
    if (response)
    @@ -484,14 +482,14 @@ static int mos7720_open(struct tty_struct *tty,
    /* set up our bulk in urb */
    usb_fill_bulk_urb(port->read_urb, serial->dev,
    usb_rcvbulkpipe(serial->dev,
    - port->bulk_in_endpointAddress),
    + port->bulk_in_endpointAddress),
    port->bulk_in_buffer,
    port->read_urb->transfer_buffer_length,
    mos7720_bulk_in_callback, mos7720_port);
    response = usb_submit_urb(port->read_urb, GFP_KERNEL);
    if (response)
    - dev_err(&port->dev,
    - "%s - Error %d submitting read urb\n", __func__, response);
    + dev_err(&port->dev, "%s - Error %d submitting read urb\n",
    + __func__, response);

    /* initialize our icount structure */
    memset(&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount));
    @@ -530,7 +528,8 @@ static int mos7720_chars_in_buffer(struct tty_struct *tty)
    }

    for (i = 0; i < NUM_URBS; ++i) {
    - if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
    + if (mos7720_port->write_urb_pool[i] &&
    + mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
    chars += URB_TRANSFER_BUFFER_SIZE;
    }
    dbg("%s - returns %d", __func__, chars);
    @@ -576,12 +575,12 @@ static void mos7720_close(struct tty_struct *tty,
    * been disconnected */
    if (!serial->disconnected) {
    data = 0x00;
    - send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
    - 0x04, &data);
    + send_mos_cmd(serial, MOS_WRITE,
    + port->number - port->serial->minor, 0x04, &data);

    data = 0x00;
    - send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
    - 0x01, &data);
    + send_mos_cmd(serial, MOS_WRITE,
    + port->number - port->serial->minor, 0x01, &data);
    }
    mutex_unlock(&serial->disc_mutex);
    mos7720_port->open = 0;
    @@ -592,7 +591,7 @@ static void mos7720_close(struct tty_struct *tty,
    static void mos7720_break(struct tty_struct *tty, int break_state)
    {
    struct usb_serial_port *port = tty->driver_data;
    - unsigned char data;
    + unsigned char data;
    struct usb_serial *serial;
    struct moschip_port *mos7720_port;

    @@ -640,7 +639,8 @@ static int mos7720_write_room(struct tty_struct *tty)

    /* FIXME: Locking */
    for (i = 0; i < NUM_URBS; ++i) {
    - if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS)
    + if (mos7720_port->write_urb_pool[i] &&
    + mos7720_port->write_urb_pool[i]->status != -EINPROGRESS)
    room += URB_TRANSFER_BUFFER_SIZE;
    }

    @@ -675,9 +675,10 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port,
    urb = NULL;

    for (i = 0; i < NUM_URBS; ++i) {
    - if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) {
    + if (mos7720_port->write_urb_pool[i] &&
    + mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) {
    urb = mos7720_port->write_urb_pool[i];
    - dbg("URB:%d",i);
    + dbg("URB:%d", i);
    break;
    }
    }
    @@ -695,7 +696,7 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port,
    goto exit;
    }
    }
    - transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE);
    + transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE);

    memcpy(urb->transfer_buffer, current_position, transfer_size);
    usb_serial_debug_data(debug, &port->dev, __func__, transfer_size,
    @@ -704,12 +705,12 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port,
    /* fill urb with data and submit */
    usb_fill_bulk_urb(urb, serial->dev,
    usb_sndbulkpipe(serial->dev,
    - port->bulk_out_endpointAddress),
    + port->bulk_out_endpointAddress),
    urb->transfer_buffer, transfer_size,
    mos7720_bulk_out_data_callback, mos7720_port);

    /* send it down the pipe */
    - status = usb_submit_urb(urb,GFP_ATOMIC);
    + status = usb_submit_urb(urb, GFP_ATOMIC);
    if (status) {
    err("%s - usb_submit_urb(write bulk) failed with status = %d",
    __func__, status);
    @@ -810,9 +811,9 @@ static int set_higher_rates(struct moschip_port *mos7720_port,
    port = mos7720_port->port;
    serial = port->serial;

    - /***********************************************
    - * Init Sequence for higher rates
    - ***********************************************/
    + /***********************************************
    + * Init Sequence for higher rates
    + ***********************************************/
    dbg("Sending Setting Commands ..........");
    port_number = port->number - port->serial->minor;

    @@ -823,7 +824,7 @@ static int set_higher_rates(struct moschip_port *mos7720_port,
    data = 0x0CF;
    send_mos_cmd(serial, MOS_WRITE, port->number, 0x02, &data);
    data = 0x00b;
    - mos7720_port->shadowMCR = data;
    + mos7720_port->shadowMCR = data;
    send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
    data = 0x00b;
    send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
    @@ -834,12 +835,12 @@ static int set_higher_rates(struct moschip_port *mos7720_port,
    send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);


    - /***********************************************
    - * Set for higher rates *
    - ***********************************************/
    + /***********************************************
    + * Set for higher rates *
    + ***********************************************/

    data = baud * 0x10;
    - send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1,&data);
    + send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data);

    data = 0x003;
    send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
    @@ -847,34 +848,33 @@ static int set_higher_rates(struct moschip_port *mos7720_port,
    send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);

    data = 0x02b;
    - mos7720_port->shadowMCR = data;
    + mos7720_port->shadowMCR = data;
    send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
    data = 0x02b;
    send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);

    - /***********************************************
    - * Set DLL/DLM
    - ***********************************************/
    + /***********************************************
    + * Set DLL/DLM
    + ***********************************************/

    data = mos7720_port->shadowLCR | UART_LCR_DLAB;
    - mos7720_port->shadowLCR = data;
    + mos7720_port->shadowLCR = data;
    send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);

    data = 0x001; /* DLL */
    - send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data);
    + send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data);
    data = 0x000; /* DLM */
    - send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
    + send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);

    data = mos7720_port->shadowLCR & ~UART_LCR_DLAB;
    - mos7720_port->shadowLCR = data;
    + mos7720_port->shadowLCR = data;
    send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);

    return 0;
    }

    /* baud rate information */
    -struct divisor_table_entry
    -{
    +struct divisor_table_entry {
    __u32 baudrate;
    __u16 divisor;
    };
    @@ -923,8 +923,8 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor)
    }
    }

    - /* After trying for all the standard baud rates *
    - * Try calculating the divisor for this baud rate */
    + /* After trying for all the standard baud rates *
    + * Try calculating the divisor for this baud rate */
    if (baudrate > 75 && baudrate < 230400) {
    /* get the divisor */
    custom = (__u16)(230400L / baudrate);
    @@ -936,7 +936,7 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor)
    custom++;
    *divisor = custom;

    - dbg("Baud %d = %d",baudrate, custom);
    + dbg("Baud %d = %d", baudrate, custom);
    return 0;
    }

    @@ -970,29 +970,29 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port,
    number = port->number - port->serial->minor;
    dbg("%s - port = %d, baud = %d", __func__, port->number, baudrate);

    - /* Calculate the Divisor */
    + /* Calculate the Divisor */
    status = calc_baud_rate_divisor(baudrate, &divisor);
    if (status) {
    err("%s - bad baud rate", __func__);
    return status;
    }

    - /* Enable access to divisor latch */
    - data = mos7720_port->shadowLCR | UART_LCR_DLAB;
    - mos7720_port->shadowLCR = data;
    - send_mos_cmd(serial, MOS_WRITE, number, UART_LCR, &data);
    + /* Enable access to divisor latch */
    + data = mos7720_port->shadowLCR | UART_LCR_DLAB;
    + mos7720_port->shadowLCR = data;
    + send_mos_cmd(serial, MOS_WRITE, number, UART_LCR, &data);

    /* Write the divisor */
    data = ((unsigned char)(divisor & 0xff));
    - send_mos_cmd(serial, MOS_WRITE, number, 0x00, &data);
    + send_mos_cmd(serial, MOS_WRITE, number, 0x00, &data);

    data = ((unsigned char)((divisor & 0xff00) >> 8));
    - send_mos_cmd(serial, MOS_WRITE, number, 0x01, &data);
    + send_mos_cmd(serial, MOS_WRITE, number, 0x01, &data);

    - /* Disable access to divisor latch */
    - data = mos7720_port->shadowLCR & ~UART_LCR_DLAB;
    - mos7720_port->shadowLCR = data;
    - send_mos_cmd(serial, MOS_WRITE, number, 0x03, &data);
    + /* Disable access to divisor latch */
    + data = mos7720_port->shadowLCR & ~UART_LCR_DLAB;
    + mos7720_port->shadowLCR = data;
    + send_mos_cmd(serial, MOS_WRITE, number, 0x03, &data);

    return status;
    }
    @@ -1095,29 +1095,31 @@ static void change_port_settings(struct tty_struct *tty,
    #define LCR_PAR_MASK 0x38 /* Mask for parity field */

    /* Update the LCR with the correct value */
    - mos7720_port->shadowLCR &= ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK);
    + mos7720_port->shadowLCR &=
    + ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK);
    mos7720_port->shadowLCR |= (lData | lParity | lStop);


    /* Disable Interrupts */
    data = 0x00;
    - send_mos_cmd(serial,MOS_WRITE,port->number - port->serial->minor, UART_IER, &data);
    + send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
    + UART_IER, &data);

    data = 0x00;
    - send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data);
    + send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data);

    data = 0xcf;
    - send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data);
    + send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data);

    /* Send the updated LCR value to the mos7720 */
    data = mos7720_port->shadowLCR;
    - send_mos_cmd(serial, MOS_WRITE, port_number, UART_LCR, &data);
    + send_mos_cmd(serial, MOS_WRITE, port_number, UART_LCR, &data);

    - data = 0x00b;
    - mos7720_port->shadowMCR = data;
    - send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
    - data = 0x00b;
    - send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
    + data = 0x00b;
    + mos7720_port->shadowMCR = data;
    + send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
    + data = 0x00b;
    + send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);

    /* set up the MCR register and send it to the mos7720 */
    mos7720_port->shadowMCR = UART_MCR_OUT2;
    @@ -1126,9 +1128,8 @@ static void change_port_settings(struct tty_struct *tty,

    if (cflag & CRTSCTS) {
    mos7720_port->shadowMCR |= (UART_MCR_XONANY);
    -
    - /* To set hardware flow control to the specified *
    - * serial port, in SP1/2_CONTROL_REG */
    + /* To set hardware flow control to the specified *
    + * serial port, in SP1/2_CONTROL_REG */
    if (port->number) {
    data = 0x001;
    send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT,
    @@ -1207,7 +1208,7 @@ static void mos7720_set_termios(struct tty_struct *tty,
    return;
    }

    - dbg("%s\n","setting termios - ASPIRE");
    + dbg("%s\n", "setting termios - ASPIRE");

    cflag = tty->termios->c_cflag;

    @@ -1224,12 +1225,12 @@ static void mos7720_set_termios(struct tty_struct *tty,
    /* change the port settings to the new ones specified */
    change_port_settings(tty, mos7720_port, old_termios);

    - if(!port->read_urb) {
    - dbg("%s","URB KILLED !!!!!\n");
    + if (!port->read_urb) {
    + dbg("%s", "URB KILLED !!!!!\n");
    return;
    }

    - if(port->read_urb->status != -EINPROGRESS) {
    + if (port->read_urb->status != -EINPROGRESS) {
    port->read_urb->dev = serial->dev;
    status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
    if (status)
    @@ -1249,8 +1250,8 @@ static void mos7720_set_termios(struct tty_struct *tty,
    * transmit holding register is empty. This functionality
    * allows an RS485 driver to be written in user space.
    */
    -static int get_lsr_info(struct tty_struct *tty, struct moschip_port *mos7720_port,
    - unsigned int __user *value)
    +static int get_lsr_info(struct tty_struct *tty,
    + struct moschip_port *mos7720_port, unsigned int __user *value)
    {
    int count;
    unsigned int result = 0;
    @@ -1301,7 +1302,7 @@ static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd,
    if (mos7720_port == NULL)
    return -1;

    - port = (struct usb_serial_port*)mos7720_port->port;
    + port = (struct usb_serial_port *)mos7720_port->port;
    mcr = mos7720_port->shadowMCR;

    if (copy_from_user(&arg, value, sizeof(int)))
    @@ -1382,7 +1383,7 @@ static int get_serial_info(struct moschip_port *mos7720_port,
    tmp.port = mos7720_port->port->number;
    tmp.irq = 0;
    tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
    - tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE;
    + tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE;
    tmp.baud_base = 9600;
    tmp.close_delay = 5*HZ;
    tmp.closing_wait = 30*HZ;
    @@ -1417,15 +1418,16 @@ static int mos7720_ioctl(struct tty_struct *tty, struct file *file,

    case TIOCSERGETLSR:
    dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
    - return get_lsr_info(tty, mos7720_port, (unsigned int __user *)arg);
    + return get_lsr_info(tty, mos7720_port,
    + (unsigned int __user *)arg);
    return 0;

    /* FIXME: These should be using the mode methods */
    case TIOCMBIS:
    case TIOCMBIC:
    case TIOCMSET:
    - dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __func__,
    - port->number);
    + dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET",
    + __func__, port->number);
    return set_modem_info(mos7720_port, cmd,
    (unsigned int __user *)arg);

    @@ -1452,7 +1454,7 @@ static int mos7720_ioctl(struct tty_struct *tty, struct file *file,
    if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
    ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
    ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
    - ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
    + ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) {
    return 0;
    }
    cprev = cnow;
    @@ -1475,7 +1477,7 @@ static int mos7720_ioctl(struct tty_struct *tty, struct file *file,
    icount.buf_overrun = cnow.buf_overrun;

    dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__,
    - port->number, icount.rx, icount.tx );
    + port->number, icount.rx, icount.tx);
    if (copy_to_user((void __user *)arg, &icount, sizeof(icount)))
    return -EFAULT;
    return 0;
    @@ -1526,7 +1528,8 @@ static int mos7720_startup(struct usb_serial *serial)
    /* Initialize all port interrupt end point to port 0 int
    * endpoint. Our device has only one interrupt endpoint
    * comman to all ports */
    - serial->port[i]->interrupt_in_endpointAddress = serial->port[0]->interrupt_in_endpointAddress;
    + serial->port[i]->interrupt_in_endpointAddress =
    + serial->port[0]->interrupt_in_endpointAddress;

    mos7720_port->port = serial->port[i];
    usb_set_serial_port_data(serial->port[i], mos7720_port);
    @@ -1538,13 +1541,15 @@ static int mos7720_startup(struct usb_serial *serial)

    /* setting configuration feature to one */
    usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
    - (__u8)0x03, 0x00,0x01,0x00, NULL, 0x00, 5*HZ);
    + (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5*HZ);

    - send_mos_cmd(serial,MOS_READ,0x00, UART_LSR, &data); // LSR For Port 1
    - dbg("LSR:%x",data);
    + /* LSR For Port 1 */
    + send_mos_cmd(serial, MOS_READ, 0x00, UART_LSR, &data);
    + dbg("LSR:%x", data);

    - send_mos_cmd(serial,MOS_READ,0x01, UART_LSR, &data); // LSR For Port 2
    - dbg("LSR:%x",data);
    + /* LSR For Port 2 */
    + send_mos_cmd(serial, MOS_READ, 0x01, UART_LSR, &data);
    + dbg("LSR:%x", data);

    return 0;
    }
    @@ -1554,7 +1559,7 @@ static void mos7720_shutdown(struct usb_serial *serial)
    int i;

    /* free private structure allocated for serial port */
    - for (i=0; i < serial->num_ports; ++i) {
    + for (i = 0; i < serial->num_ports; ++i) {
    kfree(usb_get_serial_port_data(serial->port[i]));
    usb_set_serial_port_data(serial->port[i], NULL);
    }
    @@ -1634,8 +1639,8 @@ module_init(moschip7720_init);
    module_exit(moschip7720_exit);

    /* Module information */
    -MODULE_AUTHOR( DRIVER_AUTHOR );
    -MODULE_DESCRIPTION( DRIVER_DESC );
    +MODULE_AUTHOR(DRIVER_AUTHOR);
    +MODULE_DESCRIPTION(DRIVER_DESC);
    MODULE_LICENSE("GPL");

    module_param(debug, bool, S_IRUGO | S_IWUSR);

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread
Page 3 of 4 FirstFirst 1 2 3 4 LastLast