From dfaa59878dbe3a3a419be604285f82225a95981e Mon Sep 17 00:00:00 2001 From: Damon Ding Date: Thu, 16 Jan 2025 09:17:04 +0800 Subject: [PATCH] pwm: rockchip: fix the scaler calculation in &rockchip_pwm_funcs.set_wave() If the pc->clk_rate is the same as config->clk_rate, the scaler should be set to 0. However, using the previous calculation method, the result would incorrectly be 1. Fixes: 1504b8ffcf37 ("pwm: rockchip: add dclk scale config for wave generator mode") Change-Id: I876f7f530ab841b485b8d7f139adcf825955a160 Signed-off-by: Damon Ding --- drivers/pwm/pwm-rockchip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c index 6246c5182fd2..441512796e2e 100644 --- a/drivers/pwm/pwm-rockchip.c +++ b/drivers/pwm/pwm-rockchip.c @@ -1652,7 +1652,7 @@ int rockchip_pwm_set_wave(struct pwm_device *pwm, struct rockchip_pwm_wave_confi return -EINVAL; } - pc->scaler = DIV_ROUND_CLOSEST_ULL(pc->clk_rate, config->clk_rate * 2); + pc->scaler = DIV_ROUND_CLOSEST_ULL(pc->clk_rate, config->clk_rate) / 2; if (pc->scaler > 256) { dev_err(chip->dev, "Unsupported scale factor %d(max: 512) for PWM%d\n", pc->scaler * 2, pc->channel_id);