summaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2015-02-18 11:04:46 +0700
committerJohan Hovold <johan@kernel.org>2015-02-26 17:13:05 +0100
commitd6f7f41274b548435ab5de1041a492fc4a714196 (patch)
tree5a64c8960be3e56e111e9f2499e413fefb41a4ca /drivers/usb/serial
parent2deb96b5d4bb20a33bfaf80e30f38f3433653054 (diff)
downloadlinux-d6f7f41274b548435ab5de1041a492fc4a714196.tar.bz2
USB: serial: clean up bus probe error handling
Clean up bus probe error handling by separating success and error paths. Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r--drivers/usb/serial/bus.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index b53a28692226..8936a83c96cd 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -47,39 +47,42 @@ static int usb_serial_device_probe(struct device *dev)
int minor;
port = to_usb_serial_port(dev);
- if (!port) {
- retval = -ENODEV;
- goto exit;
- }
+ if (!port)
+ return -ENODEV;
/* make sure suspend/resume doesn't race against port_probe */
retval = usb_autopm_get_interface(port->serial->interface);
if (retval)
- goto exit;
+ return retval;
driver = port->serial->type;
if (driver->port_probe) {
retval = driver->port_probe(port);
if (retval)
- goto exit_with_autopm;
+ goto err_autopm_put;
}
minor = port->minor;
tty_dev = tty_register_device(usb_serial_tty_driver, minor, dev);
if (IS_ERR(tty_dev)) {
retval = PTR_ERR(tty_dev);
- if (driver->port_remove)
- driver->port_remove(port);
- goto exit_with_autopm;
+ goto err_port_remove;
}
+ usb_autopm_put_interface(port->serial->interface);
+
dev_info(&port->serial->dev->dev,
"%s converter now attached to ttyUSB%d\n",
driver->description, minor);
-exit_with_autopm:
+ return 0;
+
+err_port_remove:
+ if (driver->port_remove)
+ driver->port_remove(port);
+err_autopm_put:
usb_autopm_put_interface(port->serial->interface);
-exit:
+
return retval;
}