aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/common/roles.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/usb/common/roles.c b/drivers/usb/common/roles.c
index 15cc76e22123..99116af07f1d 100644
--- a/drivers/usb/common/roles.c
+++ b/drivers/usb/common/roles.c
@@ -109,8 +109,15 @@ static void *usb_role_switch_match(struct device_connection *con, int ep,
109 */ 109 */
110struct usb_role_switch *usb_role_switch_get(struct device *dev) 110struct usb_role_switch *usb_role_switch_get(struct device *dev)
111{ 111{
112 return device_connection_find_match(dev, "usb-role-switch", NULL, 112 struct usb_role_switch *sw;
113 usb_role_switch_match); 113
114 sw = device_connection_find_match(dev, "usb-role-switch", NULL,
115 usb_role_switch_match);
116
117 if (!IS_ERR_OR_NULL(sw))
118 WARN_ON(!try_module_get(sw->dev.parent->driver->owner));
119
120 return sw;
114} 121}
115EXPORT_SYMBOL_GPL(usb_role_switch_get); 122EXPORT_SYMBOL_GPL(usb_role_switch_get);
116 123
@@ -122,8 +129,10 @@ EXPORT_SYMBOL_GPL(usb_role_switch_get);
122 */ 129 */
123void usb_role_switch_put(struct usb_role_switch *sw) 130void usb_role_switch_put(struct usb_role_switch *sw)
124{ 131{
125 if (!IS_ERR_OR_NULL(sw)) 132 if (!IS_ERR_OR_NULL(sw)) {
126 put_device(&sw->dev); 133 put_device(&sw->dev);
134 module_put(sw->dev.parent->driver->owner);
135 }
127} 136}
128EXPORT_SYMBOL_GPL(usb_role_switch_put); 137EXPORT_SYMBOL_GPL(usb_role_switch_put);
129 138