Re: [PATCH] phy: core: properly handle failure of pm_runtime_get functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 20, 2013 at 11:29:04AM +0530, Kishon Vijay Abraham I wrote:
> Hi Felipe,
> 
> On Friday 13 December 2013 12:01 AM, Felipe Balbi wrote:
> > In case pm_runtime_get*() fails, it still
> > increments pm usage counter, so we *must*
> > make sure to pm_runtime_put() even in those
> > cases.
> > 
> > This patch fixes that mistake the same way
> > usbcore treats those possible failures.
> 
> 
> this patch introduces compile warnings
> drivers/phy/phy-core.c: In function ‘phy_pm_runtime_get_sync’:
> drivers/phy/phy-core.c:118:1: warning: control reaches end of non-void function
> [-Wreturn-type]
> drivers/phy/phy-core.c: In function ‘phy_pm_runtime_get’:
> drivers/phy/phy-core.c:105:1: warning: control reaches end of non-void function
> [-Wreturn-type]
> 
> Thanks
> Kishon
> > 
> > Signed-off-by: Felipe Balbi <balbi@xxxxxx>
> > ---
> >  drivers/phy/phy-core.c | 12 ++++++++++--
> >  1 file changed, 10 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> > index 03cf8fb..5b61123 100644
> > --- a/drivers/phy/phy-core.c
> > +++ b/drivers/phy/phy-core.c
> > @@ -94,19 +94,27 @@ static struct phy_provider *of_phy_provider_lookup(struct device_node *node)
> >  
> >  int phy_pm_runtime_get(struct phy *phy)
> >  {
> > +	int ret;
> > +
> >  	if (!pm_runtime_enabled(&phy->dev))
> >  		return -ENOTSUPP;
> >  
> > -	return pm_runtime_get(&phy->dev);
> > +	ret = pm_runtime_get(&phy->dev);
> > +	if (ret < 0 && ret != -EINPROGRESS)
> > +		pm_runtime_put_noidle(&phy->dev);

Looks like you forgot "return ret" here.

> >  }
> >  EXPORT_SYMBOL_GPL(phy_pm_runtime_get);
> >  
> >  int phy_pm_runtime_get_sync(struct phy *phy)
> >  {
> > +	int ret;
> > +
> >  	if (!pm_runtime_enabled(&phy->dev))
> >  		return -ENOTSUPP;
> >  
> > -	return pm_runtime_get_sync(&phy->dev);
> > +	ret = pm_runtime_get_sync(&phy->dev);
> > +	if (ret < 0)
> > +		pm_runtime_put_sync(&phy->dev);

Ditto.

Br, David

> >  }
> >  EXPORT_SYMBOL_GPL(phy_pm_runtime_get_sync);
> >  
> > 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux