aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/common/clkdev.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/common/clkdev.c')
-rw-r--r--arch/arm/common/clkdev.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/arch/arm/common/clkdev.c b/arch/arm/common/clkdev.c
index 17a17b49a45b..1037bba18329 100644
--- a/arch/arm/common/clkdev.c
+++ b/arch/arm/common/clkdev.c
@@ -24,6 +24,15 @@
24static LIST_HEAD(clocks); 24static LIST_HEAD(clocks);
25static DEFINE_MUTEX(clocks_mutex); 25static DEFINE_MUTEX(clocks_mutex);
26 26
27/*
28 * Find the correct struct clk for the device and connection ID.
29 * We do slightly fuzzy matching here:
30 * An entry with a NULL ID is assumed to be a wildcard.
31 * If an entry has a device ID, it must match
32 * If an entry has a connection ID, it must match
33 * Then we take the most specific entry - with the following
34 * order of precidence: dev+con > dev only > con only.
35 */
27static struct clk *clk_find(const char *dev_id, const char *con_id) 36static struct clk *clk_find(const char *dev_id, const char *con_id)
28{ 37{
29 struct clk_lookup *p; 38 struct clk_lookup *p;
@@ -31,13 +40,17 @@ static struct clk *clk_find(const char *dev_id, const char *con_id)
31 int match, best = 0; 40 int match, best = 0;
32 41
33 list_for_each_entry(p, &clocks, node) { 42 list_for_each_entry(p, &clocks, node) {
34 if ((p->dev_id && !dev_id) || (p->con_id && !con_id))
35 continue;
36 match = 0; 43 match = 0;
37 if (p->dev_id) 44 if (p->dev_id) {
38 match += 2 * (strcmp(p->dev_id, dev_id) == 0); 45 if (!dev_id || strcmp(p->dev_id, dev_id))
39 if (p->con_id) 46 continue;
40 match += 1 * (strcmp(p->con_id, con_id) == 0); 47 match += 2;
48 }
49 if (p->con_id) {
50 if (!con_id || strcmp(p->con_id, con_id))
51 continue;
52 match += 1;
53 }
41 if (match == 0) 54 if (match == 0)
42 continue; 55 continue;
43 56