Skip to content

Commit 7c1a529

Browse files
ukleinekUwe Kleine-König
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/6b72104e5e1823170c7c9664189cc0f2ca5c2347.1750788649.git.u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent f0d91b1 commit 7c1a529

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

drivers/pwm/pwm-fsl-ftm.c

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <linux/io.h>
1111
#include <linux/kernel.h>
1212
#include <linux/module.h>
13-
#include <linux/mutex.h>
1413
#include <linux/of.h>
1514
#include <linux/platform_device.h>
1615
#include <linux/pm.h>
@@ -40,7 +39,6 @@ struct fsl_pwm_periodcfg {
4039
};
4140

4241
struct fsl_pwm_chip {
43-
struct mutex lock;
4442
struct regmap *regmap;
4543

4644
/* This value is valid iff a pwm is running */
@@ -89,11 +87,8 @@ static int fsl_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
8987
struct fsl_pwm_chip *fpc = to_fsl_chip(chip);
9088

9189
ret = clk_prepare_enable(fpc->ipg_clk);
92-
if (!ret && fpc->soc->has_enable_bits) {
93-
mutex_lock(&fpc->lock);
90+
if (!ret && fpc->soc->has_enable_bits)
9491
regmap_set_bits(fpc->regmap, FTM_SC, BIT(pwm->hwpwm + 16));
95-
mutex_unlock(&fpc->lock);
96-
}
9792

9893
return ret;
9994
}
@@ -102,11 +97,8 @@ static void fsl_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
10297
{
10398
struct fsl_pwm_chip *fpc = to_fsl_chip(chip);
10499

105-
if (fpc->soc->has_enable_bits) {
106-
mutex_lock(&fpc->lock);
100+
if (fpc->soc->has_enable_bits)
107101
regmap_clear_bits(fpc->regmap, FTM_SC, BIT(pwm->hwpwm + 16));
108-
mutex_unlock(&fpc->lock);
109-
}
110102

111103
clk_disable_unprepare(fpc->ipg_clk);
112104
}
@@ -304,7 +296,7 @@ static int fsl_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
304296
{
305297
struct fsl_pwm_chip *fpc = to_fsl_chip(chip);
306298
struct pwm_state *oldstate = &pwm->state;
307-
int ret = 0;
299+
int ret;
308300

309301
/*
310302
* oldstate to newstate : action
@@ -315,8 +307,6 @@ static int fsl_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
315307
* disabled to enabled : update settings + enable
316308
*/
317309

318-
mutex_lock(&fpc->lock);
319-
320310
if (!newstate->enabled) {
321311
if (oldstate->enabled) {
322312
regmap_set_bits(fpc->regmap, FTM_OUTMASK,
@@ -325,30 +315,28 @@ static int fsl_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
325315
clk_disable_unprepare(fpc->clk[fpc->period.clk_select]);
326316
}
327317

328-
goto end_mutex;
318+
return 0;
329319
}
330320

331321
ret = fsl_pwm_apply_config(chip, pwm, newstate);
332322
if (ret)
333-
goto end_mutex;
323+
return ret;
334324

335325
/* check if need to enable */
336326
if (!oldstate->enabled) {
337327
ret = clk_prepare_enable(fpc->clk[fpc->period.clk_select]);
338328
if (ret)
339-
goto end_mutex;
329+
return ret;
340330

341331
ret = clk_prepare_enable(fpc->clk[FSL_PWM_CLK_CNTEN]);
342332
if (ret) {
343333
clk_disable_unprepare(fpc->clk[fpc->period.clk_select]);
344-
goto end_mutex;
334+
return ret;
345335
}
346336

347337
regmap_clear_bits(fpc->regmap, FTM_OUTMASK, BIT(pwm->hwpwm));
348338
}
349339

350-
end_mutex:
351-
mutex_unlock(&fpc->lock);
352340
return ret;
353341
}
354342

@@ -408,8 +396,6 @@ static int fsl_pwm_probe(struct platform_device *pdev)
408396
return PTR_ERR(chip);
409397
fpc = to_fsl_chip(chip);
410398

411-
mutex_init(&fpc->lock);
412-
413399
fpc->soc = of_device_get_match_data(&pdev->dev);
414400

415401
base = devm_platform_ioremap_resource(pdev, 0);

0 commit comments

Comments
 (0)