public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: Fix usbhs_enable error handling
@ 2011-03-29 10:07 Axel Lin
  2011-03-29 10:32 ` Keshava Munegowda
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Axel Lin @ 2011-03-29 10:07 UTC (permalink / raw)
  To: linux-kernel; +Cc: Keshava Munegowda, Samuel Ortiz

In the case of missing platform_data we do not hold a spin_lock,
thus we should not call spin_unlock_irqrestore in the error path.

Also simplify the error handling by separating the successful path
from error path. I think this change improves readability.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/mfd/omap-usb-host.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index cb01209..4157d76 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -700,8 +700,7 @@ static int usbhs_enable(struct device *dev)
 	dev_dbg(dev, "starting TI HSUSB Controller\n");
 	if (!pdata) {
 		dev_dbg(dev, "missing platform_data\n");
-		ret =  -ENODEV;
-		goto end_enable;
+		return  -ENODEV;
 	}
 
 	spin_lock_irqsave(&omap->lock, flags);
@@ -915,7 +914,8 @@ static int usbhs_enable(struct device *dev)
 
 end_count:
 	omap->count++;
-	goto end_enable;
+	spin_unlock_irqrestore(&omap->lock, flags);
+	return 0;
 
 err_tll:
 	if (pdata->ehci_data->phy_reset) {
@@ -931,8 +931,6 @@ err_tll:
 	clk_disable(omap->usbhost_fs_fck);
 	clk_disable(omap->usbhost_hs_fck);
 	clk_disable(omap->usbhost_ick);
-
-end_enable:
 	spin_unlock_irqrestore(&omap->lock, flags);
 	return ret;
 }
-- 
1.7.1




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

* RE: [PATCH] mfd: Fix usbhs_enable error handling
  2011-03-29 10:07 [PATCH] mfd: Fix usbhs_enable error handling Axel Lin
@ 2011-03-29 10:32 ` Keshava Munegowda
  2011-03-29 10:35 ` Keshava Munegowda
  2011-04-11 19:27 ` Samuel Ortiz
  2 siblings, 0 replies; 5+ messages in thread
From: Keshava Munegowda @ 2011-03-29 10:32 UTC (permalink / raw)
  To: Axel Lin, linux-kernel; +Cc: Samuel Ortiz

> -----Original Message-----
> From: Axel Lin [mailto:axel.lin@gmail.com]
> Sent: Tuesday, March 29, 2011 3:38 PM
> To: linux-kernel@vger.kernel.org
> Cc: Keshava Munegowda; Samuel Ortiz
> Subject: [PATCH] mfd: Fix usbhs_enable error handling
>
> In the case of missing platform_data we do not hold a spin_lock,
> thus we should not call spin_unlock_irqrestore in the error path.
>
> Also simplify the error handling by separating the successful path
> from error path. I think this change improves readability.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
>  drivers/mfd/omap-usb-host.c |    8 +++-----
>  1 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
> index cb01209..4157d76 100644
> --- a/drivers/mfd/omap-usb-host.c
> +++ b/drivers/mfd/omap-usb-host.c
> @@ -700,8 +700,7 @@ static int usbhs_enable(struct device *dev)
>  	dev_dbg(dev, "starting TI HSUSB Controller\n");
>  	if (!pdata) {
>  		dev_dbg(dev, "missing platform_data\n");
> -		ret =  -ENODEV;
> -		goto end_enable;
> +		return  -ENODEV;
>  	}
>
>  	spin_lock_irqsave(&omap->lock, flags);
> @@ -915,7 +914,8 @@ static int usbhs_enable(struct device *dev)
>
>  end_count:
>  	omap->count++;
> -	goto end_enable;
> +	spin_unlock_irqrestore(&omap->lock, flags);
> +	return 0;
>
>  err_tll:
>  	if (pdata->ehci_data->phy_reset) {
> @@ -931,8 +931,6 @@ err_tll:
>  	clk_disable(omap->usbhost_fs_fck);
>  	clk_disable(omap->usbhost_hs_fck);
>  	clk_disable(omap->usbhost_ick);
> -
> -end_enable:
>  	spin_unlock_irqrestore(&omap->lock, flags);
>  	return ret;
>  }
> --
> 1.7.1
>
>
Thanks Axel!

Acked-by: Keshava Munegowda < keshava_mgowda@ti.com>

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

* RE: [PATCH] mfd: Fix usbhs_enable error handling
  2011-03-29 10:07 [PATCH] mfd: Fix usbhs_enable error handling Axel Lin
  2011-03-29 10:32 ` Keshava Munegowda
@ 2011-03-29 10:35 ` Keshava Munegowda
  2011-03-29 11:06   ` Felipe Balbi
  2011-04-11 19:27 ` Samuel Ortiz
  2 siblings, 1 reply; 5+ messages in thread
From: Keshava Munegowda @ 2011-03-29 10:35 UTC (permalink / raw)
  To: Axel Lin, linux-kernel, linux-usb, linux-omap; +Cc: Samuel Ortiz

