diff options
author | Samuel Holland <samuel@sholland.org> | 2022-12-31 11:30:55 -0600 |
---|---|---|
committer | Jernej Skrabec <jernej.skrabec@gmail.com> | 2023-01-08 21:55:17 +0100 |
commit | 657f477a89acb25ba34414ac84a51a32c5013d7b (patch) | |
tree | 6d30cf0d99dde71e57b64ab9c8e6f6ea5b75f6dd /drivers/clk/sunxi-ng/ccu_nkm.c | |
parent | 5ee541ae712e74c842a324e946ef91cb19140cab (diff) | |
download | lwn-657f477a89acb25ba34414ac84a51a32c5013d7b.tar.gz lwn-657f477a89acb25ba34414ac84a51a32c5013d7b.zip |
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_nkm.c')
-rw-r--r-- | drivers/clk/sunxi-ng/ccu_nkm.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/clk/sunxi-ng/ccu_nkm.c b/drivers/clk/sunxi-ng/ccu_nkm.c index 67da2c189b53..a0978a50edae 100644 --- a/drivers/clk/sunxi-ng/ccu_nkm.c +++ b/drivers/clk/sunxi-ng/ccu_nkm.c @@ -16,8 +16,8 @@ struct _ccu_nkm { unsigned long m, min_m, max_m; }; -static void ccu_nkm_find_best(unsigned long parent, unsigned long rate, - struct _ccu_nkm *nkm) +static unsigned long ccu_nkm_find_best(unsigned long parent, unsigned long rate, + struct _ccu_nkm *nkm) { unsigned long best_rate = 0; unsigned long best_n = 0, best_k = 0, best_m = 0; @@ -45,6 +45,8 @@ static void ccu_nkm_find_best(unsigned long parent, unsigned long rate, nkm->n = best_n; nkm->k = best_k; nkm->m = best_m; + + return best_rate; } static void ccu_nkm_disable(struct clk_hw *hw) @@ -122,9 +124,7 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux, if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV) rate *= nkm->fixed_post_div; - ccu_nkm_find_best(*parent_rate, rate, &_nkm); - - rate = *parent_rate * _nkm.n * _nkm.k / _nkm.m; + rate = ccu_nkm_find_best(*parent_rate, rate, &_nkm); if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV) rate /= nkm->fixed_post_div; |