clk: Fix rate caching in clk_get_parent_rate()

clk_get_rate() can return an error value. Recompute the rate if the
cached value is an error value.

Fixes: 4aa78300a025 ("dm: clk: Define clk_get_parent_rate() for clk operations")
Signed-off-by: Samuel Holland <samuel@sholland.org>
This commit is contained in:
Samuel Holland 2023-01-26 21:56:57 -06:00
parent 8de411e06a
commit 2efb8e6f66

View File

@ -520,7 +520,8 @@ ulong clk_get_parent_rate(struct clk *clk)
return -ENOSYS;
/* Read the 'rate' if not already set or if proper flag set*/
if (!pclk->rate || pclk->flags & CLK_GET_RATE_NOCACHE)
if (!pclk->rate || IS_ERR_VALUE(pclk->rate) ||
pclk->flags & CLK_GET_RATE_NOCACHE)
pclk->rate = clk_get_rate(pclk);
return pclk->rate;