summaryrefslogtreecommitdiff
path: root/drivers/of/base.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2012-07-17 20:41:50 (GMT)
committerArnd Bergmann <arnd@arndb.de>2012-07-17 20:41:50 (GMT)
commit36c678f3c91ac92e9524abcf9b39f9f539d60279 (patch)
treec9c0df006a7e9bcc14492b1d1fa6aa2c5c43d3a3 /drivers/of/base.c
parent4450cb7d586c3d8f6615ee437eab1d1e064b20c0 (diff)
parent14ac5b884eff23f53139dd4508f428aee906d8c2 (diff)
downloadlinux-36c678f3c91ac92e9524abcf9b39f9f539d60279.tar.xz
Merge tag 'imx-clk' of git://git.pengutronix.de/git/imx/linux-2.6 into next/clk
From Sascha Hauer <s.hauer@pengutronix.de>: i.MX clk noncritical fixes and updates * tag 'imx-clk' of git://git.pengutronix.de/git/imx/linux-2.6: ARM: imx: clk-imx31: Fix clock id for rnga driver ARM: imx: add missing item to the list of clock event modes ARM: i.MX5x CSPI: Fixed clock name for CSPI ARM: i.MX5x clocks: Fix GPT clocks ARM: i.MX5x clocks: Fix parent for PWM clocks ARM: i.MX5x clocks: Add EPIT support ARM: mx27: Reenable silicon version print ARM: clk-imx27: Fix rtc clock id Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/of/base.c')
-rw-r--r--drivers/of/base.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index d9bfd49..eada3f4 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -511,6 +511,22 @@ out:
}
EXPORT_SYMBOL(of_find_node_with_property);
+static const struct of_device_id *of_match_compat(const struct of_device_id *matches,
+ const char *compat)
+{
+ while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
+ const char *cp = matches->compatible;
+ int len = strlen(cp);
+
+ if (len > 0 && of_compat_cmp(compat, cp, len) == 0)
+ return matches;
+
+ matches++;
+ }
+
+ return NULL;
+}
+
/**
* of_match_node - Tell if an device_node has a matching of_match structure
* @matches: array of of device match structures to search in
@@ -521,9 +537,18 @@ EXPORT_SYMBOL(of_find_node_with_property);
const struct of_device_id *of_match_node(const struct of_device_id *matches,
const struct device_node *node)
{
+ struct property *prop;
+ const char *cp;
+
if (!matches)
return NULL;
+ of_property_for_each_string(node, "compatible", prop, cp) {
+ const struct of_device_id *match = of_match_compat(matches, cp);
+ if (match)
+ return match;
+ }
+
while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
int match = 1;
if (matches->name[0])
@@ -532,10 +557,7 @@ const struct of_device_id *of_match_node(const struct of_device_id *matches,
if (matches->type[0])
match &= node->type
&& !strcmp(matches->type, node->type);
- if (matches->compatible[0])
- match &= of_device_is_compatible(node,
- matches->compatible);
- if (match)
+ if (match && !matches->compatible[0])
return matches;
matches++;
}