of: fix incorrect return value of of_find_matching_node_and_match()
authorThomas Abraham <thomas.abraham@linaro.org>
Sat, 19 Jan 2013 18:20:42 +0000 (10:20 -0800)
committerRob Herring <rob.herring@calxeda.com>
Sun, 20 Jan 2013 22:26:42 +0000 (16:26 -0600)
The of_find_matching_node_and_match() function incorrectly sets the matched
entry to 'matches' when the compatible value of a node matches one of the
possible values. This results in incorrectly selecting the the first entry in
the 'matches' list as the matched entry. Fix this by noting down the result of
the call to of_match_node() and setting that as the matched entry.

Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
drivers/of/base.c

index 2390ddb22d6094d5b39809aa8f6a7510b7c25c7f..960ae5bf3ddc64b1dcdc2800919dc260fac4f198 100644 (file)
@@ -612,6 +612,7 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from,
                                        const struct of_device_id **match)
 {
        struct device_node *np;
+       const struct of_device_id *m;
 
        if (match)
                *match = NULL;
@@ -619,9 +620,10 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from,
        read_lock(&devtree_lock);
        np = from ? from->allnext : of_allnodes;
        for (; np; np = np->allnext) {
-               if (of_match_node(matches, np) && of_node_get(np)) {
+               m = of_match_node(matches, np);
+               if (m && of_node_get(np)) {
                        if (match)
-                               *match = matches;
+                               *match = m;
                        break;
                }
        }