diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-07-18 23:16:06 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-08-28 14:00:16 -0400 |
commit | 2a2c3ac0a584246cf9fdab69941b8aad54749581 (patch) | |
tree | 34729dcb70ac377ed6ea6f9f5a20ecfabd55645c /drivers/regulator/mc13783-regulator.c | |
parent | 4a247a961aaa0c611c68b56da3962c387c8e2e84 (diff) |
regulator: mc13783: Make mc13783_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/mc13783-regulator.c')
-rw-r--r-- | drivers/regulator/mc13783-regulator.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c index 4932e3449fe1..2587ea1f7438 100644 --- a/drivers/regulator/mc13783-regulator.c +++ b/drivers/regulator/mc13783-regulator.c | |||
@@ -238,9 +238,10 @@ static int mc13783_powermisc_rmw(struct mc13xxx_regulator_priv *priv, u32 mask, | |||
238 | 238 | ||
239 | BUG_ON(val & ~mask); | 239 | BUG_ON(val & ~mask); |
240 | 240 | ||
241 | mc13xxx_lock(priv->mc13xxx); | ||
241 | ret = mc13xxx_reg_read(mc13783, MC13783_REG_POWERMISC, &valread); | 242 | ret = mc13xxx_reg_read(mc13783, MC13783_REG_POWERMISC, &valread); |
242 | if (ret) | 243 | if (ret) |
243 | return ret; | 244 | goto out; |
244 | 245 | ||
245 | /* Update the stored state for Power Gates. */ | 246 | /* Update the stored state for Power Gates. */ |
246 | priv->powermisc_pwgt_state = | 247 | priv->powermisc_pwgt_state = |
@@ -253,7 +254,10 @@ static int mc13783_powermisc_rmw(struct mc13xxx_regulator_priv *priv, u32 mask, | |||
253 | valread = (valread & ~MC13783_REG_POWERMISC_PWGTSPI_M) | | 254 | valread = (valread & ~MC13783_REG_POWERMISC_PWGTSPI_M) | |
254 | priv->powermisc_pwgt_state; | 255 | priv->powermisc_pwgt_state; |
255 | 256 | ||
256 | return mc13xxx_reg_write(mc13783, MC13783_REG_POWERMISC, valread); | 257 | ret = mc13xxx_reg_write(mc13783, MC13783_REG_POWERMISC, valread); |
258 | out: | ||
259 | mc13xxx_unlock(priv->mc13xxx); | ||
260 | return ret; | ||
257 | } | 261 | } |
258 | 262 | ||
259 | static int mc13783_gpo_regulator_enable(struct regulator_dev *rdev) | 263 | static int mc13783_gpo_regulator_enable(struct regulator_dev *rdev) |
@@ -261,7 +265,6 @@ static int mc13783_gpo_regulator_enable(struct regulator_dev *rdev) | |||
261 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); | 265 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); |
262 | struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; | 266 | struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; |
263 | int id = rdev_get_id(rdev); | 267 | int id = rdev_get_id(rdev); |
264 | int ret; | ||
265 | u32 en_val = mc13xxx_regulators[id].enable_bit; | 268 | u32 en_val = mc13xxx_regulators[id].enable_bit; |
266 | 269 | ||
267 | dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); | 270 | dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); |
@@ -271,12 +274,8 @@ static int mc13783_gpo_regulator_enable(struct regulator_dev *rdev) | |||
271 | id == MC13783_REG_PWGT2SPI) | 274 | id == MC13783_REG_PWGT2SPI) |
272 | en_val = 0; | 275 | en_val = 0; |
273 | 276 | ||
274 | mc13xxx_lock(priv->mc13xxx); | 277 | return mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit, |
275 | ret = mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit, | ||
276 | en_val); | 278 | en_val); |
277 | mc13xxx_unlock(priv->mc13xxx); | ||
278 | |||
279 | return ret; | ||
280 | } | 279 | } |
281 | 280 | ||
282 | static int mc13783_gpo_regulator_disable(struct regulator_dev *rdev) | 281 | static int mc13783_gpo_regulator_disable(struct regulator_dev *rdev) |
@@ -284,7 +283,6 @@ static int mc13783_gpo_regulator_disable(struct regulator_dev *rdev) | |||
284 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); | 283 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); |
285 | struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; | 284 | struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; |
286 | int id = rdev_get_id(rdev); | 285 | int id = rdev_get_id(rdev); |
287 | int ret; | ||
288 | u32 dis_val = 0; | 286 | u32 dis_val = 0; |
289 | 287 | ||
290 | dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); | 288 | dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); |
@@ -294,12 +292,8 @@ static int mc13783_gpo_regulator_disable(struct regulator_dev *rdev) | |||
294 | id == MC13783_REG_PWGT2SPI) | 292 | id == MC13783_REG_PWGT2SPI) |
295 | dis_val = mc13xxx_regulators[id].enable_bit; | 293 | dis_val = mc13xxx_regulators[id].enable_bit; |
296 | 294 | ||
297 | mc13xxx_lock(priv->mc13xxx); | 295 | return mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit, |
298 | ret = mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit, | ||
299 | dis_val); | 296 | dis_val); |
300 | mc13xxx_unlock(priv->mc13xxx); | ||
301 | |||
302 | return ret; | ||
303 | } | 297 | } |
304 | 298 | ||
305 | static int mc13783_gpo_regulator_is_enabled(struct regulator_dev *rdev) | 299 | static int mc13783_gpo_regulator_is_enabled(struct regulator_dev *rdev) |