[PATCH 08/19] clk: divider: check divider validity for CLK_DIVIDER_EVEN_INTEGERS

Benoît Monin
2025-09-03T12:47:52Z

Ensure that the divider is even when the flag CLK_DIVIDER_EVEN_INTEGERS
is set, similar to the power of two check for CLK_DIVIDER_POWER_OF_TWO.

Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
---
drivers/clk/clk-divider.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index c1f426b8a5043cb5a1de08e1da385928ec54a2ed..8e8f87024e76625f348f1d66c15a7a938fa0c4db 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -181,6 +181,8 @@ static bool _is_valid_div(const struct clk_div_table *table, unsigned int div,
{
if (flags & CLK_DIVIDER_POWER_OF_TWO)
return is_power_of_2(div);
+ if (flags & CLK_DIVIDER_EVEN_INTEGERS)
+ return (div % 2) == 0;
if (table)
return _is_valid_table_div(table, div);
return true;

--
2.51.0