diff options
author | Samuel Holland <samuel@sholland.org> | 2022-12-31 20:30:55 +0300 |
---|---|---|
committer | Jernej Skrabec <jernej.skrabec@gmail.com> | 2023-01-08 23:55:17 +0300 |
commit | 657f477a89acb25ba34414ac84a51a32c5013d7b (patch) | |
tree | 6d30cf0d99dde71e57b64ab9c8e6f6ea5b75f6dd /drivers/clk/sunxi-ng/ccu_nk.c | |
parent | 5ee541ae712e74c842a324e946ef91cb19140cab (diff) | |
download | linux-657f477a89acb25ba34414ac84a51a32c5013d7b.tar.xz |
clk: sunxi-ng: Avoid computing the rate twice
The ccu_*_find_best() functions already compute a best_rate at the same
time as the other factors. Return this value so the caller does not need
to duplicate the computation.
Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Link: https://lore.kernel.org/r/20221231173055.42384-1-samuel@sholland.org
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Diffstat (limited to 'drivers/clk/sunxi-ng/ccu_nk.c')
-rw-r--r-- | drivers/clk/sunxi-ng/ccu_nk.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/clk/sunxi-ng/ccu_nk.c b/drivers/clk/sunxi-ng/ccu_nk.c index c4fb82af97e8..8aa35d5804f3 100644 --- a/drivers/clk/sunxi-ng/ccu_nk.c +++ b/drivers/clk/sunxi-ng/ccu_nk.c @@ -15,8 +15,8 @@ struct _ccu_nk { unsigned long k, min_k, max_k; }; -static void ccu_nk_find_best(unsigned long parent, unsigned long rate, - struct _ccu_nk *nk) +static unsigned long ccu_nk_find_best(unsigned long parent, unsigned long rate, + struct _ccu_nk *nk) { unsigned long best_rate = 0; unsigned int best_k = 0, best_n = 0; @@ -39,6 +39,8 @@ static void ccu_nk_find_best(unsigned long parent, unsigned long rate, nk->k = best_k; nk->n = best_n; + + return best_rate; } static void ccu_nk_disable(struct clk_hw *hw) @@ -104,8 +106,7 @@ static long ccu_nk_round_rate(struct clk_hw *hw, unsigned long rate, _nk.min_k = nk->k.min ?: 1; _nk.max_k = nk->k.max ?: 1 << nk->k.width; - ccu_nk_find_best(*parent_rate, rate, &_nk); - rate = *parent_rate * _nk.n * _nk.k; + rate = ccu_nk_find_best(*parent_rate, rate, &_nk); if (nk->common.features & CCU_FEATURE_FIXED_POSTDIV) rate = rate / nk->fixed_post_div; |