linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pwm: imx27: only enable the clocks once in .get_state
@ 2019-01-10 19:33 Uwe Kleine-König
  2019-03-04 11:23 ` Thierry Reding
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kleine-König @ 2019-01-10 19:33 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-pwm, NXP Linux Team, kernel

Currently the function pwm_imx27_get_state() of enables the clocks once
unconditionally at the start, a second time if the PWM is enabled and
disables unconditionally at the end.

Simplify that to enable once at the start and disable conditionally at
the end.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-imx27.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/pwm/pwm-imx27.c b/drivers/pwm/pwm-imx27.c
index 8997c4c1bd03..4dc2d62c0e1c 100644
--- a/drivers/pwm/pwm-imx27.c
+++ b/drivers/pwm/pwm-imx27.c
@@ -125,14 +125,10 @@ static void pwm_imx27_get_state(struct pwm_chip *chip,
 
 	val = readl(imx->mmio_base + MX3_PWMCR);
 
-	if (val & MX3_PWMCR_EN) {
+	if (val & MX3_PWMCR_EN)
 		state->enabled = true;
-		ret = pwm_imx27_clk_prepare_enable(chip);
-		if (ret)
-			return;
-	} else {
+	else
 		state->enabled = false;
-	}
 
 	switch (FIELD_GET(MX3_PWMCR_POUTC, val)) {
 	case MX3_PWMCR_POUTC_NORMAL:
@@ -164,7 +160,8 @@ static void pwm_imx27_get_state(struct pwm_chip *chip,
 		state->duty_cycle = 0;
 	}
 
-	pwm_imx27_clk_disable_unprepare(chip);
+	if (!state->enabled)
+		pwm_imx27_clk_disable_unprepare(chip);
 }
 
 static void pwm_imx27_sw_reset(struct pwm_chip *chip)
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] pwm: imx27: only enable the clocks once in .get_state
  2019-01-10 19:33 [PATCH] pwm: imx27: only enable the clocks once in .get_state Uwe Kleine-König
@ 2019-03-04 11:23 ` Thierry Reding
  0 siblings, 0 replies; 2+ messages in thread
From: Thierry Reding @ 2019-03-04 11:23 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: linux-pwm, NXP Linux Team, kernel

[-- Attachment #1: Type: text/plain, Size: 554 bytes --]

On Thu, Jan 10, 2019 at 08:33:53PM +0100, Uwe Kleine-König wrote:
> Currently the function pwm_imx27_get_state() of enables the clocks once
> unconditionally at the start, a second time if the PWM is enabled and
> disables unconditionally at the end.
> 
> Simplify that to enable once at the start and disable conditionally at
> the end.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/pwm/pwm-imx27.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)

Applied, thanks.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-04 11:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-10 19:33 [PATCH] pwm: imx27: only enable the clocks once in .get_state Uwe Kleine-König
2019-03-04 11:23 ` Thierry Reding

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).