drivers/clk/sunxi-ng/ccu_mp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
ccu_mp_find_best() already computes a best_rate at the same time as the
best m and p factors. Return it so the caller does not need to duplicate
the division.
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
drivers/clk/sunxi-ng/ccu_mp.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/clk/sunxi-ng/ccu_mp.c b/drivers/clk/sunxi-ng/ccu_mp.c
index 57cf2d615148..cc94a694cb67 100644
--- a/drivers/clk/sunxi-ng/ccu_mp.c
+++ b/drivers/clk/sunxi-ng/ccu_mp.c
@@ -10,9 +10,9 @@
#include "ccu_gate.h"
#include "ccu_mp.h"
-static void ccu_mp_find_best(unsigned long parent, unsigned long rate,
- unsigned int max_m, unsigned int max_p,
- unsigned int *m, unsigned int *p)
+static unsigned long ccu_mp_find_best(unsigned long parent, unsigned long rate,
+ unsigned int max_m, unsigned int max_p,
+ unsigned int *m, unsigned int *p)
{
unsigned long best_rate = 0;
unsigned int best_m = 0, best_p = 0;
@@ -35,6 +35,8 @@ static void ccu_mp_find_best(unsigned long parent, unsigned long rate,
*m = best_m;
*p = best_p;
+
+ return best_rate;
}
static unsigned long ccu_mp_find_best_with_parent_adj(struct clk_hw *hw,
@@ -109,8 +111,7 @@ static unsigned long ccu_mp_round_rate(struct ccu_mux_internal *mux,
max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1);
if (!clk_hw_can_set_rate_parent(&cmp->common.hw)) {
- ccu_mp_find_best(*parent_rate, rate, max_m, max_p, &m, &p);
- rate = *parent_rate / p / m;
+ rate = ccu_mp_find_best(*parent_rate, rate, max_m, max_p, &m, &p);
} else {
rate = ccu_mp_find_best_with_parent_adj(hw, parent_rate, rate,
max_m, max_p);
--
2.35.1
Quoting Samuel Holland (2022-08-09 18:40:24) > ccu_mp_find_best() already computes a best_rate at the same time as the > best m and p factors. Return it so the caller does not need to duplicate > the division. Did the compiler figure this out and thus this patch makes no difference to the final object code?
Hi Stephen, On 8/15/22 12:26, Stephen Boyd wrote: > Quoting Samuel Holland (2022-08-09 18:40:24) >> ccu_mp_find_best() already computes a best_rate at the same time as the >> best m and p factors. Return it so the caller does not need to duplicate >> the division. > > Did the compiler figure this out and thus this patch makes no difference > to the final object code? It makes a difference at least on my gcc version 11.1.0. Before: text data bss dec hex filename 18257 12 0 18269 475d drivers/clk/sunxi-ng/sunxi-ccu.o After: text data bss dec hex filename 18083 12 0 18095 46af drivers/clk/sunxi-ng/sunxi-ccu.o I will send a v2 covering all of the CCU clock types. Regards, Samuel
Dne sreda, 10. avgust 2022 ob 03:40:24 CEST je Samuel Holland napisal(a): > ccu_mp_find_best() already computes a best_rate at the same time as the > best m and p factors. Return it so the caller does not need to duplicate > the division. > > Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com> Other ccu_*_find_best() functions would also benefit with similar change. Best regards, Jernej
© 2016 - 2025 Red Hat, Inc.