From acd6c823d65e95a82072e8a82f0ba76eb50c1d88 Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Tue, 12 Feb 2013 21:21:49 +0000 Subject: [PATCH] --- yaml --- r: 350817 b: refs/heads/master c: 23ce04c0734e33b1042273b0ed11a8e4f7f988ca h: refs/heads/master i: 350815: bb606afbf7f8b62589e81b9c61f6e3a2bf1df068 v: v3 --- [refs] | 2 +- trunk/drivers/of/base.c | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/[refs] b/[refs] index 79a1bbc6bbd8..b292657d44a4 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: cabb7d5b7896a4d307ea6ad6d3bd045810544151 +refs/heads/master: 23ce04c0734e33b1042273b0ed11a8e4f7f988ca diff --git a/trunk/drivers/of/base.c b/trunk/drivers/of/base.c index f7a87ce1b480..c5572cb87a88 100644 --- a/trunk/drivers/of/base.c +++ b/trunk/drivers/of/base.c @@ -1096,7 +1096,7 @@ int of_parse_phandle_with_args(const struct device_node *np, const char *list_na struct of_phandle_args *out_args) { const __be32 *list, *list_end; - int size, cur_index = 0; + int rc = 0, size, cur_index = 0; uint32_t count = 0; struct device_node *node = NULL; phandle phandle; @@ -1109,6 +1109,7 @@ int of_parse_phandle_with_args(const struct device_node *np, const char *list_na /* Loop over the phandles until all the requested entry is found */ while (list < list_end) { + rc = -EINVAL; count = 0; /* @@ -1125,13 +1126,13 @@ int of_parse_phandle_with_args(const struct device_node *np, const char *list_na if (!node) { pr_err("%s: could not find phandle\n", np->full_name); - break; + goto err; } if (of_property_read_u32(node, cells_name, &count)) { pr_err("%s: could not get %s for %s\n", np->full_name, cells_name, node->full_name); - break; + goto err; } /* @@ -1141,7 +1142,7 @@ int of_parse_phandle_with_args(const struct device_node *np, const char *list_na if (list + count > list_end) { pr_err("%s: arguments longer than property\n", np->full_name); - break; + goto err; } } @@ -1151,9 +1152,10 @@ int of_parse_phandle_with_args(const struct device_node *np, const char *list_na * index matches, then fill the out_args structure and return, * or return -ENOENT for an empty entry. */ + rc = -ENOENT; if (cur_index == index) { if (!phandle) - return -ENOENT; + goto err; if (out_args) { int i; @@ -1164,6 +1166,10 @@ int of_parse_phandle_with_args(const struct device_node *np, const char *list_na for (i = 0; i < count; i++) out_args->args[i] = be32_to_cpup(list++); } + + /* Found it! return success */ + if (node) + of_node_put(node); return 0; } @@ -1173,10 +1179,16 @@ int of_parse_phandle_with_args(const struct device_node *np, const char *list_na cur_index++; } - /* Loop exited without finding a valid entry; return an error */ + /* + * Unlock node before returning result; will be one of: + * -ENOENT : index is for empty phandle + * -EINVAL : parsing error on data + */ + rc = -ENOENT; + err: if (node) of_node_put(node); - return -EINVAL; + return rc; } EXPORT_SYMBOL(of_parse_phandle_with_args);