aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/console.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/console.c')
-rw-r--r--drivers/usb/serial/console.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index f347da2ef00a..1ee6b2ab0f89 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -66,7 +66,7 @@ static int usb_console_setup(struct console *co, char *options)
66 struct usb_serial_port *port; 66 struct usb_serial_port *port;
67 int retval; 67 int retval;
68 struct tty_struct *tty = NULL; 68 struct tty_struct *tty = NULL;
69 struct ktermios *termios = NULL, dummy; 69 struct ktermios dummy;
70 70
71 dbg("%s", __func__); 71 dbg("%s", __func__);
72 72
@@ -141,15 +141,14 @@ static int usb_console_setup(struct console *co, char *options)
141 goto reset_open_count; 141 goto reset_open_count;
142 } 142 }
143 kref_init(&tty->kref); 143 kref_init(&tty->kref);
144 termios = kzalloc(sizeof(*termios), GFP_KERNEL); 144 tty_port_tty_set(&port->port, tty);
145 if (!termios) { 145 tty->driver = usb_serial_tty_driver;
146 tty->index = co->index;
147 if (tty_init_termios(tty)) {
146 retval = -ENOMEM; 148 retval = -ENOMEM;
147 err("no more memory"); 149 err("no more memory");
148 goto free_tty; 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 /* only call the device specific open if this 154 /* only call the device specific open if this
@@ -161,16 +160,16 @@ static int usb_console_setup(struct console *co, char *options)
161 160
162 if (retval) { 161 if (retval) {
163 err("could not open USB console port"); 162 err("could not open USB console port");
164 goto free_termios; 163 goto fail;
165 } 164 }
166 165
167 if (serial->type->set_termios) { 166 if (serial->type->set_termios) {
168 termios->c_cflag = cflag; 167 tty->termios->c_cflag = cflag;
169 tty_termios_encode_baud_rate(termios, baud, baud); 168 tty_termios_encode_baud_rate(tty->termios, baud, baud);
169 memset(&dummy, 0, sizeof(struct ktermios));
170 serial->type->set_termios(tty, port, &dummy); 170 serial->type->set_termios(tty, port, &dummy);
171 171
172 tty_port_tty_set(&port->port, NULL); 172 tty_port_tty_set(&port->port, NULL);
173 kfree(termios);
174 kfree(tty); 173 kfree(tty);
175 } 174 }
176 set_bit(ASYNCB_INITIALIZED, &port->port.flags); 175 set_bit(ASYNCB_INITIALIZED, &port->port.flags);
@@ -180,14 +179,12 @@ static int usb_console_setup(struct console *co, char *options)
180 --port->port.count; 179 --port->port.count;
181 /* The console is special in terms of closing the device so 180 /* The console is special in terms of closing the device so
182 * indicate this port is now acting as a system console. */ 181 * indicate this port is now acting as a system console. */
183 port->console = 1;
184 port->port.console = 1; 182 port->port.console = 1;
185 183
186 mutex_unlock(&serial->disc_mutex); 184 mutex_unlock(&serial->disc_mutex);
187 return retval; 185 return retval;
188 186
189 free_termios: 187 fail:
190 kfree(termios);
191 tty_port_tty_set(&port->port, NULL); 188 tty_port_tty_set(&port->port, NULL);
192 free_tty: 189 free_tty:
193 kfree(tty); 190 kfree(tty);
@@ -217,7 +214,7 @@ static void usb_console_write(struct console *co,
217 214
218 dbg("%s - port %d, %d byte(s)", __func__, port->number, count); 215 dbg("%s - port %d, %d byte(s)", __func__, port->number, count);
219 216
220 if (!port->console) { 217 if (!port->port.console) {
221 dbg("%s - port not opened", __func__); 218 dbg("%s - port not opened", __func__);
222 return; 219 return;
223 } 220 }
@@ -313,7 +310,7 @@ void usb_serial_console_exit(void)
313{ 310{
314 if (usbcons_info.port) { 311 if (usbcons_info.port) {
315 unregister_console(&usbcons); 312 unregister_console(&usbcons);
316 usbcons_info.port->console = 0; 313 usbcons_info.port->port.console = 0;
317 usbcons_info.port = NULL; 314 usbcons_info.port = NULL;
318 } 315 }
319} 316}