diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/serial/console.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index be086e4c76b6..b22ac3258523 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/tty.h> | 17 | #include <linux/tty.h> |
18 | #include <linux/console.h> | 18 | #include <linux/console.h> |
19 | #include <linux/serial.h> | ||
19 | #include <linux/usb.h> | 20 | #include <linux/usb.h> |
20 | #include <linux/usb/serial.h> | 21 | #include <linux/usb/serial.h> |
21 | 22 | ||
@@ -63,7 +64,7 @@ static int usb_console_setup(struct console *co, char *options) | |||
63 | char *s; | 64 | char *s; |
64 | struct usb_serial *serial; | 65 | struct usb_serial *serial; |
65 | struct usb_serial_port *port; | 66 | struct usb_serial_port *port; |
66 | int retval = 0; | 67 | int retval; |
67 | struct tty_struct *tty = NULL; | 68 | struct tty_struct *tty = NULL; |
68 | struct ktermios *termios = NULL, dummy; | 69 | struct ktermios *termios = NULL, dummy; |
69 | 70 | ||
@@ -116,13 +117,17 @@ static int usb_console_setup(struct console *co, char *options) | |||
116 | return -ENODEV; | 117 | return -ENODEV; |
117 | } | 118 | } |
118 | 119 | ||
119 | port = serial->port[0]; | 120 | retval = usb_autopm_get_interface(serial->interface); |
121 | if (retval) | ||
122 | goto error_get_interface; | ||
123 | |||
124 | port = serial->port[co->index - serial->minor]; | ||
120 | tty_port_tty_set(&port->port, NULL); | 125 | tty_port_tty_set(&port->port, NULL); |
121 | 126 | ||
122 | info->port = port; | 127 | info->port = port; |
123 | 128 | ||
124 | ++port->port.count; | 129 | ++port->port.count; |
125 | if (port->port.count == 1) { | 130 | if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) { |
126 | if (serial->type->set_termios) { | 131 | if (serial->type->set_termios) { |
127 | /* | 132 | /* |
128 | * allocate a fake tty so the driver can initialize | 133 | * allocate a fake tty so the driver can initialize |
@@ -168,6 +173,7 @@ static int usb_console_setup(struct console *co, char *options) | |||
168 | kfree(termios); | 173 | kfree(termios); |
169 | kfree(tty); | 174 | kfree(tty); |
170 | } | 175 | } |
176 | set_bit(ASYNCB_INITIALIZED, &port->port.flags); | ||
171 | } | 177 | } |
172 | /* Now that any required fake tty operations are completed restore | 178 | /* Now that any required fake tty operations are completed restore |
173 | * the tty port count */ | 179 | * the tty port count */ |
@@ -175,18 +181,22 @@ static int usb_console_setup(struct console *co, char *options) | |||
175 | /* The console is special in terms of closing the device so | 181 | /* The console is special in terms of closing the device so |
176 | * indicate this port is now acting as a system console. */ | 182 | * indicate this port is now acting as a system console. */ |
177 | port->console = 1; | 183 | port->console = 1; |
178 | retval = 0; | ||
179 | 184 | ||
180 | out: | 185 | mutex_unlock(&serial->disc_mutex); |
181 | return retval; | 186 | return retval; |
182 | free_termios: | 187 | |
188 | free_termios: | ||
183 | kfree(termios); | 189 | kfree(termios); |
184 | tty_port_tty_set(&port->port, NULL); | 190 | tty_port_tty_set(&port->port, NULL); |
185 | free_tty: | 191 | free_tty: |
186 | kfree(tty); | 192 | kfree(tty); |
187 | reset_open_count: | 193 | reset_open_count: |
188 | port->port.count = 0; | 194 | port->port.count = 0; |
189 | goto out; | 195 | usb_autopm_put_interface(serial->interface); |
196 | error_get_interface: | ||
197 | usb_serial_put(serial); | ||
198 | mutex_unlock(&serial->disc_mutex); | ||
199 | return retval; | ||
190 | } | 200 | } |
191 | 201 | ||
192 | static void usb_console_write(struct console *co, | 202 | static void usb_console_write(struct console *co, |