diff mbox series

[1/4] clk: pwm: Let .get_duty_cycle() return the real duty cycle

Message ID 3db08ded39c09aaa5004b3b8b1238111f199e819.1746006578.git.ukleinek@baylibre.com
State Accepted
Headers show
Series clk: pwm: A few improvements | expand

Commit Message

Uwe Kleine-König April 30, 2025, 9:57 a.m. UTC
pwm_get_state() returns the last requested pwm_state which might differ
from what the lowlevel PWM driver actually implemented. For the purpose
of .get_duty_cycle() the latter is the more interesting info, so use
that to determine the output parameter.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
 drivers/clk/clk-pwm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Stephen Boyd June 20, 2025, 1:14 a.m. UTC | #1
Quoting Uwe Kleine-König (2025-04-30 02:57:46)
> pwm_get_state() returns the last requested pwm_state which might differ
> from what the lowlevel PWM driver actually implemented. For the purpose
> of .get_duty_cycle() the latter is the more interesting info, so use
> that to determine the output parameter.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> ---

Applied to clk-next
diff mbox series

Patch

diff --git a/drivers/clk/clk-pwm.c b/drivers/clk/clk-pwm.c
index bd4f21c22004..429150bba8cf 100644
--- a/drivers/clk/clk-pwm.c
+++ b/drivers/clk/clk-pwm.c
@@ -48,8 +48,11 @@  static int clk_pwm_get_duty_cycle(struct clk_hw *hw, struct clk_duty *duty)
 {
 	struct clk_pwm *clk_pwm = to_clk_pwm(hw);
 	struct pwm_state state;
+	int ret;
 
-	pwm_get_state(clk_pwm->pwm, &state);
+	ret = pwm_get_state_hw(clk_pwm->pwm, &state);
+	if (ret)
+		return ret;
 
 	duty->num = state.duty_cycle;
 	duty->den = state.period;