aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pwm
diff options
context:
space:
mode:
authorUwe Kleine-König <uwe@kleine-koenig.org>2019-08-24 17:37:03 +0200
committerThierry Reding <thierry.reding@gmail.com>2019-09-21 01:48:54 +0200
commit01ccf903edd65f6421612321648fa5a7f4b7cb10 (patch)
tree7f91aa81ecbdb830970221e6b4b1743d4b594792 /drivers/pwm
parentpwm: Introduce local struct pwm_chip in pwm_apply_state() (diff)
downloadlinux-dev-01ccf903edd65f6421612321648fa5a7f4b7cb10.tar.xz
linux-dev-01ccf903edd65f6421612321648fa5a7f4b7cb10.zip
pwm: Let pwm_get_state() return the last implemented state
When pwm_apply_state() is called the lowlevel driver usually has to apply some rounding because the hardware doesn't support nanosecond resolution. So let pwm_get_state() return the actually implemented state instead of the last applied one if possible. Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r--drivers/pwm/core.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 4ab683a30629..449ba161877d 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -474,7 +474,14 @@ int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state)
if (err)
return err;
- pwm->state = *state;
+ /*
+ * .apply might have to round some values in *state, if possible
+ * read the actually implemented value back.
+ */
+ if (chip->ops->get_state)
+ chip->ops->get_state(chip, pwm, &pwm->state);
+ else
+ pwm->state = *state;
} else {
/*
* FIXME: restore the initial state in case of error.