aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2015-02-17 23:04:46 -0500
committerJohan Hovold <johan@kernel.org>2015-02-26 11:13:05 -0500
commitd6f7f41274b548435ab5de1041a492fc4a714196 (patch)
tree5a64c8960be3e56e111e9f2499e413fefb41a4ca
parent2deb96b5d4bb20a33bfaf80e30f38f3433653054 (diff)
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>
-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)
47 int minor; 47 int minor;
48 48
49 port = to_usb_serial_port(dev); 49 port = to_usb_serial_port(dev);
50 if (!port) { 50 if (!port)
51 retval = -ENODEV; 51 return -ENODEV;
52 goto exit;
53 }
54 52
55 /* make sure suspend/resume doesn't race against port_probe */ 53 /* make sure suspend/resume doesn't race against port_probe */
56 retval = usb_autopm_get_interface(port->serial->interface); 54 retval = usb_autopm_get_interface(port->serial->interface);
57 if (retval) 55 if (retval)
58 goto exit; 56 return retval;
59 57
60 driver = port->serial->type; 58 driver = port->serial->type;
61 if (driver->port_probe) { 59 if (driver->port_probe) {
62 retval = driver->port_probe(port); 60 retval = driver->port_probe(port);
63 if (retval) 61 if (retval)
64 goto exit_with_autopm; 62 goto err_autopm_put;
65 } 63 }
66 64
67 minor = port->minor; 65 minor = port->minor;
68 tty_dev = tty_register_device(usb_serial_tty_driver, minor, dev); 66 tty_dev = tty_register_device(usb_serial_tty_driver, minor, dev);
69 if (IS_ERR(tty_dev)) { 67 if (IS_ERR(tty_dev)) {
70 retval = PTR_ERR(tty_dev); 68 retval = PTR_ERR(tty_dev);
71 if (driver->port_remove) 69 goto err_port_remove;
72 driver->port_remove(port);
73 goto exit_with_autopm;
74 } 70 }
75 71
72 usb_autopm_put_interface(port->serial->interface);
73
76 dev_info(&port->serial->dev->dev, 74 dev_info(&port->serial->dev->dev,
77 "%s converter now attached to ttyUSB%d\n", 75 "%s converter now attached to ttyUSB%d\n",
78 driver->description, minor); 76 driver->description, minor);
79 77
80exit_with_autopm: 78 return 0;
79
80err_port_remove:
81 if (driver->port_remove)
82 driver->port_remove(port);
83err_autopm_put:
81 usb_autopm_put_interface(port->serial->interface); 84 usb_autopm_put_interface(port->serial->interface);
82exit: 85
83 return retval; 86 return retval;
84} 87}
85 88