Commit d6f7f412 authored by Johan Hovold's avatar Johan Hovold

USB: serial: clean up bus probe error handling

Clean up bus probe error handling by separating success and error paths.
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 2deb96b5
...@@ -47,39 +47,42 @@ static int usb_serial_device_probe(struct device *dev) ...@@ -47,39 +47,42 @@ static int usb_serial_device_probe(struct device *dev)
int minor; int minor;
port = to_usb_serial_port(dev); port = to_usb_serial_port(dev);
if (!port) { if (!port)
retval = -ENODEV; return -ENODEV;
goto exit;
}
/* make sure suspend/resume doesn't race against port_probe */ /* make sure suspend/resume doesn't race against port_probe */
retval = usb_autopm_get_interface(port->serial->interface); retval = usb_autopm_get_interface(port->serial->interface);
if (retval) if (retval)
goto exit; return retval;
driver = port->serial->type; driver = port->serial->type;
if (driver->port_probe) { if (driver->port_probe) {
retval = driver->port_probe(port); retval = driver->port_probe(port);
if (retval) if (retval)
goto exit_with_autopm; goto err_autopm_put;
} }
minor = port->minor; minor = port->minor;
tty_dev = tty_register_device(usb_serial_tty_driver, minor, dev); tty_dev = tty_register_device(usb_serial_tty_driver, minor, dev);
if (IS_ERR(tty_dev)) { if (IS_ERR(tty_dev)) {
retval = PTR_ERR(tty_dev); retval = PTR_ERR(tty_dev);
if (driver->port_remove) goto err_port_remove;
driver->port_remove(port);
goto exit_with_autopm;
} }
usb_autopm_put_interface(port->serial->interface);
dev_info(&port->serial->dev->dev, dev_info(&port->serial->dev->dev,
"%s converter now attached to ttyUSB%d\n", "%s converter now attached to ttyUSB%d\n",
driver->description, minor); 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); usb_autopm_put_interface(port->serial->interface);
exit:
return retval; return retval;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment