aboutsummaryrefslogtreecommitdiff
path: root/drivers/of/base.c
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2012-07-20 16:42:59 +0900
committerPaul Mundt <lethal@linux-sh.org>2012-07-20 16:42:59 +0900
commit9ff561fdf73493d757bbc74aa58627e1381650fb (patch)
tree4484d230662126b1ac94ea545ca5429c91e0a68b /drivers/of/base.c
parent7b98cf0cf4e8798b9e7435f966ed0d90a2a925de (diff)
parentfdd85ec3eb8cc1b663678a3efa16ee59a32e0277 (diff)
Merge branch 'common/pinctrl' into sh-latest
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 d9bfd49b193..eada3f4ef80 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++;
}