Commit 2a2c3ac0a584246cf9fdab69941b8aad54749581
Committed by
Mark Brown
1 parent
4a247a961a
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 1 changed file with 8 additions and 14 deletions Side-by-side Diff
drivers/regulator/mc13783-regulator.c
... | ... | @@ -238,9 +238,10 @@ |
238 | 238 | |
239 | 239 | BUG_ON(val & ~mask); |
240 | 240 | |
241 | + mc13xxx_lock(priv->mc13xxx); | |
241 | 242 | ret = mc13xxx_reg_read(mc13783, MC13783_REG_POWERMISC, &valread); |
242 | 243 | if (ret) |
243 | - return ret; | |
244 | + goto out; | |
244 | 245 | |
245 | 246 | /* Update the stored state for Power Gates. */ |
246 | 247 | priv->powermisc_pwgt_state = |
... | ... | @@ -253,7 +254,10 @@ |
253 | 254 | valread = (valread & ~MC13783_REG_POWERMISC_PWGTSPI_M) | |
254 | 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 | 263 | static int mc13783_gpo_regulator_enable(struct regulator_dev *rdev) |
... | ... | @@ -261,7 +265,6 @@ |
261 | 265 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); |
262 | 266 | struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; |
263 | 267 | int id = rdev_get_id(rdev); |
264 | - int ret; | |
265 | 268 | u32 en_val = mc13xxx_regulators[id].enable_bit; |
266 | 269 | |
267 | 270 | dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); |
268 | 271 | |
... | ... | @@ -271,12 +274,8 @@ |
271 | 274 | id == MC13783_REG_PWGT2SPI) |
272 | 275 | en_val = 0; |
273 | 276 | |
274 | - mc13xxx_lock(priv->mc13xxx); | |
275 | - ret = mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit, | |
277 | + return mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit, | |
276 | 278 | en_val); |
277 | - mc13xxx_unlock(priv->mc13xxx); | |
278 | - | |
279 | - return ret; | |
280 | 279 | } |
281 | 280 | |
282 | 281 | static int mc13783_gpo_regulator_disable(struct regulator_dev *rdev) |
... | ... | @@ -284,7 +283,6 @@ |
284 | 283 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); |
285 | 284 | struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; |
286 | 285 | int id = rdev_get_id(rdev); |
287 | - int ret; | |
288 | 286 | u32 dis_val = 0; |
289 | 287 | |
290 | 288 | dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); |
291 | 289 | |
... | ... | @@ -294,12 +292,8 @@ |
294 | 292 | id == MC13783_REG_PWGT2SPI) |
295 | 293 | dis_val = mc13xxx_regulators[id].enable_bit; |
296 | 294 | |
297 | - mc13xxx_lock(priv->mc13xxx); | |
298 | - ret = mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit, | |
295 | + return mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit, | |
299 | 296 | dis_val); |
300 | - mc13xxx_unlock(priv->mc13xxx); | |
301 | - | |
302 | - return ret; | |
303 | 297 | } |
304 | 298 | |
305 | 299 | static int mc13783_gpo_regulator_is_enabled(struct regulator_dev *rdev) |