Merge git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/v4l-dvb
[pandora-kernel.git] / drivers / char / specialix.c
index 4b5b5b7..037dc47 100644 (file)
@@ -131,8 +131,8 @@ static int sx_rxfifo = SPECIALIX_RXFIFO;
 #define SX_DEBUG_FIFO    0x0800
 
 
-#define func_enter() dprintk (SX_DEBUG_FLOW, "io8: enter %s\n",__FUNCTION__)
-#define func_exit()  dprintk (SX_DEBUG_FLOW, "io8: exit  %s\n", __FUNCTION__)
+#define func_enter() dprintk (SX_DEBUG_FLOW, "io8: enter %s\n",__func__)
+#define func_exit()  dprintk (SX_DEBUG_FLOW, "io8: exit  %s\n", __func__)
 
 #define jiffies_from_ms(a) ((((a) * HZ)/1000)+1)
 
@@ -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);
@@ -874,7 +874,7 @@ static irqreturn_t sx_interrupt(int dummy, void *dev_id)
 
        spin_lock_irqsave(&bp->lock, flags);
 
-       dprintk (SX_DEBUG_FLOW, "enter %s port %d room: %ld\n", __FUNCTION__, port_No(sx_get_port(bp, "INT")), SERIAL_XMIT_SIZE - sx_get_port(bp, "ITN")->xmit_cnt - 1);
+       dprintk (SX_DEBUG_FLOW, "enter %s port %d room: %ld\n", __func__, port_No(sx_get_port(bp, "INT")), SERIAL_XMIT_SIZE - sx_get_port(bp, "ITN")->xmit_cnt - 1);
        if (!(bp->flags & SX_BOARD_ACTIVE)) {
                dprintk (SX_DEBUG_IRQ, "sx: False interrupt. irq %d.\n", bp->irq);
                spin_unlock_irqrestore(&bp->lock, flags);
@@ -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))) {
@@ -1504,6 +1504,27 @@ static int sx_open(struct tty_struct * tty, struct file * filp)
        return 0;
 }
 
+static void sx_flush_buffer(struct tty_struct *tty)
+{
+       struct specialix_port *port = (struct specialix_port *)tty->driver_data;
+       unsigned long flags;
+       struct specialix_board  * bp;
+
+       func_enter();
+
+       if (sx_paranoia_check(port, tty->name, "sx_flush_buffer")) {
+               func_exit();
+               return;
+       }
+
+       bp = port_Board(port);
+       spin_lock_irqsave(&port->lock, flags);
+       port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
+       spin_unlock_irqrestore(&port->lock, flags);
+       tty_wakeup(tty);
+
+       func_exit();
+}
 
 static void sx_close(struct tty_struct * tty, struct file * filp)
 {
@@ -1526,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);
@@ -1542,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.
@@ -1550,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
@@ -1561,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);
@@ -1590,28 +1611,27 @@ 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);
-       if (tty->driver->flush_buffer)
-               tty->driver->flush_buffer(tty);
+       sx_flush_buffer(tty);
        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();
 }
@@ -1670,7 +1690,7 @@ static int sx_write(struct tty_struct * tty,
 }
 
 
-static void sx_put_char(struct tty_struct * tty, unsigned char ch)
+static int sx_put_char(struct tty_struct * tty, unsigned char ch)
 {
        struct specialix_port *port = (struct specialix_port *)tty->driver_data;
        unsigned long flags;
@@ -1680,12 +1700,12 @@ static void sx_put_char(struct tty_struct * tty, unsigned char ch)
 
        if (sx_paranoia_check(port, tty->name, "sx_put_char")) {
                func_exit();
-               return;
+               return 0;
        }
        dprintk (SX_DEBUG_TX, "check tty: %p %p\n", tty, port->xmit_buf);
        if (!port->xmit_buf) {
                func_exit();
-               return;
+               return 0;
        }
        bp = port_Board(port);
        spin_lock_irqsave(&port->lock, flags);
@@ -1695,7 +1715,7 @@ static void sx_put_char(struct tty_struct * tty, unsigned char ch)
                spin_unlock_irqrestore(&port->lock, flags);
                dprintk (SX_DEBUG_TX, "Exit size\n");
                func_exit();
-               return;
+               return 0;
        }
        dprintk (SX_DEBUG_TX, "Handle xmit: %p %p\n", port, port->xmit_buf);
        port->xmit_buf[port->xmit_head++] = ch;
@@ -1704,6 +1724,7 @@ static void sx_put_char(struct tty_struct * tty, unsigned char ch)
        spin_unlock_irqrestore(&port->lock, flags);
 
        func_exit();
