Skip to content

Commit

Permalink
USB: serial: clean up usb-serial bus device removal
Browse files Browse the repository at this point in the history
Make sure to unregister the tty-device before calling subdriver
port_remove.

This way remove will reverse probe, and specifically any port data
released in port_remove will be available throughout tty unregister.

Note that the order currently does not matter as the tty-layer can make
callbacks also after the device has been unregistered. This is
handled in usb-serial core using the disconnected flag, which is
already set when usb-serial bus device remove is called.

Cc: Peter Hurley <peter@hurleysoftware.com>
Reported-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Johan Hovold authored and Greg Kroah-Hartman committed Mar 25, 2013
1 parent 6a5c821 commit 5cb27dd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/usb/serial/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,15 @@ static int usb_serial_device_remove(struct device *dev)
/* make sure suspend/resume doesn't race against port_remove */
usb_autopm_get_interface(port->serial->interface);

minor = port->number;
tty_unregister_device(usb_serial_tty_driver, minor);

device_remove_file(&port->dev, &dev_attr_port_number);

driver = port->serial->type;
if (driver->port_remove)
retval = driver->port_remove(port);

minor = port->number;
tty_unregister_device(usb_serial_tty_driver, minor);
dev_info(dev, "%s converter now disconnected from ttyUSB%d\n",
driver->description, minor);

Expand Down

0 comments on commit 5cb27dd

Please sign in to comment.