Skip to contentSkip to conversation

usb: phy: return -ENODEV on failure of try_module_get

PATCH In review Arjun Sreedharan 2 participants 3 messages Aug 17, 2014 – Aug 18, 2014 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: phy: return -ENODEV on failure of try_module_get

When __usb_find_phy_dev() does not return error and try_module_get() fails, return -ENODEV

---
 drivers/usb/phy/phy.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/phy/phy.c +1 -0
index 36b6bce..8ad3638 100644
@@ -232,6 +232,7 @@ struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index)
 	phy = __usb_find_phy_dev(dev, &phy_bind_list, index);
 	if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
 		dev_dbg(dev, "unable to find transceiver\n");
+		phy = IS_ERR(phy) ? phy : ERR_PTR(-ENODEV);
 		goto err0;
 	}
 
Signature · 1 line
1.7.11.7
maintainer
#1 lore raw
Quoted 13 lines · Arjun Sreedharan

When __usb_find_phy_dev() does not return error and try_module_get() fails, return -ENODEV

---
 drivers/usb/phy/phy.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/phy/phy.c +0 -0
index 36b6bce..8ad3638 100644

drivers/usb/phy/phy.c struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index) · line 235

Quoted 4 lines
drivers/usb/phy/phy.c +1 -0
@@ -232,6 +232,7 @@ struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index)
 	phy = __usb_find_phy_dev(dev, &phy_bind_list, index);
 	if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
 		dev_dbg(dev, "unable to find transceiver\n");
+		phy = IS_ERR(phy) ? phy : ERR_PTR(-ENODEV);

Please just spell out the if () statement, don't use ? : unless necessary.

thanks,

greg k-h

#2 lore raw

PATCH 1/1 usb: phy: return -ENODEV on failure of try_module_get

When __usb_find_phy_dev() does not return error and try_module_get() fails, return -ENODEV.

---
 drivers/usb/phy/phy.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/phy/phy.c +3 -0
index 36b6bce..fd0d7f1 100644
@@ -232,6 +232,9 @@ struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index)
 	phy = __usb_find_phy_dev(dev, &phy_bind_list, index);
 	if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
 		dev_dbg(dev, "unable to find transceiver\n");
+		if (!IS_ERR(phy))
+			phy = ERR_PTR(-ENODEV);
+
 		goto err0;
 	}
 
Signature · 1 line
1.7.11.7