Skip to content

Commit 01b571f

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: omap-dmtimer: Drop locking
The pwm driver only provides a single PWM line, so there are no concurrent calls of the callbacks from different consumers. A single consumer is expected not to do concurrent calls into the pwm framework. So there is nothing to serialize and the lock can go away. Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 46cfec2 commit 01b571f

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

drivers/pwm/pwm-omap-dmtimer.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include <linux/err.h>
3838
#include <linux/kernel.h>
3939
#include <linux/module.h>
40-
#include <linux/mutex.h>
4140
#include <linux/of.h>
4241
#include <linux/of_platform.h>
4342
#include <clocksource/timer-ti-dm.h>
@@ -55,15 +54,13 @@
5554
* struct pwm_omap_dmtimer_chip - Structure representing a pwm chip
5655
* corresponding to omap dmtimer.
5756
* @chip: PWM chip structure representing PWM controller
58-
* @mutex: Mutex to protect pwm apply state
5957
* @dm_timer: Pointer to omap dm timer.
6058
* @pdata: Pointer to omap dm timer ops.
6159
* @dm_timer_pdev: Pointer to omap dm timer platform device
6260
*/
6361
struct pwm_omap_dmtimer_chip {
6462
struct pwm_chip chip;
6563
/* Mutex to protect pwm apply state */
66-
struct mutex mutex;
6764
struct omap_dm_timer *dm_timer;
6865
const struct omap_dm_timer_ops *pdata;
6966
struct platform_device *dm_timer_pdev;
@@ -277,13 +274,11 @@ static int pwm_omap_dmtimer_apply(struct pwm_chip *chip,
277274
const struct pwm_state *state)
278275
{
279276
struct pwm_omap_dmtimer_chip *omap = to_pwm_omap_dmtimer_chip(chip);
280-
int ret = 0;
281-
282-
mutex_lock(&omap->mutex);
277+
int ret;
283278

284279
if (pwm_omap_dmtimer_is_enabled(omap) && !state->enabled) {
285280
omap->pdata->stop(omap->dm_timer);
286-
goto unlock_mutex;
281+
return 0;
287282
}
288283

289284
if (pwm_omap_dmtimer_polarity(omap) != state->polarity)
@@ -292,7 +287,7 @@ static int pwm_omap_dmtimer_apply(struct pwm_chip *chip,
292287
ret = pwm_omap_dmtimer_config(chip, pwm, state->duty_cycle,
293288
state->period);
294289
if (ret)
295-
goto unlock_mutex;
290+
return ret;
296291

297292
if (!pwm_omap_dmtimer_is_enabled(omap) && state->enabled) {
298293
omap->pdata->set_pwm(omap->dm_timer,
@@ -303,10 +298,7 @@ static int pwm_omap_dmtimer_apply(struct pwm_chip *chip,
303298
pwm_omap_dmtimer_start(omap);
304299
}
305300

306-
unlock_mutex:
307-
mutex_unlock(&omap->mutex);
308-
309-
return ret;
301+
return 0;
310302
}
311303

312304
static const struct pwm_ops pwm_omap_dmtimer_ops = {
@@ -404,8 +396,6 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
404396
omap->chip.ops = &pwm_omap_dmtimer_ops;
405397
omap->chip.npwm = 1;
406398

407-
mutex_init(&omap->mutex);
408-
409399
ret = pwmchip_add(&omap->chip);
410400
if (ret < 0) {
411401
dev_err(&pdev->dev, "failed to register PWM\n");
@@ -452,8 +442,6 @@ static void pwm_omap_dmtimer_remove(struct platform_device *pdev)
452442
omap->pdata->free(omap->dm_timer);
453443

454444
put_device(&omap->dm_timer_pdev->dev);
455-
456-
mutex_destroy(&omap->mutex);
457445
}
458446

459447
static const struct of_device_id pwm_omap_dmtimer_of_match[] = {

0 commit comments

Comments
 (0)