diff options
author | viresh kumar <viresh.kumar@st.com> | 2012-04-19 03:23:25 (GMT) |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2012-04-19 18:34:26 (GMT) |
commit | 67b508715a61962f9b5b3ef3432e045a9cba4f1e (patch) | |
tree | f7627533b8bb86433bbd84e98145cf4d1ff2c7a6 /drivers/clk | |
parent | a8a97db984bdc5e89d42e41891543d2daaf314cb (diff) | |
download | linux-67b508715a61962f9b5b3ef3432e045a9cba4f1e.tar.xz |
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')
-rw-r--r-- | drivers/clk/clkdev.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index a9a1137..d4a5993 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -35,7 +35,12 @@ static DEFINE_MUTEX(clocks_mutex); static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) { struct clk_lookup *p, *cl = NULL; - int match, best = 0; + int match, best_found = 0, best_possible = 0; + + if (dev_id) + best_possible += 2; + if (con_id) + best_possible += 1; list_for_each_entry(p, &clocks, node) { match = 0; @@ -50,10 +55,10 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) match += 1; } - if (match > best) { + if (match > best_found) { cl = p; - if (match != 3) - best = match; + if (match != best_possible) + best_found = match; else break; } |