Commit 1dd03d8a authored by Marc Kleine-Budde's avatar Marc Kleine-Budde Committed by Felipe Balbi

usb: otg: use try_module_get in all usb_get_phy functions and add missing module_put

In patch "5d3c28b5 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: default avatarSteffen Trumtrar <s.trumtrar@pengutronix.de>
Reviewed-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: default avatarMichael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent a10840c9
...@@ -130,7 +130,7 @@ struct usb_phy *usb_get_phy(enum usb_phy_type type) ...@@ -130,7 +130,7 @@ struct usb_phy *usb_get_phy(enum usb_phy_type type)
spin_lock_irqsave(&phy_lock, flags); spin_lock_irqsave(&phy_lock, flags);
phy = __usb_find_phy(&phy_list, type); phy = __usb_find_phy(&phy_list, type);
if (IS_ERR(phy)) { if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
pr_err("unable to find transceiver of type %s\n", pr_err("unable to find transceiver of type %s\n",
usb_phy_type_string(type)); usb_phy_type_string(type));
goto err0; goto err0;
...@@ -228,7 +228,7 @@ struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index) ...@@ -228,7 +228,7 @@ struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index)
spin_lock_irqsave(&phy_lock, flags); spin_lock_irqsave(&phy_lock, flags);
phy = __usb_find_phy_dev(dev, &phy_bind_list, index); phy = __usb_find_phy_dev(dev, &phy_bind_list, index);
if (IS_ERR(phy)) { if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
pr_err("unable to find transceiver\n"); pr_err("unable to find transceiver\n");
goto err0; goto err0;
} }
...@@ -301,8 +301,12 @@ EXPORT_SYMBOL(devm_usb_put_phy); ...@@ -301,8 +301,12 @@ EXPORT_SYMBOL(devm_usb_put_phy);
*/ */
void usb_put_phy(struct usb_phy *x) void usb_put_phy(struct usb_phy *x)
{ {
if (x) if (x) {
struct module *owner = x->dev->driver->owner;
put_device(x->dev); put_device(x->dev);
module_put(owner);
}
} }
EXPORT_SYMBOL(usb_put_phy); EXPORT_SYMBOL(usb_put_phy);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment