Merge tag 'v3.5-rc6' into irqdomain/next
[deliverable/linux.git] / drivers / of / base.c
index 9282d4cc1091d64161a74dbce3966079384483e0..c499cc817c172da4f8c52e9cbae683c8b8cdfbdd 100644 (file)
@@ -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++;
        }
This page took 0.040109 seconds and 5 git commands to generate.