> -----Original Message-----
> From: Axel Lin [mailto:axel.lin@gmail.com]
> Sent: Tuesday, March 29, 2011 3:38 PM
> To: linux-kernel@vger.kernel.org
> Cc: Keshava Munegowda; Samuel Ortiz
> Subject: [PATCH] mfd: Fix usbhs_enable error handling
>
> In the case of missing platform_data we do not hold a spin_lock,
> thus we should not call spin_unlock_irqrestore in the error path.
>
> Also simplify the error handling by separating the successful path
> from error path. I think this change improves readability.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
>  drivers/mfd/omap-usb-host.c |    8 +++-----
>  1 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
> index cb01209..4157d76 100644
> --- a/drivers/mfd/omap-usb-host.c
> +++ b/drivers/mfd/omap-usb-host.c
> @@ -700,8 +700,7 @@ static int usbhs_enable(struct device *dev)
>  	dev_dbg(dev, "starting TI HSUSB Controller\n");
>  	if (!pdata) {
>  		dev_dbg(dev, "missing platform_data\n");
> -		ret =  -ENODEV;
> -		goto end_enable;
> +		return  -ENODEV;
>  	}
>
>  	spin_lock_irqsave(&omap->lock, flags);
> @@ -915,7 +914,8 @@ static int usbhs_enable(struct device *dev)
>
>  end_count:
>  	omap->count++;
> -	goto end_enable;
> +	spin_unlock_irqrestore(&omap->lock, flags);
> +	return 0;
>
>  err_tll:
>  	if (pdata->ehci_data->phy_reset) {
> @@ -931,8 +931,6 @@ err_tll:
>  	clk_disable(omap->usbhost_fs_fck);
>  	clk_disable(omap->usbhost_hs_fck);
>  	clk_disable(omap->usbhost_ick);
> -
> -end_enable:
>  	spin_unlock_irqrestore(&omap->lock, flags);
>  	return ret;
>  }
> --
> 1.7.1

Thanks Axel!
Acked-by: Keshava Munegowda < keshava_mgowda@ti.com>

>

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

* Re: [PATCH] mfd: Fix usbhs_enable error handling
  2011-03-29 10:35 ` Keshava Munegowda
@ 2011-03-29 11:06   ` Felipe Balbi
  0 siblings, 0 replies; 5+ messages in thread
From: Felipe Balbi @ 2011-03-29 11:06 UTC (permalink / raw)
  To: Keshava Munegowda
  Cc: Axel Lin, linux-kernel, linux-usb, linux-omap, Samuel Ortiz

On Tue, Mar 29, 2011 at 04:05:40PM +0530, Keshava Munegowda wrote:
> > -----Original Message-----
> > From: Axel Lin [mailto:axel.lin@gmail.com]
> > Sent: Tuesday, March 29, 2011 3:38 PM
> > To: linux-kernel@vger.kernel.org
> > Cc: Keshava Munegowda; Samuel Ortiz
> > Subject: [PATCH] mfd: Fix usbhs_enable error handling
> >
> > In the case of missing platform_data we do not hold a spin_lock,
> > thus we should not call spin_unlock_irqrestore in the error path.
> >
> > Also simplify the error handling by separating the successful path
> > from error path. I think this change improves readability.
> >
> > Signed-off-by: Axel Lin <axel.lin@gmail.com>
> > ---
> >  drivers/mfd/omap-usb-host.c |    8 +++-----
> >  1 files changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
> > index cb01209..4157d76 100644
> > --- a/drivers/mfd/omap-usb-host.c
> > +++ b/drivers/mfd/omap-usb-host.c
> > @@ -700,8 +700,7 @@ static int usbhs_enable(struct device *dev)
> >  	dev_dbg(dev, "starting TI HSUSB Controller\n");
> >  	if (!pdata) {
> >  		dev_dbg(dev, "missing platform_data\n");
> > -		ret =  -ENODEV;
> > -		goto end_enable;
> > +		return  -ENODEV;
> >  	}
> >
> >  	spin_lock_irqsave(&omap->lock, flags);
> > @@ -915,7 +914,8 @@ static int usbhs_enable(struct device *dev)
> >
> >  end_count:
> >  	omap->count++;
> > -	goto end_enable;
> > +	spin_unlock_irqrestore(&omap->lock, flags);
> > +	return 0;
> >
> >  err_tll:
> >  	if (pdata->ehci_data->phy_reset) {
> > @@ -931,8 +931,6 @@ err_tll:
> >  	clk_disable(omap->usbhost_fs_fck);
> >  	clk_disable(omap->usbhost_hs_fck);
> >  	clk_disable(omap->usbhost_ick);
> > -
> > -end_enable:
> >  	spin_unlock_irqrestore(&omap->lock, flags);
> >  	return ret;
> >  }
> > --
> > 1.7.1
> 
> Thanks Axel!
> Acked-by: Keshava Munegowda < keshava_mgowda@ti.com>

Samuel, Greg is out for the week, could you take this one through your
tree instead of waiting for a week until we get this fix merged. If you
need my Ack, here it goes:

Acked-by: Felipe Balbi <balbi@ti.com>

-- 
balbi

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

* Re: [PATCH] mfd: Fix usbhs_enable error handling
  2011-03-29 10:07 [PATCH] mfd: Fix usbhs_enable error handling Axel Lin
  2011-03-29 10:32 ` Keshava Munegowda
  2011-03-29 10:35 ` Keshava Munegowda
@ 2011-04-11 19:27 ` Samuel Ortiz
  2 siblings, 0 replies; 5+ messages in thread
From: Samuel Ortiz @ 2011-04-11 19:27 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Keshava Munegowda

Hi Axel,

On Tue, Mar 29, 2011 at 06:07:55PM +0800, Axel Lin wrote:
> In the case of missing platform_data we do not hold a spin_lock,
> thus we should not call spin_unlock_irqrestore in the error path.
> 
> Also simplify the error handling by separating the successful path
> from error path. I think this change improves readability.
Patch applied to my for-next branch, thanks.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

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

end of thread, other threads:[~2011-04-11 19:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-29 10:07 [PATCH] mfd: Fix usbhs_enable error handling Axel Lin
2011-03-29 10:32 ` Keshava Munegowda
2011-03-29 10:35 ` Keshava Munegowda
2011-03-29 11:06   ` Felipe Balbi
2011-04-11 19:27 ` Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox