diff options
author | Boris Brezillon <boris.brezillon@free-electrons.com> | 2016-04-14 15:17:39 -0400 |
---|---|---|
committer | Thierry Reding <thierry.reding@gmail.com> | 2016-05-17 08:48:02 -0400 |
commit | 09a7e4a3d9fcb95ade2cb02167e85fbeb8315ce0 (patch) | |
tree | ae68e6ab54506c65b510d83aeda3c94906a7faca /drivers/pwm | |
parent | 43a276b003ed2e03de9d94b02a1ba49c1849b931 (diff) |
pwm: Move the enabled/disabled info into pwm_state
Prepare the transition to PWM atomic update by moving the enabled and
disabled state into the pwm_state struct. This way we can easily update
the whole PWM state by copying the new state in the ->state field.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r-- | drivers/pwm/core.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index f3f91e716a42..c240b5437145 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c | |||
@@ -499,10 +499,10 @@ int pwm_enable(struct pwm_device *pwm) | |||
499 | if (!pwm) | 499 | if (!pwm) |
500 | return -EINVAL; | 500 | return -EINVAL; |
501 | 501 | ||
502 | if (!test_and_set_bit(PWMF_ENABLED, &pwm->flags)) { | 502 | if (!pwm_is_enabled(pwm)) { |
503 | err = pwm->chip->ops->enable(pwm->chip, pwm); | 503 | err = pwm->chip->ops->enable(pwm->chip, pwm); |
504 | if (err) | 504 | if (!err) |
505 | clear_bit(PWMF_ENABLED, &pwm->flags); | 505 | pwm->state.enabled = true; |
506 | } | 506 | } |
507 | 507 | ||
508 | return err; | 508 | return err; |
@@ -515,8 +515,13 @@ EXPORT_SYMBOL_GPL(pwm_enable); | |||
515 | */ | 515 | */ |
516 | void pwm_disable(struct pwm_device *pwm) | 516 | void pwm_disable(struct pwm_device *pwm) |
517 | { | 517 | { |
518 | if (pwm && test_and_clear_bit(PWMF_ENABLED, &pwm->flags)) | 518 | if (!pwm) |
519 | return; | ||
520 | |||
521 | if (pwm_is_enabled(pwm)) { | ||
519 | pwm->chip->ops->disable(pwm->chip, pwm); | 522 | pwm->chip->ops->disable(pwm->chip, pwm); |
523 | pwm->state.enabled = false; | ||
524 | } | ||
520 | } | 525 | } |
521 | EXPORT_SYMBOL_GPL(pwm_disable); | 526 | EXPORT_SYMBOL_GPL(pwm_disable); |
522 | 527 | ||