diff options
Diffstat (limited to 'drivers/usb/serial/bus.c')
-rw-r--r-- | drivers/usb/serial/bus.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index f398d1e34474..c15f2e7cefc7 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c | |||
@@ -61,18 +61,23 @@ static int usb_serial_device_probe(struct device *dev) | |||
61 | goto exit; | 61 | goto exit; |
62 | } | 62 | } |
63 | 63 | ||
64 | /* make sure suspend/resume doesn't race against port_probe */ | ||
65 | retval = usb_autopm_get_interface(port->serial->interface); | ||
66 | if (retval) | ||
67 | goto exit; | ||
68 | |||
64 | driver = port->serial->type; | 69 | driver = port->serial->type; |
65 | if (driver->port_probe) { | 70 | if (driver->port_probe) { |
66 | retval = driver->port_probe(port); | 71 | retval = driver->port_probe(port); |
67 | if (retval) | 72 | if (retval) |
68 | goto exit; | 73 | goto exit_with_autopm; |
69 | } | 74 | } |
70 | 75 | ||
71 | retval = device_create_file(dev, &dev_attr_port_number); | 76 | retval = device_create_file(dev, &dev_attr_port_number); |
72 | if (retval) { | 77 | if (retval) { |
73 | if (driver->port_remove) | 78 | if (driver->port_remove) |
74 | retval = driver->port_remove(port); | 79 | retval = driver->port_remove(port); |
75 | goto exit; | 80 | goto exit_with_autopm; |
76 | } | 81 | } |
77 | 82 | ||
78 | minor = port->number; | 83 | minor = port->number; |
@@ -81,6 +86,8 @@ static int usb_serial_device_probe(struct device *dev) | |||
81 | "%s converter now attached to ttyUSB%d\n", | 86 | "%s converter now attached to ttyUSB%d\n", |
82 | driver->description, minor); | 87 | driver->description, minor); |
83 | 88 | ||
89 | exit_with_autopm: | ||
90 | usb_autopm_put_interface(port->serial->interface); | ||
84 | exit: | 91 | exit: |
85 | return retval; | 92 | return retval; |
86 | } | 93 | } |
@@ -96,6 +103,9 @@ static int usb_serial_device_remove(struct device *dev) | |||
96 | if (!port) | 103 | if (!port) |
97 | return -ENODEV; | 104 | return -ENODEV; |
98 | 105 | ||
106 | /* make sure suspend/resume doesn't race against port_remove */ | ||
107 | usb_autopm_get_interface(port->serial->interface); | ||
108 | |||
99 | device_remove_file(&port->dev, &dev_attr_port_number); | 109 | device_remove_file(&port->dev, &dev_attr_port_number); |
100 | 110 | ||
101 | driver = port->serial->type; | 111 | driver = port->serial->type; |
@@ -107,6 +117,7 @@ static int usb_serial_device_remove(struct device *dev) | |||
107 | dev_info(dev, "%s converter now disconnected from ttyUSB%d\n", | 117 | dev_info(dev, "%s converter now disconnected from ttyUSB%d\n", |
108 | driver->description, minor); | 118 | driver->description, minor); |
109 | 119 | ||
120 | usb_autopm_put_interface(port->serial->interface); | ||
110 | return retval; | 121 | return retval; |
111 | } | 122 | } |
112 | 123 | ||