diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-07-18 23:17:15 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-08-28 14:00:23 -0400 |
commit | 825d105910d549e69748b19f83031b231152ac9d (patch) | |
tree | 27707d5f371df4f925c1bd16fb257fdc513376d4 /drivers/regulator/mc13892-regulator.c | |
parent | 2a2c3ac0a584246cf9fdab69941b8aad54749581 (diff) |
regulator: mc13892: Make mc13892_powermisc_rmw() lock protected
Then we can remove lock/unlock around the caller.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/mc13892-regulator.c')
-rw-r--r-- | drivers/regulator/mc13892-regulator.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c index b388b746452e..9d4296b96adb 100644 --- a/drivers/regulator/mc13892-regulator.c +++ b/drivers/regulator/mc13892-regulator.c | |||
@@ -305,9 +305,10 @@ static int mc13892_powermisc_rmw(struct mc13xxx_regulator_priv *priv, u32 mask, | |||
305 | 305 | ||
306 | BUG_ON(val & ~mask); | 306 | BUG_ON(val & ~mask); |
307 | 307 | ||
308 | mc13xxx_lock(priv->mc13xxx); | ||
308 | ret = mc13xxx_reg_read(mc13892, MC13892_POWERMISC, &valread); | 309 | ret = mc13xxx_reg_read(mc13892, MC13892_POWERMISC, &valread); |
309 | if (ret) | 310 | if (ret) |
310 | return ret; | 311 | goto out; |
311 | 312 | ||
312 | /* Update the stored state for Power Gates. */ | 313 | /* Update the stored state for Power Gates. */ |
313 | priv->powermisc_pwgt_state = | 314 | priv->powermisc_pwgt_state = |
@@ -320,14 +321,16 @@ static int mc13892_powermisc_rmw(struct mc13xxx_regulator_priv *priv, u32 mask, | |||
320 | valread = (valread & ~MC13892_POWERMISC_PWGTSPI_M) | | 321 | valread = (valread & ~MC13892_POWERMISC_PWGTSPI_M) | |
321 | priv->powermisc_pwgt_state; | 322 | priv->powermisc_pwgt_state; |
322 | 323 | ||
323 | return mc13xxx_reg_write(mc13892, MC13892_POWERMISC, valread); | 324 | ret = mc13xxx_reg_write(mc13892, MC13892_POWERMISC, valread); |
325 | out: | ||
326 | mc13xxx_unlock(priv->mc13xxx); | ||
327 | return ret; | ||
324 | } | 328 | } |
325 | 329 | ||
326 | static int mc13892_gpo_regulator_enable(struct regulator_dev *rdev) | 330 | static int mc13892_gpo_regulator_enable(struct regulator_dev *rdev) |
327 | { | 331 | { |
328 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); | 332 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); |
329 | int id = rdev_get_id(rdev); | 333 | int id = rdev_get_id(rdev); |
330 | int ret; | ||
331 | u32 en_val = mc13892_regulators[id].enable_bit; | 334 | u32 en_val = mc13892_regulators[id].enable_bit; |
332 | u32 mask = mc13892_regulators[id].enable_bit; | 335 | u32 mask = mc13892_regulators[id].enable_bit; |
333 | 336 | ||
@@ -340,18 +343,13 @@ static int mc13892_gpo_regulator_enable(struct regulator_dev *rdev) | |||
340 | if (id == MC13892_GPO4) | 343 | if (id == MC13892_GPO4) |
341 | mask |= MC13892_POWERMISC_GPO4ADINEN; | 344 | mask |= MC13892_POWERMISC_GPO4ADINEN; |
342 | 345 | ||
343 | mc13xxx_lock(priv->mc13xxx); | 346 | return mc13892_powermisc_rmw(priv, mask, en_val); |
344 | ret = mc13892_powermisc_rmw(priv, mask, en_val); | ||
345 | mc13xxx_unlock(priv->mc13xxx); | ||
346 | |||
347 | return ret; | ||
348 | } | 347 | } |
349 | 348 | ||
350 | static int mc13892_gpo_regulator_disable(struct regulator_dev *rdev) | 349 | static int mc13892_gpo_regulator_disable(struct regulator_dev *rdev) |
351 | { | 350 | { |
352 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); | 351 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); |
353 | int id = rdev_get_id(rdev); | 352 | int id = rdev_get_id(rdev); |
354 | int ret; | ||
355 | u32 dis_val = 0; | 353 | u32 dis_val = 0; |
356 | 354 | ||
357 | dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); | 355 | dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); |
@@ -360,12 +358,8 @@ static int mc13892_gpo_regulator_disable(struct regulator_dev *rdev) | |||
360 | if (id == MC13892_PWGT1SPI || id == MC13892_PWGT2SPI) | 358 | if (id == MC13892_PWGT1SPI || id == MC13892_PWGT2SPI) |
361 | dis_val = mc13892_regulators[id].enable_bit; | 359 | dis_val = mc13892_regulators[id].enable_bit; |
362 | 360 | ||
363 | mc13xxx_lock(priv->mc13xxx); | 361 | return mc13892_powermisc_rmw(priv, mc13892_regulators[id].enable_bit, |
364 | ret = mc13892_powermisc_rmw(priv, mc13892_regulators[id].enable_bit, | ||
365 | dis_val); | 362 | dis_val); |
366 | mc13xxx_unlock(priv->mc13xxx); | ||
367 | |||
368 | return ret; | ||
369 | } | 363 | } |
370 | 364 | ||
371 | static int mc13892_gpo_regulator_is_enabled(struct regulator_dev *rdev) | 365 | static int mc13892_gpo_regulator_is_enabled(struct regulator_dev *rdev) |