diff options
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index de9111d97a58..92200f05b531 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -168,6 +168,11 @@ static void destroy_serial(struct kref *kref) | |||
168 | kfree (serial); | 168 | kfree (serial); |
169 | } | 169 | } |
170 | 170 | ||
171 | void usb_serial_put(struct usb_serial *serial) | ||
172 | { | ||
173 | kref_put(&serial->kref, destroy_serial); | ||
174 | } | ||
175 | |||
171 | /***************************************************************************** | 176 | /***************************************************************************** |
172 | * Driver tty interface functions | 177 | * Driver tty interface functions |
173 | *****************************************************************************/ | 178 | *****************************************************************************/ |
@@ -232,7 +237,7 @@ bailout_mutex_unlock: | |||
232 | port->open_count = 0; | 237 | port->open_count = 0; |
233 | mutex_unlock(&port->mutex); | 238 | mutex_unlock(&port->mutex); |
234 | bailout_kref_put: | 239 | bailout_kref_put: |
235 | kref_put(&serial->kref, destroy_serial); | 240 | usb_serial_put(serial); |
236 | return retval; | 241 | return retval; |
237 | } | 242 | } |
238 | 243 | ||
@@ -268,7 +273,7 @@ static void serial_close(struct tty_struct *tty, struct file * filp) | |||
268 | } | 273 | } |
269 | 274 | ||
270 | mutex_unlock(&port->mutex); | 275 | mutex_unlock(&port->mutex); |
271 | kref_put(&port->serial->kref, destroy_serial); | 276 | usb_serial_put(port->serial); |
272 | } | 277 | } |
273 | 278 | ||
274 | static int serial_write (struct tty_struct * tty, const unsigned char *buf, int count) | 279 | static int serial_write (struct tty_struct * tty, const unsigned char *buf, int count) |
@@ -276,7 +281,7 @@ static int serial_write (struct tty_struct * tty, const unsigned char *buf, int | |||
276 | struct usb_serial_port *port = tty->driver_data; | 281 | struct usb_serial_port *port = tty->driver_data; |
277 | int retval = -EINVAL; | 282 | int retval = -EINVAL; |
278 | 283 | ||
279 | if (!port) | 284 | if (!port || port->serial->dev->state == USB_STATE_NOTATTACHED) |
280 | goto exit; | 285 | goto exit; |
281 | 286 | ||
282 | dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count); | 287 | dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count); |
@@ -473,7 +478,7 @@ static int serial_read_proc (char *page, char **start, off_t off, int count, int | |||
473 | begin += length; | 478 | begin += length; |
474 | length = 0; | 479 | length = 0; |
475 | } | 480 | } |
476 | kref_put(&serial->kref, destroy_serial); | 481 | usb_serial_put(serial); |
477 | } | 482 | } |
478 | *eof = 1; | 483 | *eof = 1; |
479 | done: | 484 | done: |
@@ -985,6 +990,7 @@ void usb_serial_disconnect(struct usb_interface *interface) | |||
985 | struct device *dev = &interface->dev; | 990 | struct device *dev = &interface->dev; |
986 | struct usb_serial_port *port; | 991 | struct usb_serial_port *port; |
987 | 992 | ||
993 | usb_serial_console_disconnect(serial); | ||
988 | dbg ("%s", __FUNCTION__); | 994 | dbg ("%s", __FUNCTION__); |
989 | 995 | ||
990 | usb_set_intfdata (interface, NULL); | 996 | usb_set_intfdata (interface, NULL); |
@@ -996,7 +1002,7 @@ void usb_serial_disconnect(struct usb_interface *interface) | |||
996 | } | 1002 | } |
997 | /* let the last holder of this object | 1003 | /* let the last holder of this object |
998 | * cause it to be cleaned up */ | 1004 | * cause it to be cleaned up */ |
999 | kref_put(&serial->kref, destroy_serial); | 1005 | usb_serial_put(serial); |
1000 | } | 1006 | } |
1001 | dev_info(dev, "device disconnected\n"); | 1007 | dev_info(dev, "device disconnected\n"); |
1002 | } | 1008 | } |