Commit 92d2c5e4badc622999d3b17e6dfbf6babacb52f6

Authored by Jason Wessel
Committed by Greg Kroah-Hartman
1 parent aae86e8adb

usb-console: pass baud from console to the initial tty open

The usb console code has had a long standing problem of not being able
to pass the baud rate from the kernel argument console=ttyUSB0,BAUD
down to the initial tty open, unless you were willing to settle for
9600 baud.

The solution is to directly use tty_init_termios() in
usb_console_setup() as this will preserve any changes to the initial
termios setting on future opens.

CC: Alan Cox <alan@linux.intel.com>
CC: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 1 changed file with 10 additions and 12 deletions Side-by-side Diff

drivers/usb/serial/console.c
... ... @@ -66,7 +66,7 @@
66 66 struct usb_serial_port *port;
67 67 int retval;
68 68 struct tty_struct *tty = NULL;
69   - struct ktermios *termios = NULL, dummy;
  69 + struct ktermios dummy;
70 70  
71 71 dbg("%s", __func__);
72 72  
73 73  
... ... @@ -141,15 +141,14 @@
141 141 goto reset_open_count;
142 142 }
143 143 kref_init(&tty->kref);
144   - termios = kzalloc(sizeof(*termios), GFP_KERNEL);
145   - if (!termios) {
  144 + tty_port_tty_set(&port->port, tty);
  145 + tty->driver = usb_serial_tty_driver;
  146 + tty->index = co->index;
  147 + if (tty_init_termios(tty)) {
146 148 retval = -ENOMEM;
147 149 err("no more memory");
148 150 goto free_tty;
149 151 }
150   - memset(&dummy, 0, sizeof(struct ktermios));
151   - tty->termios = termios;
152   - tty_port_tty_set(&port->port, tty);
153 152 }
154 153  
155 154 /* only call the device specific open if this
156 155  
157 156  
... ... @@ -161,16 +160,16 @@
161 160  
162 161 if (retval) {
163 162 err("could not open USB console port");
164   - goto free_termios;
  163 + goto fail;
165 164 }
166 165  
167 166 if (serial->type->set_termios) {
168   - termios->c_cflag = cflag;
169   - tty_termios_encode_baud_rate(termios, baud, baud);
  167 + tty->termios->c_cflag = cflag;
  168 + tty_termios_encode_baud_rate(tty->termios, baud, baud);
  169 + memset(&dummy, 0, sizeof(struct ktermios));
170 170 serial->type->set_termios(tty, port, &dummy);
171 171  
172 172 tty_port_tty_set(&port->port, NULL);
173   - kfree(termios);
174 173 kfree(tty);
175 174 }
176 175 set_bit(ASYNCB_INITIALIZED, &port->port.flags);
... ... @@ -185,8 +184,7 @@
185 184 mutex_unlock(&serial->disc_mutex);
186 185 return retval;
187 186  
188   - free_termios:
189   - kfree(termios);
  187 + fail:
190 188 tty_port_tty_set(&port->port, NULL);
191 189 free_tty:
192 190 kfree(tty);