Skip to content

Commit d2c8bdc

Browse files
ukleinekUwe Kleine-König
authored andcommitted
pwm: sti: Drop driver local locking
The pwm core already serializes calls to .apply(), so the driver local mutex adds no protection and can be dropped. Signed-off-by: Uwe Kleine-König <[email protected]> Link: https://lore.kernel.org/r/7ad150e40b45d6cb16fee633dcd6390a49a327a1.1750788649.git.u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 9470e7d commit d2c8bdc

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

drivers/pwm/pwm-sti.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ struct sti_pwm_chip {
9292
struct pwm_device *cur;
9393
unsigned long configured;
9494
unsigned int en_count;
95-
struct mutex sti_pwm_lock; /* To sync between enable/disable calls */
9695
void __iomem *mmio;
9796
};
9897

@@ -244,55 +243,46 @@ static int sti_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
244243
{
245244
struct sti_pwm_chip *pc = to_sti_pwmchip(chip);
246245
struct device *dev = pc->dev;
247-
int ret = 0;
246+
int ret;
248247

249248
/*
250249
* Since we have a common enable for all PWM devices, do not enable if
251250
* already enabled.
252251
*/
253-
mutex_lock(&pc->sti_pwm_lock);
254252

255253
if (!pc->en_count) {
256254
ret = clk_enable(pc->pwm_clk);
257255
if (ret)
258-
goto out;
256+
return ret;
259257

260258
ret = clk_enable(pc->cpt_clk);
261259
if (ret)
262-
goto out;
260+
return ret;
263261

264262
ret = regmap_field_write(pc->pwm_out_en, 1);
265263
if (ret) {
266264
dev_err(dev, "failed to enable PWM device %u: %d\n",
267265
pwm->hwpwm, ret);
268-
goto out;
266+
return ret;
269267
}
270268
}
271269

272270
pc->en_count++;
273271

274-
out:
275-
mutex_unlock(&pc->sti_pwm_lock);
276-
return ret;
272+
return 0;
277273
}
278274

279275
static void sti_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
280276
{
281277
struct sti_pwm_chip *pc = to_sti_pwmchip(chip);
282278

283-
mutex_lock(&pc->sti_pwm_lock);
284-
285-
if (--pc->en_count) {
286-
mutex_unlock(&pc->sti_pwm_lock);
279+
if (--pc->en_count)
287280
return;
288-
}
289281

290282
regmap_field_write(pc->pwm_out_en, 0);
291283

292284
clk_disable(pc->pwm_clk);
293285
clk_disable(pc->cpt_clk);
294-
295-
mutex_unlock(&pc->sti_pwm_lock);
296286
}
297287

298288
static void sti_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
@@ -594,7 +584,6 @@ static int sti_pwm_probe(struct platform_device *pdev)
594584

595585
pc->dev = dev;
596586
pc->en_count = 0;
597-
mutex_init(&pc->sti_pwm_lock);
598587

599588
ret = sti_pwm_probe_regmap(pc);
600589
if (ret)

0 commit comments

Comments
 (0)