]> err.no Git - linux-2.6/blobdiff - drivers/char/moxa.c
agp/sis: Suspend support for SiS AGP
[linux-2.6] / drivers / char / moxa.c
index 40ac6dedee462b89cca52fc7fecce0de8a798d39..64b7b2b18352526d92e0ebf83f6bda424aed7d1c 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/bitops.h>
+#include <linux/completion.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
@@ -142,7 +143,7 @@ struct moxa_port {
        struct tty_struct *tty;
        int cflag;
        wait_queue_head_t open_wait;
-       wait_queue_head_t close_wait;
+       struct completion close_wait;
 
        struct timer_list emptyTimer;
 
@@ -206,7 +207,7 @@ static int moxa_tiocmget(struct tty_struct *tty, struct file *file);
 static int moxa_tiocmset(struct tty_struct *tty, struct file *file,
                         unsigned int set, unsigned int clear);
 static void moxa_poll(unsigned long);
-static void moxa_set_tty_param(struct tty_struct *);
+static void moxa_set_tty_param(struct tty_struct *, struct ktermios *);
 static int moxa_block_till_ready(struct tty_struct *, struct file *,
                            struct moxa_port *);
 static void moxa_setup_empty_event(struct tty_struct *);
@@ -374,7 +375,7 @@ static int __init moxa_init(void)
                ch->closing_wait = 30 * HZ;
                ch->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
                init_waitqueue_head(&ch->open_wait);
-               init_waitqueue_head(&ch->close_wait);
+               init_completion(&ch->close_wait);
 
                setup_timer(&ch->emptyTimer, moxa_check_xmit_empty,
                                (unsigned long)ch);
@@ -499,7 +500,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
        ch->tty = tty;
        if (!(ch->asyncflags & ASYNC_INITIALIZED)) {
                ch->statusflags = 0;
-               moxa_set_tty_param(tty);
+               moxa_set_tty_param(tty, tty->termios);
                MoxaPortLineCtrl(ch->port, 1, 1);
                MoxaPortEnable(ch->port);
                ch->asyncflags |= ASYNC_INITIALIZED;
@@ -577,7 +578,7 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
                wake_up_interruptible(&ch->open_wait);
        }
        ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
-       wake_up_interruptible(&ch->close_wait);
+       complete_all(&ch->close_wait);
 }
 
 static int moxa_write(struct tty_struct *tty,
@@ -802,7 +803,7 @@ static void moxa_set_termios(struct tty_struct *tty,
 
        if (ch == NULL)
                return;
-       moxa_set_tty_param(tty);
+       moxa_set_tty_param(tty, old_termios);
        if (!(old_termios->c_cflag & CLOCAL) &&
            (tty->termios->c_cflag & CLOCAL))
                wake_up_interruptible(&ch->open_wait);
@@ -902,11 +903,11 @@ static void moxa_poll(unsigned long ignored)
 
 /******************************************************************************/
 
-static void moxa_set_tty_param(struct tty_struct *tty)
+static void moxa_set_tty_param(struct tty_struct *tty, struct ktermios *old_termios)
 {
        register struct ktermios *ts;
        struct moxa_port *ch;
-       int rts, cts, txflow, rxflow, xany;
+       int rts, cts, txflow, rxflow, xany, baud;
 
        ch = (struct moxa_port *) tty->driver_data;
        ts = tty->termios;
@@ -923,8 +924,15 @@ static void moxa_set_tty_param(struct tty_struct *tty)
                rxflow = 1;
        if (ts->c_iflag & IXANY)
                xany = 1;
+
+       /* Clear the features we don't support */
+       ts->c_cflag &= ~CMSPAR;
        MoxaPortFlowCtrl(ch->port, rts, cts, txflow, rxflow, xany);
-       MoxaPortSetTermio(ch->port, ts, tty_get_baud_rate(tty));
+       baud = MoxaPortSetTermio(ch->port, ts, tty_get_baud_rate(tty));
+       if (baud == -1)
+               baud = tty_termios_baud_rate(old_termios);
+       /* Not put the baud rate into the termios data */
+       tty_encode_baud_rate(tty, baud, baud);
 }
 
 static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp,
@@ -941,7 +949,7 @@ static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp,
         */
        if (tty_hung_up_p(filp) || (ch->asyncflags & ASYNC_CLOSING)) {
                if (ch->asyncflags & ASYNC_CLOSING)
-                       interruptible_sleep_on(&ch->close_wait);
+                       wait_for_completion_interruptible(&ch->close_wait);
 #ifdef SERIAL_DO_RESTART
                if (ch->asyncflags & ASYNC_HUP_NOTIFY)
                        return (-EAGAIN);
@@ -2064,7 +2072,7 @@ int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud)
                if (baud >= 921600L)
                        return (-1);
        }
-       MoxaPortSetBaud(port, baud);
+       baud = MoxaPortSetBaud(port, baud);
 
        if (termio->c_iflag & (IXON | IXOFF | IXANY)) {
                writeb(termio->c_cc[VSTART], ofsAddr + FuncArg);
@@ -2073,7 +2081,7 @@ int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud)
                moxa_wait_finish(ofsAddr);
 
        }
-       return (0);
+       return (baud);
 }
 
 int MoxaPortGetLineOut(int port, int *dtrState, int *rtsState)