aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/clkdev.c
diff options
context:
space:
mode:
authorviresh kumar <viresh.kumar@st.com>2012-04-18 23:23:25 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-04-19 14:34:26 -0400
commit67b508715a61962f9b5b3ef3432e045a9cba4f1e (patch)
treef7627533b8bb86433bbd84e98145cf4d1ff2c7a6 /drivers/clk/clkdev.c
parenta8a97db984bdc5e89d42e41891543d2daaf314cb (diff)
ARM: 7392/1: CLKDEV: Optimize clk_find()
clk_find must return as soon as it gets the correct clock. Currently it check all clocks until it found a lookup with both dev_id and con_id matching. If only one of them is passed, then we don't actually need to wait for both of them to match. We can quit as soon as the requested id (dev_id or con_id) matches. Signed-off-by: Viresh Kumar <viresh.kumar@st.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/clk/clkdev.c')
-rw-r--r--drivers/clk/clkdev.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index a9a113782821..d4a59931e75e 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -35,7 +35,12 @@ static DEFINE_MUTEX(clocks_mutex);
35static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) 35static struct clk_lookup *clk_find(const char *dev_id, const char *con_id)
36{ 36{
37 struct clk_lookup *p, *cl = NULL; 37 struct clk_lookup *p, *cl = NULL;
38 int match, best = 0; 38 int match, best_found = 0, best_possible = 0;
39
40 if (dev_id)
41 best_possible += 2;
42 if (con_id)
43 best_possible += 1;
39 44
40 list_for_each_entry(p, &clocks, node) { 45 list_for_each_entry(p, &clocks, node) {
41 match = 0; 46 match = 0;
@@ -50,10 +55,10 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id)
50 match += 1; 55 match += 1;
51 } 56 }
52 57
53 if (match > best) { 58 if (match > best_found) {
54 cl = p; 59 cl = p;
55 if (match != 3) 60 if (match != best_possible)
56 best = match; 61 best_found = match;
57 else 62 else
58 break; 63 break;
59 } 64 }