public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: Remove mc13xxx_unlock in regulator_register failure path
@ 2011-05-03 15:15 Axel Lin
  2011-05-03 15:21 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Axel Lin @ 2011-05-03 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yong Shen, Liam Girdwood, Mark Brown

We do not hold the mutex_lock of struct mc13xxx while calling regulator_register,
Thus remove mc13xxx_unlock in regulator_register failure path.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/mc13892-regulator.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
index 1b8f739..38e805d 100644
--- a/drivers/regulator/mc13892-regulator.c
+++ b/drivers/regulator/mc13892-regulator.c
@@ -537,8 +537,10 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev)
 
 	mc13xxx_lock(mc13892);
 	ret = mc13xxx_reg_read(mc13892, MC13892_REVISION, &val);
-	if (ret)
+	if (ret) {
+		mc13xxx_unlock(mc13892);
 		goto err_free;
+	}
 
 	/* enable switch auto mode */
 	if ((val & 0x0000FFFF) == 0x45d0) {
@@ -547,16 +549,20 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev)
 			MC13892_SWITCHERS4_SW2MODE_M,
 			MC13892_SWITCHERS4_SW1MODE_AUTO |
 			MC13892_SWITCHERS4_SW2MODE_AUTO);
-		if (ret)
+		if (ret) {
+			mc13xxx_unlock(mc13892);
 			goto err_free;
+		}
 
 		ret = mc13xxx_reg_rmw(mc13892, MC13892_SWITCHERS5,
 			MC13892_SWITCHERS5_SW3MODE_M |
 			MC13892_SWITCHERS5_SW4MODE_M,
 			MC13892_SWITCHERS5_SW3MODE_AUTO |
 			MC13892_SWITCHERS5_SW4MODE_AUTO);
-		if (ret)
+		if (ret) {
+			mc13xxx_unlock(mc13892);
 			goto err_free;
+		}
 	}
 	mc13xxx_unlock(mc13892);
 
@@ -586,7 +592,6 @@ err:
 		regulator_unregister(priv->regulators[i]);
 
 err_free:
-	mc13xxx_unlock(mc13892);
 	kfree(priv);
 
 	return ret;
-- 
1.7.1




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

* Re: [PATCH] regulator: Remove mc13xxx_unlock in regulator_register failure path
  2011-05-03 15:15 [PATCH] regulator: Remove mc13xxx_unlock in regulator_register failure path Axel Lin
@ 2011-05-03 15:21 ` Mark Brown
  2011-05-03 16:25   ` Axel Lin
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2011-05-03 15:21 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Yong Shen, Liam Girdwood

On Tue, May 03, 2011 at 11:15:04PM +0800, Axel Lin wrote:
> We do not hold the mutex_lock of struct mc13xxx while calling regulator_register,
> Thus remove mc13xxx_unlock in regulator_register failure path.

This feels painful, we shouldn't have to be faffing about with the lock
like this for basic I/O operations.  It feels like we should be pushing
the lock down into the register access functions - looking at the driver
I can't really see any reason why all this stuff is being done by hand,
especially when we've got explicit read/modify/write bitmask operations.

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

* Re: [PATCH] regulator: Remove mc13xxx_unlock in regulator_register failure path
  2011-05-03 15:21 ` Mark Brown
@ 2011-05-03 16:25   ` Axel Lin
  0 siblings, 0 replies; 3+ messages in thread
From: Axel Lin @ 2011-05-03 16:25 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, Yong Shen, Liam Girdwood

hi Mark,
> This feels painful, we shouldn't have to be faffing about with the lock
> like this for basic I/O operations.  It feels like we should be pushing
> the lock down into the register access functions - looking at the driver
> I can't really see any reason why all this stuff is being done by hand,
> especially when we've got explicit read/modify/write bitmask operations.
>

Agreed. Thanks for the review. I'll send a patch for it.

Regards,
Axel

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

end of thread, other threads:[~2011-05-03 16:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-03 15:15 [PATCH] regulator: Remove mc13xxx_unlock in regulator_register failure path Axel Lin
2011-05-03 15:21 ` Mark Brown
2011-05-03 16:25   ` Axel Lin

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