Merge git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/v4l-dvb
[pandora-kernel.git] / drivers / char / riscom8.c
index b0ba241..724b2b2 100644 (file)
@@ -638,9 +638,6 @@ static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
        unsigned char cor1 = 0, cor3 = 0;
        unsigned char mcor1 = 0, mcor2 = 0;
 
-       if (tty == NULL || tty->termios == NULL)
-               return;
-
        port->IER  = 0;
        port->COR2 = 0;
        port->MSVR = MSVR_RTS;
@@ -794,8 +791,7 @@ static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
 
        spin_lock_irqsave(&riscom_lock, flags);
 
-       if (port->port.tty)
-               clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
+       clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
        if (port->port.count == 1)
                bp->count++;
        port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
@@ -807,10 +803,9 @@ static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
 }
 
 /* Must be called with interrupts disabled */
-static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
+static void rc_shutdown_port(struct tty_struct *tty,
+                       struct riscom_board *bp, struct riscom_port *port)
 {
-       struct tty_struct *tty;
-
        if (!(port->port.flags & ASYNC_INITIALIZED))
                return;
 
@@ -830,10 +825,7 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
        }
 #endif
        tty_port_free_xmit_buf(&port->port);
-
-       tty = port->port.tty;
-
-       if (tty == NULL || C_HUPCL(tty)) {
+       if (C_HUPCL(tty)) {
                /* Drop DTR */
                bp->DTR |= (1u << port_No(port));
                rc_out(bp, RC_DTR, bp->DTR);
@@ -848,8 +840,7 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
        port->IER = 0;
        rc_out(bp, CD180_IER, port->IER);
 
-       if (tty)
-               set_bit(TTY_IO_ERROR, &tty->flags);
+       set_bit(TTY_IO_ERROR, &tty->flags);
        port->port.flags &= ~ASYNC_INITIALIZED;
 
        if (--bp->count < 0)  {
@@ -1041,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
@@ -1067,15 +1058,15 @@ static void rc_close(struct tty_struct *tty, struct file *filp)
                                break;
                }
        }
-       rc_shutdown_port(bp, port);
+       rc_shutdown_port(tty, bp, port);
        rc_flush_buffer(tty);
        tty_ldisc_flush(tty);
 
        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);
@@ -1098,9 +1089,6 @@ static int rc_write(struct tty_struct *tty,
 
        bp = port_Board(port);
 
-       if (!tty || !port->port.xmit_buf)
-               return 0;
-
        while (1) {
                spin_lock_irqsave(&riscom_lock, flags);
 
@@ -1141,9 +1129,6 @@ static int rc_put_char(struct tty_struct *tty, unsigned char ch)
        if (rc_paranoia_check(port, tty->name, "rc_put_char"))
                return 0;
 
-       if (!tty || !port->port.xmit_buf)
-               return 0;
-
        spin_lock_irqsave(&riscom_lock, flags);
 
        if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
@@ -1167,8 +1152,7 @@ static void rc_flush_chars(struct tty_struct *tty)
        if (rc_paranoia_check(port, tty->name, "rc_flush_chars"))
                return;
 
-       if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
-           !port->port.xmit_buf)
+       if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped)
                return;
 
        spin_lock_irqsave(&riscom_lock, flags);
@@ -1311,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;
@@ -1321,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;
@@ -1347,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;
 }
@@ -1488,7 +1472,7 @@ static void rc_hangup(struct tty_struct *tty)
 
        bp = port_Board(port);
 
-       rc_shutdown_port(bp, port);
+       rc_shutdown_port(tty, bp, port);
        port->port.count = 0;
        port->port.flags &= ~ASYNC_NORMAL_ACTIVE;
        port->port.tty = NULL;
@@ -1565,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;
 }