aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pwm/core.c
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@free-electrons.com>2016-04-14 15:17:38 -0400
committerThierry Reding <thierry.reding@gmail.com>2016-05-17 08:48:02 -0400
commit43a276b003ed2e03de9d94b02a1ba49c1849b931 (patch)
treeca2442d6fb895eb663ad358e43143fafa23d8cbc /drivers/pwm/core.c
parenta8c3862551e063344f80c3e05d595f9d8836f355 (diff)
pwm: Introduce the pwm_state concept
The PWM state, represented by its period, duty_cycle and polarity is currently directly stored in the PWM device. Declare a pwm_state structure embedding those field so that we can later use this struct to atomically update all the PWM parameters at once. All pwm_get_xxx() helpers are now implemented as wrappers around pwm_get_state(). Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/core.c')
-rw-r--r--drivers/pwm/core.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 64330595e17b..f3f91e716a42 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -268,7 +268,7 @@ int pwmchip_add_with_polarity(struct pwm_chip *chip,
268 pwm->chip = chip; 268 pwm->chip = chip;
269 pwm->pwm = chip->base + i; 269 pwm->pwm = chip->base + i;
270 pwm->hwpwm = i; 270 pwm->hwpwm = i;
271 pwm->polarity = polarity; 271 pwm->state.polarity = polarity;
272 272
273 radix_tree_insert(&pwm_tree, pwm->pwm, pwm); 273 radix_tree_insert(&pwm_tree, pwm->pwm, pwm);
274 } 274 }
@@ -446,8 +446,8 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
446 if (err) 446 if (err)
447 return err; 447 return err;
448 448
449 pwm->duty_cycle = duty_ns; 449 pwm->state.duty_cycle = duty_ns;
450 pwm->period = period_ns; 450 pwm->state.period = period_ns;
451 451
452 return 0; 452 return 0;
453} 453}
@@ -480,7 +480,7 @@ int pwm_set_polarity(struct pwm_device *pwm, enum pwm_polarity polarity)
480 if (err) 480 if (err)
481 return err; 481 return err;
482 482
483 pwm->polarity = polarity; 483 pwm->state.polarity = polarity;
484 484
485 return 0; 485 return 0;
486} 486}