linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: phy: return -ENODEV on failure of try_module_get
@ 2014-08-17 18:34 Arjun Sreedharan
  2014-08-18  1:59 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Arjun Sreedharan @ 2014-08-17 18:34 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, linux-usb, linux-kernel

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

Signed-off-by: Arjun Sreedharan <arjun024@gmail.com>
---
 drivers/usb/phy/phy.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index 36b6bce..8ad3638 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -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;
 	}
 
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: phy: return -ENODEV on failure of try_module_get
  2014-08-17 18:34 [PATCH] usb: phy: return -ENODEV on failure of try_module_get Arjun Sreedharan
@ 2014-08-18  1:59 ` Greg KH
  2014-08-18  5:47   ` Arjun Sreedharan
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2014-08-18  1:59 UTC (permalink / raw)
  To: Arjun Sreedharan; +Cc: balbi, linux-usb, linux-kernel

On Mon, Aug 18, 2014 at 12:04:42AM +0530, Arjun Sreedharan wrote:
> When __usb_find_phy_dev() does not return error and
> try_module_get() fails, return -ENODEV
> 
> Signed-off-by: Arjun Sreedharan <arjun024@gmail.com>
> ---
>  drivers/usb/phy/phy.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
> index 36b6bce..8ad3638 100644
> --- a/drivers/usb/phy/phy.c
> +++ b/drivers/usb/phy/phy.c
> @@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] usb: phy: return -ENODEV on failure of try_module_get
  2014-08-18  1:59 ` Greg KH
@ 2014-08-18  5:47   ` Arjun Sreedharan
  0 siblings, 0 replies; 3+ messages in thread
From: Arjun Sreedharan @ 2014-08-18  5:47 UTC (permalink / raw)
  To: balbi, gregkh; +Cc: linux-usb, linux-kernel

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

Signed-off-by: Arjun Sreedharan <arjun024@gmail.com>
---
 drivers/usb/phy/phy.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index 36b6bce..fd0d7f1 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -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;
 	}
 
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-18  5:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-17 18:34 [PATCH] usb: phy: return -ENODEV on failure of try_module_get Arjun Sreedharan
2014-08-18  1:59 ` Greg KH
2014-08-18  5:47   ` Arjun Sreedharan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).