summaryrefslogtreecommitdiff
path: root/drivers/of
diff options
context:
space:
mode:
authorJoerg Roedel <jroedel@suse.de>2016-04-04 17:49:21 +0200
committerRob Herring <robh@kernel.org>2016-04-19 17:25:15 -0500
commitabdaa77b18480361f3565d958a2acffad268c39c (patch)
tree117d1ce28587ee28e10a8d47440ea46081860762 /drivers/of
parentf623ce95a51baee6a6638f0b025efc0229a9ac0d (diff)
downloadlinux-abdaa77b18480361f3565d958a2acffad268c39c.tar.gz
linux-abdaa77b18480361f3565d958a2acffad268c39c.tar.xz
of: Introduce of_phandle_iterator_args()
This helper function can be used to copy the arguments of a phandle to an array. Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/base.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index ea5a13d3c5a5..e87e21df19d8 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1534,6 +1534,23 @@ err:
return -EINVAL;
}
+int of_phandle_iterator_args(struct of_phandle_iterator *it,
+ uint32_t *args,
+ int size)
+{
+ int i, count;
+
+ count = it->cur_count;
+
+ if (WARN_ON(size < count))
+ count = size;
+
+ for (i = 0; i < count; i++)
+ args[i] = be32_to_cpup(it->cur++);
+
+ return count;
+}
+
static int __of_parse_phandle_with_args(const struct device_node *np,
const char *list_name,
const char *cells_name,
@@ -1557,13 +1574,13 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
goto err;
if (out_args) {
- int i;
- if (WARN_ON(it.cur_count > MAX_PHANDLE_ARGS))
- it.cur_count = MAX_PHANDLE_ARGS;
+ int c;
+
+ c = of_phandle_iterator_args(&it,
+ out_args->args,
+ MAX_PHANDLE_ARGS);
out_args->np = it.node;
- out_args->args_count = it.cur_count;
- for (i = 0; i < it.cur_count; i++)
- out_args->args[i] = be32_to_cpup(it.cur++);
+ out_args->args_count = c;
} else {
of_node_put(it.node);
}