diff options
author | Ryo Kodama <ryo.kodama.vz@renesas.com> | 2018-03-09 06:24:21 -0500 |
---|---|---|
committer | Thierry Reding <thierry.reding@gmail.com> | 2018-03-27 19:20:13 -0400 |
commit | 6225f9c64b40bc8a22503e9cda70f55d7a9dd3c6 (patch) | |
tree | 3cec7123741d4d4814ce907597b9b34cbff21450 /drivers/pwm/pwm-rcar.c | |
parent | 8bbf5b426160343b554117eb9abdf4dad9a50e65 (diff) |
pwm: rcar: Fix a condition to prevent mismatch value setting to duty
This patch fixes an issue that is possible to set mismatch value to duty
for R-Car PWM if we input the following commands:
# cd /sys/class/pwm/<pwmchip>/
# echo 0 > export
# cd pwm0
# echo 30 > period
# echo 30 > duty_cycle
# echo 0 > duty_cycle
# cat duty_cycle
0
# echo 1 > enable
--> Then, the actual duty_cycle is 30, not 0.
So, this patch adds a condition into rcar_pwm_config() to fix this
issue.
Signed-off-by: Ryo Kodama <ryo.kodama.vz@renesas.com>
[shimoda: revise the commit log and add Fixes and Cc tags]
Fixes: ed6c1476bf7f ("pwm: Add support for R-Car PWM Timer")
Cc: Cc: <stable@vger.kernel.org> # v4.4+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/pwm-rcar.c')
-rw-r--r-- | drivers/pwm/pwm-rcar.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/pwm/pwm-rcar.c b/drivers/pwm/pwm-rcar.c index 1c85ecc9e7ac..0fcf94ffad32 100644 --- a/drivers/pwm/pwm-rcar.c +++ b/drivers/pwm/pwm-rcar.c | |||
@@ -156,8 +156,12 @@ static int rcar_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, | |||
156 | if (div < 0) | 156 | if (div < 0) |
157 | return div; | 157 | return div; |
158 | 158 | ||
159 | /* Let the core driver set pwm->period if disabled and duty_ns == 0 */ | 159 | /* |
160 | if (!pwm_is_enabled(pwm) && !duty_ns) | 160 | * Let the core driver set pwm->period if disabled and duty_ns == 0. |
161 | * But, this driver should prevent to set the new duty_ns if current | ||
162 | * duty_cycle is not set | ||
163 | */ | ||
164 | if (!pwm_is_enabled(pwm) && !duty_ns && !pwm->state.duty_cycle) | ||
161 | return 0; | 165 | return 0; |
162 | 166 | ||
163 | rcar_pwm_update(rp, RCAR_PWMCR_SYNC, RCAR_PWMCR_SYNC, RCAR_PWMCR); | 167 | rcar_pwm_update(rp, RCAR_PWMCR_SYNC, RCAR_PWMCR_SYNC, RCAR_PWMCR); |