[PATCH 1/2] clk: mux: improve the execution efficiency of determine_rate()

Chuan Liu via B4 Relay posted 2 patches 3 months, 3 weeks ago
[PATCH 1/2] clk: mux: improve the execution efficiency of determine_rate()
Posted by Chuan Liu via B4 Relay 3 months, 3 weeks ago
From: Chuan Liu <chuan.liu@amlogic.com>

According to the current logic of mux_is_better_rate(), even if a
parent clock matching req->rate is found again in the current loop,
it will not be selected.

Exit the loop once the best-matching parent clock is found to avoid
unnecessary function calls and reduce execution time.

Signed-off-by: Chuan Liu <chuan.liu@amlogic.com>
---
 drivers/clk/clk.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 85d2f2481acf..925e4768e3ad 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -758,6 +758,9 @@ int clk_mux_determine_rate_flags(struct clk_hw *hw,
 			best_parent = parent;
 			best = parent_rate;
 		}
+
+		if (best == req->rate)
+			break;
 	}
 
 	if (!best_parent)

-- 
2.42.0