From: Rayagonda Kokatanur <rayagonda.kokata...@broadcom.com> Handle clk_get_rate() returning <= 0 condition to avoid possible division by zero.
Fixes: daa5abc41c80 ("pwm: Add support for Broadcom iProc PWM controller") Signed-off-by: Rayagonda Kokatanur <rayagonda.kokata...@broadcom.com> Signed-off-by: Scott Branden <scott.bran...@broadcom.com> --- drivers/pwm/pwm-bcm-iproc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pwm/pwm-bcm-iproc.c b/drivers/pwm/pwm-bcm-iproc.c index 1f829edd8ee7..72a8607b6c8d 100644 --- a/drivers/pwm/pwm-bcm-iproc.c +++ b/drivers/pwm/pwm-bcm-iproc.c @@ -86,6 +86,11 @@ static void iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm, u32 value, prescale; rate = clk_get_rate(ip->clk); + if (rate == 0) { + state->period = 0; + state->duty_cycle = 0; + return; + } value = readl(ip->base + IPROC_PWM_CTRL_OFFSET); -- 2.17.1