USB: usb_serial_console: fix command line parsing
[cascardo/linux.git] / drivers / usb / serial / console.c
index 7167728..72ab3bb 100644 (file)
@@ -65,7 +65,7 @@ static int usb_console_setup(struct console *co, char *options)
        struct usb_serial_port *port;
        int retval = 0;
        struct tty_struct *tty;
-       struct termios *termios;
+       struct ktermios *termios;
 
        dbg ("%s", __FUNCTION__);
 
@@ -133,11 +133,14 @@ static int usb_console_setup(struct console *co, char *options)
        }
        co->cflag = cflag;
 
-       /* grab the first serial port that happens to be connected */
-       serial = usb_serial_get_by_index(0);
+       /*
+        * no need to check the index here: if the index is wrong, console
+        * code won't call us
+        */
+       serial = usb_serial_get_by_index(co->index);
        if (serial == NULL) {
                /* no device is connected yet, sorry :( */
-               err ("No USB device connected to ttyUSB0");
+               err ("No USB device connected to ttyUSB%i", co->index);
                return -ENODEV;
        }
 
@@ -164,6 +167,7 @@ static int usb_console_setup(struct console *co, char *options)
        }
 
        if (serial->type->set_termios) {
+               struct ktermios dummy;
                /* build up a fake tty structure so that the open call has something
                 * to look at to get the cflag value */
                tty = kzalloc(sizeof(*tty), GFP_KERNEL);
@@ -177,12 +181,13 @@ static int usb_console_setup(struct console *co, char *options)
                        kfree (tty);
                        return -ENOMEM;
                }
+               memset(&dummy, 0, sizeof(struct ktermios));
                termios->c_cflag = cflag;
                tty->termios = termios;
                port->tty = tty;
 
                /* set up the initial termios settings */
-               serial->type->set_termios(port, NULL);
+               serial->type->set_termios(port, &dummy);
                port->tty = NULL;
                kfree (termios);
                kfree (tty);