linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Thierry Reding <thierry.reding@gmail.com>,
	Lee Jones <lee.jones@linaro.org>
Cc: linux-pwm@vger.kernel.org, kernel@pengutronix.de,
	Thomas Hebb <tommyhebb@gmail.com>
Subject: [PATCH 4/5] pwm: berlin: Ensure configuring period and duty_cycle isn't wrongly skipped
Date: Thu,  1 Jul 2021 10:27:54 +0200	[thread overview]
Message-ID: <20210701082755.332593-5-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20210701082755.332593-1-u.kleine-koenig@pengutronix.de>

As the last call to berlin_pwm_apply() might have exited early if
state->enabled was false, the values for period and duty_cycle stored in
pwm->state might not have been written to hardware and it must be
ensured that they are configured before enabling the PWM.

Fixes: 30dffb42fcd4 ("pwm: berlin: Implement .apply() callback")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-berlin.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/pwm/pwm-berlin.c b/drivers/pwm/pwm-berlin.c
index 5537b5f6dd5d..e157273fd2f7 100644
--- a/drivers/pwm/pwm-berlin.c
+++ b/drivers/pwm/pwm-berlin.c
@@ -190,12 +190,9 @@ static int berlin_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 		return 0;
 	}
 
-	if (state->period != pwm->state.period ||
-	    state->duty_cycle != pwm->state.duty_cycle) {
-		err = berlin_pwm_config(chip, pwm, state->duty_cycle, state->period);
-		if (err)
-			return err;
-	}
+	err = berlin_pwm_config(chip, pwm, state->duty_cycle, state->period);
+	if (err)
+		return err;
 
 	if (!enabled)
 		return berlin_pwm_enable(chip, pwm);
-- 
2.30.2


  parent reply	other threads:[~2021-07-01  8:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-01  8:27 [PATCH 0/5] pwm: Ensure configuring period and duty_cycle isn't wrongly skipped Uwe Kleine-König
2021-07-01  8:27 ` [PATCH 1/5] pwm: sprd: " Uwe Kleine-König
2021-07-01  8:27 ` [PATCH 2/5] pwm: spear: " Uwe Kleine-König
2021-07-01  8:27 ` [PATCH 3/5] pwm: tiecap: " Uwe Kleine-König
2021-07-01  8:27 ` Uwe Kleine-König [this message]
2021-07-01  8:27 ` [PATCH 5/5] pwm: ep93xx: " Uwe Kleine-König
2021-07-08 12:36 ` [PATCH 0/5] pwm: " Uwe Kleine-König
2021-07-08 14:07   ` Thierry Reding
2021-07-08 20:36     ` Uwe Kleine-König
2021-07-14  6:39     ` Uwe Kleine-König
2021-07-14  7:39       ` Thierry Reding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210701082755.332593-5-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=kernel@pengutronix.de \
    --cc=lee.jones@linaro.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=tommyhebb@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).