+       return 1;
 }
 
 
@@ -1770,28 +1791,6 @@ static int sx_chars_in_buffer(struct tty_struct *tty)
 }
 
 
-static void sx_flush_buffer(struct tty_struct *tty)
-{
-       struct specialix_port *port = (struct specialix_port *)tty->driver_data;
-       unsigned long flags;
-       struct specialix_board  * bp;
-
-       func_enter();
-
-       if (sx_paranoia_check(port, tty->name, "sx_flush_buffer")) {
-               func_exit();
-               return;
-       }
-
-       bp = port_Board(port);
-       spin_lock_irqsave(&port->lock, flags);
-       port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
-       spin_unlock_irqrestore(&port->lock, flags);
-       tty_wakeup(tty);
-
-       func_exit();
-}
-
 
 static int sx_tiocmget(struct tty_struct *tty, struct file *file)
 {
@@ -1803,7 +1802,7 @@ static int sx_tiocmget(struct tty_struct *tty, struct file *file)
 
        func_enter();
 
-       if (sx_paranoia_check(port, tty->name, __FUNCTION__)) {
+       if (sx_paranoia_check(port, tty->name, __func__)) {
                func_exit();
                return -ENODEV;
        }
@@ -1816,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)
@@ -1845,7 +1844,7 @@ static int sx_tiocmset(struct tty_struct *tty, struct file *file,
 
        func_enter();
 
-       if (sx_paranoia_check(port, tty->name, __FUNCTION__)) {
+       if (sx_paranoia_check(port, tty->name, __func__)) {
                func_exit();
                return -ENODEV;
        }
@@ -1858,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 {
@@ -1870,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 {
@@ -1922,56 +1921,42 @@ static inline int sx_set_serial_info(struct specialix_port * port,
        int change_speed;
 
        func_enter();
-       /*
-       if (!access_ok(VERIFY_READ, (void *) newinfo, sizeof(tmp))) {
-               func_exit();
-               return -EFAULT;
-       }
-       */
+
        if (copy_from_user(&tmp, newinfo, sizeof(tmp))) {
                func_enter();
                return -EFAULT;
        }
 
-#if 0
-       if ((tmp.irq != bp->irq) ||
-           (tmp.port != bp->base) ||
-           (tmp.type != PORT_CIRRUS) ||
-           (tmp.baud_base != (SX_OSCFREQ + CD186x_TPC/2) / CD186x_TPC) ||
-           (tmp.custom_divisor != 0) ||
-           (tmp.xmit_fifo_size != CD186x_NFIFO) ||
-           (tmp.flags & ~SPECIALIX_LEGAL_FLAGS)) {
-               func_exit();
-               return -EINVAL;
-       }
-#endif
+       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) {
                sx_change_speed(bp, port);
        }
        func_exit();
+       unlock_kernel();
        return 0;
 }
 
@@ -1984,22 +1969,19 @@ static inline int sx_get_serial_info(struct specialix_port * port,
 
        func_enter();
 
-       /*
-       if (!access_ok(VERIFY_WRITE, (void *) retinfo, sizeof(tmp)))
-               return -EFAULT;
-       */
-
        memset(&tmp, 0, sizeof(tmp));
+       lock_kernel();
        tmp.type = PORT_CIRRUS;
        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();
        if (copy_to_user(retinfo, &tmp, sizeof(tmp))) {
                func_exit();
                return -EFAULT;
@@ -2045,23 +2027,6 @@ static int sx_ioctl(struct tty_struct * tty, struct file * filp,
                sx_send_break(port, arg ? arg*(HZ/10) : HZ/4);
                func_exit();
                return 0;
-        case TIOCGSOFTCAR:
-                if (put_user(C_CLOCAL(tty)?1:0, (unsigned long __user *)argp)) {
-                        func_exit();
-                        return -EFAULT;
-                }
-                func_exit();
-               return 0;
-        case TIOCSSOFTCAR:
-                if (get_user(arg, (unsigned long __user *) argp)) {
-                        func_exit();
-                        return -EFAULT;
-                }
-               tty->termios->c_cflag =
-                       ((tty->termios->c_cflag & ~CLOCAL) |
-                       (arg ? CLOCAL : 0));
-               func_exit();
-               return 0;
         case TIOCGSERIAL:
                 func_exit();
                return sx_get_serial_info(port, argp);
@@ -2234,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();
 }
@@ -2259,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);
@@ -2332,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);
        }