Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 519ef9b5 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Thierry Reding
Browse files

pwm: imx27: Only enable the clocks once in .get_state()



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: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent b4f9a726
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -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,6 +160,7 @@ static void pwm_imx27_get_state(struct pwm_chip *chip,
		state->duty_cycle = 0;
	}

	if (!state->enabled)
		pwm_imx27_clk_disable_unprepare(chip);
}