[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 Switch the synclink ports to use the new tty_port structure Signed-off-by: Alan Cox --- drivers/char/synclink.c | 195 ++++++++++++++++++++---------------------- drivers/char/synclink_gt.c | 201 +++++++++++++++++++++----------------------- drivers/char/synclinkmp.c | 203 +++++++++++++++++++++----------------------- 3 files changed, 289 insertions(+), 310 deletions(-) diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c ...

+ Reply to Thread
Page 2 of 4 FirstFirst 1 2 3 4 LastLast
Results 21 to 40 of 77

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

  1. [PATCH 18/70] synclink: use tty_port

    From: Alan Cox

    Switch the synclink ports to use the new tty_port structure

    Signed-off-by: Alan Cox
    ---

    drivers/char/synclink.c | 195 ++++++++++++++++++++----------------------
    drivers/char/synclink_gt.c | 201 +++++++++++++++++++++-----------------------
    drivers/char/synclinkmp.c | 203 +++++++++++++++++++++-----------------------
    3 files changed, 289 insertions(+), 310 deletions(-)


    diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
    index 5e4b2e6..734098f 100644
    --- a/drivers/char/synclink.c
    +++ b/drivers/char/synclink.c
    @@ -180,8 +180,7 @@ struct tx_holding_buffer {

    struct mgsl_struct {
    int magic;
    - int flags;
    - int count; /* count of opens */
    + struct tty_port port;
    int line;
    int hw_version;
    unsigned short close_delay;
    @@ -189,10 +188,8 @@ struct mgsl_struct {

    struct mgsl_icount icount;

    - struct tty_struct *tty;
    int timeout;
    int x_char; /* xon/xoff character */
    - int blocked_open; /* # of blocked opens */
    u16 read_status_mask;
    u16 ignore_status_mask;
    unsigned char *xmit_buf;
    @@ -200,9 +197,6 @@ struct mgsl_struct {
    int xmit_tail;
    int xmit_cnt;

    - wait_queue_head_t open_wait;
    - wait_queue_head_t close_wait;
    -
    wait_queue_head_t status_event_wait_q;
    wait_queue_head_t event_wait_q;
    struct timer_list tx_timer; /* HDLC transmit timeout timer */
    @@ -1134,7 +1128,7 @@ static void mgsl_bh_receive(struct mgsl_struct *info)

    static void mgsl_bh_transmit(struct mgsl_struct *info)
    {
    - struct tty_struct *tty = info->tty;
    + struct tty_struct *tty = info->port.tty;
    unsigned long flags;

    if ( debug_level >= DEBUG_LEVEL_BH )
    @@ -1276,7 +1270,7 @@ static void mgsl_isr_transmit_status( struct mgsl_struct *info )
    else
    #endif
    {
    - if (info->tty->stopped || info->tty->hw_stopped) {
    + if (info->port.tty->stopped || info->port.tty->hw_stopped) {
    usc_stop_transmitter(info);
    return;
    }
    @@ -1357,29 +1351,29 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
    wake_up_interruptible(&info->status_event_wait_q);
    wake_up_interruptible(&info->event_wait_q);

    - if ( (info->flags & ASYNC_CHECK_CD) &&
    + if ( (info->port.flags & ASYNC_CHECK_CD) &&
    (status & MISCSTATUS_DCD_LATCHED) ) {
    if ( debug_level >= DEBUG_LEVEL_ISR )
    printk("%s CD now %s...", info->device_name,
    (status & MISCSTATUS_DCD) ? "on" : "off");
    if (status & MISCSTATUS_DCD)
    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    else {
    if ( debug_level >= DEBUG_LEVEL_ISR )
    printk("doing serial hangup...");
    - if (info->tty)
    - tty_hangup(info->tty);
    + if (info->port.tty)
    + tty_hangup(info->port.tty);
    }
    }

    - if ( (info->flags & ASYNC_CTS_FLOW) &&
    + if ( (info->port.flags & ASYNC_CTS_FLOW) &&
    (status & MISCSTATUS_CTS_LATCHED) ) {
    - if (info->tty->hw_stopped) {
    + if (info->port.tty->hw_stopped) {
    if (status & MISCSTATUS_CTS) {
    if ( debug_level >= DEBUG_LEVEL_ISR )
    printk("CTS tx start...");
    - if (info->tty)
    - info->tty->hw_stopped = 0;
    + if (info->port.tty)
    + info->port.tty->hw_stopped = 0;
    usc_start_transmitter(info);
    info->pending_bh |= BH_TRANSMIT;
    return;
    @@ -1388,8 +1382,8 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
    if (!(status & MISCSTATUS_CTS)) {
    if ( debug_level >= DEBUG_LEVEL_ISR )
    printk("CTS tx stop...");
    - if (info->tty)
    - info->tty->hw_stopped = 1;
    + if (info->port.tty)
    + info->port.tty->hw_stopped = 1;
    usc_stop_transmitter(info);
    }
    }
    @@ -1423,7 +1417,7 @@ static void mgsl_isr_transmit_data( struct mgsl_struct *info )

    usc_ClearIrqPendingBits( info, TRANSMIT_DATA );

    - if (info->tty->stopped || info->tty->hw_stopped) {
    + if (info->port.tty->stopped || info->port.tty->hw_stopped) {
    usc_stop_transmitter(info);
    return;
    }
    @@ -1453,7 +1447,7 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info )
    u16 status;
    int work = 0;
    unsigned char DataByte;
    - struct tty_struct *tty = info->tty;
    + struct tty_struct *tty = info->port.tty;
    struct mgsl_icount *icount = &info->icount;

    if ( debug_level >= DEBUG_LEVEL_ISR )
    @@ -1514,7 +1508,7 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info )

    if (status & RXSTATUS_BREAK_RECEIVED) {
    flag = TTY_BREAK;
    - if (info->flags & ASYNC_SAK)
    + if (info->port.flags & ASYNC_SAK)
    do_SAK(tty);
    } else if (status & RXSTATUS_PARITY_ERROR)
    flag = TTY_PARITY;
    @@ -1771,7 +1765,7 @@ static int startup(struct mgsl_struct * info)
    if ( debug_level >= DEBUG_LEVEL_INFO )
    printk("%s(%d):mgsl_startup(%s)\n",__FILE__,__LINE__,info->device_name);

    - if (info->flags & ASYNC_INITIALIZED)
    + if (info->port.flags & ASYNC_INITIALIZED)
    return 0;

    if (!info->xmit_buf) {
    @@ -1798,8 +1792,8 @@ static int startup(struct mgsl_struct * info)
    retval = mgsl_adapter_test(info);

    if ( retval ) {
    - if (capable(CAP_SYS_ADMIN) && info->tty)
    - set_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (capable(CAP_SYS_ADMIN) && info->port.tty)
    + set_bit(TTY_IO_ERROR, &info->port.tty->flags);
    mgsl_release_resources(info);
    return retval;
    }
    @@ -1807,10 +1801,10 @@ static int startup(struct mgsl_struct * info)
    /* program hardware for current parameters */
    mgsl_change_params(info);

    - if (info->tty)
    - clear_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + clear_bit(TTY_IO_ERROR, &info->port.tty->flags);

    - info->flags |= ASYNC_INITIALIZED;
    + info->port.flags |= ASYNC_INITIALIZED;

    return 0;

    @@ -1827,7 +1821,7 @@ static void shutdown(struct mgsl_struct * info)
    {
    unsigned long flags;

    - if (!(info->flags & ASYNC_INITIALIZED))
    + if (!(info->port.flags & ASYNC_INITIALIZED))
    return;

    if (debug_level >= DEBUG_LEVEL_INFO)
    @@ -1864,7 +1858,7 @@ static void shutdown(struct mgsl_struct * info)
    /* on the ISA adapter. This has no effect for the PCI adapter */
    usc_OutReg(info, PCR, (u16)((usc_InReg(info, PCR) | BIT13) | BIT12));

    - if (!info->tty || info->tty->termios->c_cflag & HUPCL) {
    + if (!info->port.tty || info->port.tty->termios->c_cflag & HUPCL) {
    info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS);
    usc_set_serial_signals(info);
    }
    @@ -1873,10 +1867,10 @@ static void shutdown(struct mgsl_struct * info)

    mgsl_release_resources(info);

    - if (info->tty)
    - set_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + set_bit(TTY_IO_ERROR, &info->port.tty->flags);

    - info->flags &= ~ASYNC_INITIALIZED;
    + info->port.flags &= ~ASYNC_INITIALIZED;

    } /* end of shutdown() */

    @@ -1908,7 +1902,7 @@ static void mgsl_program_hw(struct mgsl_struct *info)
    usc_EnableInterrupts(info, IO_PIN);
    usc_get_serial_signals(info);

    - if (info->netcount || info->tty->termios->c_cflag & CREAD)
    + if (info->netcount || info->port.tty->termios->c_cflag & CREAD)
    usc_start_receiver(info);

    spin_unlock_irqrestore(&info->irq_spinlock,flags);
    @@ -1921,14 +1915,14 @@ static void mgsl_change_params(struct mgsl_struct *info)
    unsigned cflag;
    int bits_per_char;

    - if (!info->tty || !info->tty->termios)
    + if (!info->port.tty || !info->port.tty->termios)
    return;

    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):mgsl_change_params(%s)\n",
    __FILE__,__LINE__, info->device_name );

    - cflag = info->tty->termios->c_cflag;
    + cflag = info->port.tty->termios->c_cflag;

    /* if B0 rate (hangup) specified then negate DTR and RTS */
    /* otherwise assert DTR and RTS */
    @@ -1976,7 +1970,7 @@ static void mgsl_change_params(struct mgsl_struct *info)
    * current data rate.
    */
    if (info->params.data_rate <= 460800)
    - info->params.data_rate = tty_get_baud_rate(info->tty);
    + info->params.data_rate = tty_get_baud_rate(info->port.tty);

    if ( info->params.data_rate ) {
    info->timeout = (32*HZ*bits_per_char) /
    @@ -1985,31 +1979,31 @@ static void mgsl_change_params(struct mgsl_struct *info)
    info->timeout += HZ/50; /* Add .02 seconds of slop */

    if (cflag & CRTSCTS)
    - info->flags |= ASYNC_CTS_FLOW;
    + info->port.flags |= ASYNC_CTS_FLOW;
    else
    - info->flags &= ~ASYNC_CTS_FLOW;
    + info->port.flags &= ~ASYNC_CTS_FLOW;

    if (cflag & CLOCAL)
    - info->flags &= ~ASYNC_CHECK_CD;
    + info->port.flags &= ~ASYNC_CHECK_CD;
    else
    - info->flags |= ASYNC_CHECK_CD;
    + info->port.flags |= ASYNC_CHECK_CD;

    /* process tty input control flags */

    info->read_status_mask = RXSTATUS_OVERRUN;
    - if (I_INPCK(info->tty))
    + if (I_INPCK(info->port.tty))
    info->read_status_mask |= RXSTATUS_PARITY_ERROR | RXSTATUS_FRAMING_ERROR;
    - if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
    + if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
    info->read_status_mask |= RXSTATUS_BREAK_RECEIVED;

    - if (I_IGNPAR(info->tty))
    + if (I_IGNPAR(info->port.tty))
    info->ignore_status_mask |= RXSTATUS_PARITY_ERROR | RXSTATUS_FRAMING_ERROR;
    - if (I_IGNBRK(info->tty)) {
    + if (I_IGNBRK(info->port.tty)) {
    info->ignore_status_mask |= RXSTATUS_BREAK_RECEIVED;
    /* If ignoring parity and break indicators, ignore
    * overruns too. (For real raw support).
    */
    - if (I_IGNPAR(info->tty))
    + if (I_IGNPAR(info->port.tty))
    info->ignore_status_mask |= RXSTATUS_OVERRUN;
    }

    @@ -3113,32 +3107,32 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)

    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
    - __FILE__,__LINE__, info->device_name, info->count);
    + __FILE__,__LINE__, info->device_name, info->port.count);

    - if (!info->count)
    + if (!info->port.count)
    return;

    if (tty_hung_up_p(filp))
    goto cleanup;

    - if ((tty->count == 1) && (info->count != 1)) {
    + if ((tty->count == 1) && (info->port.count != 1)) {
    /*
    * tty->count is 1 and the tty structure will be freed.
    - * info->count should be one in this case.
    + * info->port.count should be one in this case.
    * if it's not, correct it so that the port is shutdown.
    */
    printk("mgsl_close: bad refcount; tty->count is 1, "
    - "info->count is %d\n", info->count);
    - info->count = 1;
    + "info->port.count is %d\n", info->port.count);
    + info->port.count = 1;
    }

    - info->count--;
    + info->port.count--;

    /* if at least one open remaining, leave hardware active */
    - if (info->count)
    + if (info->port.count)
    goto cleanup;

    - info->flags |= ASYNC_CLOSING;
    + info->port.flags |= ASYNC_CLOSING;

    /* set tty->closing to notify line discipline to
    * only process XON/XOFF characters. Only the N_TTY
    @@ -3155,7 +3149,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
    tty_wait_until_sent(tty, info->closing_wait);
    }

    - if (info->flags & ASYNC_INITIALIZED)
    + if (info->port.flags & ASYNC_INITIALIZED)
    mgsl_wait_until_sent(tty, info->timeout);

    mgsl_flush_buffer(tty);
    @@ -3165,23 +3159,23 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
    shutdown(info);

    tty->closing = 0;
    - info->tty = NULL;
    + info->port.tty = NULL;

    - if (info->blocked_open) {
    + if (info->port.blocked_open) {
    if (info->close_delay) {
    msleep_interruptible(jiffies_to_msecs(info->close_delay));
    }
    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    }

    - info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
    + info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);

    - wake_up_interruptible(&info->close_wait);
    + wake_up_interruptible(&info->port.close_wait);

    cleanup:
    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
    - tty->driver->name, info->count);
    + tty->driver->name, info->port.count);

    } /* end of mgsl_close() */

    @@ -3211,7 +3205,7 @@ static void mgsl_wait_until_sent(struct tty_struct *tty, int timeout)
    if (mgsl_paranoia_check(info, tty->name, "mgsl_wait_until_sent"))
    return;

    - if (!(info->flags & ASYNC_INITIALIZED))
    + if (!(info->port.flags & ASYNC_INITIALIZED))
    goto exit;

    orig_jiffies = jiffies;
    @@ -3283,11 +3277,11 @@ static void mgsl_hangup(struct tty_struct *tty)
    mgsl_flush_buffer(tty);
    shutdown(info);

    - info->count = 0;
    - info->flags &= ~ASYNC_NORMAL_ACTIVE;
    - info->tty = NULL;
    + info->port.count = 0;
    + info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
    + info->port.tty = NULL;

    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);

    } /* end of mgsl_hangup() */

    @@ -3319,7 +3313,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,

    if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
    /* nonblock mode is set or port is not enabled */
    - info->flags |= ASYNC_NORMAL_ACTIVE;
    + info->port.flags |= ASYNC_NORMAL_ACTIVE;
    return 0;
    }

    @@ -3328,25 +3322,25 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,

    /* Wait for carrier detect and the line to become
    * free (i.e., not in use by the callout). While we are in
    - * this loop, info->count is dropped by one, so that
    + * this loop, info->port.count is dropped by one, so that
    * mgsl_close() knows when to free things. We restore it upon
    * exit, either normal or abnormal.
    */

    retval = 0;
    - add_wait_queue(&info->open_wait, &wait);
    + add_wait_queue(&info->port.open_wait, &wait);

    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):block_til_ready before block on %s count=%d\n",
    - __FILE__,__LINE__, tty->driver->name, info->count );
    + __FILE__,__LINE__, tty->driver->name, info->port.count );

    spin_lock_irqsave(&info->irq_spinlock, flags);
    if (!tty_hung_up_p(filp)) {
    extra_count = true;
    - info->count--;
    + info->port.count--;
    }
    spin_unlock_irqrestore(&info->irq_spinlock, flags);
    - info->blocked_open++;
    + info->port.blocked_open++;

    while (1) {
    if (tty->termios->c_cflag & CBAUD) {
    @@ -3358,8 +3352,8 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,

    set_current_state(TASK_INTERRUPTIBLE);

    - if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)){
    - retval = (info->flags & ASYNC_HUP_NOTIFY) ?
    + if (tty_hung_up_p(filp) || !(info->port.flags & ASYNC_INITIALIZED)){
    + retval = (info->port.flags & ASYNC_HUP_NOTIFY) ?
    -EAGAIN : -ERESTARTSYS;
    break;
    }
    @@ -3368,7 +3362,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
    usc_get_serial_signals(info);
    spin_unlock_irqrestore(&info->irq_spinlock,flags);

    - if (!(info->flags & ASYNC_CLOSING) &&
    + if (!(info->port.flags & ASYNC_CLOSING) &&
    (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) {
    break;
    }
    @@ -3380,24 +3374,24 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,

    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):block_til_ready blocking on %s count=%d\n",
    - __FILE__,__LINE__, tty->driver->name, info->count );
    + __FILE__,__LINE__, tty->driver->name, info->port.count );

    schedule();
    }

    set_current_state(TASK_RUNNING);
    - remove_wait_queue(&info->open_wait, &wait);
    + remove_wait_queue(&info->port.open_wait, &wait);

    if (extra_count)
    - info->count++;
    - info->blocked_open--;
    + info->port.count++;
    + info->port.blocked_open--;

    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
    - __FILE__,__LINE__, tty->driver->name, info->count );
    + __FILE__,__LINE__, tty->driver->name, info->port.count );

    if (!retval)
    - info->flags |= ASYNC_NORMAL_ACTIVE;
    + info->port.flags |= ASYNC_NORMAL_ACTIVE;

    return retval;

    @@ -3435,22 +3429,22 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
    return -ENODEV;

    tty->driver_data = info;
    - info->tty = tty;
    + info->port.tty = tty;

    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
    - __FILE__,__LINE__,tty->driver->name, info->count);
    + __FILE__,__LINE__,tty->driver->name, info->port.count);

    /* If port is closing, signal caller to try again */
    - if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){
    - if (info->flags & ASYNC_CLOSING)
    - interruptible_sleep_on(&info->close_wait);
    - retval = ((info->flags & ASYNC_HUP_NOTIFY) ?
    + if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
    + if (info->port.flags & ASYNC_CLOSING)
    + interruptible_sleep_on(&info->port.close_wait);
    + retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
    -EAGAIN : -ERESTARTSYS);
    goto cleanup;
    }

    - info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
    + info->port.tty->low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;

    spin_lock_irqsave(&info->netlock, flags);
    if (info->netcount) {
    @@ -3458,10 +3452,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
    spin_unlock_irqrestore(&info->netlock, flags);
    goto cleanup;
    }
    - info->count++;
    + info->port.count++;
    spin_unlock_irqrestore(&info->netlock, flags);

    - if (info->count == 1) {
    + if (info->port.count == 1) {
    /* 1st open on this device, init hardware */
    retval = startup(info);
    if (retval < 0)
    @@ -3484,9 +3478,9 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
    cleanup:
    if (retval) {
    if (tty->count == 1)
    - info->tty = NULL; /* tty layer will release tty struct */
    - if(info->count)
    - info->count--;
    + info->port.tty = NULL; /* tty layer will release tty struct */
    + if(info->port.count)
    + info->port.count--;
    }

    return retval;
    @@ -4337,8 +4331,7 @@ static struct mgsl_struct* mgsl_allocate_device(void)
    info->max_frame_size = 4096;
    info->close_delay = 5*HZ/10;
    info->closing_wait = 30*HZ;
    - init_waitqueue_head(&info->open_wait);
    - init_waitqueue_head(&info->close_wait);
    + tty_port_init(&info->port);
    init_waitqueue_head(&info->status_event_wait_q);
    init_waitqueue_head(&info->event_wait_q);
    spin_lock_init(&info->irq_spinlock);
    @@ -6575,7 +6568,7 @@ static bool mgsl_get_rx_frame(struct mgsl_struct *info)
    unsigned int framesize = 0;
    bool ReturnCode = false;
    unsigned long flags;
    - struct tty_struct *tty = info->tty;
    + struct tty_struct *tty = info->port.tty;
    bool return_frame = false;

    /*
    @@ -6774,7 +6767,7 @@ static bool mgsl_get_raw_rx_frame(struct mgsl_struct *info)
    unsigned int framesize = 0;
    bool ReturnCode = false;
    unsigned long flags;
    - struct tty_struct *tty = info->tty;
    + struct tty_struct *tty = info->port.tty;

    /*
    * current_rx_buffer points to the 1st buffer of the next available
    @@ -7711,7 +7704,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
    unsigned short new_crctype;

    /* return error if TTY interface open */
    - if (info->count)
    + if (info->port.count)
    return -EBUSY;

    switch (encoding)
    @@ -7808,7 +7801,7 @@ static int hdlcdev_open(struct net_device *dev)

    /* arbitrate between network and tty opens */
    spin_lock_irqsave(&info->netlock, flags);
    - if (info->count != 0 || info->netcount != 0) {
    + if (info->port.count != 0 || info->netcount != 0) {
    printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
    spin_unlock_irqrestore(&info->netlock, flags);
    return -EBUSY;
    @@ -7894,7 +7887,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
    printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);

    /* return error if TTY interface open */
    - if (info->count)
    + if (info->port.count)
    return -EBUSY;

    if (cmd != SIOCWANDEV)
    diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
    index e473778..fc71d98 100644
    --- a/drivers/char/synclink_gt.c
    +++ b/drivers/char/synclink_gt.c
    @@ -244,11 +244,11 @@ struct _input_signal_events {
    */
    struct slgt_info {
    void *if_ptr; /* General purpose pointer (used by SPPP) */
    + struct tty_port port;

    struct slgt_info *next_device; /* device list link */

    int magic;
    - int flags;

    char device_name[25];
    struct pci_dev *pdev;
    @@ -260,23 +260,17 @@ struct slgt_info {
    /* array of pointers to port contexts on this adapter */
    struct slgt_info *port_array[SLGT_MAX_PORTS];

    - int count; /* count of opens */
    int line; /* tty line instance number */
    unsigned short close_delay;
    unsigned short closing_wait; /* time to wait before closing */

    struct mgsl_icount icount;

    - struct tty_struct *tty;
    int timeout;
    int x_char; /* xon/xoff character */
    - int blocked_open; /* # of blocked opens */
    unsigned int read_status_mask;
    unsigned int ignore_status_mask;

    - wait_queue_head_t open_wait;
    - wait_queue_head_t close_wait;
    -
    wait_queue_head_t status_event_wait_q;
    wait_queue_head_t event_wait_q;
    struct timer_list tx_timer;
    @@ -672,20 +666,20 @@ static int open(struct tty_struct *tty, struct file *filp)
    }

    tty->driver_data = info;
    - info->tty = tty;
    + info->port.tty = tty;

    - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->count));
    + DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));

    /* If port is closing, signal caller to try again */
    - if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){
    - if (info->flags & ASYNC_CLOSING)
    - interruptible_sleep_on(&info->close_wait);
    - retval = ((info->flags & ASYNC_HUP_NOTIFY) ?
    + if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
    + if (info->port.flags & ASYNC_CLOSING)
    + interruptible_sleep_on(&info->port.close_wait);
    + retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
    -EAGAIN : -ERESTARTSYS);
    goto cleanup;
    }

    - info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
    + info->port.tty->low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;

    spin_lock_irqsave(&info->netlock, flags);
    if (info->netcount) {
    @@ -693,10 +687,10 @@ static int open(struct tty_struct *tty, struct file *filp)
    spin_unlock_irqrestore(&info->netlock, flags);
    goto cleanup;
    }
    - info->count++;
    + info->port.count++;
    spin_unlock_irqrestore(&info->netlock, flags);

    - if (info->count == 1) {
    + if (info->port.count == 1) {
    /* 1st open on this device, init hardware */
    retval = startup(info);
    if (retval < 0)
    @@ -714,9 +708,9 @@ static int open(struct tty_struct *tty, struct file *filp)
    cleanup:
    if (retval) {
    if (tty->count == 1)
    - info->tty = NULL; /* tty layer will release tty struct */
    - if(info->count)
    - info->count--;
    + info->port.tty = NULL; /* tty layer will release tty struct */
    + if(info->port.count)
    + info->port.count--;
    }

    DBGINFO(("%s open rc=%d\n", info->device_name, retval));
    @@ -729,32 +723,32 @@ static void close(struct tty_struct *tty, struct file *filp)

    if (sanity_check(info, tty->name, "close"))
    return;
    - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->count));
    + DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));

    - if (!info->count)
    + if (!info->port.count)
    return;

    if (tty_hung_up_p(filp))
    goto cleanup;

    - if ((tty->count == 1) && (info->count != 1)) {
    + if ((tty->count == 1) && (info->port.count != 1)) {
    /*
    * tty->count is 1 and the tty structure will be freed.
    - * info->count should be one in this case.
    + * info->port.count should be one in this case.
    * if it's not, correct it so that the port is shutdown.
    */
    DBGERR(("%s close: bad refcount; tty->count=1, "
    - "info->count=%d\n", info->device_name, info->count));
    - info->count = 1;
    + "info->port.count=%d\n", info->device_name, info->port.count));
    + info->port.count = 1;
    }

    - info->count--;
    + info->port.count--;

    /* if at least one open remaining, leave hardware active */
    - if (info->count)
    + if (info->port.count)
    goto cleanup;

    - info->flags |= ASYNC_CLOSING;
    + info->port.flags |= ASYNC_CLOSING;

    /* set tty->closing to notify line discipline to
    * only process XON/XOFF characters. Only the N_TTY
    @@ -769,7 +763,7 @@ static void close(struct tty_struct *tty, struct file *filp)
    tty_wait_until_sent(tty, info->closing_wait);
    }

    - if (info->flags & ASYNC_INITIALIZED)
    + if (info->port.flags & ASYNC_INITIALIZED)
    wait_until_sent(tty, info->timeout);
    flush_buffer(tty);
    tty_ldisc_flush(tty);
    @@ -777,21 +771,21 @@ static void close(struct tty_struct *tty, struct file *filp)
    shutdown(info);

    tty->closing = 0;
    - info->tty = NULL;
    + info->port.tty = NULL;

    - if (info->blocked_open) {
    + if (info->port.blocked_open) {
    if (info->close_delay) {
    msleep_interruptible(jiffies_to_msecs(info->close_delay));
    }
    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    }

    - info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
    + info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);

    - wake_up_interruptible(&info->close_wait);
    + wake_up_interruptible(&info->port.close_wait);

    cleanup:
    - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->count));
    + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
    }

    static void hangup(struct tty_struct *tty)
    @@ -805,11 +799,11 @@ static void hangup(struct tty_struct *tty)
    flush_buffer(tty);
    shutdown(info);

    - info->count = 0;
    - info->flags &= ~ASYNC_NORMAL_ACTIVE;
    - info->tty = NULL;
    + info->port.count = 0;
    + info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
    + info->port.tty = NULL;

    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    }

    static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
    @@ -959,7 +953,7 @@ static void wait_until_sent(struct tty_struct *tty, int timeout)
    if (sanity_check(info, tty->name, "wait_until_sent"))
    return;
    DBGINFO(("%s wait_until_sent entry\n", info->device_name));
    - if (!(info->flags & ASYNC_INITIALIZED))
    + if (!(info->port.flags & ASYNC_INITIALIZED))
    goto exit;

    orig_jiffies = jiffies;
    @@ -1500,7 +1494,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
    unsigned short new_crctype;

    /* return error if TTY interface open */
    - if (info->count)
    + if (info->port.count)
    return -EBUSY;

    DBGINFO(("%s hdlcdev_attach\n", info->device_name));
    @@ -1600,7 +1594,7 @@ static int hdlcdev_open(struct net_device *dev)

    /* arbitrate between network and tty opens */
    spin_lock_irqsave(&info->netlock, flags);
    - if (info->count != 0 || info->netcount != 0) {
    + if (info->port.count != 0 || info->netcount != 0) {
    DBGINFO(("%s hdlc_open busy\n", dev->name));
    spin_unlock_irqrestore(&info->netlock, flags);
    return -EBUSY;
    @@ -1685,7 +1679,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
    DBGINFO(("%s hdlcdev_ioctl\n", dev->name));

    /* return error if TTY interface open */
    - if (info->count)
    + if (info->port.count)
    return -EBUSY;

    if (cmd != SIOCWANDEV)
    @@ -1906,7 +1900,7 @@ static void hdlcdev_exit(struct slgt_info *info)
    */
    static void rx_async(struct slgt_info *info)
    {
    - struct tty_struct *tty = info->tty;
    + struct tty_struct *tty = info->port.tty;
    struct mgsl_icount *icount = &info->icount;
    unsigned int start, end;
    unsigned char *p;
    @@ -2057,7 +2051,7 @@ static void bh_handler(struct work_struct *work)

    static void bh_transmit(struct slgt_info *info)
    {
    - struct tty_struct *tty = info->tty;
    + struct tty_struct *tty = info->port.tty;

    DBGBH(("%s bh_transmit\n", info->device_name));
    if (tty)
    @@ -2103,17 +2097,17 @@ static void cts_change(struct slgt_info *info, unsigned short status)
    wake_up_interruptible(&info->event_wait_q);
    info->pending_bh |= BH_STATUS;

    - if (info->flags & ASYNC_CTS_FLOW) {
    - if (info->tty) {
    - if (info->tty->hw_stopped) {
    + if (info->port.flags & ASYNC_CTS_FLOW) {
    + if (info->port.tty) {
    + if (info->port.tty->hw_stopped) {
    if (info->signals & SerialSignal_CTS) {
    - info->tty->hw_stopped = 0;
    + info->port.tty->hw_stopped = 0;
    info->pending_bh |= BH_TRANSMIT;
    return;
    }
    } else {
    if (!(info->signals & SerialSignal_CTS))
    - info->tty->hw_stopped = 1;
    + info->port.tty->hw_stopped = 1;
    }
    }
    }
    @@ -2146,12 +2140,12 @@ static void dcd_change(struct slgt_info *info, unsigned short status)
    wake_up_interruptible(&info->event_wait_q);
    info->pending_bh |= BH_STATUS;

    - if (info->flags & ASYNC_CHECK_CD) {
    + if (info->port.flags & ASYNC_CHECK_CD) {
    if (info->signals & SerialSignal_DCD)
    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    else {
    - if (info->tty)
    - tty_hangup(info->tty);
    + if (info->port.tty)
    + tty_hangup(info->port.tty);
    }
    }
    }
    @@ -2194,12 +2188,12 @@ static void isr_serial(struct slgt_info *info)
    if ((status & IRQ_RXBREAK) && (status & RXBREAK)) {
    info->icount.brk++;
    /* process break detection if tty control allows */
    - if (info->tty) {
    + if (info->port.tty) {
    if (!(status & info->ignore_status_mask)) {
    if (info->read_status_mask & MASK_BREAK) {
    - tty_insert_flip_char(info->tty, 0, TTY_BREAK);
    - if (info->flags & ASYNC_SAK)
    - do_SAK(info->tty);
    + tty_insert_flip_char(info->port.tty, 0, TTY_BREAK);
    + if (info->port.flags & ASYNC_SAK)
    + do_SAK(info->port.tty);
    }
    }
    }
    @@ -2319,7 +2313,7 @@ static void isr_txeom(struct slgt_info *info, unsigned short status)
    else
    #endif
    {
    - if (info->tty && (info->tty->stopped || info->tty->hw_stopped)) {
    + if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) {
    tx_stop(info);
    return;
    }
    @@ -2395,7 +2389,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
    for(i=0; i < info->port_count ; i++) {
    struct slgt_info *port = info->port_array[i];

    - if (port && (port->count || port->netcount) &&
    + if (port && (port->port.count || port->netcount) &&
    port->pending_bh && !port->bh_running &&
    !port->bh_requested) {
    DBGISR(("%s bh queued\n", port->device_name));
    @@ -2414,7 +2408,7 @@ static int startup(struct slgt_info *info)
    {
    DBGINFO(("%s startup\n", info->device_name));

    - if (info->flags & ASYNC_INITIALIZED)
    + if (info->port.flags & ASYNC_INITIALIZED)
    return 0;

    if (!info->tx_buf) {
    @@ -2432,10 +2426,10 @@ static int startup(struct slgt_info *info)
    /* program hardware for current parameters */
    change_params(info);

    - if (info->tty)
    - clear_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + clear_bit(TTY_IO_ERROR, &info->port.tty->flags);

    - info->flags |= ASYNC_INITIALIZED;
    + info->port.flags |= ASYNC_INITIALIZED;

    return 0;
    }
    @@ -2447,7 +2441,7 @@ static void shutdown(struct slgt_info *info)
    {
    unsigned long flags;

    - if (!(info->flags & ASYNC_INITIALIZED))
    + if (!(info->port.flags & ASYNC_INITIALIZED))
    return;

    DBGINFO(("%s shutdown\n", info->device_name));
    @@ -2470,7 +2464,7 @@ static void shutdown(struct slgt_info *info)

    slgt_irq_off(info, IRQ_ALL | IRQ_MASTER);

    - if (!info->tty || info->tty->termios->c_cflag & HUPCL) {
    + if (!info->port.tty || info->port.tty->termios->c_cflag & HUPCL) {
    info->signals &= ~(SerialSignal_DTR + SerialSignal_RTS);
    set_signals(info);
    }
    @@ -2479,10 +2473,10 @@ static void shutdown(struct slgt_info *info)

    spin_unlock_irqrestore(&info->lock,flags);

    - if (info->tty)
    - set_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + set_bit(TTY_IO_ERROR, &info->port.tty->flags);

    - info->flags &= ~ASYNC_INITIALIZED;
    + info->port.flags &= ~ASYNC_INITIALIZED;
    }

    static void program_hw(struct slgt_info *info)
    @@ -2511,7 +2505,7 @@ static void program_hw(struct slgt_info *info)
    get_signals(info);

    if (info->netcount ||
    - (info->tty && info->tty->termios->c_cflag & CREAD))
    + (info->port.tty && info->port.tty->termios->c_cflag & CREAD))
    rx_start(info);

    spin_unlock_irqrestore(&info->lock,flags);
    @@ -2525,11 +2519,11 @@ static void change_params(struct slgt_info *info)
    unsigned cflag;
    int bits_per_char;

    - if (!info->tty || !info->tty->termios)
    + if (!info->port.tty || !info->port.tty->termios)
    return;
    DBGINFO(("%s change_params\n", info->device_name));

    - cflag = info->tty->termios->c_cflag;
    + cflag = info->port.tty->termios->c_cflag;

    /* if B0 rate (hangup) specified then negate DTR and RTS */
    /* otherwise assert DTR and RTS */
    @@ -2561,7 +2555,7 @@ static void change_params(struct slgt_info *info)
    bits_per_char = info->params.data_bits +
    info->params.stop_bits + 1;

    - info->params.data_rate = tty_get_baud_rate(info->tty);
    + info->params.data_rate = tty_get_baud_rate(info->port.tty);

    if (info->params.data_rate) {
    info->timeout = (32*HZ*bits_per_char) /
    @@ -2570,30 +2564,30 @@ static void change_params(struct slgt_info *info)
    info->timeout += HZ/50; /* Add .02 seconds of slop */

    if (cflag & CRTSCTS)
    - info->flags |= ASYNC_CTS_FLOW;
    + info->port.flags |= ASYNC_CTS_FLOW;
    else
    - info->flags &= ~ASYNC_CTS_FLOW;
    + info->port.flags &= ~ASYNC_CTS_FLOW;

    if (cflag & CLOCAL)
    - info->flags &= ~ASYNC_CHECK_CD;
    + info->port.flags &= ~ASYNC_CHECK_CD;
    else
    - info->flags |= ASYNC_CHECK_CD;
    + info->port.flags |= ASYNC_CHECK_CD;

    /* process tty input control flags */

    info->read_status_mask = IRQ_RXOVER;
    - if (I_INPCK(info->tty))
    + if (I_INPCK(info->port.tty))
    info->read_status_mask |= MASK_PARITY | MASK_FRAMING;
    - if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
    + if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
    info->read_status_mask |= MASK_BREAK;
    - if (I_IGNPAR(info->tty))
    + if (I_IGNPAR(info->port.tty))
    info->ignore_status_mask |= MASK_PARITY | MASK_FRAMING;
    - if (I_IGNBRK(info->tty)) {
    + if (I_IGNBRK(info->port.tty)) {
    info->ignore_status_mask |= MASK_BREAK;
    /* If ignoring parity and break indicators, ignore
    * overruns too. (For real raw support).
    */
    - if (I_IGNPAR(info->tty))
    + if (I_IGNPAR(info->port.tty))
    info->ignore_status_mask |= MASK_OVERRUN;
    }

    @@ -3144,7 +3138,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,

    if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
    /* nonblock mode is set or port is not enabled */
    - info->flags |= ASYNC_NORMAL_ACTIVE;
    + info->port.flags |= ASYNC_NORMAL_ACTIVE;
    return 0;
    }

    @@ -3153,21 +3147,21 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,

    /* Wait for carrier detect and the line to become
    * free (i.e., not in use by the callout). While we are in
    - * this loop, info->count is dropped by one, so that
    + * this loop, info->port.count is dropped by one, so that
    * close() knows when to free things. We restore it upon
    * exit, either normal or abnormal.
    */

    retval = 0;
    - add_wait_queue(&info->open_wait, &wait);
    + add_wait_queue(&info->port.open_wait, &wait);

    spin_lock_irqsave(&info->lock, flags);
    if (!tty_hung_up_p(filp)) {
    extra_count = true;
    - info->count--;
    + info->port.count--;
    }
    spin_unlock_irqrestore(&info->lock, flags);
    - info->blocked_open++;
    + info->port.blocked_open++;

    while (1) {
    if ((tty->termios->c_cflag & CBAUD)) {
    @@ -3179,8 +3173,8 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,

    set_current_state(TASK_INTERRUPTIBLE);

    - if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)){
    - retval = (info->flags & ASYNC_HUP_NOTIFY) ?
    + if (tty_hung_up_p(filp) || !(info->port.flags & ASYNC_INITIALIZED)){
    + retval = (info->port.flags & ASYNC_HUP_NOTIFY) ?
    -EAGAIN : -ERESTARTSYS;
    break;
    }
    @@ -3189,7 +3183,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
    get_signals(info);
    spin_unlock_irqrestore(&info->lock,flags);

    - if (!(info->flags & ASYNC_CLOSING) &&
    + if (!(info->port.flags & ASYNC_CLOSING) &&
    (do_clocal || (info->signals & SerialSignal_DCD)) ) {
    break;
    }
    @@ -3204,14 +3198,14 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
    }

    set_current_state(TASK_RUNNING);
    - remove_wait_queue(&info->open_wait, &wait);
    + remove_wait_queue(&info->port.open_wait, &wait);

    if (extra_count)
    - info->count++;
    - info->blocked_open--;
    + info->port.count++;
    + info->port.blocked_open--;

    if (!retval)
    - info->flags |= ASYNC_NORMAL_ACTIVE;
    + info->port.flags |= ASYNC_NORMAL_ACTIVE;

    DBGINFO(("%s block_til_ready ready, rc=%d\n", tty->driver->name, retval));
    return retval;
    @@ -3460,8 +3454,7 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev
    info->raw_rx_size = DMABUFSIZE;
    info->close_delay = 5*HZ/10;
    info->closing_wait = 30*HZ;
    - init_waitqueue_head(&info->open_wait);
    - init_waitqueue_head(&info->close_wait);
    + tty_port_init(&info->port);
    init_waitqueue_head(&info->status_event_wait_q);
    init_waitqueue_head(&info->event_wait_q);
    spin_lock_init(&info->netlock);
    @@ -4505,7 +4498,7 @@ static bool rx_get_frame(struct slgt_info *info)
    unsigned short status;
    unsigned int framesize = 0;
    unsigned long flags;
    - struct tty_struct *tty = info->tty;
    + struct tty_struct *tty = info->port.tty;
    unsigned char addr_field = 0xff;
    unsigned int crc_size = 0;

    @@ -4656,7 +4649,7 @@ static bool rx_get_buf(struct slgt_info *info)
    DBGDATA(info, info->rbufs[i].buf, count, "rx");
    DBGINFO(("rx_get_buf size=%d\n", count));
    if (count)
    - ldisc_receive_buf(info->tty, info->rbufs[i].buf,
    + ldisc_receive_buf(info->port.tty, info->rbufs[i].buf,
    info->flag_buf, count);
    free_rbufs(info, i, i);
    return true;
    @@ -4765,11 +4758,11 @@ static int irq_test(struct slgt_info *info)
    {
    unsigned long timeout;
    unsigned long flags;
    - struct tty_struct *oldtty = info->tty;
    + struct tty_struct *oldtty = info->port.tty;
    u32 speed = info->params.data_rate;

    info->params.data_rate = 921600;
    - info->tty = NULL;
    + info->port.tty = NULL;

    spin_lock_irqsave(&info->lock, flags);
    async_mode(info);
    @@ -4797,7 +4790,7 @@ static int irq_test(struct slgt_info *info)
    spin_unlock_irqrestore(&info->lock,flags);

    info->params.data_rate = speed;
    - info->tty = oldtty;
    + info->port.tty = oldtty;

    info->init_error = info->irq_occurred ? 0 : DiagStatus_IrqFailure;
    return info->irq_occurred ? 0 : -ENODEV;
    @@ -4837,7 +4830,7 @@ static int loopback_test(struct slgt_info *info)
    int rc = -ENODEV;
    unsigned long flags;

    - struct tty_struct *oldtty = info->tty;
    + struct tty_struct *oldtty = info->port.tty;
    MGSL_PARAMS params;

    memcpy(&params, &info->params, sizeof(params));
    @@ -4845,7 +4838,7 @@ static int loopback_test(struct slgt_info *info)
    info->params.mode = MGSL_MODE_ASYNC;
    info->params.data_rate = 921600;
    info->params.loopback = 1;
    - info->tty = NULL;
    + info->port.tty = NULL;

    /* build and send transmit frame */
    for (count = 0; count < TESTFRAMESIZE; ++count)
    @@ -4883,7 +4876,7 @@ static int loopback_test(struct slgt_info *info)
    spin_unlock_irqrestore(&info->lock,flags);

    memcpy(&info->params, &params, sizeof(info->params));
    - info->tty = oldtty;
    + info->port.tty = oldtty;

    info->init_error = rc ? DiagStatus_DmaFailure : 0;
    return rc;
    diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
    index 5341b5a..5b5b292 100644
    --- a/drivers/char/synclinkmp.c
    +++ b/drivers/char/synclinkmp.c
    @@ -151,18 +151,15 @@ struct _input_signal_events {
    typedef struct _synclinkmp_info {
    void *if_ptr; /* General purpose pointer (used by SPPP) */
    int magic;
    - int flags;
    - int count; /* count of opens */
    + struct tty_port port;
    int line;
    unsigned short close_delay;
    unsigned short closing_wait; /* time to wait before closing */

    struct mgsl_icount icount;

    - struct tty_struct *tty;
    int timeout;
    int x_char; /* xon/xoff character */
    - int blocked_open; /* # of blocked opens */
    u16 read_status_mask1; /* break detection (SR1 indications) */
    u16 read_status_mask2; /* parity/framing/overun (SR2 indications) */
    unsigned char ignore_status_mask1; /* break detection (SR1 indications) */
    @@ -172,9 +169,6 @@ typedef struct _synclinkmp_info {
    int tx_get;
    int tx_count;

    - wait_queue_head_t open_wait;
    - wait_queue_head_t close_wait;
    -
    wait_queue_head_t status_event_wait_q;
    wait_queue_head_t event_wait_q;
    struct timer_list tx_timer; /* HDLC transmit timeout timer */
    @@ -462,13 +456,13 @@ static int synclinkmp_device_count = 0;
    * .text section address and breakpoint on module load.
    * This is useful for use with gdb and add-symbol-file command.
    */
    -static int break_on_load=0;
    +static int break_on_load = 0;

    /*
    * Driver major number, defaults to zero to get auto
    * assigned major number. May be forced as module parameter.
    */
    -static int ttymajor=0;
    +static int ttymajor = 0;

    /*
    * Array of user specified options for ISA adapters.
    @@ -747,22 +741,22 @@ static int open(struct tty_struct *tty, struct file *filp)
    }

    tty->driver_data = info;
    - info->tty = tty;
    + info->port.tty = tty;

    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):%s open(), old ref count = %d\n",
    - __FILE__,__LINE__,tty->driver->name, info->count);
    + __FILE__,__LINE__,tty->driver->name, info->port.count);

    /* If port is closing, signal caller to try again */
    - if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){
    - if (info->flags & ASYNC_CLOSING)
    - interruptible_sleep_on(&info->close_wait);
    - retval = ((info->flags & ASYNC_HUP_NOTIFY) ?
    + if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
    + if (info->port.flags & ASYNC_CLOSING)
    + interruptible_sleep_on(&info->port.close_wait);
    + retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
    -EAGAIN : -ERESTARTSYS);
    goto cleanup;
    }

    - info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
    + info->port.tty->low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;

    spin_lock_irqsave(&info->netlock, flags);
    if (info->netcount) {
    @@ -770,10 +764,10 @@ static int open(struct tty_struct *tty, struct file *filp)
    spin_unlock_irqrestore(&info->netlock, flags);
    goto cleanup;
    }
    - info->count++;
    + info->port.count++;
    spin_unlock_irqrestore(&info->netlock, flags);

    - if (info->count == 1) {
    + if (info->port.count == 1) {
    /* 1st open on this device, init hardware */
    retval = startup(info);
    if (retval < 0)
    @@ -796,9 +790,9 @@ static int open(struct tty_struct *tty, struct file *filp)
    cleanup:
    if (retval) {
    if (tty->count == 1)
    - info->tty = NULL; /* tty layer will release tty struct */
    - if(info->count)
    - info->count--;
    + info->port.tty = NULL; /* tty layer will release tty struct */
    + if(info->port.count)
    + info->port.count--;
    }

    return retval;
    @@ -816,33 +810,33 @@ static void close(struct tty_struct *tty, struct file *filp)

    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):%s close() entry, count=%d\n",
    - __FILE__,__LINE__, info->device_name, info->count);
    + __FILE__,__LINE__, info->device_name, info->port.count);

    - if (!info->count)
    + if (!info->port.count)
    return;

    if (tty_hung_up_p(filp))
    goto cleanup;

    - if ((tty->count == 1) && (info->count != 1)) {
    + if ((tty->count == 1) && (info->port.count != 1)) {
    /*
    * tty->count is 1 and the tty structure will be freed.
    - * info->count should be one in this case.
    + * info->port.count should be one in this case.
    * if it's not, correct it so that the port is shutdown.
    */
    printk("%s(%d):%s close: bad refcount; tty->count is 1, "
    - "info->count is %d\n",
    - __FILE__,__LINE__, info->device_name, info->count);
    - info->count = 1;
    + "info->port.count is %d\n",
    + __FILE__,__LINE__, info->device_name, info->port.count);
    + info->port.count = 1;
    }

    - info->count--;
    + info->port.count--;

    /* if at least one open remaining, leave hardware active */
    - if (info->count)
    + if (info->port.count)
    goto cleanup;

    - info->flags |= ASYNC_CLOSING;
    + info->port.flags |= ASYNC_CLOSING;

    /* set tty->closing to notify line discipline to
    * only process XON/XOFF characters. Only the N_TTY
    @@ -859,7 +853,7 @@ static void close(struct tty_struct *tty, struct file *filp)
    tty_wait_until_sent(tty, info->closing_wait);
    }

    - if (info->flags & ASYNC_INITIALIZED)
    + if (info->port.flags & ASYNC_INITIALIZED)
    wait_until_sent(tty, info->timeout);

    flush_buffer(tty);
    @@ -869,23 +863,23 @@ static void close(struct tty_struct *tty, struct file *filp)
    shutdown(info);

    tty->closing = 0;
    - info->tty = NULL;
    + info->port.tty = NULL;

    - if (info->blocked_open) {
    + if (info->port.blocked_open) {
    if (info->close_delay) {
    msleep_interruptible(jiffies_to_msecs(info->close_delay));
    }
    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    }

    - info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
    + info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);

    - wake_up_interruptible(&info->close_wait);
    + wake_up_interruptible(&info->port.close_wait);

    cleanup:
    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
    - tty->driver->name, info->count);
    + tty->driver->name, info->port.count);
    }

    /* Called by tty_hangup() when a hangup is signaled.
    @@ -905,11 +899,11 @@ static void hangup(struct tty_struct *tty)
    flush_buffer(tty);
    shutdown(info);

    - info->count = 0;
    - info->flags &= ~ASYNC_NORMAL_ACTIVE;
    - info->tty = NULL;
    + info->port.count = 0;
    + info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
    + info->port.tty = NULL;

    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    }

    /* Set new termios settings
    @@ -1123,7 +1117,7 @@ static void wait_until_sent(struct tty_struct *tty, int timeout)

    lock_kernel();

    - if (!(info->flags & ASYNC_INITIALIZED))
    + if (!(info->port.flags & ASYNC_INITIALIZED))
    goto exit;

    orig_jiffies = jiffies;
    @@ -1636,7 +1630,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
    unsigned short new_crctype;

    /* return error if TTY interface open */
    - if (info->count)
    + if (info->port.count)
    return -EBUSY;

    switch (encoding)
    @@ -1733,7 +1727,7 @@ static int hdlcdev_open(struct net_device *dev)

    /* arbitrate between network and tty opens */
    spin_lock_irqsave(&info->netlock, flags);
    - if (info->count != 0 || info->netcount != 0) {
    + if (info->port.count != 0 || info->netcount != 0) {
    printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
    spin_unlock_irqrestore(&info->netlock, flags);
    return -EBUSY;
    @@ -1819,7 +1813,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
    printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);

    /* return error if TTY interface open */
    - if (info->count)
    + if (info->port.count)
    return -EBUSY;

    if (cmd != SIOCWANDEV)
    @@ -2128,7 +2122,7 @@ static void bh_receive(SLMP_INFO *info)

    static void bh_transmit(SLMP_INFO *info)
    {
    - struct tty_struct *tty = info->tty;
    + struct tty_struct *tty = info->port.tty;

    if ( debug_level >= DEBUG_LEVEL_BH )
    printk( "%s(%d):%s bh_transmit() entry\n",
    @@ -2178,7 +2172,7 @@ static void isr_timer(SLMP_INFO * info)

    static void isr_rxint(SLMP_INFO * info)
    {
    - struct tty_struct *tty = info->tty;
    + struct tty_struct *tty = info->port.tty;
    struct mgsl_icount *icount = &info->icount;
    unsigned char status = read_reg(info, SR1) & info->ie1_value & (FLGD + IDLD + CDCD + BRKD);
    unsigned char status2 = read_reg(info, SR2) & info->ie2_value & OVRN;
    @@ -2205,7 +2199,7 @@ static void isr_rxint(SLMP_INFO * info)
    if (!(status & info->ignore_status_mask1)) {
    if (info->read_status_mask1 & BRKD) {
    tty_insert_flip_char(tty, 0, TTY_BREAK);
    - if (info->flags & ASYNC_SAK)
    + if (info->port.flags & ASYNC_SAK)
    do_SAK(tty);
    }
    }
    @@ -2239,7 +2233,7 @@ static void isr_rxrdy(SLMP_INFO * info)
    {
    u16 status;
    unsigned char DataByte;
    - struct tty_struct *tty = info->tty;
    + struct tty_struct *tty = info->port.tty;
    struct mgsl_icount *icount = &info->icount;

    if ( debug_level >= DEBUG_LEVEL_ISR )
    @@ -2352,7 +2346,7 @@ static void isr_txeom(SLMP_INFO * info, unsigned char status)
    else
    #endif
    {
    - if (info->tty && (info->tty->stopped || info->tty->hw_stopped)) {
    + if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) {
    tx_stop(info);
    return;
    }
    @@ -2407,7 +2401,7 @@ static void isr_txrdy(SLMP_INFO * info)
    return;
    }

    - if (info->tty && (info->tty->stopped || info->tty->hw_stopped)) {
    + if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) {
    tx_stop(info);
    return;
    }
    @@ -2554,29 +2548,29 @@ static void isr_io_pin( SLMP_INFO *info, u16 status )
    wake_up_interruptible(&info->status_event_wait_q);
    wake_up_interruptible(&info->event_wait_q);

    - if ( (info->flags & ASYNC_CHECK_CD) &&
    + if ( (info->port.flags & ASYNC_CHECK_CD) &&
    (status & MISCSTATUS_DCD_LATCHED) ) {
    if ( debug_level >= DEBUG_LEVEL_ISR )
    printk("%s CD now %s...", info->device_name,
    (status & SerialSignal_DCD) ? "on" : "off");
    if (status & SerialSignal_DCD)
    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    else {
    if ( debug_level >= DEBUG_LEVEL_ISR )
    printk("doing serial hangup...");
    - if (info->tty)
    - tty_hangup(info->tty);
    + if (info->port.tty)
    + tty_hangup(info->port.tty);
    }
    }

    - if ( (info->flags & ASYNC_CTS_FLOW) &&
    + if ( (info->port.flags & ASYNC_CTS_FLOW) &&
    (status & MISCSTATUS_CTS_LATCHED) ) {
    - if ( info->tty ) {
    - if (info->tty->hw_stopped) {
    + if ( info->port.tty ) {
    + if (info->port.tty->hw_stopped) {
    if (status & SerialSignal_CTS) {
    if ( debug_level >= DEBUG_LEVEL_ISR )
    printk("CTS tx start...");
    - info->tty->hw_stopped = 0;
    + info->port.tty->hw_stopped = 0;
    tx_start(info);
    info->pending_bh |= BH_TRANSMIT;
    return;
    @@ -2585,7 +2579,7 @@ static void isr_io_pin( SLMP_INFO *info, u16 status )
    if (!(status & SerialSignal_CTS)) {
    if ( debug_level >= DEBUG_LEVEL_ISR )
    printk("CTS tx stop...");
    - info->tty->hw_stopped = 1;
    + info->port.tty->hw_stopped = 1;
    tx_stop(info);
    }
    }
    @@ -2701,7 +2695,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
    * do not request bottom half processing if the
    * device is not open in a normal mode.
    */
    - if ( port && (port->count || port->netcount) &&
    + if ( port && (port->port.count || port->netcount) &&
    port->pending_bh && !port->bh_running &&
    !port->bh_requested ) {
    if ( debug_level >= DEBUG_LEVEL_ISR )
    @@ -2727,7 +2721,7 @@ static int startup(SLMP_INFO * info)
    if ( debug_level >= DEBUG_LEVEL_INFO )
    printk("%s(%d):%s tx_releaseup()\n",__FILE__,__LINE__,info->device_name);

    - if (info->flags & ASYNC_INITIALIZED)
    + if (info->port.flags & ASYNC_INITIALIZED)
    return 0;

    if (!info->tx_buf) {
    @@ -2750,10 +2744,10 @@ static int startup(SLMP_INFO * info)

    mod_timer(&info->status_timer, jiffies + msecs_to_jiffies(10));

    - if (info->tty)
    - clear_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + clear_bit(TTY_IO_ERROR, &info->port.tty->flags);

    - info->flags |= ASYNC_INITIALIZED;
    + info->port.flags |= ASYNC_INITIALIZED;

    return 0;
    }
    @@ -2764,7 +2758,7 @@ static void shutdown(SLMP_INFO * info)
    {
    unsigned long flags;

    - if (!(info->flags & ASYNC_INITIALIZED))
    + if (!(info->port.flags & ASYNC_INITIALIZED))
    return;

    if (debug_level >= DEBUG_LEVEL_INFO)
    @@ -2786,17 +2780,17 @@ static void shutdown(SLMP_INFO * info)

    reset_port(info);

    - if (!info->tty || info->tty->termios->c_cflag & HUPCL) {
    + if (!info->port.tty || info->port.tty->termios->c_cflag & HUPCL) {
    info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS);
    set_signals(info);
    }

    spin_unlock_irqrestore(&info->lock,flags);

    - if (info->tty)
    - set_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + set_bit(TTY_IO_ERROR, &info->port.tty->flags);

    - info->flags &= ~ASYNC_INITIALIZED;
    + info->port.flags &= ~ASYNC_INITIALIZED;
    }

    static void program_hw(SLMP_INFO *info)
    @@ -2827,7 +2821,7 @@ static void program_hw(SLMP_INFO *info)

    get_signals(info);

    - if (info->netcount || (info->tty && info->tty->termios->c_cflag & CREAD) )
    + if (info->netcount || (info->port.tty && info->port.tty->termios->c_cflag & CREAD) )
    rx_start(info);

    spin_unlock_irqrestore(&info->lock,flags);
    @@ -2840,14 +2834,14 @@ static void change_params(SLMP_INFO *info)
    unsigned cflag;
    int bits_per_char;

    - if (!info->tty || !info->tty->termios)
    + if (!info->port.tty || !info->port.tty->termios)
    return;

    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):%s change_params()\n",
    __FILE__,__LINE__, info->device_name );

    - cflag = info->tty->termios->c_cflag;
    + cflag = info->port.tty->termios->c_cflag;

    /* if B0 rate (hangup) specified then negate DTR and RTS */
    /* otherwise assert DTR and RTS */
    @@ -2895,7 +2889,7 @@ static void change_params(SLMP_INFO *info)
    * current data rate.
    */
    if (info->params.data_rate <= 460800) {
    - info->params.data_rate = tty_get_baud_rate(info->tty);
    + info->params.data_rate = tty_get_baud_rate(info->port.tty);
    }

    if ( info->params.data_rate ) {
    @@ -2905,30 +2899,30 @@ static void change_params(SLMP_INFO *info)
    info->timeout += HZ/50; /* Add .02 seconds of slop */

    if (cflag & CRTSCTS)
    - info->flags |= ASYNC_CTS_FLOW;
    + info->port.flags |= ASYNC_CTS_FLOW;
    else
    - info->flags &= ~ASYNC_CTS_FLOW;
    + info->port.flags &= ~ASYNC_CTS_FLOW;

    if (cflag & CLOCAL)
    - info->flags &= ~ASYNC_CHECK_CD;
    + info->port.flags &= ~ASYNC_CHECK_CD;
    else
    - info->flags |= ASYNC_CHECK_CD;
    + info->port.flags |= ASYNC_CHECK_CD;

    /* process tty input control flags */

    info->read_status_mask2 = OVRN;
    - if (I_INPCK(info->tty))
    + if (I_INPCK(info->port.tty))
    info->read_status_mask2 |= PE | FRME;
    - if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
    + if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
    info->read_status_mask1 |= BRKD;
    - if (I_IGNPAR(info->tty))
    + if (I_IGNPAR(info->port.tty))
    info->ignore_status_mask2 |= PE | FRME;
    - if (I_IGNBRK(info->tty)) {
    + if (I_IGNBRK(info->port.tty)) {
    info->ignore_status_mask1 |= BRKD;
    /* If ignoring parity and break indicators, ignore
    * overruns too. (For real raw support).
    */
    - if (I_IGNPAR(info->tty))
    + if (I_IGNPAR(info->port.tty))
    info->ignore_status_mask2 |= OVRN;
    }

    @@ -3348,7 +3342,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
    if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
    /* nonblock mode is set or port is not enabled */
    /* just verify that callout device is not active */
    - info->flags |= ASYNC_NORMAL_ACTIVE;
    + info->port.flags |= ASYNC_NORMAL_ACTIVE;
    return 0;
    }

    @@ -3357,25 +3351,25 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,

    /* Wait for carrier detect and the line to become
    * free (i.e., not in use by the callout). While we are in
    - * this loop, info->count is dropped by one, so that
    + * this loop, info->port.count is dropped by one, so that
    * close() knows when to free things. We restore it upon
    * exit, either normal or abnormal.
    */

    retval = 0;
    - add_wait_queue(&info->open_wait, &wait);
    + add_wait_queue(&info->port.open_wait, &wait);

    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):%s block_til_ready() before block, count=%d\n",
    - __FILE__,__LINE__, tty->driver->name, info->count );
    + __FILE__,__LINE__, tty->driver->name, info->port.count );

    spin_lock_irqsave(&info->lock, flags);
    if (!tty_hung_up_p(filp)) {
    extra_count = true;
    - info->count--;
    + info->port.count--;
    }
    spin_unlock_irqrestore(&info->lock, flags);
    - info->blocked_open++;
    + info->port.blocked_open++;

    while (1) {
    if ((tty->termios->c_cflag & CBAUD)) {
    @@ -3387,8 +3381,8 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,

    set_current_state(TASK_INTERRUPTIBLE);

    - if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)){
    - retval = (info->flags & ASYNC_HUP_NOTIFY) ?
    + if (tty_hung_up_p(filp) || !(info->port.flags & ASYNC_INITIALIZED)){
    + retval = (info->port.flags & ASYNC_HUP_NOTIFY) ?
    -EAGAIN : -ERESTARTSYS;
    break;
    }
    @@ -3397,7 +3391,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
    get_signals(info);
    spin_unlock_irqrestore(&info->lock,flags);

    - if (!(info->flags & ASYNC_CLOSING) &&
    + if (!(info->port.flags & ASYNC_CLOSING) &&
    (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) {
    break;
    }
    @@ -3409,24 +3403,24 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,

    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):%s block_til_ready() count=%d\n",
    - __FILE__,__LINE__, tty->driver->name, info->count );
    + __FILE__,__LINE__, tty->driver->name, info->port.count );

    schedule();
    }

    set_current_state(TASK_RUNNING);
    - remove_wait_queue(&info->open_wait, &wait);
    + remove_wait_queue(&info->port.open_wait, &wait);

    if (extra_count)
    - info->count++;
    - info->blocked_open--;
    + info->port.count++;
    + info->port.blocked_open--;

    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):%s block_til_ready() after, count=%d\n",
    - __FILE__,__LINE__, tty->driver->name, info->count );
    + __FILE__,__LINE__, tty->driver->name, info->port.count );

    if (!retval)
    - info->flags |= ASYNC_NORMAL_ACTIVE;
    + info->port.flags |= ASYNC_NORMAL_ACTIVE;

    return retval;
    }
    @@ -3813,8 +3807,7 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev)
    info->max_frame_size = 4096;
    info->close_delay = 5*HZ/10;
    info->closing_wait = 30*HZ;
    - init_waitqueue_head(&info->open_wait);
    - init_waitqueue_head(&info->close_wait);
    + tty_port_init(&info->port);
    init_waitqueue_head(&info->status_event_wait_q);
    init_waitqueue_head(&info->event_wait_q);
    spin_lock_init(&info->netlock);
    @@ -4885,7 +4878,7 @@ static bool rx_get_frame(SLMP_INFO *info)
    unsigned int framesize = 0;
    bool ReturnCode = false;
    unsigned long flags;
    - struct tty_struct *tty = info->tty;
    + struct tty_struct *tty = info->port.tty;
    unsigned char addr_field = 0xff;
    SCADESC *desc;
    SCADESC_EX *desc_ex;
    @@ -5293,11 +5286,11 @@ static bool loopback_test(SLMP_INFO *info)
    bool rc = false;
    unsigned long flags;

    - struct tty_struct *oldtty = info->tty;
    + struct tty_struct *oldtty = info->port.tty;
    u32 speed = info->params.clock_speed;

    info->params.clock_speed = 3686400;
    - info->tty = NULL;
    + info->port.tty = NULL;

    /* assume failure */
    info->init_error = DiagStatus_DmaFailure;
    @@ -5341,7 +5334,7 @@ static bool loopback_test(SLMP_INFO *info)
    spin_unlock_irqrestore(&info->lock,flags);

    info->params.clock_speed = speed;
    - info->tty = oldtty;
    + info->port.tty = oldtty;

    return rc;
    }

    --
    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 22/70] tty: add more tty_port fields

    From: Alan Cox

    Move more bits into the tty_port structure

    Signed-off-by: Alan Cox
    ---

    drivers/char/cyclades.c | 28 ++++----
    drivers/char/isicom.c | 28 ++++----
    drivers/char/moxa.c | 8 +-
    drivers/char/mxser.c | 29 +++-----
    drivers/char/riscom8.c | 24 +++----
    drivers/char/riscom8.h | 2 -
    drivers/char/rocket.c | 23 +++---
    drivers/char/rocket.h | 4 +
    drivers/char/rocket_int.h | 2 -
    drivers/char/specialix.c | 153 ++++++++++++++++++++----------------------
    drivers/char/specialix_io8.h | 8 --
    drivers/char/sx.c | 2 -
    drivers/char/synclink.c | 16 ++--
    drivers/char/synclink_gt.c | 16 ++--
    drivers/char/synclinkmp.c | 14 ++--
    drivers/char/tty_io.c | 2 +
    include/linux/cyclades.h | 6 +-
    include/linux/tty.h | 2 +
    18 files changed, 169 insertions(+), 198 deletions(-)


    diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
    index e06f637..5ee9f46 100644
    --- a/drivers/char/cyclades.c
    +++ b/drivers/char/cyclades.c
    @@ -2677,8 +2677,8 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
    */
    tty->closing = 1;
    spin_unlock_irqrestore(&card->card_lock, flags);
    - if (info->closing_wait != CY_CLOSING_WAIT_NONE)
    - tty_wait_until_sent(tty, info->closing_wait);
    + if (info->port.closing_wait != CY_CLOSING_WAIT_NONE)
    + tty_wait_until_sent(tty, info->port.closing_wait);

    spin_lock_irqsave(&card->card_lock, flags);

    @@ -2734,9 +2734,9 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
    info->port.tty = NULL;
    if (info->port.blocked_open) {
    spin_unlock_irqrestore(&card->card_lock, flags);
    - if (info->close_delay) {
    + if (info->port.close_delay) {
    msleep_interruptible(jiffies_to_msecs
    - (info->close_delay));
    + (info->port.close_delay));
    }
    wake_up_interruptible(&info->port.open_wait);
    spin_lock_irqsave(&card->card_lock, flags);
    @@ -3382,8 +3382,8 @@ get_serial_info(struct cyclades_port *info,
    cinfo->first_line;
    tmp.irq = cinfo->irq;
    tmp.flags = info->port.flags;
    - tmp.close_delay = info->close_delay;
    - tmp.closing_wait = info->closing_wait;
    + tmp.close_delay = info->port.close_delay;
    + tmp.closing_wait = info->port.closing_wait;
    tmp.baud_base = info->baud;
    tmp.custom_divisor = info->custom_divisor;
    tmp.hub6 = 0; /*!!! */
    @@ -3402,7 +3402,7 @@ set_serial_info(struct cyclades_port *info,
    old_info = *info;

    if (!capable(CAP_SYS_ADMIN)) {
    - if (new_serial.close_delay != info->close_delay ||
    + if (new_serial.close_delay != info->port.close_delay ||
    new_serial.baud_base != info->baud ||
    (new_serial.flags & ASYNC_FLAGS &
    ~ASYNC_USR_MASK) !=
    @@ -3424,8 +3424,8 @@ set_serial_info(struct cyclades_port *info,
    info->custom_divisor = new_serial.custom_divisor;
    info->port.flags = (info->port.flags & ~ASYNC_FLAGS) |
    (new_serial.flags & ASYNC_FLAGS);
    - info->close_delay = new_serial.close_delay * HZ / 100;
    - info->closing_wait = new_serial.closing_wait * HZ / 100;
    + info->port.close_delay = new_serial.close_delay * HZ / 100;
    + info->port.closing_wait = new_serial.closing_wait * HZ / 100;

    check_and_exit:
    if (info->port.flags & ASYNC_INITIALIZED) {
    @@ -3971,11 +3971,11 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
    break;
    #endif /* CONFIG_CYZ_INTR */
    case CYSETWAIT:
    - info->closing_wait = (unsigned short)arg * HZ / 100;
    + info->port.closing_wait = (unsigned short)arg * HZ / 100;
    ret_val = 0;
    break;
    case CYGETWAIT:
    - ret_val = info->closing_wait / (HZ / 100);
    + ret_val = info->port.closing_wait / (HZ / 100);
    break;
    case TIOCGSERIAL:
    ret_val = get_serial_info(info, argp);
    @@ -4376,13 +4376,13 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo)
    for (port = cinfo->first_line; port < cinfo->first_line + nports;
    port++) {
    info = &cinfo->ports[port - cinfo->first_line];
    + tty_port_init(&info->port);
    info->magic = CYCLADES_MAGIC;
    info->card = cinfo;
    info->line = port;
    - info->closing_wait = CLOSING_WAIT_DELAY;
    - info->close_delay = 5 * HZ / 10;

    - tty_port_init(&info->port);
    + info->port.closing_wait = CLOSING_WAIT_DELAY;
    + info->port.close_delay = 5 * HZ / 10;
    info->port.flags = STD_COM_FLAGS;
    init_completion(&info->shutdown_wait);
    init_waitqueue_head(&info->delta_msr_wait);
    diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
    index 20be56f..fdc9420 100644
    --- a/drivers/char/isicom.c
    +++ b/drivers/char/isicom.c
    @@ -199,10 +199,8 @@ struct isi_board {
    struct isi_port {
    unsigned short magic;
    struct tty_port port;
    - int close_delay;
    u16 channel;
    u16 status;
    - u16 closing_wait;
    struct isi_board *card;
    unsigned char *xmit_buf;
    int xmit_head;
    @@ -1051,8 +1049,8 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
    tty->closing = 1;
    spin_unlock_irqrestore(&card->card_lock, flags);

    - if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
    - tty_wait_until_sent(tty, port->closing_wait);
    + if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
    + tty_wait_until_sent(tty, port->port.closing_wait);
    /* indicate to the card that no more data can be received
    on this port */
    spin_lock_irqsave(&card->card_lock, flags);
    @@ -1071,10 +1069,10 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)

    if (port->port.blocked_open) {
    spin_unlock_irqrestore(&card->card_lock, flags);
    - if (port->close_delay) {
    + if (port->port.close_delay) {
    pr_dbg("scheduling until time out.\n");
    msleep_interruptible(
    - jiffies_to_msecs(port->close_delay));
    + jiffies_to_msecs(port->port.close_delay));
    }
    spin_lock_irqsave(&card->card_lock, flags);
    wake_up_interruptible(&port->port.open_wait);
    @@ -1256,8 +1254,8 @@ static int isicom_set_serial_info(struct isi_port *port,
    (newinfo.flags & ASYNC_SPD_MASK));

    if (!capable(CAP_SYS_ADMIN)) {
    - if ((newinfo.close_delay != port->close_delay) ||
    - (newinfo.closing_wait != port->closing_wait) ||
    + if ((newinfo.close_delay != port->port.close_delay) ||
    + (newinfo.closing_wait != port->port.closing_wait) ||
    ((newinfo.flags & ~ASYNC_USR_MASK) !=
    (port->port.flags & ~ASYNC_USR_MASK))) {
    unlock_kernel();
    @@ -1266,8 +1264,8 @@ static int isicom_set_serial_info(struct isi_port *port,
    port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
    (newinfo.flags & ASYNC_USR_MASK));
    } else {
    - port->close_delay = newinfo.close_delay;
    - port->closing_wait = newinfo.closing_wait;
    + port->port.close_delay = newinfo.close_delay;
    + port->port.closing_wait = newinfo.closing_wait;
    port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) |
    (newinfo.flags & ASYNC_FLAGS));
    }
    @@ -1294,8 +1292,8 @@ static int isicom_get_serial_info(struct isi_port *port,
    out_info.irq = port->card->irq;
    out_info.flags = port->port.flags;
    /* out_info.baud_base = ? */
    - out_info.close_delay = port->close_delay;
    - out_info.closing_wait = port->closing_wait;
    + out_info.close_delay = port->port.close_delay;
    + out_info.closing_wait = port->port.closing_wait;
    unlock_kernel();
    if (copy_to_user(info, &out_info, sizeof(out_info)))
    return -EFAULT;
    @@ -1796,13 +1794,13 @@ static int __init isicom_init(void)
    isi_card[idx].ports = port;
    spin_lock_init(&isi_card[idx].card_lock);
    for (channel = 0; channel < 16; channel++, port++) {
    + tty_port_init(&port->port);
    port->magic = ISICOM_MAGIC;
    port->card = &isi_card[idx];
    port->channel = channel;
    - port->close_delay = 50 * HZ/100;
    - port->closing_wait = 3000 * HZ/100;
    + port->port.close_delay = 50 * HZ/100;
    + port->port.closing_wait = 3000 * HZ/100;
    port->status = 0;
    - tty_port_init(&port->port);
    /* . . . */
    }
    isi_card[idx].base = 0;
    diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
    index bb9bcff..f8d48ed 100644
    --- a/drivers/char/moxa.c
    +++ b/drivers/char/moxa.c
    @@ -135,7 +135,6 @@ struct moxa_port {
    void __iomem *tableAddr;

    int type;
    - int close_delay;
    int cflag;
    unsigned long statusflags;

    @@ -822,10 +821,9 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)
    }

    for (i = 0, p = brd->ports; i < MAX_PORTS_PER_BOARD; i++, p++) {
    + tty_port_init(&p->port);
    p->type = PORT_16550A;
    - p->close_delay = 5 * HZ / 10;
    p->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
    - tty_port_init(&p->port);
    }

    switch (brd->boardType) {
    @@ -2124,7 +2122,7 @@ static int moxa_get_serial_info(struct moxa_port *info,
    .line = info->port.tty->index,
    .flags = info->port.flags,
    .baud_base = 921600,
    - .close_delay = info->close_delay
    + .close_delay = info->port.close_delay
    };
    return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
    }
    @@ -2148,7 +2146,7 @@ static int moxa_set_serial_info(struct moxa_port *info,
    (info->port.flags & ~ASYNC_USR_MASK)))
    return -EPERM;
    } else
    - info->close_delay = new_serial.close_delay * HZ / 100;
    + info->port.close_delay = new_serial.close_delay * HZ / 100;

    new_serial.flags = (new_serial.flags & ~ASYNC_FLAGS);
    new_serial.flags |= (info->port.flags & ASYNC_FLAGS);
    diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
    index e83ccee..6307e30 100644
    --- a/drivers/char/mxser.c
    +++ b/drivers/char/mxser.c
    @@ -243,10 +243,7 @@ struct mxser_port {
    unsigned char ldisc_stop_rx;

    int custom_divisor;
    - int close_delay;
    - unsigned short closing_wait;
    unsigned char err_shadow;
    - unsigned long event;

    struct async_icount icount; /* kernel counters for 4 input interrupts */
    int timeout;
    @@ -1199,8 +1196,8 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
    * the line discipline to only process XON/XOFF characters.
    */
    tty->closing = 1;
    - if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE)
    - tty_wait_until_sent(tty, info->closing_wait);
    + if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
    + tty_wait_until_sent(tty, info->port.closing_wait);
    /*
    * At this point we stop accepting input. To do this, we
    * disable the receive line status interrupts, and tell the
    @@ -1231,11 +1228,10 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
    tty_ldisc_flush(tty);

    tty->closing = 0;
    - info->event = 0;
    info->port.tty = NULL;
    if (info->port.blocked_open) {
    - if (info->close_delay)
    - schedule_timeout_interruptible(info->close_delay);
    + if (info->port.close_delay)
    + schedule_timeout_interruptible(info->port.close_delay);
    wake_up_interruptible(&info->port.open_wait);
    }

    @@ -1370,8 +1366,8 @@ static int mxser_get_serial_info(struct mxser_port *info,
    .irq = info->board->irq,
    .flags = info->port.flags,
    .baud_base = info->baud_base,
    - .close_delay = info->close_delay,
    - .closing_wait = info->closing_wait,
    + .close_delay = info->port.close_delay,
    + .closing_wait = info->port.closing_wait,
    .custom_divisor = info->custom_divisor,
    .hub6 = 0
    };
    @@ -1402,7 +1398,7 @@ static int mxser_set_serial_info(struct mxser_port *info,

    if (!capable(CAP_SYS_ADMIN)) {
    if ((new_serial.baud_base != info->baud_base) ||
    - (new_serial.close_delay != info->close_delay) ||
    + (new_serial.close_delay != info->port.close_delay) ||
    ((new_serial.flags & ~ASYNC_USR_MASK) != (info->port.flags & ~ASYNC_USR_MASK)))
    return -EPERM;
    info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK) |
    @@ -1414,8 +1410,8 @@ static int mxser_set_serial_info(struct mxser_port *info,
    */
    info->port.flags = ((info->port.flags & ~ASYNC_FLAGS) |
    (new_serial.flags & ASYNC_FLAGS));
    - info->close_delay = new_serial.close_delay * HZ / 100;
    - info->closing_wait = new_serial.closing_wait * HZ / 100;
    + info->port.close_delay = new_serial.close_delay * HZ / 100;
    + info->port.closing_wait = new_serial.closing_wait * HZ / 100;
    info->port.tty->low_latency =
    (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
    info->port.tty->low_latency = 0;
    @@ -2214,7 +2210,6 @@ static void mxser_hangup(struct tty_struct *tty)

    mxser_flush_buffer(tty);
    mxser_shutdown(info);
    - info->event = 0;
    info->port.count = 0;
    info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
    info->port.tty = NULL;
    @@ -2545,6 +2540,7 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,

    for (i = 0; i < brd->info->nports; i++) {
    info = &brd->ports[i];
    + tty_port_init(&info->port);
    info->board = brd;
    info->stop_rx = 0;
    info->ldisc_stop_rx = 0;
    @@ -2559,10 +2555,9 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,
    process_txrx_fifo(info);

    info->custom_divisor = info->baud_base * 16;
    - info->close_delay = 5 * HZ / 10;
    - info->closing_wait = 30 * HZ;
    + info->port.close_delay = 5 * HZ / 10;
    + info->port.closing_wait = 30 * HZ;
    info->normal_termios = mxvar_sdriver->init_termios;
    - tty_port_init(&info->port);
    init_waitqueue_head(&info->delta_msr_wait);
    memset(&info->mon_data, 0, sizeof(struct mxser_mon));
    info->err_shadow = 0;
    diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
    index 3ca8957..724b2b2 100644
    --- a/drivers/char/riscom8.c
    +++ b/drivers/char/riscom8.c
    @@ -1032,8 +1032,8 @@ static void rc_close(struct tty_struct *tty, struct file *filp)
    * the line discipline to only process XON/XOFF characters.
    */
    tty->closing = 1;
    - if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
    - tty_wait_until_sent(tty, port->closing_wait);
    + if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
    + tty_wait_until_sent(tty, port->port.closing_wait);
    /*
    * At this point we stop accepting input. To do this, we
    * disable the receive line status interrupts, and tell the
    @@ -1065,8 +1065,8 @@ static void rc_close(struct tty_struct *tty, struct file *filp)
    tty->closing = 0;
    port->port.tty = NULL;
    if (port->port.blocked_open) {
    - if (port->close_delay)
    - msleep_interruptible(jiffies_to_msecs(port->close_delay));
    + if (port->port.close_delay)
    + msleep_interruptible(jiffies_to_msecs(port->port.close_delay));
    wake_up_interruptible(&port->port.open_wait);
    }
    port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
    @@ -1295,8 +1295,8 @@ static int rc_set_serial_info(struct riscom_port *port,
    (tmp.flags & ASYNC_SPD_MASK));

    if (!capable(CAP_SYS_ADMIN)) {
    - if ((tmp.close_delay != port->close_delay) ||
    - (tmp.closing_wait != port->closing_wait) ||
    + if ((tmp.close_delay != port->port.close_delay) ||
    + (tmp.closing_wait != port->port.closing_wait) ||
    ((tmp.flags & ~ASYNC_USR_MASK) !=
    (port->port.flags & ~ASYNC_USR_MASK)))
    return -EPERM;
    @@ -1305,8 +1305,8 @@ static int rc_set_serial_info(struct riscom_port *port,
    } else {
    port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) |
    (tmp.flags & ASYNC_FLAGS));
    - port->close_delay = tmp.close_delay;
    - port->closing_wait = tmp.closing_wait;
    + port->port.close_delay = tmp.close_delay;
    + port->port.closing_wait = tmp.closing_wait;
    }
    if (change_speed) {
    unsigned long flags;
    @@ -1331,8 +1331,8 @@ static int rc_get_serial_info(struct riscom_port *port,
    tmp.irq = bp->irq;
    tmp.flags = port->port.flags;
    tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC;
    - tmp.close_delay = port->close_delay * HZ/100;
    - tmp.closing_wait = port->closing_wait * HZ/100;
    + tmp.close_delay = port->port.close_delay * HZ/100;
    + tmp.closing_wait = port->port.closing_wait * HZ/100;
    tmp.xmit_fifo_size = CD180_NFIFO;
    return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0;
    }
    @@ -1549,10 +1549,8 @@ static int __init rc_init_drivers(void)
    }
    memset(rc_port, 0, sizeof(rc_port));
    for (i = 0; i < RC_NPORT * RC_NBOARD; i++) {
    - rc_port[i].magic = RISCOM8_MAGIC;
    - rc_port[i].close_delay = 50 * HZ / 100;
    - rc_port[i].closing_wait = 3000 * HZ / 100;
    tty_port_init(&rc_port[i].port);
    + rc_port[i].magic = RISCOM8_MAGIC;
    }
    return 0;
    }
    diff --git a/drivers/char/riscom8.h b/drivers/char/riscom8.h
    index 29ddbab..c9876b3 100644
    --- a/drivers/char/riscom8.h
    +++ b/drivers/char/riscom8.h
    @@ -69,14 +69,12 @@ struct riscom_port {
    struct tty_port port;
    int baud_base;
    int timeout;
    - int close_delay;
    int custom_divisor;
    int xmit_head;
    int xmit_tail;
    int xmit_cnt;
    short wakeup_chars;
    short break_length;
    - unsigned short closing_wait;
    unsigned char mark_mask;
    unsigned char IER;
    unsigned char MSVR;
    diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
    index ab04adb..bdced0e 100644
    --- a/drivers/char/rocket.c
    +++ b/drivers/char/rocket.c
    @@ -72,6 +72,7 @@
    #include
    #include
    #include
    +#include
    #include
    #include
    #include
    @@ -81,7 +82,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include
    #include
    @@ -648,8 +649,8 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
    info->board = board;
    info->aiop = aiop;
    info->chan = chan;
    - info->closing_wait = 3000;
    - info->close_delay = 50;
    + info->port.closing_wait = 3000;
    + info->port.close_delay = 50;
    init_waitqueue_head(&info->port.open_wait);
    init_completion(&info->close_wait);
    info->flags &= ~ROCKET_MODE_MASK;
    @@ -1137,8 +1138,8 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
    /*
    * Wait for the transmit buffer to clear
    */
    - if (info->closing_wait != ROCKET_CLOSING_WAIT_NONE)
    - tty_wait_until_sent(tty, info->closing_wait);
    + if (info->port.closing_wait != ROCKET_CLOSING_WAIT_NONE)
    + tty_wait_until_sent(tty, info->port.closing_wait);
    /*
    * Before we drop DTR, make sure the UART transmitter
    * has completely drained; this is especially
    @@ -1168,8 +1169,8 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
    clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);

    if (info->port.blocked_open) {
    - if (info->close_delay) {
    - msleep_interruptible(jiffies_to_msecs(info->close_delay));
    + if (info->port.close_delay) {
    + msleep_interruptible(jiffies_to_msecs(info->port.close_delay));
    }
    wake_up_interruptible(&info->port.open_wait);
    } else {
    @@ -1327,8 +1328,8 @@ static int get_config(struct r_port *info, struct rocket_config __user *retinfo)
    memset(&tmp, 0, sizeof (tmp));
    tmp.line = info->line;
    tmp.flags = info->flags;
    - tmp.close_delay = info->close_delay;
    - tmp.closing_wait = info->closing_wait;
    + tmp.close_delay = info->port.close_delay;
    + tmp.closing_wait = info->port.closing_wait;
    tmp.port = rcktpt_io_addr[(info->line >> 5) & 3];

    if (copy_to_user(retinfo, &tmp, sizeof (*retinfo)))
    @@ -1353,8 +1354,8 @@ static int set_config(struct r_port *info, struct rocket_config __user *new_info
    }

    info->flags = ((info->flags & ~ROCKET_FLAGS) | (new_serial.flags & ROCKET_FLAGS));
    - info->close_delay = new_serial.close_delay;
    - info->closing_wait = new_serial.closing_wait;
    + info->port.close_delay = new_serial.close_delay;
    + info->port.closing_wait = new_serial.closing_wait;

    if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI)
    info->port.tty->alt_speed = 57600;
    diff --git a/drivers/char/rocket.h b/drivers/char/rocket.h
    index ae6b04f..a8b0919 100644
    --- a/drivers/char/rocket.h
    +++ b/drivers/char/rocket.h
    @@ -64,8 +64,8 @@ struct rocket_version {
    /*
    * For closing_wait and closing_wait2
    */
    -#define ROCKET_CLOSING_WAIT_NONE 65535
    -#define ROCKET_CLOSING_WAIT_INF 0
    +#define ROCKET_CLOSING_WAIT_NONE ASYNC_CLOSING_WAIT_NONE
    +#define ROCKET_CLOSING_WAIT_INF ASYNC_CLOSING_WAIT_INF

    /*
    * Rocketport ioctls -- "RP"
    diff --git a/drivers/char/rocket_int.h b/drivers/char/rocket_int.h
    index 3affc48..21f3ff5 100644
    --- a/drivers/char/rocket_int.h
    +++ b/drivers/char/rocket_int.h
    @@ -1133,8 +1133,6 @@ struct r_port {
    unsigned int chan:3;
    CONTROLLER_t *ctlp;
    CHANNEL_t channel;
    - int closing_wait;
    - int close_delay;
    int intmask;
    int xmit_fifo_room; /* room in xmit fifo */
    unsigned char *xmit_buf;
    diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
    index 2ee4d98..037dc47 100644
    --- a/drivers/char/specialix.c
    +++ b/drivers/char/specialix.c
    @@ -608,9 +608,9 @@ static inline struct specialix_port * sx_get_port(struct specialix_board * bp,
    dprintk (SX_DEBUG_CHAN, "channel: %d\n", channel);
    if (channel < CD186x_NCH) {
    port = &sx_port[board_No(bp) * SX_NPORT + channel];
    - dprintk (SX_DEBUG_CHAN, "port: %d %p flags: 0x%x\n",board_No(bp) * SX_NPORT + channel, port, port->flags & ASYNC_INITIALIZED);
    + dprintk (SX_DEBUG_CHAN, "port: %d %p flags: 0x%lx\n",board_No(bp) * SX_NPORT + channel, port, port->port.flags & ASYNC_INITIALIZED);

    - if (port->flags & ASYNC_INITIALIZED) {
    + if (port->port.flags & ASYNC_INITIALIZED) {
    dprintk (SX_DEBUG_CHAN, "port: %d %p\n", channel, port);
    func_exit();
    return port;
    @@ -637,7 +637,7 @@ static inline void sx_receive_exc(struct specialix_board * bp)
    func_exit();
    return;
    }
    - tty = port->tty;
    + tty = port->port.tty;

    status = sx_in(bp, CD186x_RCSR);

    @@ -673,7 +673,7 @@ static inline void sx_receive_exc(struct specialix_board * bp)
    dprintk(SX_DEBUG_RX, "sx%d: port %d: Handling break...\n",
    board_No(bp), port_No(port));
    flag = TTY_BREAK;
    - if (port->flags & ASYNC_SAK)
    + if (port->port.flags & ASYNC_SAK)
    do_SAK(tty);

    } else if (status & RCSR_PE)
    @@ -707,7 +707,7 @@ static inline void sx_receive(struct specialix_board * bp)
    func_exit();
    return;
    }
    - tty = port->tty;
    + tty = port->port.tty;

    count = sx_in(bp, CD186x_RDCR);
    dprintk (SX_DEBUG_RX, "port: %p: count: %d\n", port, count);
    @@ -734,7 +734,7 @@ static inline void sx_transmit(struct specialix_board * bp)
    return;
    }
    dprintk (SX_DEBUG_TX, "port: %p\n", port);
    - tty = port->tty;
    + tty = port->port.tty;

    if (port->IER & IER_TXEMPTY) {
    /* FIFO drained */
    @@ -811,7 +811,7 @@ static inline void sx_check_modem(struct specialix_board * bp)
    if (!(port = sx_get_port(bp, "Modem")))
    return;

    - tty = port->tty;
    + tty = port->port.tty;

    mcr = sx_in(bp, CD186x_MCR);
    printk ("mcr = %02x.\n", mcr);
    @@ -821,7 +821,7 @@ static inline void sx_check_modem(struct specialix_board * bp)
    msvr_cd = sx_in(bp, CD186x_MSVR) & MSVR_CD;
    if (msvr_cd) {
    dprintk (SX_DEBUG_SIGNALS, "Waking up guys in open.\n");
    - wake_up_interruptible(&port->open_wait);
    + wake_up_interruptible(&port->port.open_wait);
    } else {
    dprintk (SX_DEBUG_SIGNALS, "Sending HUP.\n");
    tty_hangup(tty);
    @@ -1030,7 +1030,7 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p

    func_enter();

    - if (!(tty = port->tty) || !tty->termios) {
    + if (!(tty = port->port.tty) || !tty->termios) {
    func_exit();
    return;
    }
    @@ -1052,9 +1052,9 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
    baud = tty_get_baud_rate(tty);

    if (baud == 38400) {
    - if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
    + if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
    baud = 57600;
    - if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
    + if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
    baud = 115200;
    }

    @@ -1244,7 +1244,7 @@ static int sx_setup_port(struct specialix_board *bp, struct specialix_port *port

    func_enter();

    - if (port->flags & ASYNC_INITIALIZED) {
    + if (port->port.flags & ASYNC_INITIALIZED) {
    func_exit();
    return 0;
    }
    @@ -1268,12 +1268,12 @@ static int sx_setup_port(struct specialix_board *bp, struct specialix_port *port

    spin_lock_irqsave(&port->lock, flags);

    - if (port->tty)
    - clear_bit(TTY_IO_ERROR, &port->tty->flags);
    + if (port->port.tty)
    + clear_bit(TTY_IO_ERROR, &port->port.tty->flags);

    port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
    sx_change_speed(bp, port);
    - port->flags |= ASYNC_INITIALIZED;
    + port->port.flags |= ASYNC_INITIALIZED;

    spin_unlock_irqrestore(&port->lock, flags);

    @@ -1292,7 +1292,7 @@ static void sx_shutdown_port(struct specialix_board *bp, struct specialix_port *

    func_enter();

    - if (!(port->flags & ASYNC_INITIALIZED)) {
    + if (!(port->port.flags & ASYNC_INITIALIZED)) {
    func_exit();
    return;
    }
    @@ -1315,7 +1315,7 @@ static void sx_shutdown_port(struct specialix_board *bp, struct specialix_port *
    spin_lock_irqsave(&bp->lock, flags);
    sx_out(bp, CD186x_CAR, port_No(port));

    - if (!(tty = port->tty) || C_HUPCL(tty)) {
    + if (!(tty = port->port.tty) || C_HUPCL(tty)) {
    /* Drop DTR */
    sx_out(bp, CD186x_MSVDTR, 0);
    }
    @@ -1330,7 +1330,7 @@ static void sx_shutdown_port(struct specialix_board *bp, struct specialix_port *
    spin_unlock_irqrestore(&bp->lock, flags);
    if (tty)
    set_bit(TTY_IO_ERROR, &tty->flags);
    - port->flags &= ~ASYNC_INITIALIZED;
    + port->port.flags &= ~ASYNC_INITIALIZED;

    if (!bp->count)
    sx_shutdown_board(bp);
    @@ -1354,9 +1354,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
    * If the device is in the middle of being closed, then block
    * until it's done, and then try again.
    */
    - if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
    - interruptible_sleep_on(&port->close_wait);
    - if (port->flags & ASYNC_HUP_NOTIFY) {
    + if (tty_hung_up_p(filp) || port->port.flags & ASYNC_CLOSING) {
    + interruptible_sleep_on(&port->port.close_wait);
    + if (port->port.flags & ASYNC_HUP_NOTIFY) {
    func_exit();
    return -EAGAIN;
    } else {
    @@ -1371,7 +1371,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
    */
    if ((filp->f_flags & O_NONBLOCK) ||
    (tty->flags & (1 << TTY_IO_ERROR))) {
    - port->flags |= ASYNC_NORMAL_ACTIVE;
    + port->port.flags |= ASYNC_NORMAL_ACTIVE;
    func_exit();
    return 0;
    }
    @@ -1387,13 +1387,13 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
    * exit, either normal or abnormal.
    */
    retval = 0;
    - add_wait_queue(&port->open_wait, &wait);
    + add_wait_queue(&port->port.open_wait, &wait);
    spin_lock_irqsave(&port->lock, flags);
    if (!tty_hung_up_p(filp)) {
    - port->count--;
    + port->port.count--;
    }
    spin_unlock_irqrestore(&port->lock, flags);
    - port->blocked_open++;
    + port->port.blocked_open++;
    while (1) {
    spin_lock_irqsave(&bp->lock, flags);
    sx_out(bp, CD186x_CAR, port_No(port));
    @@ -1410,14 +1410,14 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
    spin_unlock_irqrestore(&bp->lock, flags);
    set_current_state(TASK_INTERRUPTIBLE);
    if (tty_hung_up_p(filp) ||
    - !(port->flags & ASYNC_INITIALIZED)) {
    - if (port->flags & ASYNC_HUP_NOTIFY)
    + !(port->port.flags & ASYNC_INITIALIZED)) {
    + if (port->port.flags & ASYNC_HUP_NOTIFY)
    retval = -EAGAIN;
    else
    retval = -ERESTARTSYS;
    break;
    }
    - if (!(port->flags & ASYNC_CLOSING) &&
    + if (!(port->port.flags & ASYNC_CLOSING) &&
    (do_clocal || CD))
    break;
    if (signal_pending(current)) {
    @@ -1428,19 +1428,19 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
    }

    set_current_state(TASK_RUNNING);
    - remove_wait_queue(&port->open_wait, &wait);
    + remove_wait_queue(&port->port.open_wait, &wait);
    spin_lock_irqsave(&port->lock, flags);
    if (!tty_hung_up_p(filp)) {
    - port->count++;
    + port->port.count++;
    }
    - port->blocked_open--;
    + port->port.blocked_open--;
    spin_unlock_irqrestore(&port->lock, flags);
    if (retval) {
    func_exit();
    return retval;
    }

    - port->flags |= ASYNC_NORMAL_ACTIVE;
    + port->port.flags |= ASYNC_NORMAL_ACTIVE;
    func_exit();
    return 0;
    }
    @@ -1484,10 +1484,10 @@ static int sx_open(struct tty_struct * tty, struct file * filp)
    }

    spin_lock_irqsave(&bp->lock, flags);
    - port->count++;
    + port->port.count++;
    bp->count++;
    tty->driver_data = port;
    - port->tty = tty;
    + port->port.tty = tty;
    spin_unlock_irqrestore(&bp->lock, flags);

    if ((error = sx_setup_port(bp, port))) {
    @@ -1547,15 +1547,15 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
    }

    bp = port_Board(port);
    - if ((tty->count == 1) && (port->count != 1)) {
    + if ((tty->count == 1) && (port->port.count != 1)) {
    printk(KERN_ERR "sx%d: sx_close: bad port count;"
    " tty->count is 1, port count is %d\n",
    - board_No(bp), port->count);
    - port->count = 1;
    + board_No(bp), port->port.count);
    + port->port.count = 1;
    }

    - if (port->count > 1) {
    - port->count--;
    + if (port->port.count > 1) {
    + port->port.count--;
    bp->count--;

    spin_unlock_irqrestore(&port->lock, flags);
    @@ -1563,7 +1563,7 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
    func_exit();
    return;
    }
    - port->flags |= ASYNC_CLOSING;
    + port->port.flags |= ASYNC_CLOSING;
    /*
    * Now we wait for the transmit buffer to clear; and we notify
    * the line discipline to only process XON/XOFF characters.
    @@ -1571,8 +1571,8 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
    tty->closing = 1;
    spin_unlock_irqrestore(&port->lock, flags);
    dprintk (SX_DEBUG_OPEN, "Closing\n");
    - if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) {
    - tty_wait_until_sent(tty, port->closing_wait);
    + if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) {
    + tty_wait_until_sent(tty, port->port.closing_wait);
    }
    /*
    * At this point we stop accepting input. To do this, we
    @@ -1582,7 +1582,7 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
    */
    dprintk (SX_DEBUG_OPEN, "Closed\n");
    port->IER &= ~IER_RXD;
    - if (port->flags & ASYNC_INITIALIZED) {
    + if (port->port.flags & ASYNC_INITIALIZED) {
    port->IER &= ~IER_TXRDY;
    port->IER |= IER_TXEMPTY;
    spin_lock_irqsave(&bp->lock, flags);
    @@ -1611,10 +1611,10 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
    board_No(bp), bp->count, tty->index);
    bp->count = 0;
    }
    - if (--port->count < 0) {
    + if (--port->port.count < 0) {
    printk(KERN_ERR "sx%d: sx_close: bad port count for tty%d: %d\n",
    - board_No(bp), port_No(port), port->count);
    - port->count = 0;
    + board_No(bp), port_No(port), port->port.count);
    + port->port.count = 0;
    }

    sx_shutdown_port(bp, port);
    @@ -1622,16 +1622,16 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
    tty_ldisc_flush(tty);
    spin_lock_irqsave(&port->lock, flags);
    tty->closing = 0;
    - port->tty = NULL;
    + port->port.tty = NULL;
    spin_unlock_irqrestore(&port->lock, flags);
    - if (port->blocked_open) {
    - if (port->close_delay) {
    - msleep_interruptible(jiffies_to_msecs(port->close_delay));
    + if (port->port.blocked_open) {
    + if (port->port.close_delay) {
    + msleep_interruptible(jiffies_to_msecs(port->port.close_delay));
    }
    - wake_up_interruptible(&port->open_wait);
    + wake_up_interruptible(&port->port.open_wait);
    }
    - port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
    - wake_up_interruptible(&port->close_wait);
    + port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
    + wake_up_interruptible(&port->port.close_wait);

    func_exit();
    }
    @@ -1815,7 +1815,7 @@ static int sx_tiocmget(struct tty_struct *tty, struct file *file)
    dprintk (SX_DEBUG_INIT, "Got msvr[%d] = %02x, car = %d.\n",
    port_No(port), status, sx_in (bp, CD186x_CAR));
    dprintk (SX_DEBUG_INIT, "sx_port = %p, port = %p\n", sx_port, port);
    - if (SX_CRTSCTS(port->tty)) {
    + if (SX_CRTSCTS(port->port.tty)) {
    result = /* (status & MSVR_RTS) ? */ TIOCM_DTR /* : 0) */
    | ((status & MSVR_DTR) ? TIOCM_RTS : 0)
    | ((status & MSVR_CD) ? TIOCM_CAR : 0)
    @@ -1857,7 +1857,7 @@ static int sx_tiocmset(struct tty_struct *tty, struct file *file,
    /* if (set & TIOCM_DTR)
    port->MSVR |= MSVR_DTR; */

    - if (SX_CRTSCTS(port->tty)) {
    + if (SX_CRTSCTS(port->port.tty)) {
    if (set & TIOCM_RTS)
    port->MSVR |= MSVR_DTR;
    } else {
    @@ -1869,7 +1869,7 @@ static int sx_tiocmset(struct tty_struct *tty, struct file *file,
    port->MSVR &= ~MSVR_RTS; */
    /* if (clear & TIOCM_DTR)
    port->MSVR &= ~MSVR_DTR; */
    - if (SX_CRTSCTS(port->tty)) {
    + if (SX_CRTSCTS(port->port.tty)) {
    if (clear & TIOCM_RTS)
    port->MSVR &= ~MSVR_DTR;
    } else {
    @@ -1929,27 +1929,27 @@ static inline int sx_set_serial_info(struct specialix_port * port,

    lock_kernel();

    - change_speed = ((port->flags & ASYNC_SPD_MASK) !=
    + change_speed = ((port->port.flags & ASYNC_SPD_MASK) !=
    (tmp.flags & ASYNC_SPD_MASK));
    change_speed |= (tmp.custom_divisor != port->custom_divisor);

    if (!capable(CAP_SYS_ADMIN)) {
    - if ((tmp.close_delay != port->close_delay) ||
    - (tmp.closing_wait != port->closing_wait) ||
    + if ((tmp.close_delay != port->port.close_delay) ||
    + (tmp.closing_wait != port->port.closing_wait) ||
    ((tmp.flags & ~ASYNC_USR_MASK) !=
    - (port->flags & ~ASYNC_USR_MASK))) {
    + (port->port.flags & ~ASYNC_USR_MASK))) {
    func_exit();
    unlock_kernel();
    return -EPERM;
    }
    - port->flags = ((port->flags & ~ASYNC_USR_MASK) |
    + port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
    (tmp.flags & ASYNC_USR_MASK));
    port->custom_divisor = tmp.custom_divisor;
    } else {
    - port->flags = ((port->flags & ~ASYNC_FLAGS) |
    + port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) |
    (tmp.flags & ASYNC_FLAGS));
    - port->close_delay = tmp.close_delay;
    - port->closing_wait = tmp.closing_wait;
    + port->port.close_delay = tmp.close_delay;
    + port->port.closing_wait = tmp.closing_wait;
    port->custom_divisor = tmp.custom_divisor;
    }
    if (change_speed) {
    @@ -1975,10 +1975,10 @@ static inline int sx_get_serial_info(struct specialix_port * port,
    tmp.line = port - sx_port;
    tmp.port = bp->base;
    tmp.irq = bp->irq;
    - tmp.flags = port->flags;
    + tmp.flags = port->port.flags;
    tmp.baud_base = (SX_OSCFREQ + CD186x_TPC/2) / CD186x_TPC;
    - tmp.close_delay = port->close_delay * HZ/100;
    - tmp.closing_wait = port->closing_wait * HZ/100;
    + tmp.close_delay = port->port.close_delay * HZ/100;
    + tmp.closing_wait = port->port.closing_wait * HZ/100;
    tmp.custom_divisor = port->custom_divisor;
    tmp.xmit_fifo_size = CD186x_NFIFO;
    unlock_kernel();
    @@ -2199,17 +2199,17 @@ static void sx_hangup(struct tty_struct * tty)

    sx_shutdown_port(bp, port);
    spin_lock_irqsave(&port->lock, flags);
    - bp->count -= port->count;
    + bp->count -= port->port.count;
    if (bp->count < 0) {
    printk(KERN_ERR "sx%d: sx_hangup: bad board count: %d port: %d\n",
    board_No(bp), bp->count, tty->index);
    bp->count = 0;
    }
    - port->count = 0;
    - port->flags &= ~ASYNC_NORMAL_ACTIVE;
    - port->tty = NULL;
    + port->port.count = 0;
    + port->port.flags &= ~ASYNC_NORMAL_ACTIVE;
    + port->port.tty = NULL;
    spin_unlock_irqrestore(&port->lock, flags);
    - wake_up_interruptible(&port->open_wait);
    + wake_up_interruptible(&port->port.open_wait);

    func_exit();
    }
    @@ -2224,10 +2224,6 @@ static void sx_set_termios(struct tty_struct * tty, struct ktermios * old_termio
    if (sx_paranoia_check(port, tty->name, "sx_set_termios"))
    return;

    - if (tty->termios->c_cflag == old_termios->c_cflag &&
    - tty->termios->c_iflag == old_termios->c_iflag)
    - return;
    -
    bp = port_Board(port);
    spin_lock_irqsave(&port->lock, flags);
    sx_change_speed(port_Board(port), port);
    @@ -2297,10 +2293,7 @@ static int sx_init_drivers(void)
    memset(sx_port, 0, sizeof(sx_port));
    for (i = 0; i < SX_NPORT * SX_NBOARD; i++) {
    sx_port[i].magic = SPECIALIX_MAGIC;
    - sx_port[i].close_delay = 50 * HZ/100;
    - sx_port[i].closing_wait = 3000 * HZ/100;
    - init_waitqueue_head(&sx_port[i].open_wait);
    - init_waitqueue_head(&sx_port[i].close_wait);
    + tty_port_init(&sx_port[i].port);
    spin_lock_init(&sx_port[i].lock);
    }

    diff --git a/drivers/char/specialix_io8.h b/drivers/char/specialix_io8.h
    index 3f2f85b..c630052 100644
    --- a/drivers/char/specialix_io8.h
    +++ b/drivers/char/specialix_io8.h
    @@ -107,23 +107,17 @@ struct specialix_board {

    struct specialix_port {
    int magic;
    + struct tty_port port;
    int baud_base;
    int flags;
    - struct tty_struct * tty;
    - int count;
    - int blocked_open;
    int timeout;
    - int close_delay;
    unsigned char * xmit_buf;
    int custom_divisor;
    int xmit_head;
    int xmit_tail;
    int xmit_cnt;
    - wait_queue_head_t open_wait;
    - wait_queue_head_t close_wait;
    short wakeup_chars;
    short break_length;
    - unsigned short closing_wait;
    unsigned char mark_mask;
    unsigned char IER;
    unsigned char MSVR;
    diff --git a/drivers/char/sx.c b/drivers/char/sx.c
    index b1239ee..d5cffcd 100644
    --- a/drivers/char/sx.c
    +++ b/drivers/char/sx.c
    @@ -2395,6 +2395,7 @@ static int sx_init_portstructs(int nboards, int nports)
    board->ports = port;
    for (j = 0; j < boards[i].nports; j++) {
    sx_dprintk(SX_DEBUG_INIT, "initing port %d\n", j);
    + tty_port_init(&port->gs.port);
    port->gs.magic = SX_MAGIC;
    port->gs.close_delay = HZ / 2;
    port->gs.closing_wait = 30 * HZ;
    @@ -2407,7 +2408,6 @@ static int sx_init_portstructs(int nboards, int nports)
    /*
    * Initializing wait queue
    */
    - tty_port_init(&port->gs.port);
    port++;
    }
    }
    diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
    index 734098f..9f14753 100644
    --- a/drivers/char/synclink.c
    +++ b/drivers/char/synclink.c
    @@ -183,8 +183,6 @@ struct mgsl_struct {
    struct tty_port port;
    int line;
    int hw_version;
    - unsigned short close_delay;
    - unsigned short closing_wait; /* time to wait before closing */

    struct mgsl_icount icount;

    @@ -3142,11 +3140,11 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)

    /* wait for transmit data to clear all layers */

    - if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) {
    + if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) {
    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):mgsl_close(%s) calling tty_wait_until_sent\n",
    __FILE__,__LINE__, info->device_name );
    - tty_wait_until_sent(tty, info->closing_wait);
    + tty_wait_until_sent(tty, info->port.closing_wait);
    }

    if (info->port.flags & ASYNC_INITIALIZED)
    @@ -3162,8 +3160,8 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
    info->port.tty = NULL;

    if (info->port.blocked_open) {
    - if (info->close_delay) {
    - msleep_interruptible(jiffies_to_msecs(info->close_delay));
    + if (info->port.close_delay) {
    + msleep_interruptible(jiffies_to_msecs(info->port.close_delay));
    }
    wake_up_interruptible(&info->port.open_wait);
    }
    @@ -4326,12 +4324,12 @@ static struct mgsl_struct* mgsl_allocate_device(void)
    if (!info) {
    printk("Error can't allocate device instance data\n");
    } else {
    + tty_port_init(&info->port);
    info->magic = MGSL_MAGIC;
    INIT_WORK(&info->task, mgsl_bh_handler);
    info->max_frame_size = 4096;
    - info->close_delay = 5*HZ/10;
    - info->closing_wait = 30*HZ;
    - tty_port_init(&info->port);
    + info->port.close_delay = 5*HZ/10;
    + info->port.closing_wait = 30*HZ;
    init_waitqueue_head(&info->status_event_wait_q);
    init_waitqueue_head(&info->event_wait_q);
    spin_lock_init(&info->irq_spinlock);
    diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
    index fc71d98..07aa42a 100644
    --- a/drivers/char/synclink_gt.c
    +++ b/drivers/char/synclink_gt.c
    @@ -261,8 +261,6 @@ struct slgt_info {
    struct slgt_info *port_array[SLGT_MAX_PORTS];

    int line; /* tty line instance number */
    - unsigned short close_delay;
    - unsigned short closing_wait; /* time to wait before closing */

    struct mgsl_icount icount;

    @@ -758,9 +756,9 @@ static void close(struct tty_struct *tty, struct file *filp)

    /* wait for transmit data to clear all layers */

    - if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) {
    + if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) {
    DBGINFO(("%s call tty_wait_until_sent\n", info->device_name));
    - tty_wait_until_sent(tty, info->closing_wait);
    + tty_wait_until_sent(tty, info->port.closing_wait);
    }

    if (info->port.flags & ASYNC_INITIALIZED)
    @@ -774,8 +772,8 @@ static void close(struct tty_struct *tty, struct file *filp)
    info->port.tty = NULL;

    if (info->port.blocked_open) {
    - if (info->close_delay) {
    - msleep_interruptible(jiffies_to_msecs(info->close_delay));
    + if (info->port.close_delay) {
    + msleep_interruptible(jiffies_to_msecs(info->port.close_delay));
    }
    wake_up_interruptible(&info->port.open_wait);
    }
    @@ -3448,13 +3446,13 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev
    DBGERR(("%s device alloc failed adapter=%d port=%d\n",
    driver_name, adapter_num, port_num));
    } else {
    + tty_port_init(&info->port);
    info->magic = MGSL_MAGIC;
    INIT_WORK(&info->task, bh_handler);
    info->max_frame_size = 4096;
    info->raw_rx_size = DMABUFSIZE;
    - info->close_delay = 5*HZ/10;
    - info->closing_wait = 30*HZ;
    - tty_port_init(&info->port);
    + info->port.close_delay = 5*HZ/10;
    + info->port.closing_wait = 30*HZ;
    init_waitqueue_head(&info->status_event_wait_q);
    init_waitqueue_head(&info->event_wait_q);
    spin_lock_init(&info->netlock);
    diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
    index 5b5b292..c4bc090 100644
    --- a/drivers/char/synclinkmp.c
    +++ b/drivers/char/synclinkmp.c
    @@ -846,11 +846,11 @@ static void close(struct tty_struct *tty, struct file *filp)

    /* wait for transmit data to clear all layers */

    - if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) {
    + if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) {
    if (debug_level >= DEBUG_LEVEL_INFO)
    printk("%s(%d):%s close() calling tty_wait_until_sent\n",
    __FILE__,__LINE__, info->device_name );
    - tty_wait_until_sent(tty, info->closing_wait);
    + tty_wait_until_sent(tty, info->port.closing_wait);
    }

    if (info->port.flags & ASYNC_INITIALIZED)
    @@ -866,8 +866,8 @@ static void close(struct tty_struct *tty, struct file *filp)
    info->port.tty = NULL;

    if (info->port.blocked_open) {
    - if (info->close_delay) {
    - msleep_interruptible(jiffies_to_msecs(info->close_delay));
    + if (info->port.close_delay) {
    + msleep_interruptible(jiffies_to_msecs(info->port.close_delay));
    }
    wake_up_interruptible(&info->port.open_wait);
    }
    @@ -3802,12 +3802,12 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev)
    printk("%s(%d) Error can't allocate device instance data for adapter %d, port %d\n",
    __FILE__,__LINE__, adapter_num, port_num);
    } else {
    + tty_port_init(&info->port);
    info->magic = MGSL_MAGIC;
    INIT_WORK(&info->task, bh_handler);
    info->max_frame_size = 4096;
    - info->close_delay = 5*HZ/10;
    - info->closing_wait = 30*HZ;
    - tty_port_init(&info->port);
    + info->port.close_delay = 5*HZ/10;
    + info->port.closing_wait = 30*HZ;
    init_waitqueue_head(&info->status_event_wait_q);
    init_waitqueue_head(&info->event_wait_q);
    spin_lock_init(&info->netlock);
    diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
    index 87b1f9b..754feaa 100644
    --- a/drivers/char/tty_io.c
    +++ b/drivers/char/tty_io.c
    @@ -2094,6 +2094,8 @@ void tty_port_init(struct tty_port *port)
    init_waitqueue_head(&port->open_wait);
    init_waitqueue_head(&port->close_wait);
    mutex_init(&port->mutex);
    + port->close_delay = (50 * HZ) / 100;
    + port->closing_wait = (3000 * HZ) / 100;
    }
    EXPORT_SYMBOL(tty_port_init);

    diff --git a/include/linux/cyclades.h b/include/linux/cyclades.h
    index a982b74..2d3d1e0 100644
    --- a/include/linux/cyclades.h
    +++ b/include/linux/cyclades.h
    @@ -567,8 +567,6 @@ struct cyclades_port {
    int chip_rev;
    int custom_divisor;
    u8 x_char; /* to be pushed out ASAP */
    - int close_delay;
    - unsigned short closing_wait;
    int breakon;
    int breakoff;
    int xmit_head;
    @@ -586,8 +584,8 @@ struct cyclades_port {
    };

    #define CLOSING_WAIT_DELAY 30*HZ
    -#define CY_CLOSING_WAIT_NONE 65535
    -#define CY_CLOSING_WAIT_INF 0
    +#define CY_CLOSING_WAIT_NONE ASYNC_CLOSING_WAIT_NONE
    +#define CY_CLOSING_WAIT_INF ASYNC_CLOSING_WAIT_INF


    #define CyMAX_CHIPS_PER_CARD 8
    diff --git a/include/linux/tty.h b/include/linux/tty.h
    index 46008e8..4e58330 100644
    --- a/include/linux/tty.h
    +++ b/include/linux/tty.h
    @@ -188,6 +188,8 @@ struct tty_port {
    unsigned long flags; /* TTY flags ASY_*/
    struct mutex mutex; /* Locking */
    unsigned char *xmit_buf; /* Optional buffer */
    + int close_delay; /* Close port delay */
    + int closing_wait; /* Delay for output */
    };

    /*

    --
    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 31/70] cyberjack: Coding style

    From: Alan Cox

    Coding style fixups

    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/cyberjack.c | 131 +++++++++++++++++++++-------------------
    1 files changed, 69 insertions(+), 62 deletions(-)


    diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
    index 546178e..b4d7235 100644
    --- a/drivers/usb/serial/cyberjack.c
    +++ b/drivers/usb/serial/cyberjack.c
    @@ -37,7 +37,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include

    @@ -65,7 +65,7 @@ static void cyberjack_close(struct tty_struct *tty,
    struct usb_serial_port *port, struct file *filp);
    static int cyberjack_write(struct tty_struct *tty,
    struct usb_serial_port *port, const unsigned char *buf, int count);
    -static int cyberjack_write_room( struct tty_struct *tty);
    +static int cyberjack_write_room(struct tty_struct *tty);
    static void cyberjack_read_int_callback(struct urb *urb);
    static void cyberjack_read_bulk_callback(struct urb *urb);
    static void cyberjack_write_bulk_callback(struct urb *urb);
    @@ -75,7 +75,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 cyberjack_driver = {
    .name = "cyberjack",
    @@ -138,20 +138,20 @@ static int cyberjack_startup(struct usb_serial *serial)
    for (i = 0; i < serial->num_ports; ++i) {
    int result;
    serial->port[i]->interrupt_in_urb->dev = serial->dev;
    - result = usb_submit_urb(serial->port[i]->interrupt_in_urb,
    + result = usb_submit_urb(serial->port[i]->interrupt_in_urb,
    GFP_KERNEL);
    if (result)
    err(" usb_submit_urb(read int) failed");
    dbg("%s - usb_submit_urb(int urb)", __func__);
    }

    - return( 0 );
    + return 0;
    }

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

    for (i = 0; i < serial->num_ports; ++i) {
    @@ -161,7 +161,7 @@ static void cyberjack_shutdown(struct usb_serial *serial)
    usb_set_serial_port_data(serial->port[i], NULL);
    }
    }
    -
    +
    static int cyberjack_open(struct tty_struct *tty,
    struct usb_serial_port *port, struct file *filp)
    {
    @@ -171,7 +171,7 @@ static int cyberjack_open(struct tty_struct *tty,

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

    - dbg("%s - usb_clear_halt", __func__ );
    + dbg("%s - usb_clear_halt", __func__);
    usb_clear_halt(port->serial->dev, port->write_urb->pipe);

    /* force low_latency on so that our tty_push actually forces
    @@ -230,7 +230,7 @@ static int cyberjack_write(struct tty_struct *tty,

    spin_lock_irqsave(&priv->lock, flags);

    - if( (count+priv->wrfilled) > sizeof(priv->wrbuf) ) {
    + if (count+priv->wrfilled > sizeof(priv->wrbuf)) {
    /* To much data for buffer. Reset buffer. */
    priv->wrfilled = 0;
    port->write_urb_busy = 0;
    @@ -239,42 +239,43 @@ static int cyberjack_write(struct tty_struct *tty,
    }

    /* Copy data */
    - memcpy (priv->wrbuf+priv->wrfilled, buf, count);
    + memcpy(priv->wrbuf + priv->wrfilled, buf, count);

    usb_serial_debug_data(debug, &port->dev, __func__, count,
    - priv->wrbuf+priv->wrfilled);
    + priv->wrbuf + priv->wrfilled);
    priv->wrfilled += count;

    - if( priv->wrfilled >= 3 ) {
    + if (priv->wrfilled >= 3) {
    wrexpected = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3;
    dbg("%s - expected data: %d", __func__, wrexpected);
    - } else {
    + } else
    wrexpected = sizeof(priv->wrbuf);
    - }

    - if( priv->wrfilled >= wrexpected ) {
    + if (priv->wrfilled >= wrexpected) {
    /* We have enough data to begin transmission */
    int length;

    dbg("%s - transmitting data (frame 1)", __func__);
    - length = (wrexpected > port->bulk_out_size) ? port->bulk_out_size : wrexpected;
    + length = (wrexpected > port->bulk_out_size) ?
    + port->bulk_out_size : wrexpected;

    - memcpy (port->write_urb->transfer_buffer, priv->wrbuf, length );
    - priv->wrsent=length;
    + memcpy(port->write_urb->transfer_buffer, priv->wrbuf, length);
    + priv->wrsent = length;

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

    /* send the data out the bulk port */
    result = usb_submit_urb(port->write_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);
    /* Throw away data. No better idea what to do with it. */
    priv->wrfilled = 0;
    priv->wrsent = 0;
    @@ -283,12 +284,12 @@ static int cyberjack_write(struct tty_struct *tty,
    return 0;
    }

    - dbg("%s - priv->wrsent=%d", __func__,priv->wrsent);
    - dbg("%s - priv->wrfilled=%d", __func__,priv->wrfilled);
    + dbg("%s - priv->wrsent=%d", __func__, priv->wrsent);
    + dbg("%s - priv->wrfilled=%d", __func__, priv->wrfilled);

    - if( priv->wrsent>=priv->wrfilled ) {
    + if (priv->wrsent >= priv->wrfilled) {
    dbg("%s - buffer cleaned", __func__);
    - memset( priv->wrbuf, 0, sizeof(priv->wrbuf) );
    + memset(priv->wrbuf, 0, sizeof(priv->wrbuf));
    priv->wrfilled = 0;
    priv->wrsent = 0;
    }
    @@ -296,8 +297,8 @@ static int cyberjack_write(struct tty_struct *tty,

    spin_unlock_irqrestore(&priv->lock, flags);

    - return (count);
    -}
    + return count;
    +}

    static int cyberjack_write_room(struct tty_struct *tty)
    {
    @@ -319,10 +320,11 @@ static void cyberjack_read_int_callback(struct urb *urb)
    if (status)
    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);

    /* React only to interrupts signaling a bulk_in transfer */
    - if( (urb->actual_length == 4) && (data[0] == 0x01) ) {
    + if (urb->actual_length == 4 && data[0] == 0x01) {
    short old_rdtodo;

    /* This is a announcement of coming bulk_ins. */
    @@ -332,8 +334,8 @@ static void cyberjack_read_int_callback(struct urb *urb)

    old_rdtodo = priv->rdtodo;

    - if( (old_rdtodo+size)<(old_rdtodo) ) {
    - dbg( "To many bulk_in urbs to do." );
    + if (old_rdtodo + size < old_rdtodo) {
    + dbg("To many bulk_in urbs to do.");
    spin_unlock(&priv->lock);
    goto resubmit;
    }
    @@ -345,10 +347,10 @@ static void cyberjack_read_int_callback(struct urb *urb)

    spin_unlock(&priv->lock);

    - if( !old_rdtodo ) {
    + if (!old_rdtodo) {
    port->read_urb->dev = port->serial->dev;
    result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
    - if( result )
    + if (result)
    err("%s - failed resubmitting read urb, error %d", __func__, result);
    dbg("%s - usb_submit_urb(read urb)", __func__);
    }
    @@ -374,7 +376,8 @@ static void cyberjack_read_bulk_callback(struct urb *urb)

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

    - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
    + usb_serial_debug_data(debug, &port->dev, __func__,
    + urb->actual_length, data);
    if (status) {
    dbg("%s - nonzero read bulk status received: %d",
    __func__, status);
    @@ -389,15 +392,16 @@ static void cyberjack_read_bulk_callback(struct urb *urb)
    if (urb->actual_length) {
    tty_buffer_request_room(tty, urb->actual_length);
    tty_insert_flip_string(tty, data, urb->actual_length);
    - tty_flip_buffer_push(tty);
    + tty_flip_buffer_push(tty);
    }

    spin_lock(&priv->lock);

    /* Reduce urbs to do by one. */
    - priv->rdtodo-=urb->actual_length;
    + priv->rdtodo -= urb->actual_length;
    /* Just to be sure */
    - if ( priv->rdtodo<0 ) priv->rdtodo = 0;
    + if (priv->rdtodo < 0)
    + priv->rdtodo = 0;
    todo = priv->rdtodo;

    spin_unlock(&priv->lock);
    @@ -405,11 +409,12 @@ static void cyberjack_read_bulk_callback(struct urb *urb)
    dbg("%s - rdtodo: %d", __func__, todo);

    /* Continue to read if we have still urbs to do. */
    - if( todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/ ) {
    + if (todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/) {
    port->read_urb->dev = port->serial->dev;
    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);
    dbg("%s - usb_submit_urb(read urb)", __func__);
    }
    }
    @@ -432,7 +437,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb)
    spin_lock(&priv->lock);

    /* only do something if we have more data to send */
    - if( priv->wrfilled ) {
    + if (priv->wrfilled) {
    int length, blksize, result;

    dbg("%s - transmitting data (frame n)", __func__);
    @@ -440,37 +445,39 @@ static void cyberjack_write_bulk_callback(struct urb *urb)
    length = ((priv->wrfilled - priv->wrsent) > port->bulk_out_size) ?
    port->bulk_out_size : (priv->wrfilled - priv->wrsent);

    - memcpy (port->write_urb->transfer_buffer, priv->wrbuf + priv->wrsent,
    - length );
    - priv->wrsent+=length;
    + memcpy(port->write_urb->transfer_buffer,
    + priv->wrbuf + priv->wrsent, length);
    + priv->wrsent += length;

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

    /* send the data out the bulk port */
    result = usb_submit_urb(port->write_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);
    /* Throw away data. No better idea what to do with it. */
    priv->wrfilled = 0;
    priv->wrsent = 0;
    goto exit;
    }

    - dbg("%s - priv->wrsent=%d", __func__,priv->wrsent);
    - dbg("%s - priv->wrfilled=%d", __func__,priv->wrfilled);
    + dbg("%s - priv->wrsent=%d", __func__, priv->wrsent);
    + dbg("%s - priv->wrfilled=%d", __func__, priv->wrfilled);

    blksize = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3;

    - if( (priv->wrsent>=priv->wrfilled) || (priv->wrsent>=blksize) ) {
    + if (priv->wrsent >= priv->wrfilled ||
    + priv->wrsent >= blksize) {
    dbg("%s - buffer cleaned", __func__);
    - memset( priv->wrbuf, 0, sizeof(priv->wrbuf) );
    + memset(priv->wrbuf, 0, sizeof(priv->wrbuf));
    priv->wrfilled = 0;
    priv->wrsent = 0;
    }
    @@ -481,14 +488,14 @@ exit:
    usb_serial_port_softint(port);
    }

    -static int __init cyberjack_init (void)
    +static int __init cyberjack_init(void)
    {
    int retval;
    retval = usb_serial_register(&cyberjack_device);
    if (retval)
    goto failed_usb_serial_register;
    retval = usb_register(&cyberjack_driver);
    - if (retval)
    + if (retval)
    goto failed_usb_register;

    info(DRIVER_VERSION " " DRIVER_AUTHOR);
    @@ -501,18 +508,18 @@ failed_usb_serial_register:
    return retval;
    }

    -static void __exit cyberjack_exit (void)
    +static void __exit cyberjack_exit(void)
    {
    - usb_deregister (&cyberjack_driver);
    - usb_serial_deregister (&cyberjack_device);
    + usb_deregister(&cyberjack_driver);
    + usb_serial_deregister(&cyberjack_device);
    }

    module_init(cyberjack_init);
    module_exit(cyberjack_exit);

    -MODULE_AUTHOR( DRIVER_AUTHOR );
    -MODULE_DESCRIPTION( DRIVER_DESC );
    -MODULE_VERSION( DRIVER_VERSION );
    +MODULE_AUTHOR(DRIVER_AUTHOR);
    +MODULE_DESCRIPTION(DRIVER_DESC);
    +MODULE_VERSION(DRIVER_VERSION);
    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 20/70] cyclades: use tty_port

    From: Alan Cox

    Switch cyclades to use the new tty_port structure

    Signed-off-by: Alan Cox
    ---

    drivers/char/cyclades.c | 315 +++++++++++++++++++++++-----------------------
    include/linux/cyclades.h | 7 -
    2 files changed, 158 insertions(+), 164 deletions(-)


    diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
    index 2bf4b4a..e06f637 100644
    --- a/drivers/char/cyclades.c
    +++ b/drivers/char/cyclades.c
    @@ -762,7 +762,7 @@ static int cy_next_channel; /* next minor available */
    /*
    * This is used to look up the divisor speeds and the timeouts
    * We're normally limited to 15 distinct baud rates. The extra
    - * are accessed via settings in info->flags.
    + * are accessed via settings in info->port.flags.
    * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
    * 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
    * HI VHI
    @@ -1003,7 +1003,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
    cy_writeb(base_addr + (CyCAR << index), save_xir);

    /* if there is nowhere to put the data, discard it */
    - if (info->tty == NULL) {
    + if (info->port.tty == NULL) {
    if ((readb(base_addr + (CyRIVR << index)) & CyIVRMask) ==
    CyIVRRxEx) { /* exception */
    data = readb(base_addr + (CyRDSR << index));
    @@ -1015,7 +1015,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
    goto end;
    }
    /* there is an open port for this data */
    - tty = info->tty;
    + tty = info->port.tty;
    if ((readb(base_addr + (CyRIVR << index)) & CyIVRMask) ==
    CyIVRRxEx) { /* exception */
    data = readb(base_addr + (CyRDSR << index));
    @@ -1041,7 +1041,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
    readb(base_addr + (CyRDSR <<
    index)), TTY_BREAK);
    info->icount.rx++;
    - if (info->flags & ASYNC_SAK)
    + if (info->port.flags & ASYNC_SAK)
    do_SAK(tty);
    } else if (data & CyFRAME) {
    tty_insert_flip_char(tty,
    @@ -1145,7 +1145,7 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
    goto end;
    }
    info = &cinfo->ports[channel + chip * 4];
    - if (info->tty == NULL) {
    + if (info->port.tty == NULL) {
    cy_writeb(base_addr + (CySRER << index),
    readb(base_addr + (CySRER << index)) & ~CyTxRdy);
    goto end;
    @@ -1190,13 +1190,13 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
    }
    goto done;
    }
    - if (info->xmit_buf == NULL) {
    + if (info->port.xmit_buf == NULL) {
    cy_writeb(base_addr + (CySRER << index),
    readb(base_addr + (CySRER << index)) &
    ~CyTxRdy);
    goto done;
    }
    - if (info->tty->stopped || info->tty->hw_stopped) {
    + if (info->port.tty->stopped || info->port.tty->hw_stopped) {
    cy_writeb(base_addr + (CySRER << index),
    readb(base_addr + (CySRER << index)) &
    ~CyTxRdy);
    @@ -1211,7 +1211,7 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
    * character. This is necessary because there may not be room
    * for the two chars needed to send a NULL.)
    */
    - outch = info->xmit_buf[info->xmit_tail];
    + outch = info->port.xmit_buf[info->xmit_tail];
    if (outch) {
    info->xmit_cnt--;
    info->xmit_tail = (info->xmit_tail + 1) &
    @@ -1232,7 +1232,7 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
    }

    done:
    - tty_wakeup(info->tty);
    + tty_wakeup(info->port.tty);
    end:
    /* end of service */
    cy_writeb(base_addr + (CyTIR << index), save_xir & 0x3f);
    @@ -1256,7 +1256,7 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
    mdm_change = readb(base_addr + (CyMISR << index));
    mdm_status = readb(base_addr + (CyMSVR1 << index));

    - if (!info->tty)
    + if (!info->port.tty)
    goto end;

    if (mdm_change & CyANY_DELTA) {
    @@ -1273,29 +1273,29 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
    wake_up_interruptible(&info->delta_msr_wait);
    }

    - if ((mdm_change & CyDCD) && (info->flags & ASYNC_CHECK_CD)) {
    + if ((mdm_change & CyDCD) && (info->port.flags & ASYNC_CHECK_CD)) {
    if (!(mdm_status & CyDCD)) {
    - tty_hangup(info->tty);
    - info->flags &= ~ASYNC_NORMAL_ACTIVE;
    + tty_hangup(info->port.tty);
    + info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
    }
    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    }
    - if ((mdm_change & CyCTS) && (info->flags & ASYNC_CTS_FLOW)) {
    - if (info->tty->hw_stopped) {
    + if ((mdm_change & CyCTS) && (info->port.flags & ASYNC_CTS_FLOW)) {
    + if (info->port.tty->hw_stopped) {
    if (mdm_status & CyCTS) {
    /* cy_start isn't used
    because... !!! */
    - info->tty->hw_stopped = 0;
    + info->port.tty->hw_stopped = 0;
    cy_writeb(base_addr + (CySRER << index),
    readb(base_addr + (CySRER << index)) |
    CyTxRdy);
    - tty_wakeup(info->tty);
    + tty_wakeup(info->port.tty);
    }
    } else {
    if (!(mdm_status & CyCTS)) {
    /* cy_stop isn't used
    because ... !!! */
    - info->tty->hw_stopped = 1;
    + info->port.tty->hw_stopped = 1;
    cy_writeb(base_addr + (CySRER << index),
    readb(base_addr + (CySRER << index)) &
    ~CyTxRdy);
    @@ -1449,7 +1449,7 @@ static void cyz_handle_rx(struct cyclades_port *info,
    struct BUF_CTRL __iomem *buf_ctrl)
    {
    struct cyclades_card *cinfo = info->card;
    - struct tty_struct *tty = info->tty;
    + struct tty_struct *tty = info->port.tty;
    unsigned int char_count;
    int len;
    #ifdef BLOCKMOVE
    @@ -1542,7 +1542,7 @@ static void cyz_handle_tx(struct cyclades_port *info,
    struct BUF_CTRL __iomem *buf_ctrl)
    {
    struct cyclades_card *cinfo = info->card;
    - struct tty_struct *tty = info->tty;
    + struct tty_struct *tty = info->port.tty;
    u8 data;
    unsigned int char_count;
    #ifdef BLOCKMOVE
    @@ -1585,7 +1585,7 @@ static void cyz_handle_tx(struct cyclades_port *info,

    memcpy_toio((char *)(cinfo->base_addr + tx_bufaddr +
    tx_put),
    - &info->xmit_buf[info->xmit_tail],
    + &info->port.xmit_buf[info->xmit_tail],
    small_count);

    tx_put = (tx_put + small_count) & (tx_bufsize - 1);
    @@ -1597,7 +1597,7 @@ static void cyz_handle_tx(struct cyclades_port *info,
    }
    #else
    while (info->xmit_cnt && char_count) {
    - data = info->xmit_buf[info->xmit_tail];
    + data = info->port.xmit_buf[info->xmit_tail];
    info->xmit_cnt--;
    info->xmit_tail = (info->xmit_tail + 1) &
    (SERIAL_XMIT_SIZE - 1);
    @@ -1642,7 +1642,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
    special_count = 0;
    delta_count = 0;
    info = &cinfo->ports[channel];
    - tty = info->tty;
    + tty = info->port.tty;
    if (tty == NULL)
    continue;

    @@ -1668,15 +1668,15 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
    case C_CM_MDCD:
    info->icount.dcd++;
    delta_count++;
    - if (info->flags & ASYNC_CHECK_CD) {
    + if (info->port.flags & ASYNC_CHECK_CD) {
    if ((fw_ver > 241 ? ((u_long) param) :
    readl(&ch_ctrl->rs_status)) &
    C_RS_DCD) {
    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    } else {
    - tty_hangup(info->tty);
    - wake_up_interruptible(&info->open_wait);
    - info->flags &= ~ASYNC_NORMAL_ACTIVE;
    + tty_hangup(info->port.tty);
    + wake_up_interruptible(&info->port.open_wait);
    + info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
    }
    }
    break;
    @@ -1814,7 +1814,7 @@ static void cyz_poll(unsigned long arg)

    for (port = 0; port < cinfo->nports; port++) {
    info = &cinfo->ports[port];
    - tty = info->tty;
    + tty = info->port.tty;
    buf_ctrl = &(zfw_ctrl->buf_ctrl[port]);

    if (!info->throttle)
    @@ -1853,22 +1853,22 @@ static int startup(struct cyclades_port *info)

    spin_lock_irqsave(&card->card_lock, flags);

    - if (info->flags & ASYNC_INITIALIZED) {
    + if (info->port.flags & ASYNC_INITIALIZED) {
    free_page(page);
    goto errout;
    }

    if (!info->type) {
    - if (info->tty)
    - set_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + set_bit(TTY_IO_ERROR, &info->port.tty->flags);
    free_page(page);
    goto errout;
    }

    - if (info->xmit_buf)
    + if (info->port.xmit_buf)
    free_page(page);
    else
    - info->xmit_buf = (unsigned char *)page;
    + info->port.xmit_buf = (unsigned char *)page;

    spin_unlock_irqrestore(&card->card_lock, flags);

    @@ -1909,10 +1909,10 @@ static int startup(struct cyclades_port *info)

    cy_writeb(base_addr + (CySRER << index),
    readb(base_addr + (CySRER << index)) | CyRxData);
    - info->flags |= ASYNC_INITIALIZED;
    + info->port.flags |= ASYNC_INITIALIZED;

    - if (info->tty)
    - clear_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
    info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
    info->breakon = info->breakoff = 0;
    memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
    @@ -1994,9 +1994,9 @@ static int startup(struct cyclades_port *info)

    /* enable send, recv, modem !!! */

    - info->flags |= ASYNC_INITIALIZED;
    - if (info->tty)
    - clear_bit(TTY_IO_ERROR, &info->tty->flags);
    + info->port.flags |= ASYNC_INITIALIZED;
    + if (info->port.tty)
    + clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
    info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
    info->breakon = info->breakoff = 0;
    memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
    @@ -2065,7 +2065,7 @@ static void shutdown(struct cyclades_port *info)
    void __iomem *base_addr;
    int chip, channel, index;

    - if (!(info->flags & ASYNC_INITIALIZED))
    + if (!(info->port.flags & ASYNC_INITIALIZED))
    return;

    card = info->card;
    @@ -2087,14 +2087,14 @@ static void shutdown(struct cyclades_port *info)
    /* Clear delta_msr_wait queue to avoid mem leaks. */
    wake_up_interruptible(&info->delta_msr_wait);

    - if (info->xmit_buf) {
    + if (info->port.xmit_buf) {
    unsigned char *temp;
    - temp = info->xmit_buf;
    - info->xmit_buf = NULL;
    + temp = info->port.xmit_buf;
    + info->port.xmit_buf = NULL;
    free_page((unsigned long)temp);
    }
    cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
    - if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
    + if (!info->port.tty || (info->port.tty->termios->c_cflag & HUPCL)) {
    cy_writeb(base_addr + (CyMSVR1 << index), ~CyRTS);
    cy_writeb(base_addr + (CyMSVR2 << index), ~CyDTR);
    #ifdef CY_DEBUG_DTR
    @@ -2108,9 +2108,9 @@ static void shutdown(struct cyclades_port *info)
    /* it may be appropriate to clear _XMIT at
    some later date (after testing)!!! */

    - if (info->tty)
    - set_bit(TTY_IO_ERROR, &info->tty->flags);
    - info->flags &= ~ASYNC_INITIALIZED;
    + if (info->port.tty)
    + set_bit(TTY_IO_ERROR, &info->port.tty->flags);
    + info->port.flags &= ~ASYNC_INITIALIZED;
    spin_unlock_irqrestore(&card->card_lock, flags);
    } else {
    struct FIRM_ID __iomem *firm_id;
    @@ -2136,14 +2136,14 @@ static void shutdown(struct cyclades_port *info)

    spin_lock_irqsave(&card->card_lock, flags);

    - if (info->xmit_buf) {
    + if (info->port.xmit_buf) {
    unsigned char *temp;
    - temp = info->xmit_buf;
    - info->xmit_buf = NULL;
    + temp = info->port.xmit_buf;
    + info->port.xmit_buf = NULL;
    free_page((unsigned long)temp);
    }

    - if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
    + if (!info->port.tty || (info->port.tty->termios->c_cflag & HUPCL)) {
    cy_writel(&ch_ctrl[channel].rs_control,
    (__u32)(readl(&ch_ctrl[channel].rs_control) &
    ~(C_RS_RTS | C_RS_DTR)));
    @@ -2158,9 +2158,9 @@ static void shutdown(struct cyclades_port *info)
    #endif
    }

    - if (info->tty)
    - set_bit(TTY_IO_ERROR, &info->tty->flags);
    - info->flags &= ~ASYNC_INITIALIZED;
    + if (info->port.tty)
    + set_bit(TTY_IO_ERROR, &info->port.tty->flags);
    + info->port.flags &= ~ASYNC_INITIALIZED;

    spin_unlock_irqrestore(&card->card_lock, flags);
    }
    @@ -2194,10 +2194,10 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
    * If the device is in the middle of being closed, then block
    * until it's done, and then try again.
    */
    - if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) {
    - wait_event_interruptible(info->close_wait,
    - !(info->flags & ASYNC_CLOSING));
    - return (info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS;
    + if (tty_hung_up_p(filp) || (info->port.flags & ASYNC_CLOSING)) {
    + wait_event_interruptible(info->port.close_wait,
    + !(info->port.flags & ASYNC_CLOSING));
    + return (info->port.flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS;
    }

    /*
    @@ -2206,32 +2206,32 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
    */
    if ((filp->f_flags & O_NONBLOCK) ||
    (tty->flags & (1 << TTY_IO_ERROR))) {
    - info->flags |= ASYNC_NORMAL_ACTIVE;
    + info->port.flags |= ASYNC_NORMAL_ACTIVE;
    return 0;
    }

    /*
    * Block waiting for the carrier detect and the line to become
    * free (i.e., not in use by the callout). While we are in
    - * this loop, info->count is dropped by one, so that
    + * this loop, info->port.count is dropped by one, so that
    * cy_close() knows when to free things. We restore it upon
    * exit, either normal or abnormal.
    */
    retval = 0;
    - add_wait_queue(&info->open_wait, &wait);
    + add_wait_queue(&info->port.open_wait, &wait);
    #ifdef CY_DEBUG_OPEN
    printk(KERN_DEBUG "cyc block_til_ready before block: ttyC%d, "
    - "count = %d\n", info->line, info->count);
    + "count = %d\n", info->line, info->port.count);
    #endif
    spin_lock_irqsave(&cinfo->card_lock, flags);
    if (!tty_hung_up_p(filp))
    - info->count--;
    + info->port.count--;
    spin_unlock_irqrestore(&cinfo->card_lock, flags);
    #ifdef CY_DEBUG_COUNT
    printk(KERN_DEBUG "cyc block_til_ready: (%d): decrementing count to "
    - "%d\n", current->pid, info->count);
    + "%d\n", current->pid, info->port.count);
    #endif
    - info->blocked_open++;
    + info->port.blocked_open++;

    if (!IS_CYC_Z(*cinfo)) {
    chip = channel >> 2;
    @@ -2260,8 +2260,8 @@ block_til_ready(struct tty_struct *tty, struct file *filp,

    set_current_state(TASK_INTERRUPTIBLE);
    if (tty_hung_up_p(filp) ||
    - !(info->flags & ASYNC_INITIALIZED)) {
    - retval = ((info->flags & ASYNC_HUP_NOTIFY) ?
    + !(info->port.flags & ASYNC_INITIALIZED)) {
    + retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
    -EAGAIN : -ERESTARTSYS);
    break;
    }
    @@ -2269,7 +2269,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
    spin_lock_irqsave(&cinfo->card_lock, flags);
    cy_writeb(base_addr + (CyCAR << index),
    (u_char) channel);
    - if (!(info->flags & ASYNC_CLOSING) && (C_CLOCAL(tty) ||
    + if (!(info->port.flags & ASYNC_CLOSING) && (C_CLOCAL(tty) ||
    (readb(base_addr +
    (CyMSVR1 << index)) & CyDCD))) {
    spin_unlock_irqrestore(&cinfo->card_lock, flags);
    @@ -2284,7 +2284,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
    #ifdef CY_DEBUG_OPEN
    printk(KERN_DEBUG "cyc block_til_ready blocking: "
    "ttyC%d, count = %d\n",
    - info->line, info->count);
    + info->line, info->port.count);
    #endif
    schedule();
    }
    @@ -2298,7 +2298,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
    firm_id = base_addr + ID_ADDRESS;
    if (!ISZLOADED(*cinfo)) {
    __set_current_state(TASK_RUNNING);
    - remove_wait_queue(&info->open_wait, &wait);
    + remove_wait_queue(&info->port.open_wait, &wait);
    return -EINVAL;
    }

    @@ -2327,12 +2327,12 @@ block_til_ready(struct tty_struct *tty, struct file *filp,

    set_current_state(TASK_INTERRUPTIBLE);
    if (tty_hung_up_p(filp) ||
    - !(info->flags & ASYNC_INITIALIZED)) {
    - retval = ((info->flags & ASYNC_HUP_NOTIFY) ?
    + !(info->port.flags & ASYNC_INITIALIZED)) {
    + retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
    -EAGAIN : -ERESTARTSYS);
    break;
    }
    - if (!(info->flags & ASYNC_CLOSING) && (C_CLOCAL(tty) ||
    + if (!(info->port.flags & ASYNC_CLOSING) && (C_CLOCAL(tty) ||
    (readl(&ch_ctrl[channel].rs_status) &
    C_RS_DCD))) {
    break;
    @@ -2344,28 +2344,28 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
    #ifdef CY_DEBUG_OPEN
    printk(KERN_DEBUG "cyc block_til_ready blocking: "
    "ttyC%d, count = %d\n",
    - info->line, info->count);
    + info->line, info->port.count);
    #endif
    schedule();
    }
    }
    __set_current_state(TASK_RUNNING);
    - remove_wait_queue(&info->open_wait, &wait);
    + remove_wait_queue(&info->port.open_wait, &wait);
    if (!tty_hung_up_p(filp)) {
    - info->count++;
    + info->port.count++;
    #ifdef CY_DEBUG_COUNT
    printk(KERN_DEBUG "cyc:block_til_ready (%d): incrementing "
    - "count to %d\n", current->pid, info->count);
    + "count to %d\n", current->pid, info->port.count);
    #endif
    }
    - info->blocked_open--;
    + info->port.blocked_open--;
    #ifdef CY_DEBUG_OPEN
    printk(KERN_DEBUG "cyc:block_til_ready after blocking: ttyC%d, "
    - "count = %d\n", info->line, info->count);
    + "count = %d\n", info->line, info->port.count);
    #endif
    if (retval)
    return retval;
    - info->flags |= ASYNC_NORMAL_ACTIVE;
    + info->port.flags |= ASYNC_NORMAL_ACTIVE;
    return 0;
    } /* block_til_ready */

    @@ -2456,27 +2456,27 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
    printk(KERN_DEBUG "cyc:cy_open ttyC%d\n", info->line);
    #endif
    tty->driver_data = info;
    - info->tty = tty;
    + info->port.tty = tty;
    if (serial_paranoia_check(info, tty->name, "cy_open"))
    return -ENODEV;

    #ifdef CY_DEBUG_OPEN
    printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
    - info->count);
    + info->port.count);
    #endif
    - info->count++;
    + info->port.count++;
    #ifdef CY_DEBUG_COUNT
    printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
    - current->pid, info->count);
    + current->pid, info->port.count);
    #endif

    /*
    * If the port is the middle of closing, bail out now
    */
    - if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) {
    - wait_event_interruptible(info->close_wait,
    - !(info->flags & ASYNC_CLOSING));
    - return (info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS;
    + if (tty_hung_up_p(filp) || (info->port.flags & ASYNC_CLOSING)) {
    + wait_event_interruptible(info->port.close_wait,
    + !(info->port.flags & ASYNC_CLOSING));
    + return (info->port.flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS;
    }

    /*
    @@ -2641,9 +2641,9 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
    }
    #ifdef CY_DEBUG_OPEN
    printk(KERN_DEBUG "cyc:cy_close ttyC%d, count = %d\n", info->line,
    - info->count);
    + info->port.count);
    #endif
    - if ((tty->count == 1) && (info->count != 1)) {
    + if ((tty->count == 1) && (info->port.count != 1)) {
    /*
    * Uh, oh. tty->count is 1, which means that the tty
    * structure will be freed. Info->count should always
    @@ -2652,24 +2652,24 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
    * serial port won't be shutdown.
    */
    printk(KERN_ERR "cyc:cy_close: bad serial port count; "
    - "tty->count is 1, info->count is %d\n", info->count);
    - info->count = 1;
    + "tty->count is 1, info->port.count is %d\n", info->port.count);
    + info->port.count = 1;
    }
    #ifdef CY_DEBUG_COUNT
    printk(KERN_DEBUG "cyc:cy_close at (%d): decrementing count to %d\n",
    - current->pid, info->count - 1);
    + current->pid, info->port.count - 1);
    #endif
    - if (--info->count < 0) {
    + if (--info->port.count < 0) {
    #ifdef CY_DEBUG_COUNT
    printk(KERN_DEBUG "cyc:cyc_close setting count to 0\n");
    #endif
    - info->count = 0;
    + info->port.count = 0;
    }
    - if (info->count) {
    + if (info->port.count) {
    spin_unlock_irqrestore(&card->card_lock, flags);
    return;
    }
    - info->flags |= ASYNC_CLOSING;
    + info->port.flags |= ASYNC_CLOSING;

    /*
    * Now we wait for the transmit buffer to clear; and we notify
    @@ -2692,7 +2692,7 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
    cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
    cy_writeb(base_addr + (CySRER << index),
    readb(base_addr + (CySRER << index)) & ~CyRxData);
    - if (info->flags & ASYNC_INITIALIZED) {
    + if (info->port.flags & ASYNC_INITIALIZED) {
    /* Waiting for on-board buffers to be empty before
    closing the port */
    spin_unlock_irqrestore(&card->card_lock, flags);
    @@ -2731,18 +2731,18 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
    spin_lock_irqsave(&card->card_lock, flags);

    tty->closing = 0;
    - info->tty = NULL;
    - if (info->blocked_open) {
    + info->port.tty = NULL;
    + if (info->port.blocked_open) {
    spin_unlock_irqrestore(&card->card_lock, flags);
    if (info->close_delay) {
    msleep_interruptible(jiffies_to_msecs
    (info->close_delay));
    }
    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    spin_lock_irqsave(&card->card_lock, flags);
    }
    - info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
    - wake_up_interruptible(&info->close_wait);
    + info->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
    + wake_up_interruptible(&info->port.close_wait);

    #ifdef CY_DEBUG_OTHER
    printk(KERN_DEBUG "cyc:cy_close done\n");
    @@ -2777,7 +2777,7 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
    if (serial_paranoia_check(info, tty->name, "cy_write"))
    return 0;

    - if (!info->xmit_buf)
    + if (!info->port.xmit_buf)
    return 0;

    spin_lock_irqsave(&info->card->card_lock, flags);
    @@ -2788,7 +2788,7 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
    if (c <= 0)
    break;

    - memcpy(info->xmit_buf + info->xmit_head, buf, c);
    + memcpy(info->port.xmit_buf + info->xmit_head, buf, c);
    info->xmit_head = (info->xmit_head + c) &
    (SERIAL_XMIT_SIZE - 1);
    info->xmit_cnt += c;
    @@ -2826,7 +2826,7 @@ static int cy_put_char(struct tty_struct *tty, unsigned char ch)
    if (serial_paranoia_check(info, tty->name, "cy_put_char"))
    return 0;

    - if (!info->xmit_buf)
    + if (!info->port.xmit_buf)
    return 0;

    spin_lock_irqsave(&info->card->card_lock, flags);
    @@ -2835,7 +2835,7 @@ static int cy_put_char(struct tty_struct *tty, unsigned char ch)
    return 0;
    }

    - info->xmit_buf[info->xmit_head++] = ch;
    + info->port.xmit_buf[info->xmit_head++] = ch;
    info->xmit_head &= SERIAL_XMIT_SIZE - 1;
    info->xmit_cnt++;
    info->idle_stats.xmit_bytes++;
    @@ -2860,7 +2860,7 @@ static void cy_flush_chars(struct tty_struct *tty)
    return;

    if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
    - !info->xmit_buf)
    + !info->port.xmit_buf)
    return;

    start_xmit(info);
    @@ -2988,27 +2988,27 @@ static void set_line_char(struct cyclades_port *info)
    int baud, baud_rate = 0;
    int i;

    - if (!info->tty || !info->tty->termios)
    + if (!info->port.tty || !info->port.tty->termios)
    return;

    if (info->line == -1)
    return;

    - cflag = info->tty->termios->c_cflag;
    - iflag = info->tty->termios->c_iflag;
    + cflag = info->port.tty->termios->c_cflag;
    + iflag = info->port.tty->termios->c_iflag;

    /*
    * Set up the tty->alt_speed kludge
    */
    - if (info->tty) {
    - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
    - info->tty->alt_speed = 57600;
    - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
    - info->tty->alt_speed = 115200;
    - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
    - info->tty->alt_speed = 230400;
    - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
    - info->tty->alt_speed = 460800;
    + if (info->port.tty) {
    + if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
    + info->port.tty->alt_speed = 57600;
    + if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
    + info->port.tty->alt_speed = 115200;
    + if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
    + info->port.tty->alt_speed = 230400;
    + if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
    + info->port.tty->alt_speed = 460800;
    }

    card = info->card;
    @@ -3020,8 +3020,8 @@ static void set_line_char(struct cyclades_port *info)
    index = card->bus_index;

    /* baud rate */
    - baud = tty_get_baud_rate(info->tty);
    - if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
    + baud = tty_get_baud_rate(info->port.tty);
    + if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) ==
    ASYNC_SPD_CUST) {
    if (info->custom_divisor)
    baud_rate = info->baud / info->custom_divisor;
    @@ -3038,7 +3038,7 @@ static void set_line_char(struct cyclades_port *info)
    if (i == 20)
    i = 19; /* CD1400_MAX_SPEED */

    - if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
    + if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) ==
    ASYNC_SPD_CUST) {
    cyy_baud_calc(info, baud_rate);
    } else {
    @@ -3059,7 +3059,7 @@ static void set_line_char(struct cyclades_port *info)
    /* get it right for 134.5 baud */
    info->timeout = (info->xmit_fifo_size * HZ * 30 / 269) +
    2;
    - } else if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
    + } else if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) ==
    ASYNC_SPD_CUST) {
    info->timeout = (info->xmit_fifo_size * HZ * 15 /
    baud_rate) + 2;
    @@ -3108,16 +3108,16 @@ static void set_line_char(struct cyclades_port *info)

    /* CTS flow control flag */
    if (cflag & CRTSCTS) {
    - info->flags |= ASYNC_CTS_FLOW;
    + info->port.flags |= ASYNC_CTS_FLOW;
    info->cor2 |= CyCtsAE;
    } else {
    - info->flags &= ~ASYNC_CTS_FLOW;
    + info->port.flags &= ~ASYNC_CTS_FLOW;
    info->cor2 &= ~CyCtsAE;
    }
    if (cflag & CLOCAL)
    - info->flags &= ~ASYNC_CHECK_CD;
    + info->port.flags &= ~ASYNC_CHECK_CD;
    else
    - info->flags |= ASYNC_CHECK_CD;
    + info->port.flags |= ASYNC_CHECK_CD;

    /***********************************************
    The hardware option, CyRtsAO, presents RTS when
    @@ -3146,8 +3146,8 @@ static void set_line_char(struct cyclades_port *info)
    /* set line characteristics according configuration */

    cy_writeb(base_addr + (CySCHR1 << index),
    - START_CHAR(info->tty));
    - cy_writeb(base_addr + (CySCHR2 << index), STOP_CHAR(info->tty));
    + START_CHAR(info->port.tty));
    + cy_writeb(base_addr + (CySCHR2 << index), STOP_CHAR(info->port.tty));
    cy_writeb(base_addr + (CyCOR1 << index), info->cor1);
    cy_writeb(base_addr + (CyCOR2 << index), info->cor2);
    cy_writeb(base_addr + (CyCOR3 << index), info->cor3);
    @@ -3163,7 +3163,7 @@ static void set_line_char(struct cyclades_port *info)
    (info->default_timeout ? info->default_timeout : 0x02));
    /* 10ms rx timeout */

    - if (C_CLOCAL(info->tty)) {
    + if (C_CLOCAL(info->port.tty)) {
    /* without modem intr */
    cy_writeb(base_addr + (CySRER << index),
    readb(base_addr + (CySRER << index)) | CyMdmCh);
    @@ -3226,8 +3226,8 @@ static void set_line_char(struct cyclades_port *info)
    #endif
    }

    - if (info->tty)
    - clear_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
    spin_unlock_irqrestore(&card->card_lock, flags);

    } else {
    @@ -3250,8 +3250,8 @@ static void set_line_char(struct cyclades_port *info)
    buf_ctrl = &zfw_ctrl->buf_ctrl[channel];

    /* baud rate */
    - baud = tty_get_baud_rate(info->tty);
    - if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
    + baud = tty_get_baud_rate(info->port.tty);
    + if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) ==
    ASYNC_SPD_CUST) {
    if (info->custom_divisor)
    baud_rate = info->baud / info->custom_divisor;
    @@ -3266,7 +3266,7 @@ static void set_line_char(struct cyclades_port *info)
    /* get it right for 134.5 baud */
    info->timeout = (info->xmit_fifo_size * HZ * 30 / 269) +
    2;
    - } else if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
    + } else if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) ==
    ASYNC_SPD_CUST) {
    info->timeout = (info->xmit_fifo_size * HZ * 15 /
    baud_rate) + 2;
    @@ -3318,7 +3318,7 @@ static void set_line_char(struct cyclades_port *info)
    }
    /* As the HW flow control is done in firmware, the driver
    doesn't need to care about it */
    - info->flags &= ~ASYNC_CTS_FLOW;
    + info->port.flags &= ~ASYNC_CTS_FLOW;

    /* XON/XOFF/XANY flow control flags */
    sw_flow = 0;
    @@ -3337,9 +3337,9 @@ static void set_line_char(struct cyclades_port *info)

    /* CD sensitivity */
    if (cflag & CLOCAL)
    - info->flags &= ~ASYNC_CHECK_CD;
    + info->port.flags &= ~ASYNC_CHECK_CD;
    else
    - info->flags |= ASYNC_CHECK_CD;
    + info->port.flags |= ASYNC_CHECK_CD;

    if (baud == 0) { /* baud rate is zero, turn off line */
    cy_writel(&ch_ctrl->rs_control,
    @@ -3361,8 +3361,8 @@ static void set_line_char(struct cyclades_port *info)
    "was %x\n", info->line, retval);
    }

    - if (info->tty)
    - clear_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
    }
    } /* set_line_char */

    @@ -3381,7 +3381,7 @@ get_serial_info(struct cyclades_port *info,
    tmp.port = (info->card - cy_card) * 0x100 + info->line -
    cinfo->first_line;
    tmp.irq = cinfo->irq;
    - tmp.flags = info->flags;
    + tmp.flags = info->port.flags;
    tmp.close_delay = info->close_delay;
    tmp.closing_wait = info->closing_wait;
    tmp.baud_base = info->baud;
    @@ -3406,9 +3406,9 @@ set_serial_info(struct cyclades_port *info,
    new_serial.baud_base != info->baud ||
    (new_serial.flags & ASYNC_FLAGS &
    ~ASYNC_USR_MASK) !=
    - (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK))
    + (info->port.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK))
    return -EPERM;
    - info->flags = (info->flags & ~ASYNC_USR_MASK) |
    + info->port.flags = (info->port.flags & ~ASYNC_USR_MASK) |
    (new_serial.flags & ASYNC_USR_MASK);
    info->baud = new_serial.baud_base;
    info->custom_divisor = new_serial.custom_divisor;
    @@ -3422,13 +3422,13 @@ set_serial_info(struct cyclades_port *info,

    info->baud = new_serial.baud_base;
    info->custom_divisor = new_serial.custom_divisor;
    - info->flags = (info->flags & ~ASYNC_FLAGS) |
    + info->port.flags = (info->port.flags & ~ASYNC_FLAGS) |
    (new_serial.flags & ASYNC_FLAGS);
    info->close_delay = new_serial.close_delay * HZ / 100;
    info->closing_wait = new_serial.closing_wait * HZ / 100;

    check_and_exit:
    - if (info->flags & ASYNC_INITIALIZED) {
    + if (info->port.flags & ASYNC_INITIALIZED) {
    set_line_char(info);
    return 0;
    } else {
    @@ -4097,7 +4097,7 @@ static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
    */
    if (!(old_termios->c_cflag & CLOCAL) &&
    (tty->termios->c_cflag & CLOCAL))
    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    #endif
    } /* cy_set_termios */

    @@ -4326,14 +4326,14 @@ static void cy_hangup(struct tty_struct *tty)

    cy_flush_buffer(tty);
    shutdown(info);
    - info->count = 0;
    + info->port.count = 0;
    #ifdef CY_DEBUG_COUNT
    printk(KERN_DEBUG "cyc:cy_hangup (%d): setting count to 0\n",
    current->pid);
    #endif
    - info->tty = NULL;
    - info->flags &= ~ASYNC_NORMAL_ACTIVE;
    - wake_up_interruptible(&info->open_wait);
    + info->port.tty = NULL;
    + info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
    + wake_up_interruptible(&info->port.open_wait);
    } /* cy_hangup */

    /*
    @@ -4379,12 +4379,11 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo)
    info->magic = CYCLADES_MAGIC;
    info->card = cinfo;
    info->line = port;
    - info->flags = STD_COM_FLAGS;
    info->closing_wait = CLOSING_WAIT_DELAY;
    info->close_delay = 5 * HZ / 10;

    - init_waitqueue_head(&info->open_wait);
    - init_waitqueue_head(&info->close_wait);
    + tty_port_init(&info->port);
    + info->port.flags = STD_COM_FLAGS;
    init_completion(&info->shutdown_wait);
    init_waitqueue_head(&info->delta_msr_wait);

    @@ -5237,7 +5236,7 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length,
    for (j = 0; j < cy_card[i].nports; j++) {
    info = &cy_card[i].ports[j];

    - if (info->count)
    + if (info->port.count)
    size = sprintf(buf + len, "%3d %8lu %10lu %8lu "
    "%10lu %8lu %9lu %6ld\n", info->line,
    (cur_jifs - info->idle_stats.in_use) /
    @@ -5247,7 +5246,7 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length,
    (cur_jifs - info->idle_stats.recv_idle)/
    HZ, info->idle_stats.overruns,
    /* FIXME: double check locking */
    - (long)info->tty->ldisc.ops->num);
    + (long)info->port.tty->ldisc.ops->num);
    else
    size = sprintf(buf + len, "%3d %8lu %10lu %8lu "
    "%10lu %8lu %9lu %6ld\n",
    diff --git a/include/linux/cyclades.h b/include/linux/cyclades.h
    index 504cb2c..a982b74 100644
    --- a/include/linux/cyclades.h
    +++ b/include/linux/cyclades.h
    @@ -550,11 +550,11 @@ struct cyclades_icount {

    struct cyclades_port {
    int magic;
    + struct tty_port port;
    struct cyclades_card *card;
    int line;
    int flags; /* defined in tty.h */
    int type; /* UART type */
    - struct tty_struct *tty;
    int read_status_mask;
    int ignore_status_mask;
    int timeout;
    @@ -569,11 +569,8 @@ struct cyclades_port {
    u8 x_char; /* to be pushed out ASAP */
    int close_delay;
    unsigned short closing_wait;
    - int count; /* # of fd on device */
    int breakon;
    int breakoff;
    - int blocked_open; /* # of blocked opens */
    - unsigned char *xmit_buf;
    int xmit_head;
    int xmit_tail;
    int xmit_cnt;
    @@ -583,8 +580,6 @@ struct cyclades_port {
    struct cyclades_monitor mon;
    struct cyclades_idle_stats idle_stats;
    struct cyclades_icount icount;
    - wait_queue_head_t open_wait;
    - wait_queue_head_t close_wait;
    struct completion shutdown_wait;
    wait_queue_head_t delta_msr_wait;
    int throttle;

    --
    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 27/70] usb-serial-bus: tidy coding style

    From: Alan Cox

    Tidy up

    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/bus.c | 20 ++++++++++----------
    1 files changed, 10 insertions(+), 10 deletions(-)


    diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
    index 0b14aea..83bbb5b 100644
    --- a/drivers/usb/serial/bus.c
    +++ b/drivers/usb/serial/bus.c
    @@ -15,7 +15,8 @@
    #include
    #include

    -static int usb_serial_device_match (struct device *dev, struct device_driver *drv)
    +static int usb_serial_device_match(struct device *dev,
    + struct device_driver *drv)
    {
    struct usb_serial_driver *driver;
    const struct usb_serial_port *port;
    @@ -46,7 +47,7 @@ static ssize_t show_port_number(struct device *dev,

    static DEVICE_ATTR(port_number, S_IRUGO, show_port_number, NULL);

    -static int usb_serial_device_probe (struct device *dev)
    +static int usb_serial_device_probe(struct device *dev)
    {
    struct usb_serial_driver *driver;
    struct usb_serial_port *port;
    @@ -66,7 +67,7 @@ static int usb_serial_device_probe (struct device *dev)
    retval = -EIO;
    goto exit;
    }
    - retval = driver->port_probe (port);
    + retval = driver->port_probe(port);
    module_put(driver->driver.owner);
    if (retval)
    goto exit;
    @@ -77,8 +78,8 @@ static int usb_serial_device_probe (struct device *dev)
    goto exit;

    minor = port->number;
    - tty_register_device (usb_serial_tty_driver, minor, dev);
    - dev_info(&port->serial->dev->dev,
    + tty_register_device(usb_serial_tty_driver, minor, dev);
    + dev_info(&port->serial->dev->dev,
    "%s converter now attached to ttyUSB%d\n",
    driver->description, minor);

    @@ -86,7 +87,7 @@ exit:
    return retval;
    }

    -static int usb_serial_device_remove (struct device *dev)
    +static int usb_serial_device_remove(struct device *dev)
    {
    struct usb_serial_driver *driver;
    struct usb_serial_port *port;
    @@ -94,9 +95,8 @@ static int usb_serial_device_remove (struct device *dev)
    int minor;

    port = to_usb_serial_port(dev);
    - if (!port) {
    + if (!port)
    return -ENODEV;
    - }

    device_remove_file(&port->dev, &dev_attr_port_number);

    @@ -107,12 +107,12 @@ static int usb_serial_device_remove (struct device *dev)
    retval = -EIO;
    goto exit;
    }
    - retval = driver->port_remove (port);
    + retval = driver->port_remove(port);
    module_put(driver->driver.owner);
    }
    exit:
    minor = port->number;
    - tty_unregister_device (usb_serial_tty_driver, minor);
    + tty_unregister_device(usb_serial_tty_driver, minor);
    dev_info(dev, "%s converter now disconnected from ttyUSB%d\n",
    driver->description, minor);


    --
    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 19/70] tty: Clean up tiocmset

    From: Alan Cox

    Reverse the order of one test and it gets much more readable

    Signed-off-by: Alan Cox
    ---

    drivers/char/tty_io.c | 48 ++++++++++++++++++++++--------------------------
    1 files changed, 22 insertions(+), 26 deletions(-)


    diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
    index 1856096..87b1f9b 100644
    --- a/drivers/char/tty_io.c
    +++ b/drivers/char/tty_io.c
    @@ -3488,35 +3488,31 @@ static int tty_tiocmget(struct tty_struct *tty, struct file *file, int __user *p
    static int tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int cmd,
    unsigned __user *p)
    {
    - int retval = -EINVAL;
    -
    - if (tty->ops->tiocmset) {
    - unsigned int set, clear, val;
    -
    - retval = get_user(val, p);
    - if (retval)
    - return retval;
    -
    - set = clear = 0;
    - switch (cmd) {
    - case TIOCMBIS:
    - set = val;
    - break;
    - case TIOCMBIC:
    - clear = val;
    - break;
    - case TIOCMSET:
    - set = val;
    - clear = ~val;
    - break;
    - }
    + int retval;
    + unsigned int set, clear, val;

    - set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LO OP;
    - clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LO OP;
    + if (tty->ops->tiocmset == NULL)
    + return -EINVAL;

    - retval = tty->ops->tiocmset(tty, file, set, clear);
    + retval = get_user(val, p);
    + if (retval)
    + return retval;
    + set = clear = 0;
    + switch (cmd) {
    + case TIOCMBIS:
    + set = val;
    + break;
    + case TIOCMBIC:
    + clear = val;
    + break;
    + case TIOCMSET:
    + set = val;
    + clear = ~val;
    + break;
    }
    - return retval;
    + set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LO OP;
    + clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LO OP;
    + return tty->ops->tiocmset(tty, file, set, clear);
    }

    /*

    --
    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 35/70] empeg: Coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/empeg.c | 203 +++++++++++++++++++++++---------------------
    1 files changed, 107 insertions(+), 96 deletions(-)


    diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
    index 47ebdf5..a6ab5b5 100644
    --- a/drivers/usb/serial/empeg.c
    +++ b/drivers/usb/serial/empeg.c
    @@ -11,36 +11,39 @@
    * it under the terms of the GNU General Public License, as published by
    * the Free Software Foundation, version 2.
    *
    - * 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
    + *
    * (07/16/2001) gb
    - * remove unused code in empeg_close() (thanks to Oliver Neukum for pointing this
    - * out) and rewrote empeg_set_termios().
    - *
    + * remove unused code in empeg_close() (thanks to Oliver Neukum for
    + * pointing this out) and rewrote empeg_set_termios().
    + *
    * (05/30/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.
    - *
    + *
    * (01/22/2001) gb
    - * Added write_room() and chars_in_buffer() support.
    - *
    + * Added write_room() and chars_in_buffer() support.
    + *
    * (12/21/2000) gb
    * Moved termio stuff inside the port->active check.
    * Moved MOD_DEC_USE_COUNT to end of empeg_close().
    - *
    + *
    * (12/03/2000) gb
    - * Added port->port.tty->ldisc.set_termios(port->port.tty, NULL) to empeg_open()
    - * This notifies the tty driver that the termios have changed.
    - *
    + * Added port->port.tty->ldisc.set_termios(port->port.tty, NULL) to
    + * empeg_open(). This notifies the tty driver that the termios have
    + * changed.
    + *
    * (11/13/2000) gb
    - * Moved tty->low_latency = 1 from empeg_read_bulk_callback() to empeg_open()
    - * (It only needs to be set once - Doh!)
    - *
    + * Moved tty->low_latency = 1 from empeg_read_bulk_callback() to
    + * empeg_open() (It only needs to be set once - Doh!)
    + *
    * (11/11/2000) gb
    * Updated to work with id_table structure.
    - *
    + *
    * (11/04/2000) gb
    * Forked this from visor.c, and hacked it up to work with an
    * Empeg ltd. empeg-car player. Constructive criticism welcomed.
    @@ -48,7 +51,7 @@
    * use of his code, and for his guidance, advice and patience.
    * A 'Thank You' is in order for John Ripley of Empeg ltd for his
    * advice, and patience too.
    - *
    + *
    */

    #include
    @@ -60,7 +63,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include

    @@ -77,27 +80,30 @@ static int debug;
    #define EMPEG_PRODUCT_ID 0x0001

    /* function prototypes for an empeg-car player */
    -static int empeg_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
    -static void empeg_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
    -static int empeg_write (struct tty_struct *tty, struct usb_serial_port *port,
    - const unsigned char *buf,
    - int count);
    -static int empeg_write_room (struct tty_struct *tty);
    -static int empeg_chars_in_buffer (struct tty_struct *tty);
    -static void empeg_throttle (struct tty_struct *tty);
    -static void empeg_unthrottle (struct tty_struct *tty);
    -static int empeg_startup (struct usb_serial *serial);
    -static void empeg_shutdown (struct usb_serial *serial);
    -static void empeg_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios);
    -static void empeg_write_bulk_callback (struct urb *urb);
    -static void empeg_read_bulk_callback (struct urb *urb);
    +static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port,
    + struct file *filp);
    +static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port,
    + struct file *filp);
    +static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port,
    + const unsigned char *buf,
    + int count);
    +static int empeg_write_room(struct tty_struct *tty);
    +static int empeg_chars_in_buffer(struct tty_struct *tty);
    +static void empeg_throttle(struct tty_struct *tty);
    +static void empeg_unthrottle(struct tty_struct *tty);
    +static int empeg_startup(struct usb_serial *serial);
    +static void empeg_shutdown(struct usb_serial *serial);
    +static void empeg_set_termios(struct tty_struct *tty,
    + struct usb_serial_port *port, struct ktermios *old_termios);
    +static void empeg_write_bulk_callback(struct urb *urb);
    +static void empeg_read_bulk_callback(struct urb *urb);

    static struct usb_device_id id_table [] = {
    { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
    { } /* Terminating entry */
    };

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

    static struct usb_driver empeg_driver = {
    .name = "empeg",
    @@ -149,7 +155,7 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port,
    dbg("%s - port %d", __func__, port->number);

    /* Force default termio settings */
    - empeg_set_termios (tty, port, NULL) ;
    + empeg_set_termios(tty, port, NULL) ;

    bytes_in = 0;
    bytes_out = 0;
    @@ -157,7 +163,7 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port,
    /* Start reading from the device */
    usb_fill_bulk_urb(
    port->read_urb,
    - serial->dev,
    + serial->dev,
    usb_rcvbulkpipe(serial->dev,
    port->bulk_in_endpointAddress),
    port->read_urb->transfer_buffer,
    @@ -168,14 +174,16 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *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 empeg_close(struct tty_struct *tty, struct usb_serial_port *port,
    - struct file * filp)
    + struct file *filp)
    {
    dbg("%s - port %d", __func__, port->number);

    @@ -186,7 +194,8 @@ static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port,
    }


    -static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count)
    +static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port,
    + const unsigned char *buf, int count)
    {
    struct usb_serial *serial = port->serial;
    struct urb *urb;
    @@ -203,7 +212,7 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con
    /* try to find a free urb in our list of them */
    urb = NULL;

    - spin_lock_irqsave (&write_urb_pool_lock, flags);
    + spin_lock_irqsave(&write_urb_pool_lock, flags);

    for (i = 0; i < NUM_URBS; ++i) {
    if (write_urb_pool[i]->status != -EINPROGRESS) {
    @@ -212,7 +221,7 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con
    }
    }

    - spin_unlock_irqrestore (&write_urb_pool_lock, flags);
    + spin_unlock_irqrestore(&write_urb_pool_lock, flags);

    if (urb == NULL) {
    dbg("%s - no more free urbs", __func__);
    @@ -220,25 +229,27 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con
    }

    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) {
    - dev_err(&port->dev, "%s no more kernel memory...\n", __func__);
    + dev_err(&port->dev,
    + "%s no more kernel memory...\n",
    + __func__);
    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);
    + memcpy(urb->transfer_buffer, current_position, transfer_size);

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

    /* build up our urb */
    - usb_fill_bulk_urb (
    + usb_fill_bulk_urb(
    urb,
    serial->dev,
    usb_sndbulkpipe(serial->dev,
    - port->bulk_out_endpointAddress),
    + port->bulk_out_endpointAddress),
    urb->transfer_buffer,
    transfer_size,
    empeg_write_bulk_callback,
    @@ -260,7 +271,7 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con
    }
    exit:
    return bytes_sent;
    -}
    +}


    static int empeg_write_room(struct tty_struct *tty)
    @@ -272,14 +283,13 @@ static int empeg_write_room(struct tty_struct *tty)

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

    - spin_lock_irqsave (&write_urb_pool_lock, flags);
    + spin_lock_irqsave(&write_urb_pool_lock, flags);
    /* tally up the number of bytes available */
    for (i = 0; i < NUM_URBS; ++i) {
    - if (write_urb_pool[i]->status != -EINPROGRESS) {
    + if (write_urb_pool[i]->status != -EINPROGRESS)
    room += URB_TRANSFER_BUFFER_SIZE;
    - }
    - }
    - spin_unlock_irqrestore (&write_urb_pool_lock, flags);
    + }
    + spin_unlock_irqrestore(&write_urb_pool_lock, flags);
    dbg("%s - returns %d", __func__, room);
    return room;

    @@ -295,25 +305,21 @@ static int empeg_chars_in_buffer(struct tty_struct *tty)

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

    - spin_lock_irqsave (&write_urb_pool_lock, flags);
    + spin_lock_irqsave(&write_urb_pool_lock, flags);

    /* tally up the number of bytes waiting */
    for (i = 0; i < NUM_URBS; ++i) {
    - if (write_urb_pool[i]->status == -EINPROGRESS) {
    + if (write_urb_pool[i]->status == -EINPROGRESS)
    chars += URB_TRANSFER_BUFFER_SIZE;
    - }
    }

    - spin_unlock_irqrestore (&write_urb_pool_lock, flags);
    -
    + spin_unlock_irqrestore(&write_urb_pool_lock, flags);
    dbg("%s - returns %d", __func__, chars);
    -
    - return (chars);
    -
    + return chars;
    }


    -static void empeg_write_bulk_callback (struct urb *urb)
    +static void empeg_write_bulk_callback(struct urb *urb)
    {
    struct usb_serial_port *port = urb->context;
    int status = urb->status;
    @@ -330,7 +336,7 @@ static void empeg_write_bulk_callback (struct urb *urb)
    }


    -static void empeg_read_bulk_callback (struct urb *urb)
    +static void empeg_read_bulk_callback(struct urb *urb)
    {
    struct usb_serial_port *port = urb->context;
    struct tty_struct *tty;
    @@ -346,8 +352,8 @@ static void empeg_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 (urb->actual_length) {
    @@ -360,7 +366,7 @@ static void empeg_read_bulk_callback (struct urb *urb)
    /* Continue trying to always read */
    usb_fill_bulk_urb(
    port->read_urb,
    - port->serial->dev,
    + port->serial->dev,
    usb_rcvbulkpipe(port->serial->dev,
    port->bulk_in_endpointAddress),
    port->read_urb->transfer_buffer,
    @@ -371,7 +377,9 @@ static void empeg_read_bulk_callback (struct urb *urb)
    result = usb_submit_urb(port->read_urb, GFP_ATOMIC);

    if (result)
    - dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
    + dev_err(&urb->dev->dev,
    + "%s - failed resubmitting read urb, error %d\n",
    + __func__, result);

    return;

    @@ -395,11 +403,13 @@ static void empeg_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 empeg_startup (struct usb_serial *serial)
    +static int empeg_startup(struct usb_serial *serial)
    {
    int r;

    @@ -411,7 +421,7 @@ static int empeg_startup (struct usb_serial *serial)
    return -ENODEV;
    }
    dbg("%s - reset config", __func__);
    - r = usb_reset_configuration (serial->dev);
    + r = usb_reset_configuration(serial->dev);

    /* continue on with initialization */
    return r;
    @@ -419,9 +429,9 @@ static int empeg_startup (struct usb_serial *serial)
    }


    -static void empeg_shutdown (struct usb_serial *serial)
    +static void empeg_shutdown(struct usb_serial *serial)
    {
    - dbg ("%s", __func__);
    + dbg("%s", __func__);
    }


    @@ -432,14 +442,14 @@ static void empeg_set_termios(struct tty_struct *tty,
    dbg("%s - port %d", __func__, port->number);

    /*
    - * The empeg-car player wants these particular tty settings.
    - * You could, for example, change the baud rate, however the
    - * player only supports 115200 (currently), so there is really
    - * no point in support for changes to the tty settings.
    - * (at least for now)
    - *
    - * The default requirements for this device are:
    - */
    + * The empeg-car player wants these particular tty settings.
    + * You could, for example, change the baud rate, however the
    + * player only supports 115200 (currently), so there is really
    + * no point in support for changes to the tty settings.
    + * (at least for now)
    + *
    + * The default requirements for this device are:
    + */
    termios->c_iflag
    &= ~(IGNBRK /* disable ignore break */
    | BRKINT /* disable break causes interrupt */
    @@ -478,13 +488,13 @@ static void empeg_set_termios(struct tty_struct *tty,
    }


    -static int __init empeg_init (void)
    +static int __init empeg_init(void)
    {
    struct urb *urb;
    int i, retval;

    - /* create our write urb pool and transfer buffers */
    - spin_lock_init (&write_urb_pool_lock);
    + /* create our write urb pool and transfer buffers */
    + spin_lock_init(&write_urb_pool_lock);
    for (i = 0; i < NUM_URBS; ++i) {
    urb = usb_alloc_urb(0, GFP_KERNEL);
    write_urb_pool[i] = urb;
    @@ -493,9 +503,10 @@ static int __init empeg_init (void)
    continue;
    }

    - 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.",
    + err("%s - out of memory for urb buffers.",
    __func__);
    continue;
    }
    @@ -524,36 +535,36 @@ failed_usb_serial_register:
    }


    -static void __exit empeg_exit (void)
    +static void __exit empeg_exit(void)
    {
    int i;
    unsigned long flags;

    usb_deregister(&empeg_driver);
    - usb_serial_deregister (&empeg_device);
    + usb_serial_deregister(&empeg_device);

    - spin_lock_irqsave (&write_urb_pool_lock, flags);
    + spin_lock_irqsave(&write_urb_pool_lock, flags);

    for (i = 0; i < NUM_URBS; ++i) {
    if (write_urb_pool[i]) {
    - /* FIXME - uncomment the following usb_kill_urb call when
    - * the host controllers get fixed to set urb->dev = NULL after
    - * the urb is finished. Otherwise this call oopses. */
    + /* FIXME - uncomment the following usb_kill_urb call
    + * when the host controllers get fixed to set urb->dev
    + * = NULL after the urb is finished. Otherwise this
    + * call oopses. */
    /* usb_kill_urb(write_urb_pool[i]); */
    kfree(write_urb_pool[i]->transfer_buffer);
    - usb_free_urb (write_urb_pool[i]);
    + usb_free_urb(write_urb_pool[i]);
    }
    }
    -
    - spin_unlock_irqrestore (&write_urb_pool_lock, flags);
    + spin_unlock_irqrestore(&write_urb_pool_lock, flags);
    }


    module_init(empeg_init);
    module_exit(empeg_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/

  8. [PATCH 15/70] rocket: use tty_port

    From: Alan Cox

    Switch the rocketport to use the new tty_port structure

    Signed-off-by: Alan Cox
    ---

    drivers/char/rocket.c | 116 +++++++++++++++++++++++----------------------
    drivers/char/rocket_int.h | 9 +--
    2 files changed, 61 insertions(+), 64 deletions(-)


    diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
    index 743dc80..ab04adb 100644
    --- a/drivers/char/rocket.c
    +++ b/drivers/char/rocket.c
    @@ -434,15 +434,15 @@ static void rp_do_transmit(struct r_port *info)
    #endif
    if (!info)
    return;
    - if (!info->tty) {
    + if (!info->port.tty) {
    printk(KERN_WARNING "rp: WARNING %s called with "
    - "info->tty==NULL\n", __func__);
    + "info->port.tty==NULL\n", __func__);
    clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
    return;
    }

    spin_lock_irqsave(&info->slock, flags);
    - tty = info->tty;
    + tty = info->port.tty;
    info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp);

    /* Loop sending data to FIFO until done or FIFO full */
    @@ -502,13 +502,13 @@ static void rp_handle_port(struct r_port *info)
    "info->flags & NOT_INIT\n");
    return;
    }
    - if (!info->tty) {
    + if (!info->port.tty) {
    printk(KERN_WARNING "rp: WARNING: rp_handle_port called with "
    - "info->tty==NULL\n");
    + "info->port.tty==NULL\n");
    return;
    }
    cp = &info->channel;
    - tty = info->tty;
    + tty = info->port.tty;

    IntMask = sGetChanIntID(cp) & info->intmask;
    #ifdef ROCKET_DEBUG_INTR
    @@ -530,7 +530,7 @@ static void rp_handle_port(struct r_port *info)
    tty_hangup(tty);
    }
    info->cd_status = (ChanStatus & CD_ACT) ? 1 : 0;
    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    }
    #ifdef ROCKET_DEBUG_INTR
    if (IntMask & DELTA_CTS) { /* CTS change */
    @@ -650,7 +650,7 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
    info->chan = chan;
    info->closing_wait = 3000;
    info->close_delay = 50;
    - init_waitqueue_head(&info->open_wait);
    + init_waitqueue_head(&info->port.open_wait);
    init_completion(&info->close_wait);
    info->flags &= ~ROCKET_MODE_MASK;
    switch (pc104[board][line]) {
    @@ -717,7 +717,7 @@ static void configure_r_port(struct r_port *info,
    unsigned rocketMode;
    int bits, baud, divisor;
    CHANNEL_t *cp;
    - struct ktermios *t = info->tty->termios;
    + struct ktermios *t = info->port.tty->termios;

    cp = &info->channel;
    cflag = t->c_cflag;
    @@ -750,7 +750,7 @@ static void configure_r_port(struct r_port *info,
    }

    /* baud rate */
    - baud = tty_get_baud_rate(info->tty);
    + baud = tty_get_baud_rate(info->port.tty);
    if (!baud)
    baud = 9600;
    divisor = ((rp_baud_base[info->board] + (baud >> 1)) / baud) - 1;
    @@ -768,7 +768,7 @@ static void configure_r_port(struct r_port *info,
    sSetBaud(cp, divisor);

    /* FIXME: Should really back compute a baud rate from the divisor */
    - tty_encode_baud_rate(info->tty, baud, baud);
    + tty_encode_baud_rate(info->port.tty, baud, baud);

    if (cflag & CRTSCTS) {
    info->intmask |= DELTA_CTS;
    @@ -793,15 +793,15 @@ static void configure_r_port(struct r_port *info,
    * Handle software flow control in the board
    */
    #ifdef ROCKET_SOFT_FLOW
    - if (I_IXON(info->tty)) {
    + if (I_IXON(info->port.tty)) {
    sEnTxSoftFlowCtl(cp);
    - if (I_IXANY(info->tty)) {
    + if (I_IXANY(info->port.tty)) {
    sEnIXANY(cp);
    } else {
    sDisIXANY(cp);
    }
    - sSetTxXONChar(cp, START_CHAR(info->tty));
    - sSetTxXOFFChar(cp, STOP_CHAR(info->tty));
    + sSetTxXONChar(cp, START_CHAR(info->port.tty));
    + sSetTxXOFFChar(cp, STOP_CHAR(info->port.tty));
    } else {
    sDisTxSoftFlowCtl(cp);
    sDisIXANY(cp);
    @@ -813,24 +813,24 @@ static void configure_r_port(struct r_port *info,
    * Set up ignore/read mask words
    */
    info->read_status_mask = STMRCVROVRH | 0xFF;
    - if (I_INPCK(info->tty))
    + if (I_INPCK(info->port.tty))
    info->read_status_mask |= STMFRAMEH | STMPARITYH;
    - if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
    + if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
    info->read_status_mask |= STMBREAKH;

    /*
    * Characters to ignore
    */
    info->ignore_status_mask = 0;
    - if (I_IGNPAR(info->tty))
    + if (I_IGNPAR(info->port.tty))
    info->ignore_status_mask |= STMFRAMEH | STMPARITYH;
    - if (I_IGNBRK(info->tty)) {
    + if (I_IGNBRK(info->port.tty)) {
    info->ignore_status_mask |= STMBREAKH;
    /*
    * If we're ignoring parity and break indicators,
    * ignore overruns too. (For real raw support).
    */
    - if (I_IGNPAR(info->tty))
    + if (I_IGNPAR(info->port.tty))
    info->ignore_status_mask |= STMRCVROVRH;
    }

    @@ -863,7 +863,7 @@ static void configure_r_port(struct r_port *info,
    }
    }

    -/* info->count is considered critical, protected by spinlocks. */
    +/* info->port.count is considered critical, protected by spinlocks. */
    static int block_til_ready(struct tty_struct *tty, struct file *filp,
    struct r_port *info)
    {
    @@ -897,13 +897,13 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,

    /*
    * Block waiting for the carrier detect and the line to become free. While we are in
    - * this loop, info->count is dropped by one, so that rp_close() knows when to free things.
    + * this loop, info->port.count is dropped by one, so that rp_close() knows when to free things.
    * We restore it upon exit, either normal or abnormal.
    */
    retval = 0;
    - add_wait_queue(&info->open_wait, &wait);
    + add_wait_queue(&info->port.open_wait, &wait);
    #ifdef ROCKET_DEBUG_OPEN
    - printk(KERN_INFO "block_til_ready before block: ttyR%d, count = %d\n", info->line, info->count);
    + printk(KERN_INFO "block_til_ready before block: ttyR%d, count = %d\n", info->line, info->port.count);
    #endif
    spin_lock_irqsave(&info->slock, flags);

    @@ -912,10 +912,10 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
    #else
    if (!tty_hung_up_p(filp)) {
    extra_count = 1;
    - info->count--;
    + info->port.count--;
    }
    #endif
    - info->blocked_open++;
    + info->port.blocked_open++;

    spin_unlock_irqrestore(&info->slock, flags);

    @@ -940,24 +940,24 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
    }
    #ifdef ROCKET_DEBUG_OPEN
    printk(KERN_INFO "block_til_ready blocking: ttyR%d, count = %d, flags=0x%0x\n",
    - info->line, info->count, info->flags);
    + info->line, info->port.count, info->flags);
    #endif
    schedule(); /* Don't hold spinlock here, will hang PC */
    }
    __set_current_state(TASK_RUNNING);
    - remove_wait_queue(&info->open_wait, &wait);
    + remove_wait_queue(&info->port.open_wait, &wait);

    spin_lock_irqsave(&info->slock, flags);

    if (extra_count)
    - info->count++;
    - info->blocked_open--;
    + info->port.count++;
    + info->port.blocked_open--;

    spin_unlock_irqrestore(&info->slock, flags);

    #ifdef ROCKET_DEBUG_OPEN
    printk(KERN_INFO "block_til_ready after blocking: ttyR%d, count = %d\n",
    - info->line, info->count);
    + info->line, info->port.count);
    #endif
    if (retval)
    return retval;
    @@ -1001,9 +1001,9 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
    info->xmit_buf = (unsigned char *) page;

    tty->driver_data = info;
    - info->tty = tty;
    + info->port.tty = tty;

    - if (info->count++ == 0) {
    + if (info->port.count++ == 0) {
    atomic_inc(&rp_num_ports_open);

    #ifdef ROCKET_DEBUG_OPEN
    @@ -1012,7 +1012,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
    #endif
    }
    #ifdef ROCKET_DEBUG_OPEN
    - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->count);
    + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
    #endif

    /*
    @@ -1048,13 +1048,13 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
    * Set up the tty->alt_speed kludge
    */
    if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI)
    - info->tty->alt_speed = 57600;
    + info->port.tty->alt_speed = 57600;
    if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI)
    - info->tty->alt_speed = 115200;
    + info->port.tty->alt_speed = 115200;
    if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI)
    - info->tty->alt_speed = 230400;
    + info->port.tty->alt_speed = 230400;
    if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP)
    - info->tty->alt_speed = 460800;
    + info->port.tty->alt_speed = 460800;

    configure_r_port(info, NULL);
    if (tty->termios->c_cflag & CBAUD) {
    @@ -1076,7 +1076,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
    }

    /*
    - * Exception handler that closes a serial port. info->count is considered critical.
    + * Exception handler that closes a serial port. info->port.count is considered critical.
    */
    static void rp_close(struct tty_struct *tty, struct file *filp)
    {
    @@ -1089,14 +1089,14 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
    return;

    #ifdef ROCKET_DEBUG_OPEN
    - printk(KERN_INFO "rp_close ttyR%d, count = %d\n", info->line, info->count);
    + printk(KERN_INFO "rp_close ttyR%d, count = %d\n", info->line, info->port.count);
    #endif

    if (tty_hung_up_p(filp))
    return;
    spin_lock_irqsave(&info->slock, flags);

    - if ((tty->count == 1) && (info->count != 1)) {
    + if ((tty->count == 1) && (info->port.count != 1)) {
    /*
    * Uh, oh. tty->count is 1, which means that the tty
    * structure will be freed. Info->count should always
    @@ -1105,15 +1105,15 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
    * serial port won't be shutdown.
    */
    printk(KERN_WARNING "rp_close: bad serial port count; "
    - "tty->count is 1, info->count is %d\n", info->count);
    - info->count = 1;
    + "tty->count is 1, info->port.count is %d\n", info->port.count);
    + info->port.count = 1;
    }
    - if (--info->count < 0) {
    + if (--info->port.count < 0) {
    printk(KERN_WARNING "rp_close: bad serial port count for "
    - "ttyR%d: %d\n", info->line, info->count);
    - info->count = 0;
    + "ttyR%d: %d\n", info->line, info->port.count);
    + info->port.count = 0;
    }
    - if (info->count) {
    + if (info->port.count) {
    spin_unlock_irqrestore(&info->slock, flags);
    return;
    }
    @@ -1167,11 +1167,11 @@ static void rp_close(struct tty_struct *tty, struct file *filp)

    clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);

    - if (info->blocked_open) {
    + if (info->port.blocked_open) {
    if (info->close_delay) {
    msleep_interruptible(jiffies_to_msecs(info->close_delay));
    }
    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    } else {
    if (info->xmit_buf) {
    free_page((unsigned long) info->xmit_buf);
    @@ -1357,13 +1357,13 @@ static int set_config(struct r_port *info, struct rocket_config __user *new_info
    info->closing_wait = new_serial.closing_wait;

    if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI)
    - info->tty->alt_speed = 57600;
    + info->port.tty->alt_speed = 57600;
    if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI)
    - info->tty->alt_speed = 115200;
    + info->port.tty->alt_speed = 115200;
    if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI)
    - info->tty->alt_speed = 230400;
    + info->port.tty->alt_speed = 230400;
    if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP)
    - info->tty->alt_speed = 460800;
    + info->port.tty->alt_speed = 460800;

    configure_r_port(info, NULL);
    return 0;
    @@ -1636,13 +1636,13 @@ static void rp_hangup(struct tty_struct *tty)
    rp_flush_buffer(tty);
    if (info->flags & ROCKET_CLOSING)
    return;
    - if (info->count)
    + if (info->port.count)
    atomic_dec(&rp_num_ports_open);
    clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);

    - info->count = 0;
    + info->port.count = 0;
    info->flags &= ~ROCKET_NORMAL_ACTIVE;
    - info->tty = NULL;
    + info->port.tty = NULL;

    cp = &info->channel;
    sDisRxFIFO(cp);
    @@ -1653,7 +1653,7 @@ static void rp_hangup(struct tty_struct *tty)
    sClrTxXOFF(cp);
    info->flags &= ~ROCKET_INITIALIZED;

    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    }

    /*
    @@ -1762,7 +1762,7 @@ static int rp_write(struct tty_struct *tty,

    /* Write remaining data into the port's xmit_buf */
    while (1) {
    - if (!info->tty) /* Seemingly obligatory check... */
    + if (!info->port.tty) /* Seemingly obligatory check... */
    goto end;
    c = min(count, XMIT_BUF_SIZE - info->xmit_cnt - 1);
    c = min(c, XMIT_BUF_SIZE - info->xmit_head);
    diff --git a/drivers/char/rocket_int.h b/drivers/char/rocket_int.h
    index 143cc43..3affc48 100644
    --- a/drivers/char/rocket_int.h
    +++ b/drivers/char/rocket_int.h
    @@ -1125,11 +1125,9 @@ Warnings: This function writes the data byte without checking to see if

    struct r_port {
    int magic;
    + struct tty_port port;
    int line;
    - int flags;
    - int count;
    - int blocked_open;
    - struct tty_struct *tty;
    + int flags; /* Don't yet match the ASY_ flags!! */
    unsigned int board:3;
    unsigned int aiop:2;
    unsigned int chan:3;
    @@ -1148,8 +1146,7 @@ struct r_port {
    int read_status_mask;
    int cps;

    - wait_queue_head_t open_wait;
    - struct completion close_wait;
    + struct completion close_wait; /* Not yet matching the core */
    spinlock_t slock;
    struct mutex write_mtx;
    };

    --
    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 07/70] esp: use tty_port

    From: Alan Cox

    Switch esp to use the new tty_port structures

    Signed-off-by: Alan Cox
    ---

    drivers/char/esp.c | 272 +++++++++++++++++++++++-----------------------
    include/linux/hayesesp.h | 9 --
    2 files changed, 138 insertions(+), 143 deletions(-)


    diff --git a/drivers/char/esp.c b/drivers/char/esp.c
    index 84840ba..2eaf09f 100644
    --- a/drivers/char/esp.c
    +++ b/drivers/char/esp.c
    @@ -128,9 +128,9 @@ static struct tty_driver *esp_driver;

    #if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
    #define DBG_CNT(s) printk(KERN_DEBUG "(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
    - tty->name, info->flags, \
    + tty->name, info->port.flags, \
    serial_driver.refcount, \
    - info->count, tty->count, s)
    + info->port.count, tty->count, s)
    #else
    #define DBG_CNT(s)
    #endif
    @@ -172,13 +172,13 @@ static inline int serial_paranoia_check(struct esp_struct *info,

    static inline unsigned int serial_in(struct esp_struct *info, int offset)
    {
    - return inb(info->port + offset);
    + return inb(info->io_port + offset);
    }

    static inline void serial_out(struct esp_struct *info, int offset,
    unsigned char value)
    {
    - outb(value, info->port+offset);
    + outb(value, info->io_port+offset);
    }

    /*
    @@ -273,7 +273,7 @@ static inline void release_pio_buffer(struct esp_pio_buffer *buf)

    static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)
    {
    - struct tty_struct *tty = info->tty;
    + struct tty_struct *tty = info->port.tty;
    int i;
    struct esp_pio_buffer *pio_buf;
    struct esp_pio_buffer *err_buf;
    @@ -295,7 +295,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)

    for (i = 0; i < num_bytes - 1; i += 2) {
    *((unsigned short *)(pio_buf->data + i)) =
    - inw(info->port + UART_ESI_RX);
    + inw(info->io_port + UART_ESI_RX);
    err_buf->data[i] = serial_in(info, UART_ESI_RWS);
    err_buf->data[i + 1] = (err_buf->data[i] >> 3) & status_mask;
    err_buf->data[i] &= status_mask;
    @@ -308,7 +308,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)
    }

    /* make sure everything is still ok since interrupts were enabled */
    - tty = info->tty;
    + tty = info->port.tty;

    if (!tty) {
    release_pio_buffer(pio_buf);
    @@ -325,7 +325,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)

    if (err_buf->data[i] & 0x04) {
    flag = TTY_BREAK;
    - if (info->flags & ASYNC_SAK)
    + if (info->port.flags & ASYNC_SAK)
    do_SAK(tty);
    } else if (err_buf->data[i] & 0x02)
    flag = TTY_FRAME;
    @@ -370,7 +370,7 @@ static void receive_chars_dma(struct esp_struct *info, int num_bytes)
    static inline void receive_chars_dma_done(struct esp_struct *info,
    int status)
    {
    - struct tty_struct *tty = info->tty;
    + struct tty_struct *tty = info->port.tty;
    int num_bytes;
    unsigned long flags;

    @@ -396,7 +396,7 @@ static inline void receive_chars_dma_done(struct esp_struct *info,
    if (status & 0x10) {
    statflag = TTY_BREAK;
    (info->icount.brk)++;
    - if (info->flags & ASYNC_SAK)
    + if (info->port.flags & ASYNC_SAK)
    do_SAK(tty);
    } else if (status & 0x08) {
    statflag = TTY_FRAME;
    @@ -451,7 +451,7 @@ static inline void transmit_chars_pio(struct esp_struct *info,

    for (i = 0; i < space_avail - 1; i += 2) {
    outw(*((unsigned short *)(pio_buf->data + i)),
    - info->port + UART_ESI_TX);
    + info->io_port + UART_ESI_TX);
    }

    if (space_avail & 0x0001)
    @@ -470,8 +470,8 @@ static inline void transmit_chars_pio(struct esp_struct *info,
    }

    if (info->xmit_cnt < WAKEUP_CHARS) {
    - if (info->tty)
    - tty_wakeup(info->tty);
    + if (info->port.tty)
    + tty_wakeup(info->port.tty);

    #ifdef SERIAL_DEBUG_INTR
    printk("THRE...");
    @@ -507,8 +507,8 @@ static inline void transmit_chars_dma(struct esp_struct *info, int num_bytes)
    info->xmit_tail = (info->xmit_tail + dma_bytes) & (ESP_XMIT_SIZE - 1);

    if (info->xmit_cnt < WAKEUP_CHARS) {
    - if (info->tty)
    - tty_wakeup(info->tty);
    + if (info->port.tty)
    + tty_wakeup(info->port.tty);

    #ifdef SERIAL_DEBUG_INTR
    printk("THRE...");
    @@ -575,18 +575,18 @@ static void check_modem_status(struct esp_struct *info)
    wake_up_interruptible(&info->delta_msr_wait);
    }

    - if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
    + if ((info->port.flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
    #if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
    printk("ttys%d CD now %s...", info->line,
    (status & UART_MSR_DCD) ? "on" : "off");
    #endif
    if (status & UART_MSR_DCD)
    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    else {
    #ifdef SERIAL_DEBUG_OPEN
    printk("scheduling hangup...");
    #endif
    - tty_hangup(info->tty);
    + tty_hangup(info->port.tty);
    }
    }
    }
    @@ -609,7 +609,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)

    spin_lock(&info->lock);

    - if (!info->tty) {
    + if (!info->port.tty) {
    spin_unlock(&info->lock);
    return IRQ_NONE;
    }
    @@ -647,7 +647,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
    num_bytes = serial_in(info, UART_ESI_STAT1) << 8;
    num_bytes |= serial_in(info, UART_ESI_STAT2);

    - num_bytes = tty_buffer_request_room(info->tty, num_bytes);
    + num_bytes = tty_buffer_request_room(info->port.tty, num_bytes);

    if (num_bytes) {
    if (dma_bytes ||
    @@ -661,7 +661,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)

    if (!(info->stat_flags & (ESP_STAT_DMA_RX | ESP_STAT_DMA_TX)) &&
    (scratch & 0x02) && (info->IER & UART_IER_THRI)) {
    - if ((info->xmit_cnt <= 0) || info->tty->stopped) {
    + if ((info->xmit_cnt <= 0) || info->port.tty->stopped) {
    info->IER &= ~UART_IER_THRI;
    serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK);
    serial_out(info, UART_ESI_CMD2, info->IER);
    @@ -782,7 +782,7 @@ static int startup(struct esp_struct *info)

    spin_lock_irqsave(&info->lock, flags);

    - if (info->flags & ASYNC_INITIALIZED)
    + if (info->port.flags & ASYNC_INITIALIZED)
    goto out;

    if (!info->xmit_buf) {
    @@ -806,7 +806,7 @@ static int startup(struct esp_struct *info)
    num_chars |= serial_in(info, UART_ESI_STAT2);

    while (num_chars > 1) {
    - inw(info->port + UART_ESI_RX);
    + inw(info->io_port + UART_ESI_RX);
    num_chars -= 2;
    }

    @@ -834,9 +834,9 @@ static int startup(struct esp_struct *info)

    if (retval) {
    if (capable(CAP_SYS_ADMIN)) {
    - if (info->tty)
    + if (info->port.tty)
    set_bit(TTY_IO_ERROR,
    - &info->tty->flags);
    + &info->port.tty->flags);
    retval = 0;
    }
    goto out_unlocked;
    @@ -874,30 +874,30 @@ static int startup(struct esp_struct *info)
    serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK);
    serial_out(info, UART_ESI_CMD2, info->IER);

    - if (info->tty)
    - clear_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
    info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
    spin_unlock_irqrestore(&info->lock, flags);

    /*
    * Set up the tty->alt_speed kludge
    */
    - if (info->tty) {
    - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
    - info->tty->alt_speed = 57600;
    - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
    - info->tty->alt_speed = 115200;
    - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
    - info->tty->alt_speed = 230400;
    - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
    - info->tty->alt_speed = 460800;
    + if (info->port.tty) {
    + if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
    + info->port.tty->alt_speed = 57600;
    + if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
    + info->port.tty->alt_speed = 115200;
    + if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
    + info->port.tty->alt_speed = 230400;
    + if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
    + info->port.tty->alt_speed = 460800;
    }

    /*
    * set the speed of the serial port
    */
    change_speed(info);
    - info->flags |= ASYNC_INITIALIZED;
    + info->port.flags |= ASYNC_INITIALIZED;
    return 0;

    out:
    @@ -914,7 +914,7 @@ static void shutdown(struct esp_struct *info)
    {
    unsigned long flags, f;

    - if (!(info->flags & ASYNC_INITIALIZED))
    + if (!(info->port.flags & ASYNC_INITIALIZED))
    return;

    #ifdef SERIAL_DEBUG_OPEN
    @@ -951,7 +951,7 @@ static void shutdown(struct esp_struct *info)

    while (current_port) {
    if ((current_port != info) &&
    - (current_port->flags & ASYNC_INITIALIZED))
    + (current_port->port.flags & ASYNC_INITIALIZED))
    break;

    current_port = current_port->next_port;
    @@ -974,7 +974,7 @@ static void shutdown(struct esp_struct *info)
    serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK);
    serial_out(info, UART_ESI_CMD2, 0x00);

    - if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
    + if (!info->port.tty || (info->port.tty->termios->c_cflag & HUPCL))
    info->MCR &= ~(UART_MCR_DTR|UART_MCR_RTS);

    info->MCR &= ~UART_MCR_OUT2;
    @@ -982,10 +982,10 @@ static void shutdown(struct esp_struct *info)
    serial_out(info, UART_ESI_CMD2, UART_MCR);
    serial_out(info, UART_ESI_CMD2, info->MCR);

    - if (info->tty)
    - set_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + set_bit(TTY_IO_ERROR, &info->port.tty->flags);

    - info->flags &= ~ASYNC_INITIALIZED;
    + info->port.flags &= ~ASYNC_INITIALIZED;
    spin_unlock_irqrestore(&info->lock, flags);
    }

    @@ -1002,10 +1002,10 @@ static void change_speed(struct esp_struct *info)
    unsigned char flow1 = 0, flow2 = 0;
    unsigned long flags;

    - if (!info->tty || !info->tty->termios)
    + if (!info->port.tty || !info->port.tty->termios)
    return;
    - cflag = info->tty->termios->c_cflag;
    - port = info->port;
    + cflag = info->port.tty->termios->c_cflag;
    + port = info->io_port;

    /* byte size and parity */
    switch (cflag & CSIZE) {
    @@ -1029,9 +1029,9 @@ static void change_speed(struct esp_struct *info)
    if (cflag & CMSPAR)
    cval |= UART_LCR_SPAR;
    #endif
    - baud = tty_get_baud_rate(info->tty);
    + baud = tty_get_baud_rate(info->port.tty);
    if (baud == 38400 &&
    - ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
    + ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
    quot = info->custom_divisor;
    else {
    if (baud == 134) /* Special case since 134 is really 134.5 */
    @@ -1046,49 +1046,49 @@ static void change_speed(struct esp_struct *info)
    if (baud) {
    /* Actual rate */
    baud = BASE_BAUD/quot;
    - tty_encode_baud_rate(info->tty, baud, baud);
    + tty_encode_baud_rate(info->port.tty, baud, baud);
    }
    info->timeout = ((1024 * HZ * bits * quot) / BASE_BAUD) + (HZ / 50);

    /* CTS flow control flag and modem status interrupts */
    /* info->IER &= ~UART_IER_MSI; */
    if (cflag & CRTSCTS) {
    - info->flags |= ASYNC_CTS_FLOW;
    + info->port.flags |= ASYNC_CTS_FLOW;
    /* info->IER |= UART_IER_MSI; */
    flow1 = 0x04;
    flow2 = 0x10;
    } else
    - info->flags &= ~ASYNC_CTS_FLOW;
    + info->port.flags &= ~ASYNC_CTS_FLOW;
    if (cflag & CLOCAL)
    - info->flags &= ~ASYNC_CHECK_CD;
    + info->port.flags &= ~ASYNC_CHECK_CD;
    else
    - info->flags |= ASYNC_CHECK_CD;
    + info->port.flags |= ASYNC_CHECK_CD;

    /*
    * Set up parity check flag
    */
    info->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
    - if (I_INPCK(info->tty))
    + if (I_INPCK(info->port.tty))
    info->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
    - if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
    + if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
    info->read_status_mask |= UART_LSR_BI;

    info->ignore_status_mask = 0;
    #if 0
    /* This should be safe, but for some broken bits of hardware... */
    - if (I_IGNPAR(info->tty)) {
    + if (I_IGNPAR(info->port.tty)) {
    info->ignore_status_mask |= UART_LSR_PE | UART_LSR_FE;
    info->read_status_mask |= UART_LSR_PE | UART_LSR_FE;
    }
    #endif
    - if (I_IGNBRK(info->tty)) {
    + if (I_IGNBRK(info->port.tty)) {
    info->ignore_status_mask |= UART_LSR_BI;
    info->read_status_mask |= UART_LSR_BI;
    /*
    * If we're ignore parity and break indicators, ignore
    * overruns too. (For real raw support).
    */
    - if (I_IGNPAR(info->tty)) {
    + if (I_IGNPAR(info->port.tty)) {
    info->ignore_status_mask |= UART_LSR_OE | \
    UART_LSR_PE | UART_LSR_FE;
    info->read_status_mask |= UART_LSR_OE | \
    @@ -1096,7 +1096,7 @@ static void change_speed(struct esp_struct *info)
    }
    }

    - if (I_IXOFF(info->tty))
    + if (I_IXOFF(info->port.tty))
    flow1 |= 0x81;

    spin_lock_irqsave(&info->lock, flags);
    @@ -1116,10 +1116,10 @@ static void change_speed(struct esp_struct *info)
    serial_out(info, UART_ESI_CMD2, flow2);

    /* set flow control characters (XON/XOFF only) */
    - if (I_IXOFF(info->tty)) {
    + if (I_IXOFF(info->port.tty)) {
    serial_out(info, UART_ESI_CMD1, ESI_SET_FLOW_CHARS);
    - serial_out(info, UART_ESI_CMD2, START_CHAR(info->tty));
    - serial_out(info, UART_ESI_CMD2, STOP_CHAR(info->tty));
    + serial_out(info, UART_ESI_CMD2, START_CHAR(info->port.tty));
    + serial_out(info, UART_ESI_CMD2, STOP_CHAR(info->port.tty));
    serial_out(info, UART_ESI_CMD2, 0x10);
    serial_out(info, UART_ESI_CMD2, 0x21);
    switch (cflag & CSIZE) {
    @@ -1355,9 +1355,9 @@ static int get_serial_info(struct esp_struct *info,
    memset(&tmp, 0, sizeof(tmp));
    tmp.type = PORT_16550A;
    tmp.line = info->line;
    - tmp.port = info->port;
    + tmp.port = info->io_port;
    tmp.irq = info->irq;
    - tmp.flags = info->flags;
    + tmp.flags = info->port.flags;
    tmp.xmit_fifo_size = 1024;
    tmp.baud_base = BASE_BAUD;
    tmp.close_delay = info->close_delay;
    @@ -1407,7 +1407,7 @@ static int set_serial_info(struct esp_struct *info,

    if ((new_serial.type != PORT_16550A) ||
    (new_serial.hub6) ||
    - (info->port != new_serial.port) ||
    + (info->io_port != new_serial.port) ||
    (new_serial.baud_base != BASE_BAUD) ||
    (new_serial.irq > 15) ||
    (new_serial.irq < 2) ||
    @@ -1425,9 +1425,9 @@ static int set_serial_info(struct esp_struct *info,
    if (change_irq ||
    (new_serial.close_delay != info->close_delay) ||
    ((new_serial.flags & ~ASYNC_USR_MASK) !=
    - (info->flags & ~ASYNC_USR_MASK)))
    + (info->port.flags & ~ASYNC_USR_MASK)))
    return -EPERM;
    - info->flags = ((info->flags & ~ASYNC_USR_MASK) |
    + info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK) |
    (new_serial.flags & ASYNC_USR_MASK));
    info->custom_divisor = new_serial.custom_divisor;
    } else {
    @@ -1441,9 +1441,9 @@ static int set_serial_info(struct esp_struct *info,
    if ((current_async->line >= info->line) &&
    (current_async->line < (info->line + 8))) {
    if (current_async == info) {
    - if (current_async->count > 1)
    + if (current_async->port.count > 1)
    return -EBUSY;
    - } else if (current_async->count)
    + } else if (current_async->port.count)
    return -EBUSY;
    }

    @@ -1456,7 +1456,7 @@ static int set_serial_info(struct esp_struct *info,
    * At this point, we start making changes.....
    */

    - info->flags = ((info->flags & ~ASYNC_FLAGS) |
    + info->port.flags = ((info->port.flags & ~ASYNC_FLAGS) |
    (new_serial.flags & ASYNC_FLAGS));
    info->custom_divisor = new_serial.custom_divisor;
    info->close_delay = new_serial.close_delay * HZ/100;
    @@ -1487,18 +1487,18 @@ static int set_serial_info(struct esp_struct *info,
    }
    }

    - if (info->flags & ASYNC_INITIALIZED) {
    - if (((old_info.flags & ASYNC_SPD_MASK) !=
    - (info->flags & ASYNC_SPD_MASK)) ||
    + if (info->port.flags & ASYNC_INITIALIZED) {
    + if (((old_info.port.flags & ASYNC_SPD_MASK) !=
    + (info->port.flags & ASYNC_SPD_MASK)) ||
    (old_info.custom_divisor != info->custom_divisor)) {
    - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
    - info->tty->alt_speed = 57600;
    - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
    - info->tty->alt_speed = 115200;
    - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
    - info->tty->alt_speed = 230400;
    - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
    - info->tty->alt_speed = 460800;
    + if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
    + info->port.tty->alt_speed = 57600;
    + if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
    + info->port.tty->alt_speed = 115200;
    + if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
    + info->port.tty->alt_speed = 230400;
    + if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
    + info->port.tty->alt_speed = 460800;
    change_speed(info);
    }
    } else
    @@ -1554,9 +1554,9 @@ static int set_esp_config(struct esp_struct *info,

    while (current_async) {
    if (current_async == info) {
    - if (current_async->count > 1)
    + if (current_async->port.count > 1)
    return -EBUSY;
    - } else if (current_async->count)
    + } else if (current_async->port.count)
    return -EBUSY;

    current_async = current_async->next_port;
    @@ -1578,7 +1578,7 @@ static int set_esp_config(struct esp_struct *info,
    spin_unlock_irqrestore(&info->lock, flags);
    } else {
    /* DMA mode to PIO mode only */
    - if (info->count > 1)
    + if (info->port.count > 1)
    return -EBUSY;

    shutdown(info);
    @@ -1634,7 +1634,7 @@ static int set_esp_config(struct esp_struct *info,
    spin_unlock_irqrestore(&info->lock, flags);
    }

    - if (!(info->flags & ASYNC_INITIALIZED))
    + if (!(info->port.flags & ASYNC_INITIALIZED))
    retval = startup(info);

    return retval;
    @@ -1917,9 +1917,9 @@ static void rs_close(struct tty_struct *tty, struct file *filp)

    #ifdef SERIAL_DEBUG_OPEN
    printk(KERN_DEBUG "rs_close ttys%d, count = %d\n",
    - info->line, info->count);
    + info->line, info->port.count);
    #endif
    - if (tty->count == 1 && info->count != 1) {
    + if (tty->count == 1 && info->port.count != 1) {
    /*
    * Uh, oh. tty->count is 1, which means that the tty
    * structure will be freed. Info->count should always
    @@ -1927,19 +1927,19 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
    * one, we've got real problems, since it means the
    * serial port won't be shutdown.
    */
    - printk(KERN_DEBUG "rs_close: bad serial port count; tty->count is 1, info->count is %d\n", info->count);
    - info->count = 1;
    + printk(KERN_DEBUG "rs_close: bad serial port count; tty->count is 1, info->port.count is %d\n", info->port.count);
    + info->port.count = 1;
    }
    - if (--info->count < 0) {
    + if (--info->port.count < 0) {
    printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n",
    - info->line, info->count);
    - info->count = 0;
    + info->line, info->port.count);
    + info->port.count = 0;
    }
    - if (info->count) {
    + if (info->port.count) {
    DBG_CNT("before DEC-2");
    goto out;
    }
    - info->flags |= ASYNC_CLOSING;
    + info->port.flags |= ASYNC_CLOSING;

    spin_unlock_irqrestore(&info->lock, flags);
    /*
    @@ -1958,7 +1958,7 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
    /* info->IER &= ~UART_IER_RLSI; */
    info->IER &= ~UART_IER_RDI;
    info->read_status_mask &= ~UART_LSR_DR;
    - if (info->flags & ASYNC_INITIALIZED) {
    + if (info->port.flags & ASYNC_INITIALIZED) {

    spin_lock_irqsave(&info->lock, flags);
    serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK);
    @@ -1981,15 +1981,15 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
    rs_flush_buffer(tty);
    tty_ldisc_flush(tty);
    tty->closing = 0;
    - info->tty = NULL;
    + info->port.tty = NULL;

    - if (info->blocked_open) {
    + if (info->port.blocked_open) {
    if (info->close_delay)
    msleep_interruptible(jiffies_to_msecs(info->close_delay));
    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    }
    - info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
    - wake_up_interruptible(&info->close_wait);
    + info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
    + wake_up_interruptible(&info->port.close_wait);
    return;

    out:
    @@ -2047,10 +2047,10 @@ static void esp_hangup(struct tty_struct *tty)

    rs_flush_buffer(tty);
    shutdown(info);
    - info->count = 0;
    - info->flags &= ~ASYNC_NORMAL_ACTIVE;
    - info->tty = NULL;
    - wake_up_interruptible(&info->open_wait);
    + info->port.count = 0;
    + info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
    + info->port.tty = NULL;
    + wake_up_interruptible(&info->port.open_wait);
    }

    /*
    @@ -2071,11 +2071,11 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
    * until it's done, and then try again.
    */
    if (tty_hung_up_p(filp) ||
    - (info->flags & ASYNC_CLOSING)) {
    - if (info->flags & ASYNC_CLOSING)
    - interruptible_sleep_on(&info->close_wait);
    + (info->port.flags & ASYNC_CLOSING)) {
    + if (info->port.flags & ASYNC_CLOSING)
    + interruptible_sleep_on(&info->port.close_wait);
    #ifdef SERIAL_DO_RESTART
    - if (info->flags & ASYNC_HUP_NOTIFY)
    + if (info->port.flags & ASYNC_HUP_NOTIFY)
    return -EAGAIN;
    else
    return -ERESTARTSYS;
    @@ -2090,7 +2090,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
    */
    if ((filp->f_flags & O_NONBLOCK) ||
    (tty->flags & (1 << TTY_IO_ERROR))) {
    - info->flags |= ASYNC_NORMAL_ACTIVE;
    + info->port.flags |= ASYNC_NORMAL_ACTIVE;
    return 0;
    }

    @@ -2100,20 +2100,20 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
    /*
    * Block waiting for the carrier detect and the line to become
    * free (i.e., not in use by the callout). While we are in
    - * this loop, info->count is dropped by one, so that
    + * this loop, info->port.count is dropped by one, so that
    * rs_close() knows when to free things. We restore it upon
    * exit, either normal or abnormal.
    */
    retval = 0;
    - add_wait_queue(&info->open_wait, &wait);
    + add_wait_queue(&info->port.open_wait, &wait);
    #ifdef SERIAL_DEBUG_OPEN
    printk(KERN_DEBUG "block_til_ready before block: ttys%d, count = %d\n",
    - info->line, info->count);
    + info->line, info->port.count);
    #endif
    spin_lock_irqsave(&info->lock, flags);
    if (!tty_hung_up_p(filp))
    - info->count--;
    - info->blocked_open++;
    + info->port.count--;
    + info->port.blocked_open++;
    while (1) {
    if ((tty->termios->c_cflag & CBAUD)) {
    unsigned int scratch;
    @@ -2128,9 +2128,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
    }
    set_current_state(TASK_INTERRUPTIBLE);
    if (tty_hung_up_p(filp) ||
    - !(info->flags & ASYNC_INITIALIZED)) {
    + !(info->port.flags & ASYNC_INITIALIZED)) {
    #ifdef SERIAL_DO_RESTART
    - if (info->flags & ASYNC_HUP_NOTIFY)
    + if (info->port.flags & ASYNC_HUP_NOTIFY)
    retval = -EAGAIN;
    else
    retval = -ERESTARTSYS;
    @@ -2144,7 +2144,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
    if (serial_in(info, UART_ESI_STAT2) & UART_MSR_DCD)
    do_clocal = 1;

    - if (!(info->flags & ASYNC_CLOSING) &&
    + if (!(info->port.flags & ASYNC_CLOSING) &&
    (do_clocal))
    break;
    if (signal_pending(current)) {
    @@ -2153,25 +2153,25 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
    }
    #ifdef SERIAL_DEBUG_OPEN
    printk(KERN_DEBUG "block_til_ready blocking: ttys%d, count = %d\n",
    - info->line, info->count);
    + info->line, info->port.count);
    #endif
    spin_unlock_irqrestore(&info->lock, flags);
    schedule();
    spin_lock_irqsave(&info->lock, flags);
    }
    set_current_state(TASK_RUNNING);
    - remove_wait_queue(&info->open_wait, &wait);
    + remove_wait_queue(&info->port.open_wait, &wait);
    if (!tty_hung_up_p(filp))
    - info->count++;
    - info->blocked_open--;
    + info->port.count++;
    + info->port.blocked_open--;
    spin_unlock_irqrestore(&info->lock, flags);
    #ifdef SERIAL_DEBUG_OPEN
    printk(KERN_DEBUG "block_til_ready after blocking: ttys%d, count = %d\n",
    - info->line, info->count);
    + info->line, info->port.count);
    #endif
    if (retval)
    return retval;
    - info->flags |= ASYNC_NORMAL_ACTIVE;
    + info->port.flags |= ASYNC_NORMAL_ACTIVE;
    return 0;
    }

    @@ -2204,12 +2204,12 @@ static int esp_open(struct tty_struct *tty, struct file *filp)
    }

    #ifdef SERIAL_DEBUG_OPEN
    - printk(KERN_DEBUG "esp_open %s, count = %d\n", tty->name, info->count);
    + printk(KERN_DEBUG "esp_open %s, count = %d\n", tty->name, info->port.count);
    #endif
    spin_lock_irqsave(&info->lock, flags);
    - info->count++;
    + info->port.count++;
    tty->driver_data = info;
    - info->tty = tty;
    + info->port.tty = tty;

    spin_unlock_irqrestore(&info->lock, flags);

    @@ -2263,7 +2263,7 @@ static int autoconfig(struct esp_struct *info)
    int port_detected = 0;
    unsigned long flags;

    - if (!request_region(info->port, REGION_SIZE, "esp serial"))
    + if (!request_region(info->io_port, REGION_SIZE, "esp serial"))
    return -EIO;

    spin_lock_irqsave(&info->lock, flags);
    @@ -2300,7 +2300,7 @@ static int autoconfig(struct esp_struct *info)
    }
    }
    if (!port_detected)
    - release_region(info->port, REGION_SIZE);
    + release_region(info->io_port, REGION_SIZE);

    spin_unlock_irqrestore(&info->lock, flags);
    return (port_detected);
    @@ -2414,7 +2414,7 @@ static int __init espserial_init(void)
    offset = 0;

    do {
    - info->port = esp[i] + offset;
    + info->io_port = esp[i] + offset;
    info->irq = irq[i];
    info->line = (i * 8) + (offset / 8);

    @@ -2425,9 +2425,9 @@ static int __init espserial_init(void)
    }

    info->custom_divisor = (divisor[i] >> (offset / 2)) & 0xf;
    - info->flags = STD_COM_FLAGS;
    + info->port.flags = STD_COM_FLAGS;
    if (info->custom_divisor)
    - info->flags |= ASYNC_SPD_CUST;
    + info->port.flags |= ASYNC_SPD_CUST;
    info->magic = ESP_MAGIC;
    info->close_delay = 5*HZ/10;
    info->closing_wait = 30*HZ;
    @@ -2436,13 +2436,13 @@ static int __init espserial_init(void)
    info->config.flow_off = flow_off;
    info->config.pio_threshold = pio_threshold;
    info->next_port = ports;
    - init_waitqueue_head(&info->open_wait);
    - init_waitqueue_head(&info->close_wait);
    + init_waitqueue_head(&info->port.open_wait);
    + init_waitqueue_head(&info->port.close_wait);
    init_waitqueue_head(&info->delta_msr_wait);
    init_waitqueue_head(&info->break_wait);
    ports = info;
    printk(KERN_INFO "ttyP%d at 0x%04x (irq = %d) is an ESP ",
    - info->line, info->port, info->irq);
    + info->line, info->io_port, info->irq);

    if (info->line % 8) {
    printk("secondary port\n");
    @@ -2498,8 +2498,8 @@ static void __exit espserial_exit(void)
    put_tty_driver(esp_driver);

    while (ports) {
    - if (ports->port)
    - release_region(ports->port, REGION_SIZE);
    + if (ports->io_port)
    + release_region(ports->io_port, REGION_SIZE);
    temp_async = ports->next_port;
    kfree(ports);
    ports = temp_async;
    diff --git a/include/linux/hayesesp.h b/include/linux/hayesesp.h
    index 2177ee5..940aeb5 100644
    --- a/include/linux/hayesesp.h
    +++ b/include/linux/hayesesp.h
    @@ -76,11 +76,10 @@ struct hayes_esp_config {

    struct esp_struct {
    int magic;
    + struct tty_port port;
    spinlock_t lock;
    - int port;
    + int io_port;
    int irq;
    - int flags; /* defined in tty.h */
    - struct tty_struct *tty;
    int read_status_mask;
    int ignore_status_mask;
    int timeout;
    @@ -93,14 +92,10 @@ struct esp_struct {
    int MCR; /* Modem control register */
    unsigned long last_active;
    int line;
    - int count; /* # of fd on device */
    - int blocked_open; /* # of blocked opens */
    unsigned char *xmit_buf;
    int xmit_head;
    int xmit_tail;
    int xmit_cnt;
    - wait_queue_head_t open_wait;
    - wait_queue_head_t close_wait;
    wait_queue_head_t delta_msr_wait;
    wait_queue_head_t break_wait;
    struct async_icount icount; /* kernel counters for the 4 input interrupts */

    --
    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 25/70] whiteheat: fix bugs found in the tidy and audit

    From: Alan Cox

    Termios tidy up, plus fix break and DTR.

    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/whiteheat.c | 12 ++++--------
    1 files changed, 4 insertions(+), 8 deletions(-)


    diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
    index 5a3ed57..0954191 100644
    --- a/drivers/usb/serial/whiteheat.c
    +++ b/drivers/usb/serial/whiteheat.c
    @@ -652,11 +652,8 @@ static int whiteheat_open(struct tty_struct *tty,
    goto exit;
    }

    - if (tty) {
    - old_term.c_cflag = ~tty->termios->c_cflag;
    - old_term.c_iflag = ~tty->termios->c_iflag;
    - whiteheat_set_termios(tty, port, &old_term);
    - }
    + if (tty)
    + firm_setup_port(tty);

    /* Work around HCD bugs */
    usb_clear_halt(port->serial->dev, port->read_urb->pipe);
    @@ -907,7 +904,6 @@ static int whiteheat_ioctl(struct tty_struct *tty, struct file *file,
    static void whiteheat_set_termios(struct tty_struct *tty,
    struct usb_serial_port *port, struct ktermios *old_termios)
    {
    - /* FIXME */
    firm_setup_port(tty);
    }

    @@ -1303,7 +1299,7 @@ static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff)

    dtr_command.port = port->number - port->serial->minor + 1;
    dtr_command.state = onoff;
    - return firm_send_command(port, WHITEHEAT_SET_RTS,
    + return firm_send_command(port, WHITEHEAT_SET_DTR,
    (__u8 *)&dtr_command, sizeof(dtr_command));
    }

    @@ -1314,7 +1310,7 @@ static int firm_set_break(struct usb_serial_port *port, __u8 onoff)

    break_command.port = port->number - port->serial->minor + 1;
    break_command.state = onoff;
    - return firm_send_command(port, WHITEHEAT_SET_RTS,
    + return firm_send_command(port, WHITEHEAT_SET_BREAK,
    (__u8 *)&break_command, sizeof(break_command));
    }


    --
    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 32/70] cypress_m8: coding style

    From: Alan Cox

    Coding style clean ups

    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/cypress_m8.c | 617 ++++++++++++++++++++-------------------
    drivers/usb/serial/cypress_m8.h | 2
    2 files changed, 325 insertions(+), 294 deletions(-)


    diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
    index 6999d33..bb9c7c4 100644
    --- a/drivers/usb/serial/cypress_m8.c
    +++ b/drivers/usb/serial/cypress_m8.c
    @@ -2,7 +2,7 @@
    * USB Cypress M8 driver
    *
    * Copyright (C) 2004
    - * Lonnie Mendez (dignome@gmail.com)
    + * Lonnie Mendez (dignome@gmail.com)
    * Copyright (C) 2003,2004
    * Neil Whelchel (koyama@firstlight.net)
    *
    @@ -11,19 +11,21 @@
    * 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://geocities.com/i0xox0i for information on this driver and the
    * earthmate usb device.
    *
    * Lonnie Mendez
    * 4-29-2005
    - * Fixed problem where setting or retreiving the serial config would fail with
    - * EPIPE. Removed CRTS toggling so the driver behaves more like other usbserial
    - * adapters. Issued new interval of 1ms instead of the default 10ms. As a
    - * result, transfer speed has been substantially increased. From avg. 850bps to
    - * avg. 3300bps. initial termios has also been modified. Cleaned up code and
    - * formatting issues so it is more readable. Replaced the C++ style comments.
    + * Fixed problem where setting or retreiving the serial config would fail
    + * with EPIPE. Removed CRTS toggling so the driver behaves more like
    + * other usbserial adapters. Issued new interval of 1ms instead of the
    + * default 10ms. As a result, transfer speed has been substantially
    + * increased from avg. 850bps to avg. 3300bps. initial termios has also
    + * been modified. Cleaned up code and formatting issues so it is more
    + * readable. Replaced the C++ style comments.
    *
    * Lonnie Mendez
    * 12-15-2004
    @@ -42,10 +44,11 @@
    *
    */

    -/* Thanks to Neil Whelchel for writing the first cypress m8 implementation for linux. */
    +/* Thanks to Neil Whelchel for writing the first cypress m8 implementation
    + for linux. */
    /* Thanks to cypress for providing references for the hid reports. */
    /* Thanks to Jiang Zhang for providing links and for general help. */
    -/* Code originates and was built up from ftdi_sio, belkin, pl2303 and others. */
    +/* Code originates and was built up from ftdi_sio, belkin, pl2303 and others.*/


    #include
    @@ -62,7 +65,7 @@
    #include
    #include
    #include
    -#include
    +#include

    #include "cypress_m8.h"

    @@ -112,7 +115,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 cypress_driver = {
    .name = "cypress",
    @@ -146,11 +149,13 @@ struct cypress_private {
    __u8 rx_flags; /* throttling - used from whiteheat/ftdi_sio */
    enum packet_format pkt_fmt; /* format to use for packet send / receive */
    int get_cfg_unsafe; /* If true, the CYPRESS_GET_CONFIG is unsafe */
    - int baud_rate; /* stores current baud rate in integer form */
    + int baud_rate; /* stores current baud rate in
    + integer form */
    int isthrottled; /* if throttled, discard reads */
    wait_queue_head_t delta_msr_wait; /* used for TIOCMIWAIT */
    char prev_status, diff_status; /* used for TIOCMIWAIT */
    - /* we pass a pointer to this as the arguement sent to cypress_set_termios old_termios */
    + /* we pass a pointer to this as the arguement sent to
    + cypress_set_termios old_termios */
    struct ktermios tmp_termios; /* stores the old termios settings */
    };

    @@ -163,33 +168,41 @@ struct cypress_buf {
    };

    /* function prototypes for the Cypress USB to serial device */
    -static int cypress_earthmate_startup (struct usb_serial *serial);
    -static int cypress_hidcom_startup (struct usb_serial *serial);
    -static int cypress_ca42v2_startup (struct usb_serial *serial);
    -static void cypress_shutdown (struct usb_serial *serial);
    -static int cypress_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
    -static void cypress_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
    -static int cypress_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
    -static void cypress_send (struct usb_serial_port *port);
    -static int cypress_write_room (struct tty_struct *tty);
    -static int cypress_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg);
    -static void cypress_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old);
    -static int cypress_tiocmget (struct tty_struct *tty, struct file *file);
    -static int cypress_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear);
    -static int cypress_chars_in_buffer (struct tty_struct *tty);
    -static void cypress_throttle (struct tty_struct *tty);
    -static void cypress_unthrottle (struct tty_struct *tty);
    -static void cypress_set_dead (struct usb_serial_port *port);
    -static void cypress_read_int_callback (struct urb *urb);
    -static void cypress_write_int_callback (struct urb *urb);
    +static int cypress_earthmate_startup(struct usb_serial *serial);
    +static int cypress_hidcom_startup(struct usb_serial *serial);
    +static int cypress_ca42v2_startup(struct usb_serial *serial);
    +static void cypress_shutdown(struct usb_serial *serial);
    +static int cypress_open(struct tty_struct *tty,
    + struct usb_serial_port *port, struct file *filp);
    +static void cypress_close(struct tty_struct *tty,
    + struct usb_serial_port *port, struct file *filp);
    +static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port,
    + const unsigned char *buf, int count);
    +static void cypress_send(struct usb_serial_port *port);
    +static int cypress_write_room(struct tty_struct *tty);
    +static int cypress_ioctl(struct tty_struct *tty, struct file *file,
    + unsigned int cmd, unsigned long arg);
    +static void cypress_set_termios(struct tty_struct *tty,
    + struct usb_serial_port *port, struct ktermios *old);
    +static int cypress_tiocmget(struct tty_struct *tty, struct file *file);
    +static int cypress_tiocmset(struct tty_struct *tty, struct file *file,
    + unsigned int set, unsigned int clear);
    +static int cypress_chars_in_buffer(struct tty_struct *tty);
    +static void cypress_throttle(struct tty_struct *tty);
    +static void cypress_unthrottle(struct tty_struct *tty);
    +static void cypress_set_dead(struct usb_serial_port *port);
    +static void cypress_read_int_callback(struct urb *urb);
    +static void cypress_write_int_callback(struct urb *urb);
    /* write buffer functions */
    static struct cypress_buf *cypress_buf_alloc(unsigned int size);
    -static void cypress_buf_free(struct cypress_buf *cb);
    -static void cypress_buf_clear(struct cypress_buf *cb);
    -static unsigned int cypress_buf_data_avail(struct cypress_buf *cb);
    -static unsigned int cypress_buf_space_avail(struct cypress_buf *cb);
    -static unsigned int cypress_buf_put(struct cypress_buf *cb, const char *buf, unsigned int count);
    -static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf, unsigned int count);
    +static void cypress_buf_free(struct cypress_buf *cb);
    +static void cypress_buf_clear(struct cypress_buf *cb);
    +static unsigned int cypress_buf_data_avail(struct cypress_buf *cb);
    +static unsigned int cypress_buf_space_avail(struct cypress_buf *cb);
    +static unsigned int cypress_buf_put(struct cypress_buf *cb,
    + const char *buf, unsigned int count);
    +static unsigned int cypress_buf_get(struct cypress_buf *cb,
    + char *buf, unsigned int count);


    static struct usb_serial_driver cypress_earthmate_device = {
    @@ -247,7 +260,7 @@ static struct usb_serial_driver cypress_hidcom_device = {
    static struct usb_serial_driver cypress_ca42v2_device = {
    .driver = {
    .owner = THIS_MODULE,
    - .name = "nokiaca42v2",
    + .name = "nokiaca42v2",
    },
    .description = "Nokia CA-42 V2 Adapter",
    .usb_driver = &cypress_driver,
    @@ -322,7 +335,7 @@ static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate)


    /* This function can either set or retrieve the current serial line settings */
    -static int cypress_serial_control (struct tty_struct *tty,
    +static int cypress_serial_control(struct tty_struct *tty,
    struct usb_serial_port *port, speed_t baud_rate, int data_bits,
    int stop_bits, int parity_enable, int parity_type, int reset,
    int cypress_request_type)
    @@ -333,111 +346,114 @@ static int cypress_serial_control (struct tty_struct *tty,
    unsigned long flags;

    dbg("%s", __func__);
    -
    +
    priv = usb_get_serial_port_data(port);

    if (!priv->comm_is_ok)
    return -ENODEV;

    - switch(cypress_request_type) {
    - case CYPRESS_SET_CONFIG:
    + switch (cypress_request_type) {
    + case CYPRESS_SET_CONFIG:
    + new_baudrate = priv->baud_rate;
    + /* 0 means 'Hang up' so doesn't change the true bit rate */
    + if (baud_rate == 0)
    new_baudrate = priv->baud_rate;
    - /* 0 means 'Hang up' so doesn't change the true bit rate */
    - if (baud_rate == 0)
    - new_baudrate = priv->baud_rate;
    - /* Change of speed ? */
    - else if (baud_rate != priv->baud_rate) {
    - dbg("%s - baud rate is changing", __func__);
    - retval = analyze_baud_rate(port, baud_rate);
    - if (retval >= 0) {
    - new_baudrate = retval;
    - dbg("%s - New baud rate set to %d",
    - __func__, new_baudrate);
    - }
    - }
    - dbg("%s - baud rate is being sent as %d", __func__, new_baudrate);
    -
    - memset(feature_buffer, 0, sizeof(feature_buffer));
    - /* fill the feature_buffer with new configuration */
    - *((u_int32_t *)feature_buffer) = new_baudrate;
    -
    - feature_buffer[4] |= data_bits; /* assign data bits in 2 bit space ( max 3 ) */
    - /* 1 bit gap */
    - feature_buffer[4] |= (stop_bits << 3); /* assign stop bits in 1 bit space */
    - feature_buffer[4] |= (parity_enable << 4); /* assign parity flag in 1 bit space */
    - feature_buffer[4] |= (parity_type << 5); /* assign parity type in 1 bit space */
    - /* 1 bit gap */
    - feature_buffer[4] |= (reset << 7); /* assign reset at end of byte, 1 bit space */
    -
    - dbg("%s - device is being sent this feature report:", __func__);
    - dbg("%s - %02X - %02X - %02X - %02X - %02X", __func__, feature_buffer[0], feature_buffer[1],
    - feature_buffer[2], feature_buffer[3], feature_buffer[4]);
    -
    - do {
    - retval = usb_control_msg(port->serial->dev,
    - usb_sndctrlpipe(port->serial->dev, 0),
    - HID_REQ_SET_REPORT,
    - USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
    - 0x0300, 0, feature_buffer,
    - sizeof(feature_buffer), 500);
    -
    - if (tries++ >= 3)
    - break;
    -
    - } while (retval != sizeof(feature_buffer) &&
    - retval != -ENODEV);
    -
    - if (retval != sizeof(feature_buffer)) {
    - err("%s - failed sending serial line settings - %d", __func__, retval);
    - cypress_set_dead(port);
    - } else {
    - spin_lock_irqsave(&priv->lock, flags);
    - priv->baud_rate = new_baudrate;
    - priv->current_config = feature_buffer[4];
    - spin_unlock_irqrestore(&priv->lock, flags);
    - /* If we asked for a speed change encode it */
    - if (baud_rate)
    - tty_encode_baud_rate(tty,
    - new_baudrate, new_baudrate);
    - }
    - break;
    - case CYPRESS_GET_CONFIG:
    - if (priv->get_cfg_unsafe) {
    - /* Not implemented for this device,
    - and if we try to do it we're likely
    - to crash the hardware. */
    - return -ENOTTY;
    - }
    - dbg("%s - retreiving serial line settings", __func__);
    - /* set initial values in feature buffer */
    - memset(feature_buffer, 0, sizeof(feature_buffer));
    -
    - do {
    - retval = usb_control_msg(port->serial->dev,
    - usb_rcvctrlpipe(port->serial->dev, 0),
    - HID_REQ_GET_REPORT,
    - USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
    - 0x0300, 0, feature_buffer,
    - sizeof(feature_buffer), 500);
    -
    - if (tries++ >= 3)
    - break;
    -
    - } while (retval != sizeof(feature_buffer) &&
    - retval != -ENODEV);
    -
    - if (retval != sizeof(feature_buffer)) {
    - err("%s - failed to retrieve serial line settings - %d", __func__, retval);
    - cypress_set_dead(port);
    - return retval;
    - } else {
    - spin_lock_irqsave(&priv->lock, flags);
    -
    - /* store the config in one byte, and later use bit masks to check values */
    - priv->current_config = feature_buffer[4];
    - priv->baud_rate = *((u_int32_t *)feature_buffer);
    - spin_unlock_irqrestore(&priv->lock, flags);
    + /* Change of speed ? */
    + else if (baud_rate != priv->baud_rate) {
    + dbg("%s - baud rate is changing", __func__);
    + retval = analyze_baud_rate(port, baud_rate);
    + if (retval >= 0) {
    + new_baudrate = retval;
    + dbg("%s - New baud rate set to %d",
    + __func__, new_baudrate);
    }
    + }
    + dbg("%s - baud rate is being sent as %d",
    + __func__, new_baudrate);
    +
    + memset(feature_buffer, 0, sizeof(feature_buffer));
    + /* fill the feature_buffer with new configuration */
    + *((u_int32_t *)feature_buffer) = new_baudrate;
    + feature_buffer[4] |= data_bits; /* assign data bits in 2 bit space ( max 3 ) */
    + /* 1 bit gap */
    + feature_buffer[4] |= (stop_bits << 3); /* assign stop bits in 1 bit space */
    + feature_buffer[4] |= (parity_enable << 4); /* assign parity flag in 1 bit space */
    + feature_buffer[4] |= (parity_type << 5); /* assign parity type in 1 bit space */
    + /* 1 bit gap */
    + feature_buffer[4] |= (reset << 7); /* assign reset at end of byte, 1 bit space */
    +
    + dbg("%s - device is being sent this feature report:",
    + __func__);
    + dbg("%s - %02X - %02X - %02X - %02X - %02X", __func__,
    + feature_buffer[0], feature_buffer[1],
    + feature_buffer[2], feature_buffer[3],
    + feature_buffer[4]);
    +
    + do {
    + retval = usb_control_msg(port->serial->dev,
    + usb_sndctrlpipe(port->serial->dev, 0),
    + HID_REQ_SET_REPORT,
    + USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
    + 0x0300, 0, feature_buffer,
    + sizeof(feature_buffer), 500);
    +
    + if (tries++ >= 3)
    + break;
    +
    + } while (retval != sizeof(feature_buffer) &&
    + retval != -ENODEV);
    +
    + if (retval != sizeof(feature_buffer)) {
    + err("%s - failed sending serial line settings - %d",
    + __func__, retval);
    + cypress_set_dead(port);
    + } else {
    + spin_lock_irqsave(&priv->lock, flags);
    + priv->baud_rate = new_baudrate;
    + priv->current_config = feature_buffer[4];
    + spin_unlock_irqrestore(&priv->lock, flags);
    + /* If we asked for a speed change encode it */
    + if (baud_rate)
    + tty_encode_baud_rate(tty,
    + new_baudrate, new_baudrate);
    + }
    + break;
    + case CYPRESS_GET_CONFIG:
    + if (priv->get_cfg_unsafe) {
    + /* Not implemented for this device,
    + and if we try to do it we're likely
    + to crash the hardware. */
    + return -ENOTTY;
    + }
    + dbg("%s - retreiving serial line settings", __func__);
    + /* set initial values in feature buffer */
    + memset(feature_buffer, 0, sizeof(feature_buffer));
    +
    + do {
    + retval = usb_control_msg(port->serial->dev,
    + usb_rcvctrlpipe(port->serial->dev, 0),
    + HID_REQ_GET_REPORT,
    + USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
    + 0x0300, 0, feature_buffer,
    + sizeof(feature_buffer), 500);
    +
    + if (tries++ >= 3)
    + break;
    + } while (retval != sizeof(feature_buffer)
    + && retval != -ENODEV);
    +
    + if (retval != sizeof(feature_buffer)) {
    + err("%s - failed to retrieve serial line settings - %d", __func__, retval);
    + cypress_set_dead(port);
    + return retval;
    + } else {
    + spin_lock_irqsave(&priv->lock, flags);
    + /* store the config in one byte, and later
    + use bit masks to check values */
    + priv->current_config = feature_buffer[4];
    + priv->baud_rate = *((u_int32_t *)feature_buffer);
    + spin_unlock_irqrestore(&priv->lock, flags);
    + }
    }
    spin_lock_irqsave(&priv->lock, flags);
    ++priv->cmd_count;
    @@ -470,14 +486,14 @@ static void cypress_set_dead(struct usb_serial_port *port)
    ************************************************** ***************************/


    -static int generic_startup (struct usb_serial *serial)
    +static int generic_startup(struct usb_serial *serial)
    {
    struct cypress_private *priv;
    struct usb_serial_port *port = serial->port[0];

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

    - priv = kzalloc(sizeof (struct cypress_private), GFP_KERNEL);
    + priv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL);
    if (!priv)
    return -ENOMEM;

    @@ -489,9 +505,9 @@ static int generic_startup (struct usb_serial *serial)
    return -ENOMEM;
    }
    init_waitqueue_head(&priv->delta_msr_wait);
    -
    - usb_reset_configuration (serial->dev);
    -
    +
    + usb_reset_configuration(serial->dev);
    +
    priv->cmd_ctrl = 0;
    priv->line_control = 0;
    priv->termios_initialized = 0;
    @@ -502,30 +518,30 @@ static int generic_startup (struct usb_serial *serial)
    small. Otherwise we can use the slightly more compact
    format. This is in accordance with the cypress_m8 serial
    converter app note. */
    - if (port->interrupt_out_size > 9) {
    + if (port->interrupt_out_size > 9)
    priv->pkt_fmt = packet_format_1;
    - } else {
    + else
    priv->pkt_fmt = packet_format_2;
    - }
    +
    if (interval > 0) {
    priv->write_urb_interval = interval;
    priv->read_urb_interval = interval;
    dbg("%s - port %d read & write intervals forced to %d",
    - __func__,port->number,interval);
    + __func__, port->number, interval);
    } else {
    priv->write_urb_interval = port->interrupt_out_urb->interval;
    priv->read_urb_interval = port->interrupt_in_urb->interval;
    dbg("%s - port %d intervals: read=%d write=%d",
    - __func__,port->number,
    - priv->read_urb_interval,priv->write_urb_interval);
    + __func__, port->number,
    + priv->read_urb_interval, priv->write_urb_interval);
    }
    usb_set_serial_port_data(port, priv);
    -
    +
    return 0;
    }


    -static int cypress_earthmate_startup (struct usb_serial *serial)
    +static int cypress_earthmate_startup(struct usb_serial *serial)
    {
    struct cypress_private *priv;
    struct usb_serial_port *port = serial->port[0];
    @@ -543,7 +559,8 @@ static int cypress_earthmate_startup (struct usb_serial *serial)
    /* All Earthmate devices use the separated-count packet
    format! Idiotic. */
    priv->pkt_fmt = packet_format_1;
    - if (serial->dev->descriptor.idProduct != cpu_to_le16(PRODUCT_ID_EARTHMATEUSB)) {
    + if (serial->dev->descriptor.idProduct !=
    + cpu_to_le16(PRODUCT_ID_EARTHMATEUSB)) {
    /* The old original USB Earthmate seemed able to
    handle GET_CONFIG requests; everything they've
    produced since that time crashes if this command is
    @@ -557,7 +574,7 @@ static int cypress_earthmate_startup (struct usb_serial *serial)
    } /* cypress_earthmate_startup */


    -static int cypress_hidcom_startup (struct usb_serial *serial)
    +static int cypress_hidcom_startup(struct usb_serial *serial)
    {
    struct cypress_private *priv;

    @@ -571,12 +588,12 @@ static int cypress_hidcom_startup (struct usb_serial *serial)

    priv = usb_get_serial_port_data(serial->port[0]);
    priv->chiptype = CT_CYPHIDCOM;
    -
    +
    return 0;
    } /* cypress_hidcom_startup */


    -static int cypress_ca42v2_startup (struct usb_serial *serial)
    +static int cypress_ca42v2_startup(struct usb_serial *serial)
    {
    struct cypress_private *priv;

    @@ -595,11 +612,11 @@ static int cypress_ca42v2_startup (struct usb_serial *serial)
    } /* cypress_ca42v2_startup */


    -static void cypress_shutdown (struct usb_serial *serial)
    +static void cypress_shutdown(struct usb_serial *serial)
    {
    struct cypress_private *priv;

    - dbg ("%s - port %d", __func__, serial->port[0]->number);
    + dbg("%s - port %d", __func__, serial->port[0]->number);

    /* all open ports are closed at this point */

    @@ -650,7 +667,9 @@ static int cypress_open(struct tty_struct *tty,
    result = cypress_write(tty, port, NULL, 0);

    if (result) {
    - dev_err(&port->dev, "%s - failed setting the control lines - error %d\n", __func__, result);
    + dev_err(&port->dev,
    + "%s - failed setting the control lines - error %d\n",
    + __func__, result);
    return result;
    } else
    dbg("%s - success setting the control lines", __func__);
    @@ -659,19 +678,22 @@ static int cypress_open(struct tty_struct *tty,
    cypress_set_termios(tty, port, &priv->tmp_termios);

    /* setup the port and start reading from the device */
    - if(!port->interrupt_in_urb){
    + if (!port->interrupt_in_urb) {
    err("%s - interrupt_in_urb is empty!", __func__);
    - return(-1);
    + return -1;
    }

    usb_fill_int_urb(port->interrupt_in_urb, serial->dev,
    usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress),
    - port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length,
    + port->interrupt_in_urb->transfer_buffer,
    + port->interrupt_in_urb->transfer_buffer_length,
    cypress_read_int_callback, port, priv->read_urb_interval);
    result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);

    - if (result){
    - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result);
    + if (result) {
    + dev_err(&port->dev,
    + "%s - failed submitting read urb, error %d\n",
    + __func__, result);
    cypress_set_dead(port);
    }

    @@ -680,7 +702,7 @@ static int cypress_open(struct tty_struct *tty,


    static void cypress_close(struct tty_struct *tty,
    - struct usb_serial_port *port, struct file * filp)
    + struct usb_serial_port *port, struct file *filp)
    {
    struct cypress_private *priv = usb_get_serial_port_data(port);
    unsigned int c_cflag;
    @@ -722,15 +744,15 @@ static void cypress_close(struct tty_struct *tty,
    if (tty) {
    bps = tty_get_baud_rate(tty);
    if (bps > 1200)
    - timeout = max((HZ*2560)/bps,HZ/10);
    + timeout = max((HZ * 2560) / bps, HZ / 10);
    else
    - timeout = 2*HZ;
    + timeout = 2 * HZ;
    schedule_timeout_interruptible(timeout);
    }

    dbg("%s - stopping urbs", __func__);
    - usb_kill_urb (port->interrupt_in_urb);
    - usb_kill_urb (port->interrupt_out_urb);
    + usb_kill_urb(port->interrupt_in_urb);
    + usb_kill_urb(port->interrupt_out_urb);

    if (tty) {
    c_cflag = tty->termios->c_cflag;
    @@ -746,8 +768,8 @@ static void cypress_close(struct tty_struct *tty,
    }

    if (stats)
    - dev_info (&port->dev, "Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n",
    - priv->bytes_in, priv->bytes_out, priv->cmd_count);
    + dev_info(&port->dev, "Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n",
    + priv->bytes_in, priv->bytes_out, priv->cmd_count);
    mutex_unlock(&port->serial->disc_mutex);
    } /* cypress_close */

    @@ -757,7 +779,7 @@ static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port,
    {
    struct cypress_private *priv = usb_get_serial_port_data(port);
    unsigned long flags;
    -
    +
    dbg("%s - port %d, %d bytes", __func__, port->number, count);

    /* line control commands, which need to be executed immediately,
    @@ -767,10 +789,10 @@ static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port,
    count = 0;
    goto finish;
    }
    -
    +
    if (!count)
    return count;
    -
    +
    spin_lock_irqsave(&priv->lock, flags);
    count = cypress_buf_put(priv->buf, buf, count);
    spin_unlock_irqrestore(&priv->lock, flags);
    @@ -787,13 +809,14 @@ static void cypress_send(struct usb_serial_port *port)
    int count = 0, result, offset, actual_size;
    struct cypress_private *priv = usb_get_serial_port_data(port);
    unsigned long flags;
    -
    +
    if (!priv->comm_is_ok)
    return;

    dbg("%s - port %d", __func__, port->number);
    - dbg("%s - interrupt out size is %d", __func__, port->interrupt_out_size);
    -
    + dbg("%s - interrupt out size is %d", __func__,
    + port->interrupt_out_size);
    +
    spin_lock_irqsave(&priv->lock, flags);
    if (priv->write_urb_in_use) {
    dbg("%s - can't write, urb in use", __func__);
    @@ -803,7 +826,8 @@ static void cypress_send(struct usb_serial_port *port)
    spin_unlock_irqrestore(&priv->lock, flags);

    /* clear buffer */
    - memset(port->interrupt_out_urb->transfer_buffer, 0, port->interrupt_out_size);
    + memset(port->interrupt_out_urb->transfer_buffer, 0,
    + port->interrupt_out_size);

    spin_lock_irqsave(&priv->lock, flags);
    switch (priv->pkt_fmt) {
    @@ -834,9 +858,8 @@ static void cypress_send(struct usb_serial_port *port)
    count = cypress_buf_get(priv->buf, &port->interrupt_out_buffer[offset],
    port->interrupt_out_size-offset);

    - if (count == 0) {
    + if (count == 0)
    return;
    - }

    switch (priv->pkt_fmt) {
    default:
    @@ -860,26 +883,29 @@ send:
    actual_size = count +
    (priv->pkt_fmt == packet_format_1 ? 2 : 1);

    - usb_serial_debug_data(debug, &port->dev, __func__, port->interrupt_out_size,
    - port->interrupt_out_urb->transfer_buffer);
    + usb_serial_debug_data(debug, &port->dev, __func__,
    + port->interrupt_out_size,
    + port->interrupt_out_urb->transfer_buffer);

    usb_fill_int_urb(port->interrupt_out_urb, port->serial->dev,
    usb_sndintpipe(port->serial->dev, port->interrupt_out_endpointAddress),
    port->interrupt_out_buffer, port->interrupt_out_size,
    cypress_write_int_callback, port, priv->write_urb_interval);
    - result = usb_submit_urb (port->interrupt_out_urb, GFP_ATOMIC);
    + result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC);
    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);
    priv->write_urb_in_use = 0;
    cypress_set_dead(port);
    }

    spin_lock_irqsave(&priv->lock, flags);
    - if (priv->cmd_ctrl) {
    + if (priv->cmd_ctrl)
    priv->cmd_ctrl = 0;
    - }
    - priv->bytes_out += count; /* do not count the line control and size bytes */
    +
    + /* do not count the line control and size bytes */
    + priv->bytes_out += count;
    spin_unlock_irqrestore(&priv->lock, flags);

    usb_serial_port_softint(port);
    @@ -912,7 +938,7 @@ static int cypress_tiocmget(struct tty_struct *tty, struct file *file)
    __u8 status, control;
    unsigned int result = 0;
    unsigned long flags;
    -
    +
    dbg("%s - port %d", __func__, port->number);

    spin_lock_irqsave(&priv->lock, flags);
    @@ -939,7 +965,7 @@ static int cypress_tiocmset(struct tty_struct *tty, struct file *file,
    struct usb_serial_port *port = tty->driver_data;
    struct cypress_private *priv = usb_get_serial_port_data(port);
    unsigned long flags;
    -
    +
    dbg("%s - port %d", __func__, port->number);

    spin_lock_irqsave(&priv->lock, flags);
    @@ -958,7 +984,7 @@ static int cypress_tiocmset(struct tty_struct *tty, struct file *file,
    }


    -static int cypress_ioctl(struct tty_struct *tty, struct file * file,
    +static int cypress_ioctl(struct tty_struct *tty, struct file *file,
    unsigned int cmd, unsigned long arg)
    {
    struct usb_serial_port *port = tty->driver_data;
    @@ -967,38 +993,37 @@ static int cypress_ioctl(struct tty_struct *tty, struct file * file,
    dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);

    switch (cmd) {
    - /* This code comes from drivers/char/serial.c and ftdi_sio.c */
    - case TIOCMIWAIT:
    - while (priv != NULL) {
    - interruptible_sleep_on(&priv->delta_msr_wait);
    - /* see if a signal did it */
    - if (signal_pending(current))
    - return -ERESTARTSYS;
    - else {
    - char diff = priv->diff_status;
    -
    - 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 & UART_RI)) ||
    - ((arg & TIOCM_DSR) && (diff & UART_DSR)) ||
    - ((arg & TIOCM_CD) && (diff & UART_CD)) ||
    - ((arg & TIOCM_CTS) && (diff & UART_CTS)) ) {
    - return 0;
    - }
    - /* otherwise caller can't care less about what happened,
    - * and so we continue to wait for more events.
    - */
    - }
    + /* This code comes from drivers/char/serial.c and ftdi_sio.c */
    + case TIOCMIWAIT:
    + while (priv != NULL) {
    + interruptible_sleep_on(&priv->delta_msr_wait);
    + /* see if a signal did it */
    + if (signal_pending(current))
    + return -ERESTARTSYS;
    + else {
    + char diff = priv->diff_status;
    + 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 & UART_RI)) ||
    + ((arg & TIOCM_DSR) && (diff & UART_DSR)) ||
    + ((arg & TIOCM_CD) && (diff & UART_CD)) ||
    + ((arg & TIOCM_CTS) && (diff & UART_CTS)))
    + return 0;
    + /* otherwise caller can't care less about what
    + * happened, and so we continue to wait for
    + * more events.
    + */
    }
    - return 0;
    - default:
    - break;
    + }
    + return 0;
    + default:
    + break;
    }
    dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __func__, cmd);
    return -ENOIOCTLCMD;
    @@ -1070,23 +1095,22 @@ static void cypress_set_termios(struct tty_struct *tty,

    if (cflag & CSIZE) {
    switch (cflag & CSIZE) {
    - case CS5:
    - data_bits = 0;
    - break;
    - case CS6:
    - data_bits = 1;
    - break;
    - case CS7:
    - data_bits = 2;
    - break;
    - case CS8:
    - data_bits = 3;
    - break;
    - default:
    - err("%s - CSIZE was set, but not CS5-CS8",
    - __func__);
    - data_bits = 3;
    - }
    + case CS5:
    + data_bits = 0;
    + break;
    + case CS6:
    + data_bits = 1;
    + break;
    + case CS7:
    + data_bits = 2;
    + break;
    + case CS8:
    + data_bits = 3;
    + break;
    + default:
    + err("%s - CSIZE was set, but not CS5-CS8",
    + __func__);
    + data_bits = 3;
    } else
    data_bits = 3;

    @@ -1104,8 +1128,10 @@ static void cypress_set_termios(struct tty_struct *tty,
    "%d data_bits (+5)", __func__, stop_bits,
    parity_enable, parity_type, data_bits);

    - cypress_serial_control(tty, port, tty_get_baud_rate(tty), data_bits, stop_bits,
    - parity_enable, parity_type, 0, CYPRESS_SET_CONFIG);
    + cypress_serial_control(tty, port, tty_get_baud_rate(tty),
    + data_bits, stop_bits,
    + parity_enable, parity_type,
    + 0, CYPRESS_SET_CONFIG);

    /* we perform a CYPRESS_GET_CONFIG so that the current settings are
    * filled into the private structure this should confirm that all is
    @@ -1116,7 +1142,7 @@ static void cypress_set_termios(struct tty_struct *tty,
    * termios flag base comes from empeg.c */

    spin_lock_irqsave(&priv->lock, flags);
    - if ( (priv->chiptype == CT_EARTHMATE) && (priv->baud_rate == 4800) ) {
    + if (priv->chiptype == CT_EARTHMATE && priv->baud_rate == 4800) {
    dbg("Using custom termios settings for a baud rate of "
    "4800bps.");
    /* define custom termios settings for NMEA protocol */
    @@ -1164,7 +1190,7 @@ static int cypress_chars_in_buffer(struct tty_struct *tty)
    unsigned long flags;

    dbg("%s - port %d", __func__, port->number);
    -
    +
    spin_lock_irqsave(&priv->lock, flags);
    chars = cypress_buf_data_avail(priv->buf);
    spin_unlock_irqrestore(&priv->lock, flags);
    @@ -1243,12 +1269,13 @@ static void cypress_read_int_callback(struct urb *urb)
    /* precursor to disconnect so just go away */
    return;
    case -EPIPE:
    - usb_clear_halt(port->serial->dev,0x81);
    + usb_clear_halt(port->serial->dev, 0x81);
    break;
    default:
    /* something ugly is going on... */
    - dev_err(&urb->dev->dev,"%s - unexpected nonzero read status received: %d\n",
    - __func__, status);
    + dev_err(&urb->dev->dev,
    + "%s - unexpected nonzero read status received: %d\n",
    + __func__, status);
    cypress_set_dead(port);
    return;
    }
    @@ -1296,8 +1323,8 @@ static void cypress_read_int_callback(struct urb *urb)
    goto continue_read;
    }

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

    spin_lock_irqsave(&priv->lock, flags);
    /* check to see if status has changed */
    @@ -1356,7 +1383,8 @@ continue_read:
    port->interrupt_in_endpointAddress),
    port->interrupt_in_urb->transfer_buffer,
    port->interrupt_in_urb->transfer_buffer_length,
    - cypress_read_int_callback, port, priv->read_urb_interval);
    + cypress_read_int_callback, port,
    + priv->read_urb_interval);
    result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
    if (result) {
    dev_err(&urb->dev->dev, "%s - failed resubmitting "
    @@ -1380,42 +1408,43 @@ static void cypress_write_int_callback(struct urb *urb)
    dbg("%s - port %d", __func__, port->number);

    switch (status) {
    - case 0:
    - /* success */
    + case 0:
    + /* success */
    + break;
    + case -ECONNRESET:
    + case -ENOENT:
    + case -ESHUTDOWN:
    + /* this urb is terminated, clean up */
    + dbg("%s - urb shutting down with status: %d",
    + __func__, status);
    + priv->write_urb_in_use = 0;
    + return;
    + case -EPIPE: /* no break needed; clear halt and resubmit */
    + if (!priv->comm_is_ok)
    break;
    - case -ECONNRESET:
    - case -ENOENT:
    - case -ESHUTDOWN:
    - /* this urb is terminated, clean up */
    - dbg("%s - urb shutting down with status: %d",
    - __func__, status);
    - priv->write_urb_in_use = 0;
    + usb_clear_halt(port->serial->dev, 0x02);
    + /* error in the urb, so we have to resubmit it */
    + dbg("%s - nonzero write bulk status received: %d",
    + __func__, status);
    + port->interrupt_out_urb->transfer_buffer_length = 1;
    + port->interrupt_out_urb->dev = port->serial->dev;
    + result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC);
    + if (!result)
    return;
    - case -EPIPE: /* no break needed; clear halt and resubmit */
    - if (!priv->comm_is_ok)
    - break;
    - usb_clear_halt(port->serial->dev, 0x02);
    - /* error in the urb, so we have to resubmit it */
    - dbg("%s - nonzero write bulk status received: %d",
    - __func__, status);
    - port->interrupt_out_urb->transfer_buffer_length = 1;
    - port->interrupt_out_urb->dev = port->serial->dev;
    - result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC);
    - if (!result)
    - return;
    - dev_err(&urb->dev->dev, "%s - failed resubmitting write urb, error %d\n",
    - __func__, result);
    - cypress_set_dead(port);
    - break;
    - default:
    - dev_err(&urb->dev->dev,"%s - unexpected nonzero write status received: %d\n",
    - __func__, status);
    - cypress_set_dead(port);
    - break;
    + dev_err(&urb->dev->dev,
    + "%s - failed resubmitting write urb, error %d\n",
    + __func__, result);
    + cypress_set_dead(port);
    + break;
    + default:
    + dev_err(&urb->dev->dev,
    + "%s - unexpected nonzero write status received: %d\n",
    + __func__, status);
    + cypress_set_dead(port);
    + break;
    }
    -
    priv->write_urb_in_use = 0;
    -
    +
    /* send any buffered data */
    cypress_send(port);
    }
    @@ -1497,7 +1526,8 @@ static void cypress_buf_clear(struct cypress_buf *cb)
    static unsigned int cypress_buf_data_avail(struct cypress_buf *cb)
    {
    if (cb != NULL)
    - return ((cb->buf_size + cb->buf_put - cb->buf_get) % cb->buf_size);
    + return (cb->buf_size + cb->buf_put - cb->buf_get)
    + % cb->buf_size;
    else
    return 0;
    }
    @@ -1513,7 +1543,8 @@ static unsigned int cypress_buf_data_avail(struct cypress_buf *cb)
    static unsigned int cypress_buf_space_avail(struct cypress_buf *cb)
    {
    if (cb != NULL)
    - return ((cb->buf_size + cb->buf_get - cb->buf_put - 1) % cb->buf_size);
    + return (cb->buf_size + cb->buf_get - cb->buf_put - 1)
    + % cb->buf_size;
    else
    return 0;
    }
    @@ -1613,9 +1644,9 @@ static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf,
    static int __init cypress_init(void)
    {
    int retval;
    -
    +
    dbg("%s", __func__);
    -
    +
    retval = usb_serial_register(&cypress_earthmate_device);
    if (retval)
    goto failed_em_register;
    @@ -1643,23 +1674,23 @@ failed_em_register:
    }


    -static void __exit cypress_exit (void)
    +static void __exit cypress_exit(void)
    {
    dbg("%s", __func__);

    - usb_deregister (&cypress_driver);
    - usb_serial_deregister (&cypress_earthmate_device);
    - usb_serial_deregister (&cypress_hidcom_device);
    - usb_serial_deregister (&cypress_ca42v2_device);
    + usb_deregister(&cypress_driver);
    + usb_serial_deregister(&cypress_earthmate_device);
    + usb_serial_deregister(&cypress_hidcom_device);
    + usb_serial_deregister(&cypress_ca42v2_device);
    }


    module_init(cypress_init);
    module_exit(cypress_exit);

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

    module_param(debug, bool, S_IRUGO | S_IWUSR);
    diff --git a/drivers/usb/serial/cypress_m8.h b/drivers/usb/serial/cypress_m8.h
    index 0388065..e772b01 100644
    --- a/drivers/usb/serial/cypress_m8.h
    +++ b/drivers/usb/serial/cypress_m8.h
    @@ -54,7 +54,7 @@
    #define UART_DSR 0x20 /* data set ready - flow control - device to host */
    #define CONTROL_RTS 0x10 /* request to send - flow control - host to device */
    #define UART_CTS 0x10 /* clear to send - flow control - device to host */
    -#define UART_RI 0x10 /* ring indicator - modem - device to host */
    +#define UART_RI 0x10 /* ring indicator - modem - device to host */
    #define UART_CD 0x40 /* carrier detect - modem - device to host */
    #define CYP_ERROR 0x08 /* received from input report - device to host */
    /* Note - the below has nothing to to with the "feature report" reset */

    --
    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 14/70] mxser: use tty_port

    From: Alan Cox

    Switch mxser to use the new tty_port structure

    Signed-off-by: Alan Cox
    ---

    drivers/char/mxser.c | 257 +++++++++++++++++++++++++-------------------------
    1 files changed, 126 insertions(+), 131 deletions(-)


    diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
    index 4b81a85..e83ccee 100644
    --- a/drivers/char/mxser.c
    +++ b/drivers/char/mxser.c
    @@ -222,8 +222,8 @@ struct mxser_mon_ext {
    struct mxser_board;

    struct mxser_port {
    + struct tty_port port;
    struct mxser_board *board;
    - struct tty_struct *tty;

    unsigned long ioaddr;
    unsigned long opmode_ioaddr;
    @@ -234,7 +234,6 @@ struct mxser_port {
    int rx_low_water;
    int baud_base; /* max. speed */
    int type; /* UART type */
    - int flags; /* defined in tty.h */

    int x_char; /* xon/xoff character */
    int IER; /* Interrupt Enable Register */
    @@ -249,15 +248,12 @@ struct mxser_port {
    unsigned char err_shadow;
    unsigned long event;

    - int count; /* # of fd on device */
    - int blocked_open; /* # of blocked opens */
    struct async_icount icount; /* kernel counters for 4 input interrupts */
    int timeout;

    int read_status_mask;
    int ignore_status_mask;
    int xmit_fifo_size;
    - unsigned char *xmit_buf;
    int xmit_head;
    int xmit_tail;
    int xmit_cnt;
    @@ -267,7 +263,6 @@ struct mxser_port {
    struct mxser_mon mon_data;

    spinlock_t slock;
    - wait_queue_head_t open_wait;
    wait_queue_head_t delta_msr_wait;
    };

    @@ -575,7 +570,7 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,
    */
    if ((filp->f_flags & O_NONBLOCK) ||
    test_bit(TTY_IO_ERROR, &tty->flags)) {
    - port->flags |= ASYNC_NORMAL_ACTIVE;
    + port->port.flags |= ASYNC_NORMAL_ACTIVE;
    return 0;
    }

    @@ -585,32 +580,32 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,
    /*
    * Block waiting for the carrier detect and the line to become
    * free (i.e., not in use by the callout). While we are in
    - * this loop, port->count is dropped by one, so that
    + * this loop, port->port.count is dropped by one, so that
    * mxser_close() knows when to free things. We restore it upon
    * exit, either normal or abnormal.
    */
    retval = 0;
    - add_wait_queue(&port->open_wait, &wait);
    + add_wait_queue(&port->port.open_wait, &wait);

    spin_lock_irqsave(&port->slock, flags);
    if (!tty_hung_up_p(filp))
    - port->count--;
    + port->port.count--;
    spin_unlock_irqrestore(&port->slock, flags);
    - port->blocked_open++;
    + port->port.blocked_open++;
    while (1) {
    spin_lock_irqsave(&port->slock, flags);
    outb(inb(port->ioaddr + UART_MCR) |
    UART_MCR_DTR | UART_MCR_RTS, port->ioaddr + UART_MCR);
    spin_unlock_irqrestore(&port->slock, flags);
    set_current_state(TASK_INTERRUPTIBLE);
    - if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) {
    - if (port->flags & ASYNC_HUP_NOTIFY)
    + if (tty_hung_up_p(filp) || !(port->port.flags & ASYNC_INITIALIZED)) {
    + if (port->port.flags & ASYNC_HUP_NOTIFY)
    retval = -EAGAIN;
    else
    retval = -ERESTARTSYS;
    break;
    }
    - if (!(port->flags & ASYNC_CLOSING) &&
    + if (!(port->port.flags & ASYNC_CLOSING) &&
    (do_clocal ||
    (inb(port->ioaddr + UART_MSR) & UART_MSR_DCD)))
    break;
    @@ -621,13 +616,13 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,
    schedule();
    }
    set_current_state(TASK_RUNNING);
    - remove_wait_queue(&port->open_wait, &wait);
    + remove_wait_queue(&port->port.open_wait, &wait);
    if (!tty_hung_up_p(filp))
    - port->count++;
    - port->blocked_open--;
    + port->port.count++;
    + port->port.blocked_open--;
    if (retval)
    return retval;
    - port->flags |= ASYNC_NORMAL_ACTIVE;
    + port->port.flags |= ASYNC_NORMAL_ACTIVE;
    return 0;
    }

    @@ -636,7 +631,7 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
    int quot = 0, baud;
    unsigned char cval;

    - if (!info->tty || !info->tty->termios)
    + if (!info->port.tty || !info->port.tty->termios)
    return -1;

    if (!(info->ioaddr))
    @@ -647,13 +642,13 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)

    if (newspd == 134) {
    quot = 2 * info->baud_base / 269;
    - tty_encode_baud_rate(info->tty, 134, 134);
    + tty_encode_baud_rate(info->port.tty, 134, 134);
    } else if (newspd) {
    quot = info->baud_base / newspd;
    if (quot == 0)
    quot = 1;
    baud = info->baud_base/quot;
    - tty_encode_baud_rate(info->tty, baud, baud);
    + tty_encode_baud_rate(info->port.tty, baud, baud);
    } else {
    quot = 0;
    }
    @@ -679,7 +674,7 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
    outb(cval, info->ioaddr + UART_LCR); /* reset DLAB */

    #ifdef BOTHER
    - if (C_BAUD(info->tty) == BOTHER) {
    + if (C_BAUD(info->port.tty) == BOTHER) {
    quot = info->baud_base % newspd;
    quot *= 8;
    if (quot % newspd > newspd / 2) {
    @@ -707,14 +702,14 @@ static int mxser_change_speed(struct mxser_port *info,
    int ret = 0;
    unsigned char status;

    - if (!info->tty || !info->tty->termios)
    + if (!info->port.tty || !info->port.tty->termios)
    return ret;
    - cflag = info->tty->termios->c_cflag;
    + cflag = info->port.tty->termios->c_cflag;
    if (!(info->ioaddr))
    return ret;

    - if (mxser_set_baud_method[info->tty->index] == 0)
    - mxser_set_baud(info, tty_get_baud_rate(info->tty));
    + if (mxser_set_baud_method[info->port.tty->index] == 0)
    + mxser_set_baud(info, tty_get_baud_rate(info->port.tty));

    /* byte size and parity */
    switch (cflag & CSIZE) {
    @@ -777,15 +772,15 @@ static int mxser_change_speed(struct mxser_port *info,
    info->IER &= ~UART_IER_MSI;
    info->MCR &= ~UART_MCR_AFE;
    if (cflag & CRTSCTS) {
    - info->flags |= ASYNC_CTS_FLOW;
    + info->port.flags |= ASYNC_CTS_FLOW;
    info->IER |= UART_IER_MSI;
    if ((info->type == PORT_16550A) || (info->board->chip_flag)) {
    info->MCR |= UART_MCR_AFE;
    } else {
    status = inb(info->ioaddr + UART_MSR);
    - if (info->tty->hw_stopped) {
    + if (info->port.tty->hw_stopped) {
    if (status & UART_MSR_CTS) {
    - info->tty->hw_stopped = 0;
    + info->port.tty->hw_stopped = 0;
    if (info->type != PORT_16550A &&
    !info->board->chip_flag) {
    outb(info->IER & ~UART_IER_THRI,
    @@ -795,11 +790,11 @@ static int mxser_change_speed(struct mxser_port *info,
    outb(info->IER, info->ioaddr +
    UART_IER);
    }
    - tty_wakeup(info->tty);
    + tty_wakeup(info->port.tty);
    }
    } else {
    if (!(status & UART_MSR_CTS)) {
    - info->tty->hw_stopped = 1;
    + info->port.tty->hw_stopped = 1;
    if ((info->type != PORT_16550A) &&
    (!info->board->chip_flag)) {
    info->IER &= ~UART_IER_THRI;
    @@ -810,13 +805,13 @@ static int mxser_change_speed(struct mxser_port *info,
    }
    }
    } else {
    - info->flags &= ~ASYNC_CTS_FLOW;
    + info->port.flags &= ~ASYNC_CTS_FLOW;
    }
    outb(info->MCR, info->ioaddr + UART_MCR);
    if (cflag & CLOCAL) {
    - info->flags &= ~ASYNC_CHECK_CD;
    + info->port.flags &= ~ASYNC_CHECK_CD;
    } else {
    - info->flags |= ASYNC_CHECK_CD;
    + info->port.flags |= ASYNC_CHECK_CD;
    info->IER |= UART_IER_MSI;
    }
    outb(info->IER, info->ioaddr + UART_IER);
    @@ -825,21 +820,21 @@ static int mxser_change_speed(struct mxser_port *info,
    * Set up parity check flag
    */
    info->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
    - if (I_INPCK(info->tty))
    + if (I_INPCK(info->port.tty))
    info->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
    - if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
    + if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
    info->read_status_mask |= UART_LSR_BI;

    info->ignore_status_mask = 0;

    - if (I_IGNBRK(info->tty)) {
    + if (I_IGNBRK(info->port.tty)) {
    info->ignore_status_mask |= UART_LSR_BI;
    info->read_status_mask |= UART_LSR_BI;
    /*
    * If we're ignore parity and break indicators, ignore
    * overruns too. (For real raw support).
    */
    - if (I_IGNPAR(info->tty)) {
    + if (I_IGNPAR(info->port.tty)) {
    info->ignore_status_mask |=
    UART_LSR_OE |
    UART_LSR_PE |
    @@ -851,16 +846,16 @@ static int mxser_change_speed(struct mxser_port *info,
    }
    }
    if (info->board->chip_flag) {
    - mxser_set_must_xon1_value(info->ioaddr, START_CHAR(info->tty));
    - mxser_set_must_xoff1_value(info->ioaddr, STOP_CHAR(info->tty));
    - if (I_IXON(info->tty)) {
    + mxser_set_must_xon1_value(info->ioaddr, START_CHAR(info->port.tty));
    + mxser_set_must_xoff1_value(info->ioaddr, STOP_CHAR(info->port.tty));
    + if (I_IXON(info->port.tty)) {
    mxser_enable_must_rx_software_flow_control(
    info->ioaddr);
    } else {
    mxser_disable_must_rx_software_flow_control(
    info->ioaddr);
    }
    - if (I_IXOFF(info->tty)) {
    + if (I_IXOFF(info->port.tty)) {
    mxser_enable_must_tx_software_flow_control(
    info->ioaddr);
    } else {
    @@ -890,15 +885,15 @@ static void mxser_check_modem_status(struct mxser_port *port, int status)
    port->mon_data.modem_status = status;
    wake_up_interruptible(&port->delta_msr_wait);

    - if ((port->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
    + if ((port->port.flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
    if (status & UART_MSR_DCD)
    - wake_up_interruptible(&port->open_wait);
    + wake_up_interruptible(&port->port.open_wait);
    }

    - if (port->flags & ASYNC_CTS_FLOW) {
    - if (port->tty->hw_stopped) {
    + if (port->port.flags & ASYNC_CTS_FLOW) {
    + if (port->port.tty->hw_stopped) {
    if (status & UART_MSR_CTS) {
    - port->tty->hw_stopped = 0;
    + port->port.tty->hw_stopped = 0;

    if ((port->type != PORT_16550A) &&
    (!port->board->chip_flag)) {
    @@ -908,11 +903,11 @@ static void mxser_check_modem_status(struct mxser_port *port, int status)
    outb(port->IER, port->ioaddr +
    UART_IER);
    }
    - tty_wakeup(port->tty);
    + tty_wakeup(port->port.tty);
    }
    } else {
    if (!(status & UART_MSR_CTS)) {
    - port->tty->hw_stopped = 1;
    + port->port.tty->hw_stopped = 1;
    if (port->type != PORT_16550A &&
    !port->board->chip_flag) {
    port->IER &= ~UART_IER_THRI;
    @@ -935,23 +930,23 @@ static int mxser_startup(struct mxser_port *info)

    spin_lock_irqsave(&info->slock, flags);

    - if (info->flags & ASYNC_INITIALIZED) {
    + if (info->port.flags & ASYNC_INITIALIZED) {
    free_page(page);
    spin_unlock_irqrestore(&info->slock, flags);
    return 0;
    }

    if (!info->ioaddr || !info->type) {
    - if (info->tty)
    - set_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + set_bit(TTY_IO_ERROR, &info->port.tty->flags);
    free_page(page);
    spin_unlock_irqrestore(&info->slock, flags);
    return 0;
    }
    - if (info->xmit_buf)
    + if (info->port.xmit_buf)
    free_page(page);
    else
    - info->xmit_buf = (unsigned char *) page;
    + info->port.xmit_buf = (unsigned char *) page;

    /*
    * Clear the FIFO buffers and disable them
    @@ -973,8 +968,8 @@ static int mxser_startup(struct mxser_port *info)
    if (inb(info->ioaddr + UART_LSR) == 0xff) {
    spin_unlock_irqrestore(&info->slock, flags);
    if (capable(CAP_SYS_ADMIN)) {
    - if (info->tty)
    - set_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + set_bit(TTY_IO_ERROR, &info->port.tty->flags);
    return 0;
    } else
    return -ENODEV;
    @@ -1012,15 +1007,15 @@ static int mxser_startup(struct mxser_port *info)
    (void) inb(info->ioaddr + UART_IIR);
    (void) inb(info->ioaddr + UART_MSR);

    - if (info->tty)
    - clear_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
    info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;

    /*
    * and set the speed of the serial port
    */
    mxser_change_speed(info, NULL);
    - info->flags |= ASYNC_INITIALIZED;
    + info->port.flags |= ASYNC_INITIALIZED;
    spin_unlock_irqrestore(&info->slock, flags);

    return 0;
    @@ -1034,7 +1029,7 @@ static void mxser_shutdown(struct mxser_port *info)
    {
    unsigned long flags;

    - if (!(info->flags & ASYNC_INITIALIZED))
    + if (!(info->port.flags & ASYNC_INITIALIZED))
    return;

    spin_lock_irqsave(&info->slock, flags);
    @@ -1048,15 +1043,15 @@ static void mxser_shutdown(struct mxser_port *info)
    /*
    * Free the IRQ, if necessary
    */
    - if (info->xmit_buf) {
    - free_page((unsigned long) info->xmit_buf);
    - info->xmit_buf = NULL;
    + if (info->port.xmit_buf) {
    + free_page((unsigned long) info->port.xmit_buf);
    + info->port.xmit_buf = NULL;
    }

    info->IER = 0;
    outb(0x00, info->ioaddr + UART_IER);

    - if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
    + if (!info->port.tty || (info->port.tty->termios->c_cflag & HUPCL))
    info->MCR &= ~(UART_MCR_DTR | UART_MCR_RTS);
    outb(info->MCR, info->ioaddr + UART_MCR);

    @@ -1072,10 +1067,10 @@ static void mxser_shutdown(struct mxser_port *info)
    /* read data port to reset things */
    (void) inb(info->ioaddr + UART_RX);

    - if (info->tty)
    - set_bit(TTY_IO_ERROR, &info->tty->flags);
    + if (info->port.tty)
    + set_bit(TTY_IO_ERROR, &info->port.tty->flags);

    - info->flags &= ~ASYNC_INITIALIZED;
    + info->port.flags &= ~ASYNC_INITIALIZED;

    if (info->board->chip_flag)
    SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->ioaddr);
    @@ -1105,12 +1100,12 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
    return -ENODEV;

    tty->driver_data = info;
    - info->tty = tty;
    + info->port.tty = tty;
    /*
    * Start up serial port
    */
    spin_lock_irqsave(&info->slock, flags);
    - info->count++;
    + info->port.count++;
    spin_unlock_irqrestore(&info->slock, flags);
    retval = mxser_startup(info);
    if (retval)
    @@ -1170,34 +1165,34 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
    spin_unlock_irqrestore(&info->slock, flags);
    return;
    }
    - if ((tty->count == 1) && (info->count != 1)) {
    + if ((tty->count == 1) && (info->port.count != 1)) {
    /*
    * Uh, oh. tty->count is 1, which means that the tty
    - * structure will be freed. Info->count should always
    + * structure will be freed. Info->port.count should always
    * be one in these conditions. If it's greater than
    * one, we've got real problems, since it means the
    * serial port won't be shutdown.
    */
    printk(KERN_ERR "mxser_close: bad serial port count; "
    - "tty->count is 1, info->count is %d\n", info->count);
    - info->count = 1;
    + "tty->count is 1, info->port.count is %d\n", info->port.count);
    + info->port.count = 1;
    }
    - if (--info->count < 0) {
    + if (--info->port.count < 0) {
    printk(KERN_ERR "mxser_close: bad serial port count for "
    - "ttys%d: %d\n", tty->index, info->count);
    - info->count = 0;
    + "ttys%d: %d\n", tty->index, info->port.count);
    + info->port.count = 0;
    }
    - if (info->count) {
    + if (info->port.count) {
    spin_unlock_irqrestore(&info->slock, flags);
    return;
    }
    - info->flags |= ASYNC_CLOSING;
    + info->port.flags |= ASYNC_CLOSING;
    spin_unlock_irqrestore(&info->slock, flags);
    /*
    * Save the termios structure, since this port may have
    * separate termios for callout and dialin.
    */
    - if (info->flags & ASYNC_NORMAL_ACTIVE)
    + if (info->port.flags & ASYNC_NORMAL_ACTIVE)
    info->normal_termios = *tty->termios;
    /*
    * Now we wait for the transmit buffer to clear; and we notify
    @@ -1216,7 +1211,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
    if (info->board->chip_flag)
    info->IER &= ~MOXA_MUST_RECV_ISR;

    - if (info->flags & ASYNC_INITIALIZED) {
    + if (info->port.flags & ASYNC_INITIALIZED) {
    outb(info->IER, info->ioaddr + UART_IER);
    /*
    * Before we drop DTR, make sure the UART transmitter
    @@ -1237,14 +1232,14 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)

    tty->closing = 0;
    info->event = 0;
    - info->tty = NULL;
    - if (info->blocked_open) {
    + info->port.tty = NULL;
    + if (info->port.blocked_open) {
    if (info->close_delay)
    schedule_timeout_interruptible(info->close_delay);
    - wake_up_interruptible(&info->open_wait);
    + wake_up_interruptible(&info->port.open_wait);
    }

    - info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
    + info->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
    }

    static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count)
    @@ -1253,7 +1248,7 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
    struct mxser_port *info = tty->driver_data;
    unsigned long flags;

    - if (!info->xmit_buf)
    + if (!info->port.xmit_buf)
    return 0;

    while (1) {
    @@ -1262,7 +1257,7 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
    if (c <= 0)
    break;

    - memcpy(info->xmit_buf + info->xmit_head, buf, c);
    + memcpy(info->port.xmit_buf + info->xmit_head, buf, c);
    spin_lock_irqsave(&info->slock, flags);
    info->xmit_head = (info->xmit_head + c) &
    (SERIAL_XMIT_SIZE - 1);
    @@ -1294,14 +1289,14 @@ static int mxser_put_char(struct tty_struct *tty, unsigned char ch)
    struct mxser_port *info = tty->driver_data;
    unsigned long flags;

    - if (!info->xmit_buf)
    + if (!info->port.xmit_buf)
    return 0;

    if (info->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
    return 0;

    spin_lock_irqsave(&info->slock, flags);
    - info->xmit_buf[info->xmit_head++] = ch;
    + info->port.xmit_buf[info->xmit_head++] = ch;
    info->xmit_head &= SERIAL_XMIT_SIZE - 1;
    info->xmit_cnt++;
    spin_unlock_irqrestore(&info->slock, flags);
    @@ -1327,7 +1322,7 @@ static void mxser_flush_chars(struct tty_struct *tty)

    if (info->xmit_cnt <= 0 ||
    tty->stopped ||
    - !info->xmit_buf ||
    + !info->port.xmit_buf ||
    (tty->hw_stopped &&
    (info->type != PORT_16550A) &&
    (!info->board->chip_flag)
    @@ -1370,10 +1365,10 @@ static int mxser_get_serial_info(struct mxser_port *info,
    {
    struct serial_struct tmp = {
    .type = info->type,
    - .line = info->tty->index,
    + .line = info->port.tty->index,
    .port = info->ioaddr,
    .irq = info->board->irq,
    - .flags = info->flags,
    + .flags = info->port.flags,
    .baud_base = info->baud_base,
    .close_delay = info->close_delay,
    .closing_wait = info->closing_wait,
    @@ -1403,33 +1398,33 @@ static int mxser_set_serial_info(struct mxser_port *info,
    new_serial.port != info->ioaddr)
    return -EINVAL;

    - flags = info->flags & ASYNC_SPD_MASK;
    + flags = info->port.flags & ASYNC_SPD_MASK;

    if (!capable(CAP_SYS_ADMIN)) {
    if ((new_serial.baud_base != info->baud_base) ||
    (new_serial.close_delay != info->close_delay) ||
    - ((new_serial.flags & ~ASYNC_USR_MASK) != (info->flags & ~ASYNC_USR_MASK)))
    + ((new_serial.flags & ~ASYNC_USR_MASK) != (info->port.flags & ~ASYNC_USR_MASK)))
    return -EPERM;
    - info->flags = ((info->flags & ~ASYNC_USR_MASK) |
    + info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK) |
    (new_serial.flags & ASYNC_USR_MASK));
    } else {
    /*
    * OK, past this point, all the error checking has been done.
    * At this point, we start making changes.....
    */
    - info->flags = ((info->flags & ~ASYNC_FLAGS) |
    + info->port.flags = ((info->port.flags & ~ASYNC_FLAGS) |
    (new_serial.flags & ASYNC_FLAGS));
    info->close_delay = new_serial.close_delay * HZ / 100;
    info->closing_wait = new_serial.closing_wait * HZ / 100;
    - info->tty->low_latency =
    - (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
    - info->tty->low_latency = 0;
    - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST &&
    + info->port.tty->low_latency =
    + (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
    + info->port.tty->low_latency = 0;
    + if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST &&
    (new_serial.baud_base != info->baud_base ||
    new_serial.custom_divisor !=
    info->custom_divisor)) {
    baud = new_serial.baud_base / new_serial.custom_divisor;
    - tty_encode_baud_rate(info->tty, baud, baud);
    + tty_encode_baud_rate(info->port.tty, baud, baud);
    }
    }

    @@ -1437,8 +1432,8 @@ static int mxser_set_serial_info(struct mxser_port *info,

    process_txrx_fifo(info);

    - if (info->flags & ASYNC_INITIALIZED) {
    - if (flags != (info->flags & ASYNC_SPD_MASK)) {
    + if (info->port.flags & ASYNC_INITIALIZED) {
    + if (flags != (info->port.flags & ASYNC_SPD_MASK)) {
    spin_lock_irqsave(&info->slock, sl_flags);
    mxser_change_speed(info, NULL);
    spin_unlock_irqrestore(&info->slock, sl_flags);
    @@ -1693,12 +1688,12 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
    continue;
    }

    - if (!port->tty || !port->tty->termios)
    + if (!port->port.tty || !port->port.tty->termios)
    GMStatus[i].cflag =
    port->normal_termios.c_cflag;
    else
    GMStatus[i].cflag =
    - port->tty->termios->c_cflag;
    + port->port.tty->termios->c_cflag;

    status = inb(port->ioaddr + UART_MSR);
    if (status & 0x80 /*UART_MSR_DCD */ )
    @@ -1755,14 +1750,14 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
    mon_data_ext.modem_status[i] =
    port->mon_data.modem_status;
    mon_data_ext.baudrate[i] =
    - tty_get_baud_rate(port->tty);
    + tty_get_baud_rate(port->port.tty);

    - if (!port->tty || !port->tty->termios) {
    + if (!port->port.tty || !port->port.tty->termios) {
    cflag = port->normal_termios.c_cflag;
    iflag = port->normal_termios.c_iflag;
    } else {
    - cflag = port->tty->termios->c_cflag;
    - iflag = port->tty->termios->c_iflag;
    + cflag = port->port.tty->termios->c_cflag;
    + iflag = port->port.tty->termios->c_iflag;
    }

    mon_data_ext.databits[i] = cflag & CSIZE;
    @@ -1989,7 +1984,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
    else
    info->mon_data.hold_reason |= NPPI_NOTIFY_XOFFXENT;

    - if (info->tty->hw_stopped)
    + if (info->port.tty->hw_stopped)
    info->mon_data.hold_reason |= NPPI_NOTIFY_CTSHOLD;
    else
    info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD;
    @@ -2038,7 +2033,7 @@ static void mxser_stoprx(struct tty_struct *tty)
    }
    }

    - if (info->tty->termios->c_cflag & CRTSCTS) {
    + if (info->port.tty->termios->c_cflag & CRTSCTS) {
    info->MCR &= ~UART_MCR_RTS;
    outb(info->MCR, info->ioaddr + UART_MCR);
    }
    @@ -2075,7 +2070,7 @@ static void mxser_unthrottle(struct tty_struct *tty)
    }
    }

    - if (info->tty->termios->c_cflag & CRTSCTS) {
    + if (info->port.tty->termios->c_cflag & CRTSCTS) {
    info->MCR |= UART_MCR_RTS;
    outb(info->MCR, info->ioaddr + UART_MCR);
    }
    @@ -2106,7 +2101,7 @@ static void mxser_start(struct tty_struct *tty)
    unsigned long flags;

    spin_lock_irqsave(&info->slock, flags);
    - if (info->xmit_cnt && info->xmit_buf) {
    + if (info->xmit_cnt && info->port.xmit_buf) {
    outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
    info->IER |= UART_IER_THRI;
    outb(info->IER, info->ioaddr + UART_IER);
    @@ -2220,10 +2215,10 @@ static void mxser_hangup(struct tty_struct *tty)
    mxser_flush_buffer(tty);
    mxser_shutdown(info);
    info->event = 0;
    - info->count = 0;
    - info->flags &= ~ASYNC_NORMAL_ACTIVE;
    - info->tty = NULL;
    - wake_up_interruptible(&info->open_wait);
    + info->port.count = 0;
    + info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
    + info->port.tty = NULL;
    + wake_up_interruptible(&info->port.open_wait);
    }

    /*
    @@ -2246,7 +2241,7 @@ static void mxser_rs_break(struct tty_struct *tty, int break_state)

    static void mxser_receive_chars(struct mxser_port *port, int *status)
    {
    - struct tty_struct *tty = port->tty;
    + struct tty_struct *tty = port->port.tty;
    unsigned char ch, gdl;
    int ignored = 0;
    int cnt = 0;
    @@ -2302,7 +2297,7 @@ intr_old:
    flag = TTY_BREAK;
    port->icount.brk++;

    - if (port->flags & ASYNC_SAK)
    + if (port->port.flags & ASYNC_SAK)
    do_SAK(tty);
    } else if (*status & UART_LSR_PE) {
    flag = TTY_PARITY;
    @@ -2333,7 +2328,7 @@ intr_old:
    } while (*status & UART_LSR_DR);

    end_intr:
    - mxvar_log.rxcnt[port->tty->index] += cnt;
    + mxvar_log.rxcnt[port->port.tty->index] += cnt;
    port->mon_data.rxcnt += cnt;
    port->mon_data.up_rxcnt += cnt;

    @@ -2354,18 +2349,18 @@ static void mxser_transmit_chars(struct mxser_port *port)
    if (port->x_char) {
    outb(port->x_char, port->ioaddr + UART_TX);
    port->x_char = 0;
    - mxvar_log.txcnt[port->tty->index]++;
    + mxvar_log.txcnt[port->port.tty->index]++;
    port->mon_data.txcnt++;
    port->mon_data.up_txcnt++;
    port->icount.tx++;
    return;
    }

    - if (port->xmit_buf == NULL)
    + if (port->port.xmit_buf == NULL)
    return;

    - if ((port->xmit_cnt <= 0) || port->tty->stopped ||
    - (port->tty->hw_stopped &&
    + if ((port->xmit_cnt <= 0) || port->port.tty->stopped ||
    + (port->port.tty->hw_stopped &&
    (port->type != PORT_16550A) &&
    (!port->board->chip_flag))) {
    port->IER &= ~UART_IER_THRI;
    @@ -2376,20 +2371,20 @@ static void mxser_transmit_chars(struct mxser_port *port)
    cnt = port->xmit_cnt;
    count = port->xmit_fifo_size;
    do {
    - outb(port->xmit_buf[port->xmit_tail++],
    + outb(port->port.xmit_buf[port->xmit_tail++],
    port->ioaddr + UART_TX);
    port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE - 1);
    if (--port->xmit_cnt <= 0)
    break;
    } while (--count > 0);
    - mxvar_log.txcnt[port->tty->index] += (cnt - port->xmit_cnt);
    + mxvar_log.txcnt[port->port.tty->index] += (cnt - port->xmit_cnt);

    port->mon_data.txcnt += (cnt - port->xmit_cnt);
    port->mon_data.up_txcnt += (cnt - port->xmit_cnt);
    port->icount.tx += (cnt - port->xmit_cnt);

    if (port->xmit_cnt < WAKEUP_CHARS)
    - tty_wakeup(port->tty);
    + tty_wakeup(port->port.tty);

    if (port->xmit_cnt <= 0) {
    port->IER &= ~UART_IER_THRI;
    @@ -2440,9 +2435,9 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
    if (iir & UART_IIR_NO_INT)
    break;
    iir &= MOXA_MUST_IIR_MASK;
    - if (!port->tty ||
    - (port->flags & ASYNC_CLOSING) ||
    - !(port->flags &
    + if (!port->port.tty ||
    + (port->port.flags & ASYNC_CLOSING) ||
    + !(port->port.flags &
    ASYNC_INITIALIZED)) {
    status = inb(port->ioaddr + UART_LSR);
    outb(0x27, port->ioaddr + UART_FCR);
    @@ -2558,7 +2553,7 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,
    if (brd->chip_flag != MOXA_OTHER_UART)
    mxser_enable_must_enchance_mode(info->ioaddr);

    - info->flags = ASYNC_SHARE_IRQ;
    + info->port.flags = ASYNC_SHARE_IRQ;
    info->type = brd->uart_type;

    process_txrx_fifo(info);
    @@ -2567,7 +2562,7 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,
    info->close_delay = 5 * HZ / 10;
    info->closing_wait = 30 * HZ;
    info->normal_termios = mxvar_sdriver->init_termios;
    - init_waitqueue_head(&info->open_wait);
    + tty_port_init(&info->port);
    init_waitqueue_head(&info->delta_msr_wait);
    memset(&info->mon_data, 0, sizeof(struct mxser_mon));
    info->err_shadow = 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/

  13. [PATCH 08/70] gs: use tty_port

    From: Alan Cox

    Switch drivers using the old "generic serial" driver to use the tty_port
    structures

    Signed-off-by: Alan Cox
    ---

    drivers/char/generic_serial.c | 158 ++++++++++++++++++++--------------------
    drivers/char/rio/rio_linux.c | 20 +++--
    drivers/char/rio/riocmd.c | 10 +--
    drivers/char/rio/riointr.c | 10 +--
    drivers/char/rio/rioparam.c | 2 -
    drivers/char/rio/riotty.c | 16 ++--
    drivers/char/sx.c | 115 ++++++++++++++---------------
    include/linux/generic_serial.h | 8 +-
    8 files changed, 166 insertions(+), 173 deletions(-)


    diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
    index 252f73e..4bde737 100644
    --- a/drivers/char/generic_serial.c
    +++ b/drivers/char/generic_serial.c
    @@ -60,7 +60,7 @@ int gs_put_char(struct tty_struct * tty, unsigned char ch)

    if (!port) return 0;

    - if (! (port->flags & ASYNC_INITIALIZED)) return 0;
    + if (! (port->port.flags & ASYNC_INITIALIZED)) return 0;

    /* Take a lock on the serial tranmit buffer! */
    mutex_lock(& port->port_write_mutex);
    @@ -103,7 +103,7 @@ int gs_write(struct tty_struct * tty,

    if (!port) return 0;

    - if (! (port->flags & ASYNC_INITIALIZED))
    + if (! (port->port.flags & ASYNC_INITIALIZED))
    return 0;

    /* get exclusive "write" access to this port (problem 3) */
    @@ -141,13 +141,13 @@ int gs_write(struct tty_struct * tty,
    mutex_unlock(& port->port_write_mutex);

    gs_dprintk (GS_DEBUG_WRITE, "write: interrupts are %s\n",
    - (port->flags & GS_TX_INTEN)?"enabled": "disabled");
    + (port->port.flags & GS_TX_INTEN)?"enabled": "disabled");

    if (port->xmit_cnt &&
    !tty->stopped &&
    !tty->hw_stopped &&
    - !(port->flags & GS_TX_INTEN)) {
    - port->flags |= GS_TX_INTEN;
    + !(port->port.flags & GS_TX_INTEN)) {
    + port->port.flags |= GS_TX_INTEN;
    port->rd->enable_tx_interrupts (port);
    }
    func_exit ();
    @@ -208,7 +208,7 @@ static int gs_wait_tx_flushed (void * ptr, unsigned long timeout)
    gs_dprintk (GS_DEBUG_FLUSH, "port=%p.\n", port);
    if (port) {
    gs_dprintk (GS_DEBUG_FLUSH, "xmit_cnt=%x, xmit_buf=%p, tty=%p.\n",
    - port->xmit_cnt, port->xmit_buf, port->tty);
    + port->xmit_cnt, port->xmit_buf, port->port.tty);
    }

    if (!port || port->xmit_cnt < 0 || !port->xmit_buf) {
    @@ -217,7 +217,7 @@ static int gs_wait_tx_flushed (void * ptr, unsigned long timeout)
    return -EINVAL; /* This is an error which we don't know how to handle. */
    }

    - rcib = gs_real_chars_in_buffer(port->tty);
    + rcib = gs_real_chars_in_buffer(port->port.tty);

    if(rcib <= 0) {
    gs_dprintk (GS_DEBUG_FLUSH, "nothing to wait for.\n");
    @@ -236,7 +236,7 @@ static int gs_wait_tx_flushed (void * ptr, unsigned long timeout)

    /* the expression is actually jiffies < end_jiffies, but that won't
    work around the wraparound. Tricky eh? */
    - while ((charsleft = gs_real_chars_in_buffer (port->tty)) &&
    + while ((charsleft = gs_real_chars_in_buffer (port->port.tty)) &&
    time_after (end_jiffies, jiffies)) {
    /* Units check:
    chars * (bits/char) * (jiffies /sec) / (bits/sec) = jiffies!
    @@ -309,7 +309,7 @@ void gs_flush_chars(struct tty_struct * tty)
    }

    /* Beats me -- REW */
    - port->flags |= GS_TX_INTEN;
    + port->port.flags |= GS_TX_INTEN;
    port->rd->enable_tx_interrupts (port);
    func_exit ();
    }
    @@ -329,8 +329,8 @@ void gs_stop(struct tty_struct * tty)

    if (port->xmit_cnt &&
    port->xmit_buf &&
    - (port->flags & GS_TX_INTEN) ) {
    - port->flags &= ~GS_TX_INTEN;
    + (port->port.flags & GS_TX_INTEN) ) {
    + port->port.flags &= ~GS_TX_INTEN;
    port->rd->disable_tx_interrupts (port);
    }
    func_exit ();
    @@ -349,8 +349,8 @@ void gs_start(struct tty_struct * tty)

    if (port->xmit_cnt &&
    port->xmit_buf &&
    - !(port->flags & GS_TX_INTEN) ) {
    - port->flags |= GS_TX_INTEN;
    + !(port->port.flags & GS_TX_INTEN) ) {
    + port->port.flags |= GS_TX_INTEN;
    port->rd->enable_tx_interrupts (port);
    }
    func_exit ();
    @@ -365,7 +365,7 @@ static void gs_shutdown_port (struct gs_port *port)

    if (!port) return;

    - if (!(port->flags & ASYNC_INITIALIZED))
    + if (!(port->port.flags & ASYNC_INITIALIZED))
    return;

    spin_lock_irqsave(&port->driver_lock, flags);
    @@ -375,12 +375,12 @@ static void gs_shutdown_port (struct gs_port *port)
    port->xmit_buf = NULL;
    }

    - if (port->tty)
    - set_bit(TTY_IO_ERROR, &port->tty->flags);
    + if (port->port.tty)
    + set_bit(TTY_IO_ERROR, &port->port.tty->flags);

    port->rd->shutdown_port (port);

    - port->flags &= ~ASYNC_INITIALIZED;
    + port->port.flags &= ~ASYNC_INITIALIZED;
    spin_unlock_irqrestore(&port->driver_lock, flags);

    func_exit();
    @@ -396,16 +396,16 @@ void gs_hangup(struct tty_struct *tty)
    if (!tty) return;

    port = tty->driver_data;
    - tty = port->tty;
    + tty = port->port.tty;
    if (!tty)
    return;

    gs_shutdown_port (port);
    - port->flags &= ~(ASYNC_NORMAL_ACTIVE|GS_ACTIVE);
    - port->tty = NULL;
    - port->count = 0;
    + port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|GS_ACTIVE);
    + port->port.tty = NULL;
    + port->port.count = 0;

    - wake_up_interruptible(&port->open_wait);
    + wake_up_interruptible(&port->port.open_wait);
    func_exit ();
    }

    @@ -424,7 +424,7 @@ int gs_block_til_ready(void *port_, struct file * filp)

    if (!port) return 0;

    - tty = port->tty;
    + tty = port->port.tty;

    if (!tty) return 0;

    @@ -433,9 +433,9 @@ int gs_block_til_ready(void *port_, struct file * filp)
    * If the device is in the middle of being closed, then block
    * until it's done, and then try again.
    */
    - if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
    - interruptible_sleep_on(&port->close_wait);
    - if (port->flags & ASYNC_HUP_NOTIFY)
    + if (tty_hung_up_p(filp) || port->port.flags & ASYNC_CLOSING) {
    + interruptible_sleep_on(&port->port.close_wait);
    + if (port->port.flags & ASYNC_HUP_NOTIFY)
    return -EAGAIN;
    else
    return -ERESTARTSYS;
    @@ -449,7 +449,7 @@ int gs_block_til_ready(void *port_, struct file * filp)
    */
    if ((filp->f_flags & O_NONBLOCK) ||
    (tty->flags & (1 << TTY_IO_ERROR))) {
    - port->flags |= ASYNC_NORMAL_ACTIVE;
    + port->port.flags |= ASYNC_NORMAL_ACTIVE;
    return 0;
    }

    @@ -461,34 +461,34 @@ int gs_block_til_ready(void *port_, struct file * filp)
    /*
    * Block waiting for the carrier detect and the line to become
    * free (i.e., not in use by the callout). While we are in
    - * this loop, port->count is dropped by one, so that
    + * this loop, port->port.count is dropped by one, so that
    * rs_close() knows when to free things. We restore it upon
    * exit, either normal or abnormal.
    */
    retval = 0;

    - add_wait_queue(&port->open_wait, &wait);
    + add_wait_queue(&port->port.open_wait, &wait);

    gs_dprintk (GS_DEBUG_BTR, "after add waitq.\n");
    spin_lock_irqsave(&port->driver_lock, flags);
    if (!tty_hung_up_p(filp)) {
    - port->count--;
    + port->port.count--;
    }
    spin_unlock_irqrestore(&port->driver_lock, flags);
    - port->blocked_open++;
    + port->port.blocked_open++;
    while (1) {
    CD = port->rd->get_CD (port);
    gs_dprintk (GS_DEBUG_BTR, "CD is now %d.\n", CD);
    set_current_state (TASK_INTERRUPTIBLE);
    if (tty_hung_up_p(filp) ||
    - !(port->flags & ASYNC_INITIALIZED)) {
    - if (port->flags & ASYNC_HUP_NOTIFY)
    + !(port->port.flags & ASYNC_INITIALIZED)) {
    + if (port->port.flags & ASYNC_HUP_NOTIFY)
    retval = -EAGAIN;
    else
    retval = -ERESTARTSYS;
    break;
    }
    - if (!(port->flags & ASYNC_CLOSING) &&
    + if (!(port->port.flags & ASYNC_CLOSING) &&
    (do_clocal || CD))
    break;
    gs_dprintk (GS_DEBUG_BTR, "signal_pending is now: %d (%lx)\n",
    @@ -500,17 +500,17 @@ int gs_block_til_ready(void *port_, struct file * filp)
    schedule();
    }
    gs_dprintk (GS_DEBUG_BTR, "Got out of the loop. (%d)\n",
    - port->blocked_open);
    + port->port.blocked_open);
    set_current_state (TASK_RUNNING);
    - remove_wait_queue(&port->open_wait, &wait);
    + remove_wait_queue(&port->port.open_wait, &wait);
    if (!tty_hung_up_p(filp)) {
    - port->count++;
    + port->port.count++;
    }
    - port->blocked_open--;
    + port->port.blocked_open--;
    if (retval)
    return retval;

    - port->flags |= ASYNC_NORMAL_ACTIVE;
    + port->port.flags |= ASYNC_NORMAL_ACTIVE;
    func_exit ();
    return 0;
    }
    @@ -529,10 +529,10 @@ void gs_close(struct tty_struct * tty, struct file * filp)

    if (!port) return;

    - if (!port->tty) {
    + if (!port->port.tty) {
    /* This seems to happen when this is called from vhangup. */
    - gs_dprintk (GS_DEBUG_CLOSE, "gs: Odd: port->tty is NULL\n");
    - port->tty = tty;
    + gs_dprintk (GS_DEBUG_CLOSE, "gs: Odd: port->port.tty is NULL\n");
    + port->port.tty = tty;
    }

    spin_lock_irqsave(&port->driver_lock, flags);
    @@ -545,23 +545,23 @@ void gs_close(struct tty_struct * tty, struct file * filp)
    return;
    }

    - if ((tty->count == 1) && (port->count != 1)) {
    + if ((tty->count == 1) && (port->port.count != 1)) {
    printk(KERN_ERR "gs: gs_close port %p: bad port count;"
    - " tty->count is 1, port count is %d\n", port, port->count);
    - port->count = 1;
    + " tty->count is 1, port count is %d\n", port, port->port.count);
    + port->port.count = 1;
    }
    - if (--port->count < 0) {
    - printk(KERN_ERR "gs: gs_close port %p: bad port count: %d\n", port, port->count);
    - port->count = 0;
    + if (--port->port.count < 0) {
    + printk(KERN_ERR "gs: gs_close port %p: bad port count: %d\n", port, port->port.count);
    + port->port.count = 0;
    }

    - if (port->count) {
    - gs_dprintk(GS_DEBUG_CLOSE, "gs_close port %p: count: %d\n", port, port->count);
    + if (port->port.count) {
    + gs_dprintk(GS_DEBUG_CLOSE, "gs_close port %p: count: %d\n", port, port->port.count);
    spin_unlock_irqrestore(&port->driver_lock, flags);
    func_exit ();
    return;
    }
    - port->flags |= ASYNC_CLOSING;
    + port->port.flags |= ASYNC_CLOSING;

    /*
    * Now we wait for the transmit buffer to clear; and we notify
    @@ -585,7 +585,7 @@ void gs_close(struct tty_struct * tty, struct file * filp)
    if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
    gs_wait_tx_flushed (port, port->closing_wait);

    - port->flags &= ~GS_ACTIVE;
    + port->port.flags &= ~GS_ACTIVE;

    gs_flush_buffer(tty);

    @@ -595,18 +595,18 @@ void gs_close(struct tty_struct * tty, struct file * filp)
    port->event = 0;
    port->rd->close (port);
    port->rd->shutdown_port (port);
    - port->tty = NULL;
    + port->port.tty = NULL;

    - if (port->blocked_open) {
    + if (port->port.blocked_open) {
    if (port->close_delay) {
    spin_unlock_irqrestore(&port->driver_lock, flags);
    msleep_interruptible(jiffies_to_msecs(port->close_delay));
    spin_lock_irqsave(&port->driver_lock, flags);
    }
    - wake_up_interruptible(&port->open_wait);
    + wake_up_interruptible(&port->port.open_wait);
    }
    - port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING | ASYNC_INITIALIZED);
    - wake_up_interruptible(&port->close_wait);
    + port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING | ASYNC_INITIALIZED);
    + wake_up_interruptible(&port->port.close_wait);

    func_exit ();
    }
    @@ -626,10 +626,10 @@ void gs_set_termios (struct tty_struct * tty,
    port = tty->driver_data;

    if (!port) return;
    - if (!port->tty) {
    + if (!port->port.tty) {
    /* This seems to happen when this is called after gs_close. */
    - gs_dprintk (GS_DEBUG_TERMIOS, "gs: Odd: port->tty is NULL\n");
    - port->tty = tty;
    + gs_dprintk (GS_DEBUG_TERMIOS, "gs: Odd: port->port.tty is NULL\n");
    + port->port.tty = tty;
    }


    @@ -651,15 +651,15 @@ void gs_set_termios (struct tty_struct * tty,
    baudrate = tty_get_baud_rate(tty);

    if ((tiosp->c_cflag & CBAUD) == B38400) {
    - if ( (port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
    + if ( (port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
    baudrate = 57600;
    - else if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
    + else if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
    baudrate = 115200;
    - else if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
    + else if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
    baudrate = 230400;
    - else if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
    + else if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
    baudrate = 460800;
    - else if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)
    + else if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)
    baudrate = (port->baud_base / port->custom_divisor);
    }

    @@ -715,7 +715,7 @@ int gs_init_port(struct gs_port *port)

    func_enter ();

    - if (port->flags & ASYNC_INITIALIZED) {
    + if (port->port.flags & ASYNC_INITIALIZED) {
    func_exit ();
    return 0;
    }
    @@ -737,15 +737,15 @@ int gs_init_port(struct gs_port *port)
    }

    spin_lock_irqsave (&port->driver_lock, flags);
    - if (port->tty)
    - clear_bit(TTY_IO_ERROR, &port->tty->flags);
    + if (port->port.tty)
    + clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
    mutex_init(&port->port_write_mutex);
    port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
    spin_unlock_irqrestore(&port->driver_lock, flags);
    - gs_set_termios(port->tty, NULL);
    + gs_set_termios(port->port.tty, NULL);
    spin_lock_irqsave (&port->driver_lock, flags);
    - port->flags |= ASYNC_INITIALIZED;
    - port->flags &= ~GS_TX_INTEN;
    + port->port.flags |= ASYNC_INITIALIZED;
    + port->port.flags &= ~GS_TX_INTEN;

    spin_unlock_irqrestore(&port->driver_lock, flags);
    func_exit ();
    @@ -764,11 +764,11 @@ int gs_setserial(struct gs_port *port, struct serial_struct __user *sp)
    if ((sio.baud_base != port->baud_base) ||
    (sio.close_delay != port->close_delay) ||
    ((sio.flags & ~ASYNC_USR_MASK) !=
    - (port->flags & ~ASYNC_USR_MASK)))
    + (port->port.flags & ~ASYNC_USR_MASK)))
    return(-EPERM);
    }

    - port->flags = (port->flags & ~ASYNC_USR_MASK) |
    + port->port.flags = (port->port.flags & ~ASYNC_USR_MASK) |
    (sio.flags & ASYNC_USR_MASK);

    port->baud_base = sio.baud_base;
    @@ -776,7 +776,7 @@ int gs_setserial(struct gs_port *port, struct serial_struct __user *sp)
    port->closing_wait = sio.closing_wait;
    port->custom_divisor = sio.custom_divisor;

    - gs_set_termios (port->tty, NULL);
    + gs_set_termios (port->port.tty, NULL);

    return 0;
    }
    @@ -793,7 +793,7 @@ int gs_getserial(struct gs_port *port, struct serial_struct __user *sp)
    struct serial_struct sio;

    memset(&sio, 0, sizeof(struct serial_struct));
    - sio.flags = port->flags;
    + sio.flags = port->port.flags;
    sio.baud_base = port->baud_base;
    sio.close_delay = port->close_delay;
    sio.closing_wait = port->closing_wait;
    @@ -821,10 +821,10 @@ void gs_got_break(struct gs_port *port)
    {
    func_enter ();

    - tty_insert_flip_char(port->tty, 0, TTY_BREAK);
    - tty_schedule_flip(port->tty);
    - if (port->flags & ASYNC_SAK) {
    - do_SAK (port->tty);
    + tty_insert_flip_char(port->port.tty, 0, TTY_BREAK);
    + tty_schedule_flip(port->port.tty);
    + if (port->port.flags & ASYNC_SAK) {
    + do_SAK (port->port.tty);
    }

    func_exit ();
    diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
    index e49e6e6..0cdfee1 100644
    --- a/drivers/char/rio/rio_linux.c
    +++ b/drivers/char/rio/rio_linux.c
    @@ -431,7 +431,7 @@ static void rio_disable_tx_interrupts(void *ptr)
    {
    func_enter();

    - /* port->gs.flags &= ~GS_TX_INTEN; */
    + /* port->gs.port.flags &= ~GS_TX_INTEN; */

    func_exit();
    }
    @@ -455,7 +455,7 @@ static void rio_enable_tx_interrupts(void *ptr)
    * In general we cannot count on "tx empty" interrupts, although
    * the interrupt routine seems to be able to tell the difference.
    */
    - PortP->gs.flags &= ~GS_TX_INTEN;
    + PortP->gs.port.flags &= ~GS_TX_INTEN;

    func_exit();
    }
    @@ -510,7 +510,7 @@ static void rio_shutdown_port(void *ptr)
    func_enter();

    PortP = (struct Port *) ptr;
    - PortP->gs.tty = NULL;
    + PortP->gs.port.tty = NULL;
    func_exit();
    }

    @@ -529,7 +529,7 @@ static void rio_hungup(void *ptr)
    func_enter();

    PortP = (struct Port *) ptr;
    - PortP->gs.tty = NULL;
    + PortP->gs.port.tty = NULL;

    func_exit();
    }
    @@ -549,12 +549,12 @@ static void rio_close(void *ptr)

    riotclose(ptr);

    - if (PortP->gs.count) {
    - printk(KERN_ERR "WARNING port count:%d\n", PortP->gs.count);
    - PortP->gs.count = 0;
    + if (PortP->gs.port.count) {
    + printk(KERN_ERR "WARNING port count:%d\n", PortP->gs.port.count);
    + PortP->gs.port.count = 0;
    }

    - PortP->gs.tty = NULL;
    + PortP->gs.port.tty = NULL;
    func_exit();
    }

    @@ -849,8 +849,8 @@ static int rio_init_datastructures(void)
    /*
    * Initializing wait queue
    */
    - init_waitqueue_head(&port->gs.open_wait);
    - init_waitqueue_head(&port->gs.close_wait);
    + init_waitqueue_head(&port->gs.port.open_wait);
    + init_waitqueue_head(&port->gs.port.close_wait);
    }
    #else
    /* We could postpone initializing them to when they are configured. */
    diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
    index 391f0b4..01f2654 100644
    --- a/drivers/char/rio/riocmd.c
    +++ b/drivers/char/rio/riocmd.c
    @@ -484,12 +484,12 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc
    ** If the device is a modem, then check the modem
    ** carrier.
    */
    - if (PortP->gs.tty == NULL)
    + if (PortP->gs.port.tty == NULL)
    break;
    - if (PortP->gs.tty->termios == NULL)
    + if (PortP->gs.port.tty->termios == NULL)
    break;

    - if (!(PortP->gs.tty->termios->c_cflag & CLOCAL) && ((PortP->State & (RIO_MOPEN | RIO_WOPEN)))) {
    + if (!(PortP->gs.port.tty->termios->c_cflag & CLOCAL) && ((PortP->State & (RIO_MOPEN | RIO_WOPEN)))) {

    rio_dprintk(RIO_DEBUG_CMD, "Is there a Carrier?\n");
    /*
    @@ -506,7 +506,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc
    ** wakeup anyone in WOPEN
    */
    if (PortP->State & (PORT_ISOPEN | RIO_WOPEN))
    - wake_up_interruptible(&PortP->gs.open_wait);
    + wake_up_interruptible(&PortP->gs.port.open_wait);
    }
    } else {
    /*
    @@ -514,7 +514,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc
    */
    if (PortP->State & RIO_CARR_ON) {
    if (PortP->State & (PORT_ISOPEN | RIO_WOPEN | RIO_MOPEN))
    - tty_hangup(PortP->gs.tty);
    + tty_hangup(PortP->gs.port.tty);
    PortP->State &= ~RIO_CARR_ON;
    rio_dprintk(RIO_DEBUG_CMD, "Carrirer just went down\n");
    }
    diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c
    index 11c7987..71f8760 100644
    --- a/drivers/char/rio/riointr.c
    +++ b/drivers/char/rio/riointr.c
    @@ -102,7 +102,7 @@ void RIOTxEnable(char *en)

    PortP = (struct Port *) en;
    p = (struct rio_info *) PortP->p;
    - tty = PortP->gs.tty;
    + tty = PortP->gs.port.tty;


    rio_dprintk(RIO_DEBUG_INTR, "tx port %d: %d chars queued.\n", PortP->PortNum, PortP->gs.xmit_cnt);
    @@ -158,7 +158,7 @@ void RIOTxEnable(char *en)
    rio_spin_unlock_irqrestore(&PortP->portSem, flags);

    if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars + 2 * PKT_MAX_DATA_LEN))
    - tty_wakeup(PortP->gs.tty);
    + tty_wakeup(PortP->gs.port.tty);

    }

    @@ -241,7 +241,7 @@ void RIOServiceHost(struct rio_info *p, struct Host *HostP)
    ** find corresponding tty structure. The process of mapping
    ** the ports puts these here.
    */
    - ttyP = PortP->gs.tty;
    + ttyP = PortP->gs.port.tty;

    /*
    ** Lock the port before we begin working on it.
    @@ -335,7 +335,7 @@ void RIOServiceHost(struct rio_info *p, struct Host *HostP)
    ** find corresponding tty structure. The process of mapping
    ** the ports puts these here.
    */
    - ttyP = PortP->gs.tty;
    + ttyP = PortP->gs.port.tty;
    /* If ttyP is NULL, the port is getting closed. Forget about it. */
    if (!ttyP) {
    rio_dprintk(RIO_DEBUG_INTR, "no tty, so skipping.\n");
    @@ -542,7 +542,7 @@ static void RIOReceive(struct rio_info *p, struct Port *PortP)

    intCount++;

    - TtyP = PortP->gs.tty;
    + TtyP = PortP->gs.port.tty;
    if (!TtyP) {
    rio_dprintk(RIO_DEBUG_INTR, "RIOReceive: tty is null. \n");
    return;
    diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c
    index 447ca34..d687c17 100644
    --- a/drivers/char/rio/rioparam.c
    +++ b/drivers/char/rio/rioparam.c
    @@ -160,7 +160,7 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)

    func_enter();

    - TtyP = PortP->gs.tty;
    + TtyP = PortP->gs.port.tty;

    rio_dprintk(RIO_DEBUG_PARAM, "RIOParam: Port:%d cmd:%d Modem:%d SleepFlag:%d Mapped: %d, tty=%p\n", PortP->PortNum, cmd, Modem, SleepFlag, PortP->Mapped, TtyP);

    diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
    index 95a88a4..2fb49e8 100644
    --- a/drivers/char/rio/riotty.c
    +++ b/drivers/char/rio/riotty.c
    @@ -140,14 +140,14 @@ int riotopen(struct tty_struct *tty, struct file *filp)

    tty->driver_data = PortP;

    - PortP->gs.tty = tty;
    - PortP->gs.count++;
    + PortP->gs.port.tty = tty;
    + PortP->gs.port.count++;

    rio_dprintk(RIO_DEBUG_TTY, "%d bytes in tx buffer\n", PortP->gs.xmit_cnt);

    retval = gs_init_port(&PortP->gs);
    if (retval) {
    - PortP->gs.count--;
    + PortP->gs.port.count--;
    return -ENXIO;
    }
    /*
    @@ -293,7 +293,7 @@ int riotopen(struct tty_struct *tty, struct file *filp)
    ** insert test for carrier here. -- ???
    ** I already see that test here. What's the deal? -- REW
    */
    - if ((PortP->gs.tty->termios->c_cflag & CLOCAL) ||
    + if ((PortP->gs.port.tty->termios->c_cflag & CLOCAL) ||
    (PortP->ModemState & RIOC_MSVR1_CD)) {
    rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort);
    /*
    @@ -301,16 +301,16 @@ int riotopen(struct tty_struct *tty, struct file *filp)
    wakeup((caddr_t) &tp->tm.c_canq);
    */
    PortP->State |= RIO_CARR_ON;
    - wake_up_interruptible(&PortP->gs.open_wait);
    + wake_up_interruptible(&PortP->gs.port.open_wait);
    } else { /* no carrier - wait for DCD */
    /*
    - while (!(PortP->gs.tty->termios->c_state & CARR_ON) &&
    + while (!(PortP->gs.port.tty->termios->c_state & CARR_ON) &&
    !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted )
    */
    while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) {
    rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort);
    /*
    - PortP->gs.tty->termios->c_state |= WOPEN;
    + PortP->gs.port.tty->termios->c_state |= WOPEN;
    */
    PortP->State |= RIO_WOPEN;
    rio_spin_unlock_irqrestore(&PortP->portSem, flags);
    @@ -380,7 +380,7 @@ int riotclose(void *ptr)
    /* PortP = p->RIOPortp[SysPort]; */
    rio_dprintk(RIO_DEBUG_TTY, "Port is at address %p\n", PortP);
    /* tp = PortP->TtyP; *//* Get tty */
    - tty = PortP->gs.tty;
    + tty = PortP->gs.port.tty;
    rio_dprintk(RIO_DEBUG_TTY, "TTY is at address %p\n", tty);

    if (PortP->gs.closing_wait)
    diff --git a/drivers/char/sx.c b/drivers/char/sx.c
    index b1a7a8c..b1239ee 100644
    --- a/drivers/char/sx.c
    +++ b/drivers/char/sx.c
    @@ -1,4 +1,3 @@
    -
    /* sx.c -- driver for the Specialix SX series cards.
    *
    * This driver will also support the older SI, and XIO cards.
    @@ -930,7 +929,7 @@ static int sx_set_real_termios(void *ptr)

    func_enter2();

    - if (!port->gs.tty)
    + if (!port->gs.port.tty)
    return 0;

    /* What is this doing here? -- REW
    @@ -941,19 +940,19 @@ static int sx_set_real_termios(void *ptr)

    sx_set_baud(port);

    -#define CFLAG port->gs.tty->termios->c_cflag
    +#define CFLAG port->gs.port.tty->termios->c_cflag
    sx_write_channel_byte(port, hi_mr1,
    - (C_PARENB(port->gs.tty) ? MR1_WITH : MR1_NONE) |
    - (C_PARODD(port->gs.tty) ? MR1_ODD : MR1_EVEN) |
    - (C_CRTSCTS(port->gs.tty) ? MR1_RTS_RXFLOW : 0) |
    + (C_PARENB(port->gs.port.tty) ? MR1_WITH : MR1_NONE) |
    + (C_PARODD(port->gs.port.tty) ? MR1_ODD : MR1_EVEN) |
    + (C_CRTSCTS(port->gs.port.tty) ? MR1_RTS_RXFLOW : 0) |
    (((CFLAG & CSIZE) == CS8) ? MR1_8_BITS : 0) |
    (((CFLAG & CSIZE) == CS7) ? MR1_7_BITS : 0) |
    (((CFLAG & CSIZE) == CS6) ? MR1_6_BITS : 0) |
    (((CFLAG & CSIZE) == CS5) ? MR1_5_BITS : 0));

    sx_write_channel_byte(port, hi_mr2,
    - (C_CRTSCTS(port->gs.tty) ? MR2_CTS_TXFLOW : 0) |
    - (C_CSTOPB(port->gs.tty) ? MR2_2_STOP :
    + (C_CRTSCTS(port->gs.port.tty) ? MR2_CTS_TXFLOW : 0) |
    + (C_CSTOPB(port->gs.port.tty) ? MR2_2_STOP :
    MR2_1_STOP));

    switch (CFLAG & CSIZE) {
    @@ -976,44 +975,44 @@ static int sx_set_real_termios(void *ptr)
    }

    sx_write_channel_byte(port, hi_prtcl,
    - (I_IXON(port->gs.tty) ? SP_TXEN : 0) |
    - (I_IXOFF(port->gs.tty) ? SP_RXEN : 0) |
    - (I_IXANY(port->gs.tty) ? SP_TANY : 0) | SP_DCEN);
    + (I_IXON(port->gs.port.tty) ? SP_TXEN : 0) |
    + (I_IXOFF(port->gs.port.tty) ? SP_RXEN : 0) |
    + (I_IXANY(port->gs.port.tty) ? SP_TANY : 0) | SP_DCEN);

    sx_write_channel_byte(port, hi_break,
    - (I_IGNBRK(port->gs.tty) ? BR_IGN : 0 |
    - I_BRKINT(port->gs.tty) ? BR_INT : 0));
    + (I_IGNBRK(port->gs.port.tty) ? BR_IGN : 0 |
    + I_BRKINT(port->gs.port.tty) ? BR_INT : 0));

    - sx_write_channel_byte(port, hi_txon, START_CHAR(port->gs.tty));
    - sx_write_channel_byte(port, hi_rxon, START_CHAR(port->gs.tty));
    - sx_write_channel_byte(port, hi_txoff, STOP_CHAR(port->gs.tty));
    - sx_write_channel_byte(port, hi_rxoff, STOP_CHAR(port->gs.tty));
    + sx_write_channel_byte(port, hi_txon, START_CHAR(port->gs.port.tty));
    + sx_write_channel_byte(port, hi_rxon, START_CHAR(port->gs.port.tty));
    + sx_write_channel_byte(port, hi_txoff, STOP_CHAR(port->gs.port.tty));
    + sx_write_channel_byte(port, hi_rxoff, STOP_CHAR(port->gs.port.tty));

    sx_reconfigure_port(port);

    /* Tell line discipline whether we will do input cooking */
    - if (I_OTHER(port->gs.tty)) {
    - clear_bit(TTY_HW_COOK_IN, &port->gs.tty->flags);
    + if (I_OTHER(port->gs.port.tty)) {
    + clear_bit(TTY_HW_COOK_IN, &port->gs.port.tty->flags);
    } else {
    - set_bit(TTY_HW_COOK_IN, &port->gs.tty->flags);
    + set_bit(TTY_HW_COOK_IN, &port->gs.port.tty->flags);
    }
    sx_dprintk(SX_DEBUG_TERMIOS, "iflags: %x(%d) ",
    - (unsigned int)port->gs.tty->termios->c_iflag,
    - I_OTHER(port->gs.tty));
    + (unsigned int)port->gs.port.tty->termios->c_iflag,
    + I_OTHER(port->gs.port.tty));

    /* Tell line discipline whether we will do output cooking.
    * If OPOST is set and no other output flags are set then we can do output
    * processing. Even if only *one* other flag in the O_OTHER group is set
    * we do cooking in software.
    */
    - if (O_OPOST(port->gs.tty) && !O_OTHER(port->gs.tty)) {
    - set_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags);
    + if (O_OPOST(port->gs.port.tty) && !O_OTHER(port->gs.port.tty)) {
    + set_bit(TTY_HW_COOK_OUT, &port->gs.port.tty->flags);
    } else {
    - clear_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags);
    + clear_bit(TTY_HW_COOK_OUT, &port->gs.port.tty->flags);
    }
    sx_dprintk(SX_DEBUG_TERMIOS, "oflags: %x(%d)\n",
    - (unsigned int)port->gs.tty->termios->c_oflag,
    - O_OTHER(port->gs.tty));
    + (unsigned int)port->gs.port.tty->termios->c_oflag,
    + O_OTHER(port->gs.port.tty));
    /* port->c_dcd = sx_get_CD (port); */
    func_exit();
    return 0;
    @@ -1102,8 +1101,8 @@ static void sx_transmit_chars(struct sx_port *port)
    sx_disable_tx_interrupts(port);
    }

    - if ((port->gs.xmit_cnt <= port->gs.wakeup_chars) && port->gs.tty) {
    - tty_wakeup(port->gs.tty);
    + if ((port->gs.xmit_cnt <= port->gs.wakeup_chars) && port->gs.port.tty) {
    + tty_wakeup(port->gs.port.tty);
    sx_dprintk(SX_DEBUG_TRANSMIT, "Waking up.... ldisc (%d)....\n",
    port->gs.wakeup_chars);
    }
    @@ -1126,7 +1125,7 @@ static inline void sx_receive_chars(struct sx_port *port)
    unsigned char *rp;

    func_enter2();
    - tty = port->gs.tty;
    + tty = port->gs.port.tty;
    while (1) {
    rx_op = sx_read_channel_byte(port, hi_rxopos);
    c = (sx_read_channel_byte(port, hi_rxipos) - rx_op) & 0xff;
    @@ -1211,12 +1210,12 @@ static inline void sx_check_modem_signals(struct sx_port *port)
    /* DCD went UP */
    if ((sx_read_channel_byte(port, hi_hstat) !=
    HS_IDLE_CLOSED) &&
    - !(port->gs.tty->termios->
    + !(port->gs.port.tty->termios->
    c_cflag & CLOCAL)) {
    /* Are we blocking in open? */
    sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD "
    "active, unblocking open\n");
    - wake_up_interruptible(&port->gs.
    + wake_up_interruptible(&port->gs.port.
    open_wait);
    } else {
    sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD "
    @@ -1224,10 +1223,10 @@ static inline void sx_check_modem_signals(struct sx_port *port)
    }
    } else {
    /* DCD went down! */
    - if (!(port->gs.tty->termios->c_cflag & CLOCAL)){
    + if (!(port->gs.port.tty->termios->c_cflag & CLOCAL)){
    sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD "
    "dropped. hanging up....\n");
    - tty_hangup(port->gs.tty);
    + tty_hangup(port->gs.port.tty);
    } else {
    sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD "
    "dropped. ignoring.\n");
    @@ -1325,7 +1324,7 @@ static irqreturn_t sx_interrupt(int irq, void *ptr)

    for (i = 0; i < board->nports; i++) {
    port = &board->ports[i];
    - if (port->gs.flags & GS_ACTIVE) {
    + if (port->gs.port.flags & GS_ACTIVE) {
    if (sx_read_channel_byte(port, hi_state)) {
    sx_dprintk(SX_DEBUG_INTERRUPTS, "Port %d: "
    "modem signal change?... \n",i);
    @@ -1334,7 +1333,7 @@ static irqreturn_t sx_interrupt(int irq, void *ptr)
    if (port->gs.xmit_cnt) {
    sx_transmit_chars(port);
    }
    - if (!(port->gs.flags & SX_RX_THROTTLE)) {
    + if (!(port->gs.port.flags & SX_RX_THROTTLE)) {
    sx_receive_chars(port);
    }
    }
    @@ -1373,7 +1372,7 @@ static void sx_disable_tx_interrupts(void *ptr)
    struct sx_port *port = ptr;
    func_enter2();

    - port->gs.flags &= ~GS_TX_INTEN;
    + port->gs.port.flags &= ~GS_TX_INTEN;

    func_exit();
    }
    @@ -1394,7 +1393,7 @@ static void sx_enable_tx_interrupts(void *ptr)

    /* XXX Must be "HIGH_WATER" for SI card according to doc. */
    if (data_in_buffer < LOW_WATER)
    - port->gs.flags &= ~GS_TX_INTEN;
    + port->gs.port.flags &= ~GS_TX_INTEN;

    func_exit();
    }
    @@ -1442,8 +1441,8 @@ static void sx_shutdown_port(void *ptr)

    func_enter();

    - port->gs.flags &= ~GS_ACTIVE;
    - if (port->gs.tty && (port->gs.tty->termios->c_cflag & HUPCL)) {
    + port->gs.port.flags &= ~GS_ACTIVE;
    + if (port->gs.port.tty && (port->gs.port.tty->termios->c_cflag & HUPCL)) {
    sx_setsignals(port, 0, 0);
    sx_reconfigure_port(port);
    }
    @@ -1485,8 +1484,8 @@ static int sx_open(struct tty_struct *tty, struct file *filp)
    spin_lock_irqsave(&port->gs.driver_lock, flags);

    tty->driver_data = port;
    - port->gs.tty = tty;
    - port->gs.count++;
    + port->gs.port.tty = tty;
    + port->gs.port.count++;
    spin_unlock_irqrestore(&port->gs.driver_lock, flags);

    sx_dprintk(SX_DEBUG_OPEN, "starting port\n");
    @@ -1497,12 +1496,12 @@ static int sx_open(struct tty_struct *tty, struct file *filp)
    retval = gs_init_port(&port->gs);
    sx_dprintk(SX_DEBUG_OPEN, "done gs_init\n");
    if (retval) {
    - port->gs.count--;
    + port->gs.port.count--;
    return retval;
    }

    - port->gs.flags |= GS_ACTIVE;
    - if (port->gs.count <= 1)
    + port->gs.port.flags |= GS_ACTIVE;
    + if (port->gs.port.count <= 1)
    sx_setsignals(port, 1, 1);

    #if 0
    @@ -1513,12 +1512,12 @@ static int sx_open(struct tty_struct *tty, struct file *filp)
    my_hd_io(port->board->base + port->ch_base, sizeof(*port));
    #endif

    - if (port->gs.count <= 1) {
    + if (port->gs.port.count <= 1) {
    if (sx_send_command(port, HS_LOPEN, -1, HS_IDLE_OPEN) != 1) {
    printk(KERN_ERR "sx: Card didn't respond to LOPEN "
    "command.\n");
    spin_lock_irqsave(&port->gs.driver_lock, flags);
    - port->gs.count--;
    + port->gs.port.count--;
    spin_unlock_irqrestore(&port->gs.driver_lock, flags);
    return -EIO;
    }
    @@ -1526,11 +1525,11 @@ static int sx_open(struct tty_struct *tty, struct file *filp)

    retval = gs_block_til_ready(port, filp);
    sx_dprintk(SX_DEBUG_OPEN, "Block til ready returned %d. Count=%d\n",
    - retval, port->gs.count);
    + retval, port->gs.port.count);

    if (retval) {
    /*
    - * Don't lower gs.count here because sx_close() will be called later
    + * Don't lower gs.port.count here because sx_close() will be called later
    */

    return retval;
    @@ -1571,14 +1570,14 @@ static void sx_close(void *ptr)
    }

    sx_dprintk(SX_DEBUG_CLOSE, "waited %d jiffies for close. count=%d\n",
    - 5 * HZ - to - 1, port->gs.count);
    + 5 * HZ - to - 1, port->gs.port.count);

    - if (port->gs.count) {
    + if (port->gs.port.count) {
    sx_dprintk(SX_DEBUG_CLOSE, "WARNING port count:%d\n",
    - port->gs.count);
    + port->gs.port.count);
    /*printk("%s SETTING port count to zero: %p count: %d\n",
    - __func__, port, port->gs.count);
    - port->gs.count = 0;*/
    + __func__, port, port->gs.port.count);
    + port->gs.port.count = 0;*/
    }

    func_exit();
    @@ -1939,7 +1938,7 @@ static void sx_throttle(struct tty_struct *tty)
    * control then throttle the port.
    */
    if ((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty))) {
    - port->gs.flags |= SX_RX_THROTTLE;
    + port->gs.port.flags |= SX_RX_THROTTLE;
    }
    func_exit();
    }
    @@ -1953,7 +1952,7 @@ static void sx_unthrottle(struct tty_struct *tty)
    * this port in case we disabled flow control while the port
    * was throttled
    */
    - port->gs.flags &= ~SX_RX_THROTTLE;
    + port->gs.port.flags &= ~SX_RX_THROTTLE;
    func_exit();
    return;
    }
    @@ -2408,9 +2407,7 @@ static int sx_init_portstructs(int nboards, int nports)
    /*
    * Initializing wait queue
    */
    - init_waitqueue_head(&port->gs.open_wait);
    - init_waitqueue_head(&port->gs.close_wait);
    -
    + tty_port_init(&port->gs.port);
    port++;
    }
    }
    diff --git a/include/linux/generic_serial.h b/include/linux/generic_serial.h
    index 1108336..4cc9139 100644
    --- a/include/linux/generic_serial.h
    +++ b/include/linux/generic_serial.h
    @@ -14,6 +14,7 @@

    #ifdef __KERNEL__
    #include
    +#include

    struct real_driver {
    void (*disable_tx_interrupts) (void *);
    @@ -33,17 +34,12 @@ struct real_driver {

    struct gs_port {
    int magic;
    + struct tty_port port;
    unsigned char *xmit_buf;
    int xmit_head;
    int xmit_tail;
    int xmit_cnt;
    struct mutex port_write_mutex;
    - int flags;
    - wait_queue_head_t open_wait;
    - wait_queue_head_t close_wait;
    - int count;
    - int blocked_open;
    - struct tty_struct *tty;
    unsigned long event;
    unsigned short closing_wait;
    int close_delay;

    --
    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 43/70] io_edgeport: Fix various bogus returns to the tty layer

    From: Alan Cox

    The edgeport reports negative error codes to functions that do not
    expect them. This can cause ports to jam forever

    Signed-off-by: Alan Cox
    ---

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


    diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
    index 3cb2511..44d020e 100644
    --- a/drivers/usb/serial/io_edgeport.c
    +++ b/drivers/usb/serial/io_edgeport.c
    @@ -1444,15 +1444,15 @@ static int edge_write_room(struct tty_struct *tty)
    dbg("%s", __func__);

    if (edge_port == NULL)
    - return -ENODEV;
    + return 0;
    if (edge_port->closePending)
    - return -ENODEV;
    + return 0;

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

    if (!edge_port->open) {
    dbg("%s - port not opened", __func__);
    - return -EINVAL;
    + return 0;
    }

    /* total of both buffers is still txCredit */
    @@ -1484,13 +1484,13 @@ static int edge_chars_in_buffer(struct tty_struct *tty)
    dbg("%s", __func__);

    if (edge_port == NULL)
    - return -ENODEV;
    + return 0;
    if (edge_port->closePending)
    - return -ENODEV;
    + return 0;

    if (!edge_port->open) {
    dbg("%s - port not opened", __func__);
    - return -EINVAL;
    + return 0;
    }

    spin_lock_irqsave(&edge_port->ep_lock, flags);

    --
    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 38/70] garmin_gps: Coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/garmin_gps.c | 354 +++++++++++++++++++--------------------
    1 files changed, 176 insertions(+), 178 deletions(-)


    diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
    index 06cfa43..2e663f1 100644
    --- a/drivers/usb/serial/garmin_gps.c
    +++ b/drivers/usb/serial/garmin_gps.c
    @@ -33,7 +33,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include
    #include
    @@ -44,7 +44,7 @@
    static int initial_mode = 1;

    /* debug flag */
    -static int debug = 0;
    +static int debug;

    #define GARMIN_VENDOR_ID 0x091E

    @@ -56,7 +56,7 @@ static int debug = 0;
    #define VERSION_MINOR 31

    #define _STR(s) #s
    -#define _DRIVER_VERSION(a,b) "v" _STR(a) "." _STR(b)
    +#define _DRIVER_VERSION(a, b) "v" _STR(a) "." _STR(b)
    #define DRIVER_VERSION _DRIVER_VERSION(VERSION_MAJOR, VERSION_MINOR)
    #define DRIVER_AUTHOR "hermann kneissel"
    #define DRIVER_DESC "garmin gps driver"
    @@ -65,37 +65,37 @@ static int debug = 0;
    #define EINVPKT 1000 /* invalid packet structure */


    -// size of the header of a packet using the usb protocol
    +/* size of the header of a packet using the usb protocol */
    #define GARMIN_PKTHDR_LENGTH 12

    -// max. possible size of a packet using the serial protocol
    -#define MAX_SERIAL_PKT_SIZ (3+255+3)
    +/* max. possible size of a packet using the serial protocol */
    +#define MAX_SERIAL_PKT_SIZ (3 + 255 + 3)

    -// max. possible size of a packet with worst case stuffing
    -#define MAX_SERIAL_PKT_SIZ_STUFFED MAX_SERIAL_PKT_SIZ+256
    +/* max. possible size of a packet with worst case stuffing */
    +#define MAX_SERIAL_PKT_SIZ_STUFFED (MAX_SERIAL_PKT_SIZ + 256)

    -// size of a buffer able to hold a complete (no stuffing) packet
    -// (the document protocol does not contain packets with a larger
    -// size, but in theory a packet may be 64k+12 bytes - if in
    -// later protocol versions larger packet sizes occur, this value
    -// should be increased accordingly, so the input buffer is always
    -// large enough the store a complete packet inclusive header)
    -#define GPS_IN_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ)
    +/* size of a buffer able to hold a complete (no stuffing) packet
    + * (the document protocol does not contain packets with a larger
    + * size, but in theory a packet may be 64k+12 bytes - if in
    + * later protocol versions larger packet sizes occur, this value
    + * should be increased accordingly, so the input buffer is always
    + * large enough the store a complete packet inclusive header) */
    +#define GPS_IN_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ)

    -// size of a buffer able to hold a complete (incl. stuffing) packet
    -#define GPS_OUT_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ_STUFFED)
    +/* size of a buffer able to hold a complete (incl. stuffing) packet */
    +#define GPS_OUT_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ_STUFFED)

    -// where to place the packet id of a serial packet, so we can
    -// prepend the usb-packet header without the need to move the
    -// packets data
    +/* where to place the packet id of a serial packet, so we can
    + * prepend the usb-packet header without the need to move the
    + * packets data */
    #define GSP_INITIAL_OFFSET (GARMIN_PKTHDR_LENGTH-2)

    -// max. size of incoming private packets (header+1 param)
    +/* max. size of incoming private packets (header+1 param) */
    #define PRIVPKTSIZ (GARMIN_PKTHDR_LENGTH+4)

    #define GARMIN_LAYERID_TRANSPORT 0
    #define GARMIN_LAYERID_APPL 20
    -// our own layer-id to use for some control mechanisms
    +/* our own layer-id to use for some control mechanisms */
    #define GARMIN_LAYERID_PRIVATE 0x01106E4B

    #define GARMIN_PKTID_PVT_DATA 51
    @@ -103,7 +103,7 @@ static int debug = 0;

    #define CMND_ABORT_TRANSFER 0

    -// packet ids used in private layer
    +/* packet ids used in private layer */
    #define PRIV_PKTID_SET_DEBUG 1
    #define PRIV_PKTID_SET_MODE 2
    #define PRIV_PKTID_INFO_REQ 3
    @@ -121,7 +121,8 @@ static int debug = 0;
    struct garmin_packet {
    struct list_head list;
    int seq;
    - int size; // the real size of the data array, always > 0
    + /* the real size of the data array, always > 0 */
    + int size;
    __u8 data[1];
    };

    @@ -164,7 +165,7 @@ struct garmin_data {
    #define MODE_NATIVE 0
    #define MODE_GARMIN_SERIAL 1

    -// Flags used in garmin_data.flags:
    +/* Flags used in garmin_data.flags: */
    #define FLAGS_SESSION_REPLY_MASK 0x00C0
    #define FLAGS_SESSION_REPLY1_SEEN 0x0080
    #define FLAGS_SESSION_REPLY2_SEEN 0x0040
    @@ -185,7 +186,7 @@ struct garmin_data {


    /* function prototypes */
    -static void gsp_next_packet(struct garmin_data * garmin_data_p);
    +static void gsp_next_packet(struct garmin_data *garmin_data_p);
    static int garmin_write_bulk(struct usb_serial_port *port,
    const unsigned char *buf, int count,
    int dismiss_ack);
    @@ -217,12 +218,13 @@ static unsigned char const PRIVATE_REQ[]


    static struct usb_device_id id_table [] = {
    - /* the same device id seems to be used by all usb enabled gps devices */
    - { USB_DEVICE(GARMIN_VENDOR_ID, 3 ) },
    + /* the same device id seems to be used by all
    + usb enabled GPS devices */
    + { USB_DEVICE(GARMIN_VENDOR_ID, 3) },
    { } /* Terminating entry */
    };

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

    static struct usb_driver garmin_driver = {
    .name = "garmin_gps",
    @@ -233,9 +235,10 @@ static struct usb_driver garmin_driver = {
    };


    -static inline int noResponseFromAppLayer(struct garmin_data * garmin_data_p)
    +static inline int noResponseFromAppLayer(struct garmin_data *garmin_data_p)
    {
    - return atomic_read(&garmin_data_p->req_count) == atomic_read(&garmin_data_p->resp_count);
    + return atomic_read(&garmin_data_p->req_count) ==
    + atomic_read(&garmin_data_p->resp_count);
    }


    @@ -261,10 +264,10 @@ static inline int getDataLength(const __u8 *usbPacket)
    */
    static inline int isAbortTrfCmnd(const unsigned char *buf)
    {
    - if (0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ,
    - sizeof(GARMIN_STOP_TRANSFER_REQ)) ||
    - 0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ_V2,
    - sizeof(GARMIN_STOP_TRANSFER_REQ_V2)))
    + if (0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ,
    + sizeof(GARMIN_STOP_TRANSFER_REQ)) ||
    + 0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ_V2,
    + sizeof(GARMIN_STOP_TRANSFER_REQ_V2)))
    return 1;
    else
    return 0;
    @@ -279,7 +282,7 @@ static void send_to_tty(struct usb_serial_port *port,

    if (tty && actual_length) {

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

    tty_buffer_request_room(tty, actual_length);
    @@ -296,7 +299,7 @@ static void send_to_tty(struct usb_serial_port *port,
    /*
    * queue a received (usb-)packet for later processing
    */
    -static int pkt_add(struct garmin_data * garmin_data_p,
    +static int pkt_add(struct garmin_data *garmin_data_p,
    unsigned char *data, unsigned int data_length)
    {
    int state = 0;
    @@ -307,7 +310,7 @@ static int pkt_add(struct garmin_data * garmin_data_p,
    /* process only packets containg data ... */
    if (data_length) {
    pkt = kmalloc(sizeof(struct garmin_packet)+data_length,
    - GFP_ATOMIC);
    + GFP_ATOMIC);
    if (pkt == NULL) {
    dev_err(&garmin_data_p->port->dev, "out of memory\n");
    return 0;
    @@ -325,16 +328,15 @@ static int pkt_add(struct garmin_data * garmin_data_p,

    /* in serial mode, if someone is waiting for data from
    the device, iconvert and send the next packet to tty. */
    - if (result && (state == STATE_GSP_WAIT_DATA)) {
    + if (result && (state == STATE_GSP_WAIT_DATA))
    gsp_next_packet(garmin_data_p);
    - }
    }
    return result;
    }


    /* get the next pending packet */
    -static struct garmin_packet *pkt_pop(struct garmin_data * garmin_data_p)
    +static struct garmin_packet *pkt_pop(struct garmin_data *garmin_data_p)
    {
    unsigned long flags;
    struct garmin_packet *result = NULL;
    @@ -350,7 +352,7 @@ static struct garmin_packet *pkt_pop(struct garmin_data * garmin_data_p)


    /* free up all queued data */
    -static void pkt_clear(struct garmin_data * garmin_data_p)
    +static void pkt_clear(struct garmin_data *garmin_data_p)
    {
    unsigned long flags;
    struct garmin_packet *result = NULL;
    @@ -372,7 +374,7 @@ static void pkt_clear(struct garmin_data * garmin_data_p)
    ************************************************** ****************************/

    /* send an ack packet back to the tty */
    -static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id)
    +static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id)
    {
    __u8 pkt[10];
    __u8 cksum = 0;
    @@ -391,9 +393,8 @@ static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id)
    *ptr++ = pkt_id;
    cksum += pkt_id;

    - if (pkt_id == DLE) {
    + if (pkt_id == DLE)
    *ptr++ = DLE;
    - }

    *ptr++ = 0;
    *ptr++ = 0xFF & (-cksum);
    @@ -415,12 +416,12 @@ static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id)
    * at GSP_INITIAL_OFFSET.
    *
    * count - number of bytes in the input buffer including space reserved for
    - * the usb header: GSP_INITIAL_OFFSET + number of bytes in packet
    + * the usb header: GSP_INITIAL_OFFSET + number of bytes in packet
    * (including pkt-id, data-length a. cksum)
    */
    -static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)
    +static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count)
    {
    - const __u8* recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET;
    + const __u8 *recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET;
    __le32 *usbdata = (__le32 *) garmin_data_p->inbuffer;

    int cksum = 0;
    @@ -440,8 +441,8 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)
    cksum += *recpkt++;
    cksum += *recpkt++;

    - // sanity check, remove after test ...
    - if ((__u8*)&(usbdata[3]) != recpkt) {
    + /* sanity check, remove after test ... */
    + if ((__u8 *)&(usbdata[3]) != recpkt) {
    dbg("%s - ptr mismatch %p - %p",
    __func__, &(usbdata[4]), recpkt);
    return -EINVPKT;
    @@ -462,7 +463,7 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)
    usbdata[1] = __cpu_to_le32(pktid);
    usbdata[2] = __cpu_to_le32(size);

    - garmin_write_bulk (garmin_data_p->port, garmin_data_p->inbuffer,
    + garmin_write_bulk(garmin_data_p->port, garmin_data_p->inbuffer,
    GARMIN_PKTHDR_LENGTH+size, 0);

    /* if this was an abort-transfer command, flush all
    @@ -495,7 +496,7 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)
    * if the input is an abort command, drop all queued data.
    */

    -static int gsp_receive(struct garmin_data * garmin_data_p,
    +static int gsp_receive(struct garmin_data *garmin_data_p,
    const unsigned char *buf, int count)
    {
    unsigned long flags;
    @@ -504,10 +505,11 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
    int i = 0;
    __u8 *dest;
    int size;
    - // dleSeen: set if last byte read was a DLE
    + /* dleSeen: set if last byte read was a DLE */
    int dleSeen;
    - // skip: if set, skip incoming data until possible start of
    - // new packet
    + /* skip: if set, skip incoming data until possible start of
    + * new packet
    + */
    int skip;
    __u8 data;

    @@ -521,14 +523,13 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
    dbg("%s - dle=%d skip=%d size=%d count=%d",
    __func__, dleSeen, skip, size, count);

    - if (size == 0) {
    + if (size == 0)
    size = GSP_INITIAL_OFFSET;
    - }

    while (offs < count) {

    data = *(buf+offs);
    - offs ++;
    + offs++;

    if (data == DLE) {
    if (skip) { /* start of a new pkt */
    @@ -554,9 +555,8 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
    ack_or_nak_seen = NAK;
    dbg("NAK packet complete.");
    } else {
    - dbg("packet complete "
    - "- id=0x%X.",
    - 0xFF & data);
    + dbg("packet complete - id=0x%X.",
    + 0xFF & data);
    gsp_rec_packet(garmin_data_p, size);
    }

    @@ -589,7 +589,7 @@ static int gsp_receive(struct garmin_data * garmin_data_p,

    garmin_data_p->insize = size;

    - // copy flags back to structure
    + /* copy flags back to structure */
    if (skip)
    garmin_data_p->flags |= FLAGS_GSP_SKIP;
    else
    @@ -600,16 +600,13 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
    else
    garmin_data_p->flags &= ~FLAGS_GSP_DLESEEN;

    - if (ack_or_nak_seen) {
    + if (ack_or_nak_seen)
    garmin_data_p->state = STATE_GSP_WAIT_DATA;
    - }

    spin_unlock_irqrestore(&garmin_data_p->lock, flags);

    - if (ack_or_nak_seen) {
    + if (ack_or_nak_seen)
    gsp_next_packet(garmin_data_p);
    - }
    -
    return count;
    }

    @@ -623,7 +620,7 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
    *
    * return <0 on error, 0 if packet is incomplete or > 0 if packet was sent
    */
    -static int gsp_send(struct garmin_data * garmin_data_p,
    +static int gsp_send(struct garmin_data *garmin_data_p,
    const unsigned char *buf, int count)
    {
    const unsigned char *src;
    @@ -631,11 +628,11 @@ static int gsp_send(struct garmin_data * garmin_data_p,
    int pktid = 0;
    int datalen = 0;
    int cksum = 0;
    - int i=0;
    + int i = 0;
    int k;

    dbg("%s - state %d - %d bytes.", __func__,
    - garmin_data_p->state, count);
    + garmin_data_p->state, count);

    k = garmin_data_p->outsize;
    if ((k+count) > GPS_OUT_BUFSIZ) {
    @@ -650,7 +647,7 @@ static int gsp_send(struct garmin_data * garmin_data_p,

    if (k >= GARMIN_PKTHDR_LENGTH) {
    pktid = getPacketId(garmin_data_p->outbuffer);
    - datalen= getDataLength(garmin_data_p->outbuffer);
    + datalen = getDataLength(garmin_data_p->outbuffer);
    i = GARMIN_PKTHDR_LENGTH + datalen;
    if (k < i)
    return 0;
    @@ -658,19 +655,18 @@ static int gsp_send(struct garmin_data * garmin_data_p,
    return 0;
    }

    - dbg("%s - %d bytes in buffer, %d bytes in pkt.", __func__,
    - k, i);
    + dbg("%s - %d bytes in buffer, %d bytes in pkt.", __func__, k, i);

    /* garmin_data_p->outbuffer now contains a complete packet */

    usb_serial_debug_data(debug, &garmin_data_p->port->dev,
    - __func__, k, garmin_data_p->outbuffer);
    + __func__, k, garmin_data_p->outbuffer);

    garmin_data_p->outsize = 0;

    if (GARMIN_LAYERID_APPL != getLayerId(garmin_data_p->outbuffer)) {
    - dbg("not an application packet (%d)",
    - getLayerId(garmin_data_p->outbuffer));
    + dbg("not an application packet (%d)",
    + getLayerId(garmin_data_p->outbuffer));
    return -1;
    }

    @@ -688,14 +684,14 @@ static int gsp_send(struct garmin_data * garmin_data_p,

    k = 0;
    src = garmin_data_p->outbuffer+GARMIN_PKTHDR_LENGTH;
    - for (i=0; i + for (i = 0; i < datalen; i++) {
    if (*src++ == DLE)
    k++;
    }

    src = garmin_data_p->outbuffer+GARMIN_PKTHDR_LENGTH;
    if (k > (GARMIN_PKTHDR_LENGTH-2)) {
    - /* can't add stuffing DLEs in place, move data to end
    + /* can't add stuffing DLEs in place, move data to end
    of buffer ... */
    dst = garmin_data_p->outbuffer+GPS_OUT_BUFSIZ-datalen;
    memcpy(dst, src, datalen);
    @@ -712,14 +708,14 @@ static int gsp_send(struct garmin_data * garmin_data_p,
    if (datalen == DLE)
    *dst++ = DLE;

    - for (i=0; i + for (i = 0; i < datalen; i++) {
    __u8 c = *src++;
    *dst++ = c;
    cksum += c;
    if (c == DLE)
    *dst++ = DLE;
    }
    -
    +
    cksum = 0xFF & -cksum;
    *dst++ = cksum;
    if (cksum == DLE)
    @@ -744,7 +740,7 @@ static int gsp_send(struct garmin_data * garmin_data_p,
    /*
    * Process the next pending data packet - if there is one
    */
    -static void gsp_next_packet(struct garmin_data * garmin_data_p)
    +static void gsp_next_packet(struct garmin_data *garmin_data_p)
    {
    struct garmin_packet *pkt = NULL;

    @@ -774,17 +770,17 @@ static void gsp_next_packet(struct garmin_data * garmin_data_p)
    * buf contains the data read, it may span more than one packet
    * or even incomplete packets
    */
    -static int nat_receive(struct garmin_data * garmin_data_p,
    +static int nat_receive(struct garmin_data *garmin_data_p,
    const unsigned char *buf, int count)
    {
    unsigned long flags;
    - __u8 * dest;
    + __u8 *dest;
    int offs = 0;
    int result = count;
    int len;

    while (offs < count) {
    - // if buffer contains header, copy rest of data
    + /* if buffer contains header, copy rest of data */
    if (garmin_data_p->insize >= GARMIN_PKTHDR_LENGTH)
    len = GARMIN_PKTHDR_LENGTH
    +getDataLength(garmin_data_p->inbuffer);
    @@ -792,9 +788,9 @@ static int nat_receive(struct garmin_data * garmin_data_p,
    len = GARMIN_PKTHDR_LENGTH;

    if (len >= GPS_IN_BUFSIZ) {
    - /* seem to be an invalid packet, ignore rest of input */
    - dbg("%s - packet size too large: %d",
    - __func__, len);
    + /* seems to be an invalid packet, ignore rest
    + of input */
    + dbg("%s - packet size too large: %d", __func__, len);
    garmin_data_p->insize = 0;
    count = 0;
    result = -EINVPKT;
    @@ -804,7 +800,7 @@ static int nat_receive(struct garmin_data * garmin_data_p,
    len = (count-offs);
    if (len > 0) {
    dest = garmin_data_p->inbuffer
    - +garmin_data_p->insize;
    + + garmin_data_p->insize;
    memcpy(dest, buf+offs, len);
    garmin_data_p->insize += len;
    offs += len;
    @@ -816,17 +812,19 @@ static int nat_receive(struct garmin_data * garmin_data_p,
    len = GARMIN_PKTHDR_LENGTH+
    getDataLength(garmin_data_p->inbuffer);
    if (garmin_data_p->insize >= len) {
    - garmin_write_bulk (garmin_data_p->port,
    - garmin_data_p->inbuffer,
    - len, 0);
    + garmin_write_bulk(garmin_data_p->port,
    + garmin_data_p->inbuffer,
    + len, 0);
    garmin_data_p->insize = 0;

    /* if this was an abort-transfer command,
    flush all queued data. */
    if (isAbortTrfCmnd(garmin_data_p->inbuffer)) {
    - spin_lock_irqsave(&garmin_data_p->lock, flags);
    + spin_lock_irqsave(&garmin_data_p->lock,
    + flags);
    garmin_data_p->flags |= FLAGS_DROP_DATA;
    - spin_unlock_irqrestore(&garmin_data_p->lock, flags);
    + spin_unlock_irqrestore(
    + &garmin_data_p->lock, flags);
    pkt_clear(garmin_data_p);
    }
    }
    @@ -842,7 +840,7 @@ static int nat_receive(struct garmin_data * garmin_data_p,

    static void priv_status_resp(struct usb_serial_port *port)
    {
    - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
    + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
    __le32 *pkt = (__le32 *)garmin_data_p->privpkt;

    pkt[0] = __cpu_to_le32(GARMIN_LAYERID_PRIVATE);
    @@ -852,7 +850,7 @@ static void priv_status_resp(struct usb_serial_port *port)
    pkt[4] = __cpu_to_le32(garmin_data_p->mode);
    pkt[5] = __cpu_to_le32(garmin_data_p->serial_num);

    - send_to_tty(port, (__u8*)pkt, 6*4);
    + send_to_tty(port, (__u8 *)pkt, 6 * 4);
    }


    @@ -864,7 +862,7 @@ static int process_resetdev_request(struct usb_serial_port *port)
    {
    unsigned long flags;
    int status;
    - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
    + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);

    spin_lock_irqsave(&garmin_data_p->lock, flags);
    garmin_data_p->flags &= ~(CLEAR_HALT_REQUIRED);
    @@ -872,8 +870,8 @@ static int process_resetdev_request(struct usb_serial_port *port)
    garmin_data_p->serial_num = 0;
    spin_unlock_irqrestore(&garmin_data_p->lock, flags);

    - usb_kill_urb (port->interrupt_in_urb);
    - dbg("%s - usb_reset_device", __func__ );
    + usb_kill_urb(port->interrupt_in_urb);
    + dbg("%s - usb_reset_device", __func__);
    status = usb_reset_device(port->serial->dev);
    if (status)
    dbg("%s - usb_reset_device failed: %d",
    @@ -886,7 +884,7 @@ static int process_resetdev_request(struct usb_serial_port *port)
    /*
    * clear all cached data
    */
    -static int garmin_clear(struct garmin_data * garmin_data_p)
    +static int garmin_clear(struct garmin_data *garmin_data_p)
    {
    unsigned long flags;
    int status = 0;
    @@ -896,8 +894,7 @@ static int garmin_clear(struct garmin_data * garmin_data_p)
    if (port != NULL && atomic_read(&garmin_data_p->resp_count)) {
    /* send a terminate command */
    status = garmin_write_bulk(port, GARMIN_STOP_TRANSFER_REQ,
    - sizeof(GARMIN_STOP_TRANSFER_REQ),
    - 1);
    + sizeof(GARMIN_STOP_TRANSFER_REQ), 1);
    }

    /* flush all queued data */
    @@ -920,28 +917,26 @@ static int garmin_init_session(struct usb_serial_port *port)
    {
    unsigned long flags;
    struct usb_serial *serial = port->serial;
    - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
    + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
    int status = 0;

    if (status == 0) {
    - usb_kill_urb (port->interrupt_in_urb);
    + usb_kill_urb(port->interrupt_in_urb);

    dbg("%s - adding interrupt input", __func__);
    port->interrupt_in_urb->dev = serial->dev;
    status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
    if (status)
    dev_err(&serial->dev->dev,
    - "%s - failed submitting interrupt urb,"
    - " error %d\n",
    - __func__, status);
    + "%s - failed submitting interrupt urb, error %d\n",
    + __func__, status);
    }

    if (status == 0) {
    dbg("%s - starting session ...", __func__);
    garmin_data_p->state = STATE_ACTIVE;
    status = garmin_write_bulk(port, GARMIN_START_SESSION_REQ,
    - sizeof(GARMIN_START_SESSION_REQ),
    - 0);
    + sizeof(GARMIN_START_SESSION_REQ), 0);

    if (status >= 0) {

    @@ -951,14 +946,14 @@ static int garmin_init_session(struct usb_serial_port *port)

    /* not needed, but the win32 driver does it too ... */
    status = garmin_write_bulk(port,
    - GARMIN_START_SESSION_REQ2,
    - sizeof(GARMIN_START_SESSION_REQ2),
    - 0);
    + GARMIN_START_SESSION_REQ2,
    + sizeof(GARMIN_START_SESSION_REQ2), 0);
    if (status >= 0) {
    status = 0;
    spin_lock_irqsave(&garmin_data_p->lock, flags);
    garmin_data_p->ignorePkts++;
    - spin_unlock_irqrestore(&garmin_data_p->lock, flags);
    + spin_unlock_irqrestore(&garmin_data_p->lock,
    + flags);
    }
    }
    }
    @@ -970,12 +965,12 @@ static int garmin_init_session(struct usb_serial_port *port)



    -static int garmin_open (struct tty_struct *tty,
    +static int garmin_open(struct tty_struct *tty,
    struct usb_serial_port *port, struct file *filp)
    {
    unsigned long flags;
    int status = 0;
    - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
    + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);

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

    @@ -996,8 +991,8 @@ static int garmin_open (struct tty_struct *tty,
    spin_unlock_irqrestore(&garmin_data_p->lock, flags);

    /* shutdown any bulk reads that might be going on */
    - usb_kill_urb (port->write_urb);
    - usb_kill_urb (port->read_urb);
    + usb_kill_urb(port->write_urb);
    + usb_kill_urb(port->read_urb);

    if (garmin_data_p->state == STATE_RESET)
    status = garmin_init_session(port);
    @@ -1008,10 +1003,10 @@ static int garmin_open (struct tty_struct *tty,


    static void garmin_close(struct tty_struct *tty,
    - struct usb_serial_port *port, struct file * filp)
    + struct usb_serial_port *port, struct file *filp)
    {
    struct usb_serial *serial = port->serial;
    - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
    + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);

    dbg("%s - port %d - mode=%d state=%d flags=0x%X", __func__,
    port->number, garmin_data_p->mode,
    @@ -1025,8 +1020,8 @@ static void garmin_close(struct tty_struct *tty,
    garmin_clear(garmin_data_p);

    /* shutdown our urbs */
    - usb_kill_urb (port->read_urb);
    - usb_kill_urb (port->write_urb);
    + usb_kill_urb(port->read_urb);
    + usb_kill_urb(port->write_urb);

    if (!port->serial->disconnected) {
    if (noResponseFromAppLayer(garmin_data_p) ||
    @@ -1042,20 +1037,22 @@ static void garmin_close(struct tty_struct *tty,
    mutex_unlock(&port->serial->disc_mutex);
    }

    -static void garmin_write_bulk_callback (struct urb *urb)
    +static void garmin_write_bulk_callback(struct urb *urb)
    {
    unsigned long flags;
    struct usb_serial_port *port = urb->context;
    int status = urb->status;

    if (port) {
    - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
    + struct garmin_data *garmin_data_p =
    + usb_get_serial_port_data(port);

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

    if (GARMIN_LAYERID_APPL == getLayerId(urb->transfer_buffer)
    && (garmin_data_p->mode == MODE_GARMIN_SERIAL)) {
    - gsp_send_ack(garmin_data_p, ((__u8 *)urb->transfer_buffer)[4]);
    + gsp_send_ack(garmin_data_p,
    + ((__u8 *)urb->transfer_buffer)[4]);
    }

    if (status) {
    @@ -1069,20 +1066,21 @@ static void garmin_write_bulk_callback (struct urb *urb)
    usb_serial_port_softint(port);
    }

    - /* Ignore errors that resulted from garmin_write_bulk with dismiss_ack=1 */
    + /* Ignore errors that resulted from garmin_write_bulk with
    + dismiss_ack = 1 */

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


    -static int garmin_write_bulk (struct usb_serial_port *port,
    +static int garmin_write_bulk(struct usb_serial_port *port,
    const unsigned char *buf, int count,
    int dismiss_ack)
    {
    unsigned long flags;
    struct usb_serial *serial = port->serial;
    - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
    + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
    struct urb *urb;
    unsigned char *buffer;
    int status;
    @@ -1094,7 +1092,7 @@ static int garmin_write_bulk (struct usb_serial_port *port,
    garmin_data_p->flags &= ~FLAGS_DROP_DATA;
    spin_unlock_irqrestore(&garmin_data_p->lock, flags);

    - buffer = kmalloc (count, GFP_ATOMIC);
    + buffer = kmalloc(count, GFP_ATOMIC);
    if (!buffer) {
    dev_err(&port->dev, "out of memory\n");
    return -ENOMEM;
    @@ -1103,17 +1101,17 @@ static int garmin_write_bulk (struct usb_serial_port *port,
    urb = usb_alloc_urb(0, GFP_ATOMIC);
    if (!urb) {
    dev_err(&port->dev, "no more free urbs\n");
    - kfree (buffer);
    + kfree(buffer);
    return -ENOMEM;
    }

    - 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,
    - port->bulk_out_endpointAddress),
    + usb_fill_bulk_urb(urb, serial->dev,
    + usb_sndbulkpipe(serial->dev,
    + port->bulk_out_endpointAddress),
    buffer, count,
    garmin_write_bulk_callback,
    dismiss_ack ? NULL : port);
    @@ -1131,24 +1129,23 @@ static int garmin_write_bulk (struct usb_serial_port *port,
    status = usb_submit_urb(urb, GFP_ATOMIC);
    if (status) {
    dev_err(&port->dev,
    - "%s - usb_submit_urb(write bulk) "
    - "failed with status = %d\n",
    + "%s - usb_submit_urb(write bulk) failed with status = %d\n",
    __func__, status);
    count = status;
    }

    /* we are done with this urb, so let the host driver
    * really free it when it is finished with it */
    - usb_free_urb (urb);
    + usb_free_urb(urb);

    return count;
    }

    -static int garmin_write (struct tty_struct *tty, struct usb_serial_port *port,
    +static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port,
    const unsigned char *buf, int count)
    {
    int pktid, pktsiz, len;
    - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
    + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
    __le32 *privpkt = (__le32 *)garmin_data_p->privpkt;

    usb_serial_debug_data(debug, &port->dev, __func__, count, buf);
    @@ -1165,15 +1162,16 @@ static int garmin_write (struct tty_struct *tty, struct usb_serial_port *port,
    pktid = getPacketId(garmin_data_p->privpkt);

    if (count == (GARMIN_PKTHDR_LENGTH+pktsiz)
    - && GARMIN_LAYERID_PRIVATE == getLayerId(garmin_data_p->privpkt)) {
    + && GARMIN_LAYERID_PRIVATE ==
    + getLayerId(garmin_data_p->privpkt)) {

    dbg("%s - processing private request %d",
    __func__, pktid);

    - // drop all unfinished transfers
    + /* drop all unfinished transfers */
    garmin_clear(garmin_data_p);

    - switch(pktid) {
    + switch (pktid) {

    case PRIV_PKTID_SET_DEBUG:
    if (pktsiz != 4)
    @@ -1228,25 +1226,25 @@ static int garmin_write_room(struct tty_struct *tty)
    /*
    * Report back the bytes currently available in the output buffer.
    */
    - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
    + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
    return GPS_OUT_BUFSIZ-garmin_data_p->outsize;
    }


    -static void garmin_read_process(struct garmin_data * garmin_data_p,
    +static void garmin_read_process(struct garmin_data *garmin_data_p,
    unsigned char *data, unsigned data_length)
    {
    if (garmin_data_p->flags & FLAGS_DROP_DATA) {
    /* abort-transfer cmd is actice */
    dbg("%s - pkt dropped", __func__);
    } else if (garmin_data_p->state != STATE_DISCONNECTED &&
    - garmin_data_p->state != STATE_RESET ) {
    + garmin_data_p->state != STATE_RESET) {

    /* remember any appl.layer packets, so we know
    if a reset is required or not when closing
    the device */
    if (0 == memcmp(data, GARMIN_APP_LAYER_REPLY,
    - sizeof(GARMIN_APP_LAYER_REPLY))) {
    + sizeof(GARMIN_APP_LAYER_REPLY))) {
    atomic_inc(&garmin_data_p->resp_count);
    }

    @@ -1256,9 +1254,8 @@ static void garmin_read_process(struct garmin_data * garmin_data_p,
    if (garmin_data_p->flags & FLAGS_QUEUING) {
    pkt_add(garmin_data_p, data, data_length);
    } else if (garmin_data_p->mode == MODE_GARMIN_SERIAL) {
    - if (getLayerId(data) == GARMIN_LAYERID_APPL) {
    + if (getLayerId(data) == GARMIN_LAYERID_APPL)
    pkt_add(garmin_data_p, data, data_length);
    - }
    } else {
    send_to_tty(garmin_data_p->port, data, data_length);
    }
    @@ -1266,12 +1263,12 @@ static void garmin_read_process(struct garmin_data * garmin_data_p,
    }


    -static void garmin_read_bulk_callback (struct urb *urb)
    +static void garmin_read_bulk_callback(struct urb *urb)
    {
    unsigned long flags;
    struct usb_serial_port *port = urb->context;
    struct usb_serial *serial = port->serial;
    - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
    + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
    unsigned char *data = urb->transfer_buffer;
    int status = urb->status;
    int retval;
    @@ -1289,7 +1286,7 @@ static void garmin_read_bulk_callback (struct urb *urb)
    return;
    }

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

    garmin_read_process(garmin_data_p, data, urb->actual_length);
    @@ -1323,13 +1320,13 @@ static void garmin_read_bulk_callback (struct urb *urb)
    }


    -static void garmin_read_int_callback (struct urb *urb)
    +static void garmin_read_int_callback(struct urb *urb)
    {
    unsigned long flags;
    int retval;
    struct usb_serial_port *port = urb->context;
    struct usb_serial *serial = port->serial;
    - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
    + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
    unsigned char *data = urb->transfer_buffer;
    int status = urb->status;

    @@ -1355,30 +1352,31 @@ static void garmin_read_int_callback (struct urb *urb)

    if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) &&
    0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY,
    - sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) {
    + sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) {

    dbg("%s - bulk data available.", __func__);

    if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) {

    /* bulk data available */
    - 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,
    garmin_read_bulk_callback, port);
    retval = usb_submit_urb(port->read_urb, GFP_ATOMIC);
    if (retval) {
    dev_err(&port->dev,
    - "%s - failed submitting read urb, error %d\n",
    - __func__, retval);
    + "%s - failed submitting read urb, error %d\n",
    + __func__, retval);
    } else {
    spin_lock_irqsave(&garmin_data_p->lock, flags);
    garmin_data_p->flags |= FLAGS_BULK_IN_ACTIVE;
    /* do not send this packet to the user */
    garmin_data_p->ignorePkts = 1;
    - spin_unlock_irqrestore(&garmin_data_p->lock, flags);
    + spin_unlock_irqrestore(&garmin_data_p->lock,
    + flags);
    }
    } else {
    /* bulk-in transfer still active */
    @@ -1389,15 +1387,15 @@ static void garmin_read_int_callback (struct urb *urb)

    } else if (urb->actual_length == (4+sizeof(GARMIN_START_SESSION_REPLY))
    && 0 == memcmp(data, GARMIN_START_SESSION_REPLY,
    - sizeof(GARMIN_START_SESSION_REPLY))) {
    + sizeof(GARMIN_START_SESSION_REPLY))) {

    spin_lock_irqsave(&garmin_data_p->lock, flags);
    garmin_data_p->flags |= FLAGS_SESSION_REPLY1_SEEN;
    spin_unlock_irqrestore(&garmin_data_p->lock, flags);

    /* save the serial number */
    - garmin_data_p->serial_num
    - = __le32_to_cpup((__le32*)(data+GARMIN_PKTHDR_LENGTH ));
    + garmin_data_p->serial_num = __le32_to_cpup(
    + (__le32 *)(data+GARMIN_PKTHDR_LENGTH));

    dbg("%s - start-of-session reply seen - serial %u.",
    __func__, garmin_data_p->serial_num);
    @@ -1416,7 +1414,7 @@ static void garmin_read_int_callback (struct urb *urb)
    }

    port->interrupt_in_urb->dev = port->serial->dev;
    - retval = usb_submit_urb (urb, GFP_ATOMIC);
    + retval = usb_submit_urb(urb, GFP_ATOMIC);
    if (retval)
    dev_err(&urb->dev->dev,
    "%s - Error %d submitting interrupt urb\n",
    @@ -1429,7 +1427,7 @@ static void garmin_read_int_callback (struct urb *urb)
    * and then sets a timer to call itself again until all queued data
    * is sent.
    */
    -static int garmin_flush_queue(struct garmin_data * garmin_data_p)
    +static int garmin_flush_queue(struct garmin_data *garmin_data_p)
    {
    unsigned long flags;
    struct garmin_packet *pkt;
    @@ -1454,7 +1452,7 @@ static int garmin_flush_queue(struct garmin_data * garmin_data_p)
    static void garmin_throttle(struct tty_struct *tty)
    {
    struct usb_serial_port *port = tty->driver_data;
    - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
    + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
    unsigned long flags;

    dbg("%s - port %d", __func__, port->number);
    @@ -1466,10 +1464,10 @@ static void garmin_throttle(struct tty_struct *tty)
    }


    -static void garmin_unthrottle (struct tty_struct *tty)
    +static void garmin_unthrottle(struct tty_struct *tty)
    {
    struct usb_serial_port *port = tty->driver_data;
    - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
    + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
    unsigned long flags;
    int status;

    @@ -1513,7 +1511,7 @@ static int garmin_attach(struct usb_serial *serial)
    {
    int status = 0;
    struct usb_serial_port *port = serial->port[0];
    - struct garmin_data * garmin_data_p = NULL;
    + struct garmin_data *garmin_data_p = NULL;

    dbg("%s", __func__);

    @@ -1525,7 +1523,7 @@ static int garmin_attach(struct usb_serial *serial)
    init_timer(&garmin_data_p->timer);
    spin_lock_init(&garmin_data_p->lock);
    INIT_LIST_HEAD(&garmin_data_p->pktlist);
    - //garmin_data_p->timer.expires = jiffies + session_timeout;
    + /* garmin_data_p->timer.expires = jiffies + session_timeout; */
    garmin_data_p->timer.data = (unsigned long)garmin_data_p;
    garmin_data_p->timer.function = timeout_handler;
    garmin_data_p->port = port;
    @@ -1542,13 +1540,13 @@ static int garmin_attach(struct usb_serial *serial)
    static void garmin_shutdown(struct usb_serial *serial)
    {
    struct usb_serial_port *port = serial->port[0];
    - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
    + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);

    dbg("%s", __func__);

    - usb_kill_urb (port->interrupt_in_urb);
    + usb_kill_urb(port->interrupt_in_urb);
    del_timer_sync(&garmin_data_p->timer);
    - kfree (garmin_data_p);
    + kfree(garmin_data_p);
    usb_set_serial_port_data(port, NULL);
    }

    @@ -1578,7 +1576,7 @@ static struct usb_serial_driver garmin_device = {



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

    @@ -1598,10 +1596,10 @@ failed_garmin_register:
    }


    -static void __exit garmin_exit (void)
    +static void __exit garmin_exit(void)
    {
    - usb_deregister (&garmin_driver);
    - usb_serial_deregister (&garmin_device);
    + usb_deregister(&garmin_driver);
    + usb_serial_deregister(&garmin_device);
    }


    @@ -1610,8 +1608,8 @@ static void __exit garmin_exit (void)
    module_init(garmin_init);
    module_exit(garmin_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_IWUSR | S_IRUGO);

    --
    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 56/70] kobil_sct: Fix ioctls

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/kobil_sct.c | 6 ++++--
    1 files changed, 4 insertions(+), 2 deletions(-)


    diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
    index f0f8353..deba28e 100644
    --- a/drivers/usb/serial/kobil_sct.c
    +++ b/drivers/usb/serial/kobil_sct.c
    @@ -640,9 +640,11 @@ static void kobil_set_termios(struct tty_struct *tty,

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

    speed = tty_get_baud_rate(tty);
    switch (speed) {
    @@ -704,7 +706,7 @@ static int kobil_ioctl(struct tty_struct *tty, struct file *file,
    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;
    + return -ENOIOCTLCMD;

    switch (cmd) {
    case TCFLSH:

    --
    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 49/70] tty-usb-iuu-phoenix: Clean up to coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/iuu_phoenix.c | 15 ++++++---------
    1 files changed, 6 insertions(+), 9 deletions(-)


    diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
    index d654148..ddff37f 100644
    --- a/drivers/usb/serial/iuu_phoenix.c
    +++ b/drivers/usb/serial/iuu_phoenix.c
    @@ -318,11 +318,10 @@ static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
    port->bulk_out_endpointAddress), buf,
    count, &actual, HZ * 1);

    - if (status != IUU_OPERATION_OK) {
    + if (status != IUU_OPERATION_OK)
    dbg("%s - error = %2x", __func__, status);
    - } else {
    + else
    dbg("%s - write OK !", __func__);
    - }
    return status;
    }

    @@ -342,12 +341,10 @@ static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
    port->bulk_in_endpointAddress), buf,
    count, &actual, HZ * 1);

    - if (status != IUU_OPERATION_OK) {
    + if (status != IUU_OPERATION_OK)
    dbg("%s - error = %2x", __func__, status);
    - } else {
    + else
    dbg("%s - read OK !", __func__);
    - }
    -
    return status;
    }

    @@ -770,14 +767,14 @@ static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port,
    if (priv->writelen > 0) {
    /* buffer already filled but not commited */
    spin_unlock_irqrestore(&priv->lock, flags);
    - return (0);
    + return 0;
    }
    /* fill the buffer */
    memcpy(priv->writebuf, buf, count);
    priv->writelen = count;
    spin_unlock_irqrestore(&priv->lock, flags);

    - return (count);
    + return count;
    }

    static void read_rxcmd_callback(struct urb *urb)

    --
    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 47/70] tty-usb-ipw: Coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/ipw.c | 279 ++++++++++++++++++++++++----------------------
    1 files changed, 144 insertions(+), 135 deletions(-)


    diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
    index a89ebfe..a842025 100644
    --- a/drivers/usb/serial/ipw.c
    +++ b/drivers/usb/serial/ipw.c
    @@ -10,27 +10,27 @@
    * (at your option) any later version.
    *
    * All information about the device was acquired using SnoopyPro
    - * on MSFT's O/S, and examing the MSFT drivers' debug output
    + * on MSFT's O/S, and examing the MSFT drivers' debug output
    * (insanely left _on_ in the enduser version)
    *
    * It was written out of frustration with the IPWireless USB modem
    * supplied by Axity3G/Sentech South Africa not supporting
    * Linux whatsoever.
    *
    - * Nobody provided any proprietary information that was not already
    + * Nobody provided any proprietary information that was not already
    * available for this device.
    - *
    - * The modem adheres to the "3GPP TS 27.007 AT command set for 3G
    - * User Equipment (UE)" standard, available from
    + *
    + * The modem adheres to the "3GPP TS 27.007 AT command set for 3G
    + * User Equipment (UE)" standard, available from
    * http://www.3gpp.org/ftp/Specs/html-info/27007.htm
    *
    * The code was only tested the IPWireless handheld modem distributed
    * in South Africa by Sentech.
    - *
    + *
    * It may work for Woosh Inc in .nz too, as it appears they use the
    * same kit.
    *
    - * There is still some work to be done in terms of handling
    + * There is still some work to be done in terms of handling
    * DCD, DTR, RTS, CTS which are currently faked.
    * It's good enough for PPP at this point. It's based off all kinds of
    * code found in usb/serial and usb/class
    @@ -47,7 +47,7 @@
    #include
    #include
    #include
    -#include
    +#include

    /*
    * Version Information
    @@ -64,7 +64,7 @@

    /* Message sizes */
    #define EVENT_BUFFER_SIZE 0xFF
    -#define CHAR2INT16(c1,c0) (((u32)((c1) & 0xff) << 8) + (u32)((c0) & 0xff))
    +#define CHAR2INT16(c1, c0) (((u32)((c1) & 0xff) << 8) + (u32)((c0) & 0xff))
    #define NUM_BULK_URBS 24
    #define NUM_CONTROL_URBS 16

    @@ -94,33 +94,34 @@ enum {

    /* data bits */
    #define ipw_dtb_7 0x700
    -#define ipw_dtb_8 0x810 // ok so the define is misleading, I know, but forces 8,n,1
    - // I mean, is there a point to any other setting these days?
    +#define ipw_dtb_8 0x810 /* ok so the define is misleading, I know, but forces 8,n,1 */
    + /* I mean, is there a point to any other setting these days? */

    /* usb control request types : */
    -#define IPW_SIO_RXCTL 0x00 // control bulk rx channel transmissions, value=1/0 (on/off)
    -#define IPW_SIO_SET_BAUD 0x01 // set baud, value=requested ipw_sio_bxxxx
    -#define IPW_SIO_SET_LINE 0x03 // set databits, parity. value=ipw_dtb_x
    -#define IPW_SIO_SET_PIN 0x03 // set/clear dtr/rts value=ipw_pin_xxx
    -#define IPW_SIO_POLL 0x08 // get serial port status byte, call with value=0
    -#define IPW_SIO_INIT 0x11 // initializes ? value=0 (appears as first thing todo on open)
    -#define IPW_SIO_PURGE 0x12 // purge all transmissions?, call with value=numchar_to_purge
    -#define IPW_SIO_HANDFLOW 0x13 // set xon/xoff limits value=0, and a buffer of 0x10 bytes
    -#define IPW_SIO_SETCHARS 0x13 // set the flowcontrol special chars, value=0, buf=6 bytes,
    - // last 2 bytes contain flowcontrol chars e.g. 00 00 00 00 11 13
    +#define IPW_SIO_RXCTL 0x00 /* control bulk rx channel transmissions, value=1/0 (on/off) */
    +#define IPW_SIO_SET_BAUD 0x01 /* set baud, value=requested ipw_sio_bxxxx */
    +#define IPW_SIO_SET_LINE 0x03 /* set databits, parity. value=ipw_dtb_x */
    +#define IPW_SIO_SET_PIN 0x03 /* set/clear dtr/rts value=ipw_pin_xxx */
    +#define IPW_SIO_POLL 0x08 /* get serial port status byte, call with value=0 */
    +#define IPW_SIO_INIT 0x11 /* initializes ? value=0 (appears as first thing todo on open) */
    +#define IPW_SIO_PURGE 0x12 /* purge all transmissions?, call with value=numchar_to_purge */
    +#define IPW_SIO_HANDFLOW 0x13 /* set xon/xoff limits value=0, and a buffer of 0x10 bytes */
    +#define IPW_SIO_SETCHARS 0x13 /* set the flowcontrol special chars, value=0, buf=6 bytes, */
    + /* last 2 bytes contain flowcontrol chars e.g. 00 00 00 00 11 13 */

    /* values used for request IPW_SIO_SET_PIN */
    #define IPW_PIN_SETDTR 0x101
    #define IPW_PIN_SETRTS 0x202
    #define IPW_PIN_CLRDTR 0x100
    -#define IPW_PIN_CLRRTS 0x200 // unconfirmed
    +#define IPW_PIN_CLRRTS 0x200 /* unconfirmed */

    /* values used for request IPW_SIO_RXCTL */
    #define IPW_RXBULK_ON 1
    #define IPW_RXBULK_OFF 0

    /* various 16 byte hardcoded transferbuffers used by flow control */
    -#define IPW_BYTES_FLOWINIT { 0x01, 0, 0, 0, 0x40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
    +#define IPW_BYTES_FLOWINIT { 0x01, 0, 0, 0, 0x40, 0, 0, 0, \
    + 0, 0, 0, 0, 0, 0, 0, 0 }

    /* Interpretation of modem status lines */
    /* These need sorting out by individually connecting pins and checking
    @@ -132,17 +133,6 @@ enum {
    #define IPW_CTS ((1<<5) | (1<<4))

    #define IPW_WANTS_TO_SEND 0x30
    -//#define IPW_DTR /* Data Terminal Ready */
    -//#define IPW_CTS /* Clear To Send */
    -//#define IPW_CD /* Carrier Detect */
    -//#define IPW_DSR /* Data Set Ready */
    -//#define IPW_RxD /* Receive pin */
    -
    -//#define IPW_LE
    -//#define IPW_RTS
    -//#define IPW_ST
    -//#define IPW_SR
    -//#define IPW_RI /* Ring Indicator */

    static struct usb_device_id usb_ipw_ids[] = {
    { USB_DEVICE(IPW_VID, IPW_PID) },
    @@ -177,7 +167,8 @@ static void ipw_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) {
    @@ -187,15 +178,17 @@ static void ipw_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,
    + 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,
    - ipw_read_bulk_callback, port);
    + port->read_urb->transfer_buffer,
    + port->read_urb->transfer_buffer_length,
    + ipw_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);
    + dev_err(&port->dev,
    + "%s - failed resubmitting read urb, error %d\n",
    + __func__, result);
    return;
    }

    @@ -216,26 +209,30 @@ static int ipw_open(struct tty_struct *tty,
    if (tty)
    tty->low_latency = 1;

    - /* --1: Tell the modem to initialize (we think) From sniffs this is always the
    - * first thing that gets sent to the modem during opening of the device */
    - dbg("%s: Sending SIO_INIT (we guess)",__func__);
    - result = usb_control_msg(dev, usb_sndctrlpipe(dev,0),
    - IPW_SIO_INIT,
    - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    - 0,
    - 0, /* index */
    - NULL,
    - 0,
    - 100000);
    + /* --1: Tell the modem to initialize (we think) From sniffs this is
    + * always the first thing that gets sent to the modem during
    + * opening of the device */
    + dbg("%s: Sending SIO_INIT (we guess)", __func__);
    + result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
    + IPW_SIO_INIT,
    + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    + 0,
    + 0, /* index */
    + NULL,
    + 0,
    + 100000);
    if (result < 0)
    - dev_err(&port->dev, "Init of modem failed (error = %d)\n", result);
    + dev_err(&port->dev,
    + "Init of modem failed (error = %d)\n", result);

    /* reset the bulk pipes */
    - usb_clear_halt(dev, usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress));
    - usb_clear_halt(dev, usb_sndbulkpipe(dev, port->bulk_out_endpointAddress));
    + usb_clear_halt(dev,
    + usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress));
    + usb_clear_halt(dev,
    + usb_sndbulkpipe(dev, port->bulk_out_endpointAddress));

    - /*--2: Start reading from the device */
    - dbg("%s: setting up bulk read callback",__func__);
    + /*--2: Start reading from the device */
    + dbg("%s: setting up bulk read callback", __func__);
    usb_fill_bulk_urb(port->read_urb, dev,
    usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress),
    port->bulk_in_buffer,
    @@ -243,67 +240,72 @@ static int ipw_open(struct tty_struct *tty,
    ipw_read_bulk_callback, port);
    result = usb_submit_urb(port->read_urb, GFP_KERNEL);
    if (result < 0)
    - dbg("%s - usb_submit_urb(read bulk) failed with status %d", __func__, result);
    + dbg("%s - usb_submit_urb(read bulk) failed with status %d",
    + __func__, result);

    /*--3: Tell the modem to open the floodgates on the rx bulk channel */
    - dbg("%s:asking modem for RxRead (RXBULK_ON)",__func__);
    + dbg("%s:asking modem for RxRead (RXBULK_ON)", __func__);
    result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
    - IPW_SIO_RXCTL,
    - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    - IPW_RXBULK_ON,
    - 0, /* index */
    - NULL,
    - 0,
    - 100000);
    - if (result < 0)
    - dev_err(&port->dev, "Enabling bulk RxRead failed (error = %d)\n", result);
    + IPW_SIO_RXCTL,
    + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    + IPW_RXBULK_ON,
    + 0, /* index */
    + NULL,
    + 0,
    + 100000);
    + if (result < 0)
    + dev_err(&port->dev,
    + "Enabling bulk RxRead failed (error = %d)\n", result);

    /*--4: setup the initial flowcontrol */
    - dbg("%s:setting init flowcontrol (%s)",__func__,buf_flow_init);
    + dbg("%s:setting init flowcontrol (%s)", __func__, buf_flow_init);
    result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
    - IPW_SIO_HANDFLOW,
    - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    - 0,
    - 0,
    - buf_flow_init,
    - 0x10,
    - 200000);
    + IPW_SIO_HANDFLOW,
    + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    + 0,
    + 0,
    + buf_flow_init,
    + 0x10,
    + 200000);
    if (result < 0)
    - dev_err(&port->dev, "initial flowcontrol failed (error = %d)\n", result);
    + dev_err(&port->dev,
    + "initial flowcontrol failed (error = %d)\n", result);


    /*--5: raise the dtr */
    - dbg("%s:raising dtr",__func__);
    + dbg("%s:raising dtr", __func__);
    result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
    - IPW_SIO_SET_PIN,
    - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    - IPW_PIN_SETDTR,
    - 0,
    - NULL,
    - 0,
    - 200000);
    + IPW_SIO_SET_PIN,
    + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    + IPW_PIN_SETDTR,
    + 0,
    + NULL,
    + 0,
    + 200000);
    if (result < 0)
    - dev_err(&port->dev, "setting dtr failed (error = %d)\n", result);
    + dev_err(&port->dev,
    + "setting dtr failed (error = %d)\n", result);

    /*--6: raise the rts */
    - dbg("%s:raising rts",__func__);
    + dbg("%s:raising rts", __func__);
    result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
    - IPW_SIO_SET_PIN,
    - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    - IPW_PIN_SETRTS,
    - 0,
    - NULL,
    - 0,
    - 200000);
    + IPW_SIO_SET_PIN,
    + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    + IPW_PIN_SETRTS,
    + 0,
    + NULL,
    + 0,
    + 200000);
    if (result < 0)
    - dev_err(&port->dev, "setting dtr failed (error = %d)\n", result);
    -
    + dev_err(&port->dev,
    + "setting dtr failed (error = %d)\n", result);
    +
    kfree(buf_flow_init);
    return 0;
    }

    static void ipw_close(struct tty_struct *tty,
    - struct usb_serial_port *port, struct file * filp)
    + struct usb_serial_port *port, struct file *filp)
    {
    struct usb_device *dev = port->serial->dev;
    int result;
    @@ -314,56 +316,62 @@ static void ipw_close(struct tty_struct *tty,
    }

    /*--1: drop the dtr */
    - dbg("%s:dropping dtr",__func__);
    + dbg("%s:dropping dtr", __func__);
    result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
    - IPW_SIO_SET_PIN,
    - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    - IPW_PIN_CLRDTR,
    - 0,
    - NULL,
    - 0,
    - 200000);
    + IPW_SIO_SET_PIN,
    + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    + IPW_PIN_CLRDTR,
    + 0,
    + NULL,
    + 0,
    + 200000);
    if (result < 0)
    - dev_err(&port->dev, "dropping dtr failed (error = %d)\n", result);
    + dev_err(&port->dev, "dropping dtr failed (error = %d)\n",
    + result);

    /*--2: drop the rts */
    - dbg("%s:dropping rts",__func__);
    + dbg("%s:dropping rts", __func__);
    result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
    - IPW_SIO_SET_PIN, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    - IPW_PIN_CLRRTS,
    - 0,
    - NULL,
    - 0,
    - 200000);
    + IPW_SIO_SET_PIN, USB_TYPE_VENDOR |
    + USB_RECIP_INTERFACE | USB_DIR_OUT,
    + IPW_PIN_CLRRTS,
    + 0,
    + NULL,
    + 0,
    + 200000);
    if (result < 0)
    - dev_err(&port->dev, "dropping rts failed (error = %d)\n", result);
    + dev_err(&port->dev,
    + "dropping rts failed (error = %d)\n", result);


    /*--3: purge */
    - dbg("%s:sending purge",__func__);
    + dbg("%s:sending purge", __func__);
    result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
    - IPW_SIO_PURGE, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    - 0x03,
    - 0,
    - NULL,
    - 0,
    - 200000);
    + IPW_SIO_PURGE, USB_TYPE_VENDOR |
    + USB_RECIP_INTERFACE | USB_DIR_OUT,
    + 0x03,
    + 0,
    + NULL,
    + 0,
    + 200000);
    if (result < 0)
    dev_err(&port->dev, "purge failed (error = %d)\n", result);


    - /* send RXBULK_off (tell modem to stop transmitting bulk data on rx chan) */
    + /* send RXBULK_off (tell modem to stop transmitting bulk data on
    + rx chan) */
    result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
    - IPW_SIO_RXCTL,
    - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    - IPW_RXBULK_OFF,
    - 0, /* index */
    - NULL,
    - 0,
    - 100000);
    + IPW_SIO_RXCTL,
    + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
    + IPW_RXBULK_OFF,
    + 0, /* index */
    + NULL,
    + 0,
    + 100000);

    if (result < 0)
    - dev_err(&port->dev, "Disabling bulk RxRead failed (error = %d)\n", result);
    + dev_err(&port->dev,
    + "Disabling bulk RxRead failed (error = %d)\n", result);

    /* shutdown any in-flight urbs that we know about */
    usb_kill_urb(port->read_urb);
    @@ -393,7 +401,7 @@ static int ipw_write(struct tty_struct *tty, struct usb_serial_port *port,
    int ret;

    dbg("%s: TOP: count=%d, in_interrupt=%ld", __func__,
    - count, in_interrupt() );
    + count, in_interrupt());

    if (count == 0) {
    dbg("%s - write request of 0 bytes", __func__);
    @@ -424,13 +432,14 @@ static int ipw_write(struct tty_struct *tty, struct usb_serial_port *port,
    ret = usb_submit_urb(port->write_urb, GFP_ATOMIC);
    if (ret != 0) {
    port->write_urb_busy = 0;
    - dbg("%s - usb_submit_urb(write bulk) failed with error = %d", __func__, ret);
    + dbg("%s - usb_submit_urb(write bulk) failed with error = %d",
    + __func__, ret);
    return ret;
    }

    dbg("%s returning %d", __func__, count);
    return count;
    -}
    +}

    static int ipw_probe(struct usb_serial_port *port)
    {
    @@ -489,8 +498,8 @@ module_init(usb_ipw_init);
    module_exit(usb_ipw_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/

  19. [PATCH 59/70] tty-usb-pl2303: Coding style

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/pl2303.c | 64 ++++++++++++++++++++++++-------------------
    1 files changed, 36 insertions(+), 28 deletions(-)


    diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
    index 8eec785..a65328a 100644
    --- a/drivers/usb/serial/pl2303.c
    +++ b/drivers/usb/serial/pl2303.c
    @@ -10,7 +10,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
    *
    */

    @@ -25,7 +26,7 @@
    #include
    #include
    #include
    -#include
    +#include
    #include
    #include
    #include "pl2303.h"
    @@ -115,7 +116,7 @@ static struct usb_driver pl2303_driver = {
    #define CONTROL_RTS 0x02

    #define BREAK_REQUEST_TYPE 0x21
    -#define BREAK_REQUEST 0x23
    +#define BREAK_REQUEST 0x23
    #define BREAK_ON 0xffff
    #define BREAK_OFF 0x0000

    @@ -221,7 +222,7 @@ static unsigned int pl2303_buf_data_avail(struct pl2303_buf *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;
    }

    /*
    @@ -235,7 +236,7 @@ static unsigned int pl2303_buf_space_avail(struct pl2303_buf *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;
    }

    /*
    @@ -394,7 +395,7 @@ static int pl2303_startup(struct usb_serial *serial)

    cleanup:
    kfree(buf);
    - for (--i; i>=0; --i) {
    + for (--i; i >= 0; --i) {
    priv = usb_get_serial_port_data(serial->port[i]);
    pl2303_buf_free(priv->buf);
    kfree(priv);
    @@ -406,7 +407,7 @@ cleanup:
    static int set_control_lines(struct usb_device *dev, u8 value)
    {
    int retval;
    -
    +
    retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
    SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE,
    value, 0, NULL, 0, 100);
    @@ -451,7 +452,7 @@ static void pl2303_send(struct usb_serial_port *port)
    dev_err(&port->dev, "%s - failed submitting write urb,"
    " error %d\n", __func__, result);
    priv->write_urb_in_use = 0;
    - // TODO: reschedule pl2303_send
    + /* TODO: reschedule pl2303_send */
    }

    usb_serial_port_softint(port);
    @@ -560,11 +561,19 @@ static void pl2303_set_termios(struct tty_struct *tty,

    if (cflag & CSIZE) {
    switch (cflag & CSIZE) {
    - case CS5: buf[6] = 5; break;
    - case CS6: buf[6] = 6; break;
    - case CS7: buf[6] = 7; break;
    - default:
    - case CS8: buf[6] = 8; break;
    + case CS5:
    + buf[6] = 5;
    + break;
    + case CS6:
    + buf[6] = 6;
    + break;
    + case CS7:
    + buf[6] = 7;
    + break;
    + default:
    + case CS8:
    + buf[6] = 8;
    + break;
    }
    dbg("%s - data bits = %d", __func__, buf[6]);
    }
    @@ -693,7 +702,7 @@ static void pl2303_close(struct tty_struct *tty,
    /* that is not unnecessarily long) */
    bps = tty_get_baud_rate(tty);
    if (bps > 1200)
    - timeout = max((HZ*2560)/bps,HZ/10);
    + timeout = max((HZ*2560)/bps, HZ/10);
    else
    timeout = 2*HZ;
    schedule_timeout_interruptible(timeout);
    @@ -739,7 +748,7 @@ static int pl2303_open(struct tty_struct *tty,
    if (tty)
    pl2303_set_termios(tty, port, &tmp_termios);

    - //FIXME: need to assert RTS and DTR if CRTSCTS off
    + /* FIXME: need to assert RTS and DTR if CRTSCTS off */

    dbg("%s - submitting read urb", __func__);
    port->read_urb->dev = serial->dev;
    @@ -842,12 +851,12 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
    status = priv->line_status;
    spin_unlock_irqrestore(&priv->lock, flags);

    - changed=prevstatus^status;
    + changed = prevstatus ^ status;

    if (((arg & TIOCM_RNG) && (changed & UART_RING)) ||
    ((arg & TIOCM_DSR) && (changed & UART_DSR)) ||
    ((arg & TIOCM_CD) && (changed & UART_DCD)) ||
    - ((arg & TIOCM_CTS) && (changed & UART_CTS)) ) {
    + ((arg & TIOCM_CTS) && (changed & UART_CTS))) {
    return 0;
    }
    prevstatus = status;
    @@ -863,15 +872,13 @@ static int pl2303_ioctl(struct tty_struct *tty, struct file *file,
    dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd);

    switch (cmd) {
    - case TIOCMIWAIT:
    - dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
    - return wait_modem_info(port, arg);
    -
    - default:
    - dbg("%s not supported = 0x%04x", __func__, cmd);
    - break;
    + case TIOCMIWAIT:
    + dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
    + return wait_modem_info(port, arg);
    + default:
    + dbg("%s not supported = 0x%04x", __func__, cmd);
    + break;
    }
    -
    return -ENOIOCTLCMD;
    }

    @@ -888,7 +895,8 @@ static void pl2303_break_ctl(struct tty_struct *tty, int break_state)
    state = BREAK_OFF;
    else
    state = BREAK_ON;
    - dbg("%s - turning break %s", __func__, state==BREAK_OFF ? "off" : "on");
    + dbg("%s - turning break %s", __func__,
    + state == BREAK_OFF ? "off" : "on");

    result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
    BREAK_REQUEST, BREAK_REQUEST_TYPE, state,
    @@ -942,7 +950,7 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
    if (actual_length < length)
    return;

    - /* Save off the uart status for others to look at */
    + /* Save off the uart status for others to look at */
    spin_lock_irqsave(&priv->lock, flags);
    priv->line_status = data[status_idx];
    spin_unlock_irqrestore(&priv->lock, flags);
    @@ -1041,7 +1049,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)

    /* break takes precedence over parity, */
    /* which takes precedence over framing errors */
    - if (line_status & UART_BREAK_ERROR )
    + if (line_status & UART_BREAK_ERROR)
    tty_flag = TTY_BREAK;
    else if (line_status & UART_PARITY_ERROR)
    tty_flag = TTY_PARITY;

    --
    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 37/70] funsoft: Switch to linux/uaccess

    From: Alan Cox



    Signed-off-by: Alan Cox
    ---

    drivers/usb/serial/funsoft.c | 2 +-
    1 files changed, 1 insertions(+), 1 deletions(-)


    diff --git a/drivers/usb/serial/funsoft.c b/drivers/usb/serial/funsoft.c
    index e8ba2cb..d30f736 100644
    --- a/drivers/usb/serial/funsoft.c
    +++ b/drivers/usb/serial/funsoft.c
    @@ -14,7 +14,7 @@
    #include
    #include
    #include
    -#include
    +#include

    static int debug;


    --
    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 2 of 4 FirstFirst 1 2 3 4 LastLast