Merge tag 'spi-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc
[deliverable/linux.git] / drivers / of / base.c
index bc86ea2af668454efb2a75fd55108e36eb602a47..c181b94abc363b64a4a38c2e39625b7564dc2267 100644 (file)
@@ -173,9 +173,9 @@ struct property *of_find_property(const struct device_node *np,
                return NULL;
 
        read_lock(&devtree_lock);
-       for (pp = np->properties; pp != 0; pp = pp->next) {
+       for (pp = np->properties; pp; pp = pp->next) {
                if (of_prop_cmp(pp->name, name) == 0) {
-                       if (lenp != 0)
+                       if (lenp)
                                *lenp = pp->length;
                        break;
                }
@@ -497,7 +497,7 @@ struct device_node *of_find_node_with_property(struct device_node *from,
        read_lock(&devtree_lock);
        np = from ? from->allnext : allnodes;
        for (; np; np = np->allnext) {
-               for (pp = np->properties; pp != 0; pp = pp->next) {
+               for (pp = np->properties; pp; pp = pp->next) {
                        if (of_prop_cmp(pp->name, prop_name) == 0) {
                                of_node_get(np);
                                goto out;
@@ -511,22 +511,6 @@ 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
@@ -537,18 +521,9 @@ static const struct of_device_id *of_match_compat(const struct of_device_id *mat
 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])
@@ -557,7 +532,10 @@ 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 (match && !matches->compatible[0])
+               if (matches->compatible[0])
+                       match &= of_device_is_compatible(node,
+                                               matches->compatible);
+               if (match)
                        return matches;
                matches++;
        }
@@ -924,7 +902,7 @@ int of_parse_phandle_with_args(struct device_node *np, const char *list_name,
        /* Retrieve the phandle list property */
        list = of_get_property(np, list_name, &size);
        if (!list)
-               return -EINVAL;
+               return -ENOENT;
        list_end = list + size / sizeof(*list);
 
        /* Loop over the phandles until all the requested entry is found */
@@ -1202,7 +1180,7 @@ static void of_alias_add(struct alias_prop *ap, struct device_node *np,
        ap->stem[stem_len] = 0;
        list_add_tail(&ap->link, &aliases_lookup);
        pr_debug("adding DT alias:%s: stem=%s id=%i node=%s\n",
-                ap->alias, ap->stem, ap->id, np ? np->full_name : NULL);
+                ap->alias, ap->stem, ap->id, of_node_full_name(np));
 }
 
 /**
This page took 0.025055 seconds and 5 git commands to generate.