diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2013-02-27 09:11:13 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-03-04 02:33:30 -0500 |
commit | 1dd03d8a510dae402096b194385a1373100450dc (patch) | |
tree | fdb98b38bb816b090e36a66720abb0ec04a67802 /drivers/usb/otg | |
parent | a10840c9acbeca7aada3543823fdb59909342d96 (diff) |
usb: otg: use try_module_get in all usb_get_phy functions and add missing module_put
In patch "5d3c28b usb: otg: add device tree support to otg library"
devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to lock the
phy driver in memory. The corresponding module_put() is missing in that patch.
This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
Further the missing module_put() is added to usb_put_phy().
Tested-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/otg')
-rw-r--r-- | drivers/usb/otg/otg.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c index e1814397ca3a..2bd03d261a50 100644 --- a/drivers/usb/otg/otg.c +++ b/drivers/usb/otg/otg.c | |||
@@ -130,7 +130,7 @@ struct usb_phy *usb_get_phy(enum usb_phy_type type) | |||
130 | spin_lock_irqsave(&phy_lock, flags); | 130 | spin_lock_irqsave(&phy_lock, flags); |
131 | 131 | ||
132 | phy = __usb_find_phy(&phy_list, type); | 132 | phy = __usb_find_phy(&phy_list, type); |
133 | if (IS_ERR(phy)) { | 133 | if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) { |
134 | pr_err("unable to find transceiver of type %s\n", | 134 | pr_err("unable to find transceiver of type %s\n", |
135 | usb_phy_type_string(type)); | 135 | usb_phy_type_string(type)); |
136 | goto err0; | 136 | goto err0; |
@@ -228,7 +228,7 @@ struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index) | |||
228 | spin_lock_irqsave(&phy_lock, flags); | 228 | spin_lock_irqsave(&phy_lock, flags); |
229 | 229 | ||
230 | phy = __usb_find_phy_dev(dev, &phy_bind_list, index); | 230 | phy = __usb_find_phy_dev(dev, &phy_bind_list, index); |
231 | if (IS_ERR(phy)) { | 231 | if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) { |
232 | pr_err("unable to find transceiver\n"); | 232 | pr_err("unable to find transceiver\n"); |
233 | goto err0; | 233 | goto err0; |
234 | } | 234 | } |
@@ -301,8 +301,12 @@ EXPORT_SYMBOL(devm_usb_put_phy); | |||
301 | */ | 301 | */ |
302 | void usb_put_phy(struct usb_phy *x) | 302 | void usb_put_phy(struct usb_phy *x) |
303 | { | 303 | { |
304 | if (x) | 304 | if (x) { |
305 | struct module *owner = x->dev->driver->owner; | ||
306 | |||
305 | put_device(x->dev); | 307 | put_device(x->dev); |
308 | module_put(owner); | ||
309 | } | ||
306 | } | 310 | } |
307 | EXPORT_SYMBOL(usb_put_phy); | 311 | EXPORT_SYMBOL(usb_put_phy); |
308 | 312 | ||