[PATCH v1 1/5] pwm: tiecap: Fix type of variable holding clock rate
From: Uwe Kleine-König
Date: Fri Nov 27 2026 - 12:40:16 EST
clk_get_rate() returns an unsigned long. Make clk_rate the same type
to fix silent discarding of relevant bits for architectures where
sizeof(long) > sizeof(int).
To let .get_state() handle that possibly bigger variable use
DIV64_U64_ROUND_UP() instead of DIV_ROUND_UP_ULL() as the latter assumes
the divisor to be a u32.
Fixes: 8e0cb05b3b75 ("pwm: pwm-tiecap: PWM driver support for ECAP APWM")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx>
---
drivers/pwm/pwm-tiecap.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/pwm/pwm-tiecap.c b/drivers/pwm/pwm-tiecap.c
index 9a490b8d60ec..7ca23a7576bf 100644
--- a/drivers/pwm/pwm-tiecap.c
+++ b/drivers/pwm/pwm-tiecap.c
@@ -37,7 +37,7 @@ struct ecap_context {
};
struct ecap_pwm_chip {
- unsigned int clk_rate;
+ unsigned long clk_rate;
void __iomem *mmio_base;
struct ecap_context ctx;
};
@@ -232,10 +232,10 @@ static int ecap_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
state->polarity = value & ECCTL2_APWM_POL_LOW ? PWM_POLARITY_INVERSED :
PWM_POLARITY_NORMAL;
- state->period = DIV_ROUND_UP_ULL((u64)period_cycles * NSEC_PER_SEC,
- pc->clk_rate);
- state->duty_cycle = DIV_ROUND_UP_ULL((u64)duty_cycles * NSEC_PER_SEC,
- pc->clk_rate);
+ state->period = DIV64_U64_ROUND_UP((u64)period_cycles * NSEC_PER_SEC,
+ pc->clk_rate);
+ state->duty_cycle = DIV64_U64_ROUND_UP((u64)duty_cycles * NSEC_PER_SEC,
+ pc->clk_rate);
return 0;
}
--
2.47.3