[PATCH 4/6] clk: Fix rate caching in clk_get_parent_rate()
Michal Suchánek
msuchanek at suse.de
Mon Feb 20 11:41:35 CET 2023
On Sun, Feb 19, 2023 at 11:59:37PM -0600, Samuel Holland wrote:
> 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 at sholland.org>
> ---
>
> drivers/clk/clk-uclass.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
> index 5bce976b060..9d052e5a814 100644
> --- a/drivers/clk/clk-uclass.c
> +++ b/drivers/clk/clk-uclass.c
> @@ -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;
With the current code that randomly returns one or the other this is the
correct thing to do.
Reviewed-by: Michal Suchánek <msuchanek at suse.de>
Thanks
Michal
More information about the U-Boot
mailing list