diff mbox series

[6/6] pwm: sun4i: don't delay if the PWM is already off

Message ID 20210531044608.1006024-7-roman.beranek@prusa3d.com
State Changes Requested
Headers show
Series pwm: sun4i: only wait 2 cycles prior to disabling | expand

Commit Message

Roman Beranek May 31, 2021, 4:46 a.m. UTC
Signed-off-by: Roman Beranek <roman.beranek@prusa3d.com>
---
 drivers/pwm/pwm-sun4i.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Pascal Roeleven June 10, 2021, 1:41 p.m. UTC | #1
On 2021-05-31 06:46, Roman Beranek wrote:
> Signed-off-by: Roman Beranek <roman.beranek@prusa3d.com>
> ---
>  drivers/pwm/pwm-sun4i.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
> index 6ab06b9749d0..88bd90498d1f 100644
> --- a/drivers/pwm/pwm-sun4i.c
> +++ b/drivers/pwm/pwm-sun4i.c
> @@ -304,7 +304,7 @@ static int sun4i_pwm_apply(struct pwm_chip *chip,
> struct pwm_device *pwm,
>  
>  	sun4i_pwm_writel(sun4i_pwm, ctrl, PWM_CTRL_REG);
>  
> -	if (state->enabled) {
> +	if (state->enabled || !cstate.enabled) {
>  		mutex_unlock(&sun4i_pwm->ctrl_lock);
>  		return 0;
>  	}

Btw, this now leaves the gate open if the controller is currently
disabled and we are only changing the period register and staying
disabled. This becomes an issue because we always expect the gate to be
disabled when the controller is disabled.

Regards,
Pascal
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
index 6ab06b9749d0..88bd90498d1f 100644
--- a/drivers/pwm/pwm-sun4i.c
+++ b/drivers/pwm/pwm-sun4i.c
@@ -304,7 +304,7 @@  static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 	sun4i_pwm_writel(sun4i_pwm, ctrl, PWM_CTRL_REG);
 
-	if (state->enabled) {
+	if (state->enabled || !cstate.enabled) {
 		mutex_unlock(&sun4i_pwm->ctrl_lock);
 		return 0;
 	}