public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] regulator: Put mutex lock down to mc13783_powermisc_rmw function
@ 2011-05-03 16:40 Axel Lin
  2011-05-03 16:42 ` [PATCH 2/2] regulator: Put mutex lock down to mc13892_powermisc_rmw function Axel Lin
  2011-05-03 17:47 ` [PATCH 1/2] regulator: Put mutex lock down to mc13783_powermisc_rmw function Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Axel Lin @ 2011-05-03 16:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yong Shen, Liam Girdwood, Mark Brown

mc13783_powermisc_rmw function is doing read/modify/write bitmask operations,
thus add the lock to protect it.
Then we can remove the lock/unlock from the caller.

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

diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c
index 3e5d0c3..13d699c 100644
--- a/drivers/regulator/mc13783-regulator.c
+++ b/drivers/regulator/mc13783-regulator.c
@@ -235,11 +235,12 @@ static int mc13783_powermisc_rmw(struct mc13xxx_regulator_priv *priv, u32 mask,
 	int ret;
 	u32 valread;
 
+	mc13xxx_lock(mc13783);
 	BUG_ON(val & ~mask);
 
 	ret = mc13xxx_reg_read(mc13783, MC13783_REG_POWERMISC, &valread);
 	if (ret)
-		return ret;
+		goto out;
 
 	/* Update the stored state for Power Gates. */
 	priv->powermisc_pwgt_state =
@@ -252,7 +253,10 @@ static int mc13783_powermisc_rmw(struct mc13xxx_regulator_priv *priv, u32 mask,
 	valread = (valread & ~MC13783_REG_POWERMISC_PWGTSPI_M) |
 						priv->powermisc_pwgt_state;
 
-	return mc13xxx_reg_write(mc13783, MC13783_REG_POWERMISC, valread);
+	ret = mc13xxx_reg_write(mc13783, MC13783_REG_POWERMISC, valread);
+out:
+	mc13xxx_unlock(mc13783);
+	return ret;
 }
 
 static int mc13783_gpo_regulator_enable(struct regulator_dev *rdev)
@@ -270,10 +274,8 @@ static int mc13783_gpo_regulator_enable(struct regulator_dev *rdev)
 	    id == MC13783_REG_PWGT2SPI)
 		en_val = 0;
 
-	mc13xxx_lock(priv->mc13xxx);
 	ret = mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit,
 					en_val);
-	mc13xxx_unlock(priv->mc13xxx);
 
 	return ret;
 }
@@ -293,10 +295,8 @@ static int mc13783_gpo_regulator_disable(struct regulator_dev *rdev)
 	    id == MC13783_REG_PWGT2SPI)
 		dis_val = mc13xxx_regulators[id].enable_bit;
 
-	mc13xxx_lock(priv->mc13xxx);
 	ret = mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit,
 					dis_val);
-	mc13xxx_unlock(priv->mc13xxx);
 
 	return ret;
 }
-- 
1.7.1




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

* [PATCH 2/2] regulator: Put mutex lock down to mc13892_powermisc_rmw function
  2011-05-03 16:40 [PATCH 1/2] regulator: Put mutex lock down to mc13783_powermisc_rmw function Axel Lin
@ 2011-05-03 16:42 ` Axel Lin
  2011-05-03 17:47 ` [PATCH 1/2] regulator: Put mutex lock down to mc13783_powermisc_rmw function Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Axel Lin @ 2011-05-03 16:42 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yong Shen, Liam Girdwood, Mark Brown

mc13892_powermisc_rmw function is doing read/modify/write bitmask operations,
thus add the lock to protect it.
Then we can remove the lock/unlock from the caller.

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

diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
index 679b315..763895d 100644
--- a/drivers/regulator/mc13892-regulator.c
+++ b/drivers/regulator/mc13892-regulator.c
@@ -302,11 +302,12 @@ static int mc13892_powermisc_rmw(struct mc13xxx_regulator_priv *priv, u32 mask,
 	int ret;
 	u32 valread;
 
+	mc13xxx_lock(mc13892);
 	BUG_ON(val & ~mask);
 
 	ret = mc13xxx_reg_read(mc13892, MC13892_POWERMISC, &valread);
 	if (ret)
-		return ret;
+		goto out;
 
 	/* Update the stored state for Power Gates. */
 	priv->powermisc_pwgt_state =
@@ -319,7 +320,10 @@ static int mc13892_powermisc_rmw(struct mc13xxx_regulator_priv *priv, u32 mask,
 	valread = (valread & ~MC13892_POWERMISC_PWGTSPI_M) |
 		priv->powermisc_pwgt_state;
 
-	return mc13xxx_reg_write(mc13892, MC13892_POWERMISC, valread);
+	ret = mc13xxx_reg_write(mc13892, MC13892_POWERMISC, valread);
+out:
+	mc13xxx_unlock(mc13892);
+	return ret;
 }
 
 static int mc13892_gpo_regulator_enable(struct regulator_dev *rdev)
@@ -339,9 +343,7 @@ static int mc13892_gpo_regulator_enable(struct regulator_dev *rdev)
 	if (id == MC13892_GPO4)
 		mask |= MC13892_POWERMISC_GPO4ADINEN;
 
-	mc13xxx_lock(priv->mc13xxx);
 	ret = mc13892_powermisc_rmw(priv, mask, en_val);
-	mc13xxx_unlock(priv->mc13xxx);
 
 	return ret;
 }
@@ -359,10 +361,8 @@ static int mc13892_gpo_regulator_disable(struct regulator_dev *rdev)
 	if (id == MC13892_PWGT1SPI || id == MC13892_PWGT2SPI)
 		dis_val = mc13892_regulators[id].enable_bit;
 
-	mc13xxx_lock(priv->mc13xxx);
 	ret = mc13892_powermisc_rmw(priv, mc13892_regulators[id].enable_bit,
 		dis_val);
-	mc13xxx_unlock(priv->mc13xxx);
 
 	return ret;
 }
-- 
1.7.1




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

* Re: [PATCH 1/2] regulator: Put mutex lock down to mc13783_powermisc_rmw function
  2011-05-03 16:40 [PATCH 1/2] regulator: Put mutex lock down to mc13783_powermisc_rmw function Axel Lin
  2011-05-03 16:42 ` [PATCH 2/2] regulator: Put mutex lock down to mc13892_powermisc_rmw function Axel Lin
@ 2011-05-03 17:47 ` Mark Brown
  2011-05-04  4:33   ` Axel Lin
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Brown @ 2011-05-03 17:47 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Yong Shen, Liam Girdwood

On Wed, May 04, 2011 at 12:40:30AM +0800, Axel Lin wrote:
> mc13783_powermisc_rmw function is doing read/modify/write bitmask operations,
> thus add the lock to protect it.
> Then we can remove the lock/unlock from the caller.

This should be squashed in with the MFD patch I think otherwise we'll
get bisection points with either no lock or double locking (which upsets
lockdep IIRC).  The change itself looks good, though, and similarly for
patch 2

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

* Re: [PATCH 1/2] regulator: Put mutex lock down to mc13783_powermisc_rmw function
  2011-05-03 17:47 ` [PATCH 1/2] regulator: Put mutex lock down to mc13783_powermisc_rmw function Mark Brown
@ 2011-05-04  4:33   ` Axel Lin
  0 siblings, 0 replies; 4+ messages in thread
From: Axel Lin @ 2011-05-04  4:33 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, Yong Shen, Liam Girdwood

Hi Mark,
2011/5/4 Mark Brown <broonie@opensource.wolfsonmicro.com>:
> On Wed, May 04, 2011 at 12:40:30AM +0800, Axel Lin wrote:
>> mc13783_powermisc_rmw function is doing read/modify/write bitmask operations,
>> thus add the lock to protect it.
>> Then we can remove the lock/unlock from the caller.
>
> This should be squashed in with the MFD patch I think otherwise we'll
> get bisection points with either no lock or double locking (which upsets
> lockdep IIRC).  The change itself looks good, though, and similarly for
> patch 2
>

I think these 2 patches are independent from the MFD patch.

The MFD patch modified the mc13xxx_reg_rmw which is not called by
mc13783_powermisc_rmw and mc13783_powermisc_rmw functions.
I double checked the usage of mc13783_powermisc_rmw and mc13783_powermisc_rmw,
I think these 2 patches can be applied either with or without the MFD patch.

Regards,
Axel

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

end of thread, other threads:[~2011-05-04  4:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-03 16:40 [PATCH 1/2] regulator: Put mutex lock down to mc13783_powermisc_rmw function Axel Lin
2011-05-03 16:42 ` [PATCH 2/2] regulator: Put mutex lock down to mc13892_powermisc_rmw function Axel Lin
2011-05-03 17:47 ` [PATCH 1/2] regulator: Put mutex lock down to mc13783_powermisc_rmw function Mark Brown
2011-05-04  4:33   ` Axel Lin

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