diff options
Diffstat (limited to 'drivers/usb/serial/bus.c')
-rw-r--r-- | drivers/usb/serial/bus.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index 9374bd2aba20..8936a83c96cd 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c | |||
@@ -38,56 +38,51 @@ static int usb_serial_device_match(struct device *dev, | |||
38 | return 0; | 38 | return 0; |
39 | } | 39 | } |
40 | 40 | ||
41 | static ssize_t port_number_show(struct device *dev, | ||
42 | struct device_attribute *attr, char *buf) | ||
43 | { | ||
44 | struct usb_serial_port *port = to_usb_serial_port(dev); | ||
45 | |||
46 | return sprintf(buf, "%d\n", port->port_number); | ||
47 | } | ||
48 | static DEVICE_ATTR_RO(port_number); | ||
49 | |||
50 | static int usb_serial_device_probe(struct device *dev) | 41 | static int usb_serial_device_probe(struct device *dev) |
51 | { | 42 | { |
52 | struct usb_serial_driver *driver; | 43 | struct usb_serial_driver *driver; |
53 | struct usb_serial_port *port; | 44 | struct usb_serial_port *port; |
45 | struct device *tty_dev; | ||
54 | int retval = 0; | 46 | int retval = 0; |
55 | int minor; | 47 | int minor; |
56 | 48 | ||
57 | port = to_usb_serial_port(dev); | 49 | port = to_usb_serial_port(dev); |
58 | if (!port) { | 50 | if (!port) |
59 | retval = -ENODEV; | 51 | return -ENODEV; |
60 | goto exit; | ||
61 | } | ||
62 | 52 | ||
63 | /* make sure suspend/resume doesn't race against port_probe */ | 53 | /* make sure suspend/resume doesn't race against port_probe */ |
64 | retval = usb_autopm_get_interface(port->serial->interface); | 54 | retval = usb_autopm_get_interface(port->serial->interface); |
65 | if (retval) | 55 | if (retval) |
66 | goto exit; | 56 | return retval; |
67 | 57 | ||
68 | driver = port->serial->type; | 58 | driver = port->serial->type; |
69 | if (driver->port_probe) { | 59 | if (driver->port_probe) { |
70 | retval = driver->port_probe(port); | 60 | retval = driver->port_probe(port); |
71 | if (retval) | 61 | if (retval) |
72 | goto exit_with_autopm; | 62 | goto err_autopm_put; |
73 | } | 63 | } |
74 | 64 | ||
75 | retval = device_create_file(dev, &dev_attr_port_number); | 65 | minor = port->minor; |
76 | if (retval) { | 66 | tty_dev = tty_register_device(usb_serial_tty_driver, minor, dev); |
77 | if (driver->port_remove) | 67 | if (IS_ERR(tty_dev)) { |
78 | retval = driver->port_remove(port); | 68 | retval = PTR_ERR(tty_dev); |
79 | goto exit_with_autopm; | 69 | goto err_port_remove; |
80 | } | 70 | } |
81 | 71 | ||
82 | minor = port->minor; | 72 | usb_autopm_put_interface(port->serial->interface); |
83 | tty_register_device(usb_serial_tty_driver, minor, dev); | 73 | |
84 | dev_info(&port->serial->dev->dev, | 74 | dev_info(&port->serial->dev->dev, |
85 | "%s converter now attached to ttyUSB%d\n", | 75 | "%s converter now attached to ttyUSB%d\n", |
86 | driver->description, minor); | 76 | driver->description, minor); |
87 | 77 | ||
88 | exit_with_autopm: | 78 | return 0; |
79 | |||
80 | err_port_remove: | ||
81 | if (driver->port_remove) | ||
82 | driver->port_remove(port); | ||
83 | err_autopm_put: | ||
89 | usb_autopm_put_interface(port->serial->interface); | 84 | usb_autopm_put_interface(port->serial->interface); |
90 | exit: | 85 | |
91 | return retval; | 86 | return retval; |
92 | } | 87 | } |
93 | 88 | ||
@@ -114,8 +109,6 @@ static int usb_serial_device_remove(struct device *dev) | |||
114 | minor = port->minor; | 109 | minor = port->minor; |
115 | tty_unregister_device(usb_serial_tty_driver, minor); | 110 | tty_unregister_device(usb_serial_tty_driver, minor); |
116 | 111 | ||
117 | device_remove_file(&port->dev, &dev_attr_port_number); | ||
118 | |||
119 | driver = port->serial->type; | 112 | driver = port->serial->type; |
120 | if (driver->port_remove) | 113 | if (driver->port_remove) |
121 | retval = driver->port_remove(port); | 114 | retval = driver->port_remove(port); |