Re: [PATCH RFC RFT v3 01/13] clk: divider: Add CLK_DIVIDER_INVALID_ZERO flag

From: Jerome Brunet

Date: Thu Dec 03 2026 - 10:31:18 EST


> When a divider register reads zero, divider_recalc_rate() currently
> emits a warning (unless CLK_DIVIDER_ALLOW_ZERO is set) and returns
> the parent rate.
>
> This behaviour assumes a zero divisor acts as a pass-through, which
> does not apply to all hardware. Some dividers, for example PLL
> pre-dividers on Amlogic SoCs, come out of reset with a zero value
> that does not produce a usable clock. Returning the parent rate
> hides this fault behind an incorrect, plausible value.
>
> CLK_DIVIDER_ALLOW_ZERO only suppresses the warning while still
> reporting the parent rate, so it cannot represent this hardware
> behaviour.
>
> Add CLK_DIVIDER_INVALID_ZERO for dividers where a zero divisor value
> is invalid. When this flag is set, recalc_rate() returns 0, making
> the faulty state visible to the clock framework rather than hiding it
> as a pass-through.
>
> Return -EINVAL when the decoded divisor is zero in
> divider_ro_determine_rate, rather than dividing by zero or reporting
> a rate which does not exist.
>

Suggested-by: Jerome Brunet <jbrunet@xxxxxxxxxxxx>
> Signed-off-by: Jian Hu <jian.hu@xxxxxxxxxxx>
Reviewed-by: Jerome Brunet <jbrunet@xxxxxxxxxxxx>

Brian, could you let us know what you think about this ?

--
Jerome