diff options
author | Boris Brezillon <boris.brezillon@free-electrons.com> | 2015-07-01 04:21:47 -0400 |
---|---|---|
committer | Thierry Reding <thierry.reding@gmail.com> | 2015-07-20 03:46:06 -0400 |
commit | 5c31252c4a86dc591c23f1a951edd52ad791ef0e (patch) | |
tree | 4a955e92027bbf95cd5fc9222245c0e4c8810a43 /drivers/pwm/pwm-atmel.c | |
parent | d770e558e21961ad6cfdf0ff7df0eb5d7d4f0754 (diff) |
pwm: Add the pwm_is_enabled() helper
Some PWM drivers are testing the PWMF_ENABLED flag. Create a helper
function to hide the logic behind enabled test. This will allow us to
smoothly move from the current approach to an atomic PWM update
approach.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/pwm-atmel.c')
-rw-r--r-- | drivers/pwm/pwm-atmel.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c index a947c9095d9d..b3b294de88e0 100644 --- a/drivers/pwm/pwm-atmel.c +++ b/drivers/pwm/pwm-atmel.c | |||
@@ -114,7 +114,7 @@ static int atmel_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, | |||
114 | u32 val; | 114 | u32 val; |
115 | int ret; | 115 | int ret; |
116 | 116 | ||
117 | if (test_bit(PWMF_ENABLED, &pwm->flags) && (period_ns != pwm->period)) { | 117 | if (pwm_is_enabled(pwm) && (period_ns != pwm->period)) { |
118 | dev_err(chip->dev, "cannot change PWM period while enabled\n"); | 118 | dev_err(chip->dev, "cannot change PWM period while enabled\n"); |
119 | return -EBUSY; | 119 | return -EBUSY; |
120 | } | 120 | } |
@@ -176,7 +176,7 @@ static void atmel_pwm_config_v1(struct pwm_chip *chip, struct pwm_device *pwm, | |||
176 | * If the PWM channel is enabled, only update CDTY by using the update | 176 | * If the PWM channel is enabled, only update CDTY by using the update |
177 | * register, it needs to set bit 10 of CMR to 0 | 177 | * register, it needs to set bit 10 of CMR to 0 |
178 | */ | 178 | */ |
179 | if (test_bit(PWMF_ENABLED, &pwm->flags)) | 179 | if (pwm_is_enabled(pwm)) |
180 | return; | 180 | return; |
181 | /* | 181 | /* |
182 | * If the PWM channel is disabled, write value to duty and period | 182 | * If the PWM channel is disabled, write value to duty and period |
@@ -191,7 +191,7 @@ static void atmel_pwm_config_v2(struct pwm_chip *chip, struct pwm_device *pwm, | |||
191 | { | 191 | { |
192 | struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip); | 192 | struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip); |
193 | 193 | ||
194 | if (test_bit(PWMF_ENABLED, &pwm->flags)) { | 194 | if (pwm_is_enabled(pwm)) { |
195 | /* | 195 | /* |
196 | * If the PWM channel is enabled, using the duty update register | 196 | * If the PWM channel is enabled, using the duty update register |
197 | * to update the value. | 197 | * to update the value. |