From 6ae97be59c7bce32c83d4cdb39902d64831dc714 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Wed, 30 Apr 2025 11:57:46 +0200 Subject: [PATCH] clk: pwm: Let .get_duty_cycle() return the real duty cycle MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Link: https://lore.kernel.org/r/3db08ded39c09aaa5004b3b8b1238111f199e819.1746006578.git.ukleinek@baylibre.com Signed-off-by: Stephen Boyd --- drivers/clk/clk-pwm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk-pwm.c b/drivers/clk/clk-pwm.c index bd4f21c220046..429150bba8cf0 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; -- 2.47.2