]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/usb/serial/ark3116.c
Merge branch 'for-2.6.24' of master.kernel.org:/pub/scm/linux/kernel/git/galak/powerp...
[linux-2.6-omap-h63xx.git] / drivers / usb / serial / ark3116.c
index fe437125f14bc9f86cdb2b4352c04c2c2528aca6..ddfee918000dc5fd8b6b997d75a81625472821c4 100644 (file)
@@ -161,7 +161,8 @@ static void ark3116_set_termios(struct usb_serial_port *port,
 {
        struct usb_serial *serial = port->serial;
        struct ark3116_private *priv = usb_get_serial_port_data(port);
-       unsigned int cflag = port->tty->termios->c_cflag;
+       struct ktermios *termios = port->tty->termios;
+       unsigned int cflag = termios->c_cflag;
        unsigned long flags;
        int baud;
        int ark3116_baud;
@@ -172,31 +173,19 @@ static void ark3116_set_termios(struct usb_serial_port *port,
 
        dbg("%s - port %d", __FUNCTION__, port->number);
 
-       if ((!port->tty) || (!port->tty->termios)) {
-               dbg("%s - no tty structures", __FUNCTION__);
-               return;
-       }
-
        spin_lock_irqsave(&priv->lock, flags);
        if (!priv->termios_initialized) {
                *(port->tty->termios) = tty_std_termios;
                port->tty->termios->c_cflag = B9600 | CS8
                                              | CREAD | HUPCL | CLOCAL;
+               termios->c_ispeed = 9600;
+               termios->c_ospeed = 9600;
                priv->termios_initialized = 1;
        }
        spin_unlock_irqrestore(&priv->lock, flags);
 
-       cflag = port->tty->termios->c_cflag;
-
-       /* check that they really want us to change something: */
-       if (old_termios) {
-               if ((cflag == old_termios->c_cflag) &&
-                   (RELEVANT_IFLAG(port->tty->termios->c_iflag) ==
-                    RELEVANT_IFLAG(old_termios->c_iflag))) {
-                       dbg("%s - nothing to change...", __FUNCTION__);
-                       return;
-               }
-       }
+       cflag = termios->c_cflag;
+       termios->c_cflag &= ~(CMSPAR|CRTSCTS);
 
        buf = kmalloc(1, GFP_KERNEL);
        if (!buf) {
@@ -220,7 +209,7 @@ static void ark3116_set_termios(struct usb_serial_port *port,
                        dbg("setting CS7");
                        break;
                default:
-                       err("CSIZE was set but not CS5-CS8, using CS8!");
+                       dbg("CSIZE was set but not CS5-CS8, using CS8!");
                        /* fall through */
                case CS8:
                        config |= 0x03;
@@ -251,38 +240,37 @@ static void ark3116_set_termios(struct usb_serial_port *port,
        }
 
        /* set baudrate */
-       baud = 0;
-       switch (cflag & CBAUD) {
-               case B0:
-                       err("can't set 0 baud, using 9600 instead");
+       baud = tty_get_baud_rate(port->tty);
+
+       switch (baud) {
+               case 75:
+               case 150:
+               case 300:
+               case 600:
+               case 1200:
+               case 1800:
+               case 2400:
+               case 4800:
+               case 9600:
+               case 19200:
+               case 38400:
+               case 57600:
+               case 115200:
+               case 230400:
+               case 460800:
+                       /* Report the resulting rate back to the caller */
+                       tty_encode_baud_rate(port->tty, baud, baud);
                        break;
-               case B75:       baud = 75;      break;
-               case B150:      baud = 150;     break;
-               case B300:      baud = 300;     break;
-               case B600:      baud = 600;     break;
-               case B1200:     baud = 1200;    break;
-               case B1800:     baud = 1800;    break;
-               case B2400:     baud = 2400;    break;
-               case B4800:     baud = 4800;    break;
-               case B9600:     baud = 9600;    break;
-               case B19200:    baud = 19200;   break;
-               case B38400:    baud = 38400;   break;
-               case B57600:    baud = 57600;   break;
-               case B115200:   baud = 115200;  break;
-               case B230400:   baud = 230400;  break;
-               case B460800:   baud = 460800;  break;
+               /* set 9600 as default (if given baudrate is invalid for example) */
                default:
-                       dbg("does not support the baudrate requested (fix it)");
-                       break;
+                       tty_encode_baud_rate(port->tty, 9600, 9600);
+               case 0:
+                       baud = 9600;
        }
 
-       /* set 9600 as default (if given baudrate is invalid for example) */
-       if (baud == 0)
-               baud = 9600;
-
        /*
         * found by try'n'error, be careful, maybe there are other options
-        * for multiplicator etc!
+        * for multiplicator etc! (3.5 for example)
         */
        if (baud == 460800)
                /* strange, for 460800 the formula is wrong
@@ -322,6 +310,7 @@ static void ark3116_set_termios(struct usb_serial_port *port,
        /* TEST ARK3116_SND(154, 0xFE, 0x40, 0xFFFF, 0x0006); */
 
        kfree(buf);
+
        return;
 }