Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pwm: fsl-ftm: Drop driver local locking

The pwm core serializes calls to .apply(), so the driver local lock isn't
needed for that. It only has the effect to serialize .apply() with
.request() and .free() for a different PWM, and .request() and .free
against each other. But given that .request and .free() only do a single
regmap operation under the lock and regmap itself serializes register
accesses, it might happen without the lock that the calls are interleaved
now, but affecting different PWMs, so nothing bad can happen.

So the mutex has no effect and can be dropped.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/6b72104e5e1823170c7c9664189cc0f2ca5c2347.1750788649.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>

authored by

Uwe Kleine-König and committed by
Uwe Kleine-König
7c1a529a f0d91b16

+7 -21
+7 -21
drivers/pwm/pwm-fsl-ftm.c
··· 10 10 #include <linux/io.h> 11 11 #include <linux/kernel.h> 12 12 #include <linux/module.h> 13 - #include <linux/mutex.h> 14 13 #include <linux/of.h> 15 14 #include <linux/platform_device.h> 16 15 #include <linux/pm.h> ··· 39 40 }; 40 41 41 42 struct fsl_pwm_chip { 42 - struct mutex lock; 43 43 struct regmap *regmap; 44 44 45 45 /* This value is valid iff a pwm is running */ ··· 87 89 struct fsl_pwm_chip *fpc = to_fsl_chip(chip); 88 90 89 91 ret = clk_prepare_enable(fpc->ipg_clk); 90 - if (!ret && fpc->soc->has_enable_bits) { 91 - mutex_lock(&fpc->lock); 92 + if (!ret && fpc->soc->has_enable_bits) 92 93 regmap_set_bits(fpc->regmap, FTM_SC, BIT(pwm->hwpwm + 16)); 93 - mutex_unlock(&fpc->lock); 94 - } 95 94 96 95 return ret; 97 96 } ··· 97 102 { 98 103 struct fsl_pwm_chip *fpc = to_fsl_chip(chip); 99 104 100 - if (fpc->soc->has_enable_bits) { 101 - mutex_lock(&fpc->lock); 105 + if (fpc->soc->has_enable_bits) 102 106 regmap_clear_bits(fpc->regmap, FTM_SC, BIT(pwm->hwpwm + 16)); 103 - mutex_unlock(&fpc->lock); 104 - } 105 107 106 108 clk_disable_unprepare(fpc->ipg_clk); 107 109 } ··· 296 304 { 297 305 struct fsl_pwm_chip *fpc = to_fsl_chip(chip); 298 306 struct pwm_state *oldstate = &pwm->state; 299 - int ret = 0; 307 + int ret; 300 308 301 309 /* 302 310 * oldstate to newstate : action ··· 307 315 * disabled to enabled : update settings + enable 308 316 */ 309 317 310 - mutex_lock(&fpc->lock); 311 - 312 318 if (!newstate->enabled) { 313 319 if (oldstate->enabled) { 314 320 regmap_set_bits(fpc->regmap, FTM_OUTMASK, ··· 315 325 clk_disable_unprepare(fpc->clk[fpc->period.clk_select]); 316 326 } 317 327 318 - goto end_mutex; 328 + return 0; 319 329 } 320 330 321 331 ret = fsl_pwm_apply_config(chip, pwm, newstate); 322 332 if (ret) 323 - goto end_mutex; 333 + return ret; 324 334 325 335 /* check if need to enable */ 326 336 if (!oldstate->enabled) { 327 337 ret = clk_prepare_enable(fpc->clk[fpc->period.clk_select]); 328 338 if (ret) 329 - goto end_mutex; 339 + return ret; 330 340 331 341 ret = clk_prepare_enable(fpc->clk[FSL_PWM_CLK_CNTEN]); 332 342 if (ret) { 333 343 clk_disable_unprepare(fpc->clk[fpc->period.clk_select]); 334 - goto end_mutex; 344 + return ret; 335 345 } 336 346 337 347 regmap_clear_bits(fpc->regmap, FTM_OUTMASK, BIT(pwm->hwpwm)); 338 348 } 339 349 340 - end_mutex: 341 - mutex_unlock(&fpc->lock); 342 350 return ret; 343 351 } 344 352 ··· 395 407 if (IS_ERR(chip)) 396 408 return PTR_ERR(chip); 397 409 fpc = to_fsl_chip(chip); 398 - 399 - mutex_init(&fpc->lock); 400 410 401 411 fpc->soc = of_device_get_match_data(&pdev->dev); 402 412