Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/354073/?format=api
{ "id": 354073, "url": "http://patchwork.ozlabs.org/api/patches/354073/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-tegra/patch/1401448834-32659-2-git-send-email-hdoyu@nvidia.com/", "project": { "id": 21, "url": "http://patchwork.ozlabs.org/api/projects/21/?format=api", "name": "Linux Tegra Development", "link_name": "linux-tegra", "list_id": "linux-tegra.vger.kernel.org", "list_email": "linux-tegra@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1401448834-32659-2-git-send-email-hdoyu@nvidia.com>", "list_archive_url": null, "date": "2014-05-30T11:20:14", "name": "[PATCHv8,01/21] of: introduce of_property_for_each_phandle_with_args()", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "c2d7b0e0aca835fff6bde99a33a03c1e99957ddf", "submitter": { "id": 10265, "url": "http://patchwork.ozlabs.org/api/people/10265/?format=api", "name": "Hiroshi Doyu", "email": "hdoyu@nvidia.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-tegra/patch/1401448834-32659-2-git-send-email-hdoyu@nvidia.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/354073/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/354073/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-tegra-owner@vger.kernel.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 431A41400E2\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 30 May 2014 21:20:45 +1000 (EST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752074AbaE3LUm (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tFri, 30 May 2014 07:20:42 -0400", "from hqemgate14.nvidia.com ([216.228.121.143]:12083 \"EHLO\n\thqemgate14.nvidia.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751745AbaE3LUl (ORCPT\n\t<rfc822;linux-tegra@vger.kernel.org>);\n\tFri, 30 May 2014 07:20:41 -0400", "from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by\n\thqemgate14.nvidia.com\n\tid <B5388699b0000>; Fri, 30 May 2014 04:20:59 -0700", "from hqemhub01.nvidia.com ([172.20.12.94])\n\tby hqnvupgp08.nvidia.com (PGP Universal service);\n\tFri, 30 May 2014 04:15:37 -0700", "from deemhub02.nvidia.com (10.21.69.138) by hqemhub01.nvidia.com\n\t(172.20.150.30) with Microsoft SMTP Server (TLS) id 8.3.342.0;\n\tFri, 30 May 2014 04:20:40 -0700", "from oreo.nvidia.com (10.21.65.27) by deemhub02.nvidia.com\n\t(10.21.69.138) with Microsoft SMTP Server (TLS) id 8.3.342.0;\n\tFri, 30 May 2014 13:20:38 +0200" ], "X-PGP-Universal": "processed;\n\tby hqnvupgp08.nvidia.com on Fri, 30 May 2014 04:15:37 -0700", "From": "Hiroshi Doyu <hdoyu@nvidia.com>", "To": "<linux-tegra@vger.kernel.org>", "Subject": "[PATCHv8 01/21] of: introduce\n\tof_property_for_each_phandle_with_args()", "Date": "Fri, 30 May 2014 14:20:14 +0300", "Message-ID": "<1401448834-32659-2-git-send-email-hdoyu@nvidia.com>", "X-Mailer": "git-send-email 2.0.0.rc1.15.g7e76a2f", "In-Reply-To": "<1401448834-32659-1-git-send-email-hdoyu@nvidia.com>", "References": "<1401448834-32659-1-git-send-email-hdoyu@nvidia.com>", "X-NVConfidentiality": "public", "MIME-Version": "1.0", "Content-Type": "text/plain", "Sender": "linux-tegra-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-tegra.vger.kernel.org>", "X-Mailing-List": "linux-tegra@vger.kernel.org" }, "content": "Iterating over a property containing a list of phandles with arguments\nis a common operation for device drivers. This patch adds a new\nof_property_for_each_phandle_with_args() macro to make the iteration\nsimpler.\n\nSigned-off-by: Hiroshi Doyu <hdoyu@nvidia.com>\nCc: Rob Herring <robherring2@gmail.com>\nCc: Grant Likely <grant.likely@linaro.org>\nReviewed-by: Stephen Warren <swarren@nvidia.com>\n---\n drivers/of/base.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++\n include/linux/of.h | 36 ++++++++++++++++++++++++++++++++++++\n 2 files changed, 86 insertions(+)", "diff": "diff --git a/drivers/of/base.c b/drivers/of/base.c\nindex 03e7fc6c93e8..9c6834794fd5 100644\n--- a/drivers/of/base.c\n+++ b/drivers/of/base.c\n@@ -1492,6 +1492,56 @@ void of_print_phandle_args(const char *msg, const struct of_phandle_args *args)\n \tprintk(\"\\n\");\n }\n \n+void of_phandle_iter_next(struct of_phandle_iter *iter)\n+{\n+\tstruct device_node *dn;\n+\tint i, count;\n+\n+\tif (!iter->cur || (iter->cur >= iter->end))\n+\t\tgoto err_out;\n+\n+\tdn = of_find_node_by_phandle(be32_to_cpup(iter->cur++));\n+\tif (!dn)\n+\t\tgoto err_out;\n+\n+\tif (iter->cells_name) {\n+\t\tif (of_property_read_u32(dn, iter->cells_name, &count))\n+\t\t\tgoto err_out;\n+\t} else {\n+\t\tcount = iter->cell_count;\n+\t}\n+\n+\titer->out_args.np = dn;\n+\titer->out_args.args_count = count;\n+\tfor (i = 0; i < count; i++)\n+\t\titer->out_args.args[i] = be32_to_cpup(iter->cur++);\n+\n+\treturn;\n+\n+err_out:\n+\titer->cur = NULL;\n+}\n+EXPORT_SYMBOL_GPL(of_phandle_iter_next);\n+\n+void of_phandle_iter_start(struct of_phandle_iter *iter,\n+\t\t\t const struct device_node *np,\n+\t\t\t const char *list_name, const char *cells_name,\n+\t\t\t int cell_count)\n+{\n+\tsize_t bytes;\n+\n+\titer->cur = of_get_property(np, list_name, &bytes);\n+\tif (!iter->cur)\n+\t\treturn;\n+\titer->end = iter->cur;\n+\tif (bytes)\n+\t\titer->end += bytes / sizeof(*iter->cur);\n+\titer->cells_name = cells_name;\n+\titer->cell_count = cell_count;\n+\tof_phandle_iter_next(iter);\n+}\n+EXPORT_SYMBOL_GPL(of_phandle_iter_start);\n+\n static int __of_parse_phandle_with_args(const struct device_node *np,\n \t\t\t\t\tconst char *list_name,\n \t\t\t\t\tconst char *cells_name,\ndiff --git a/include/linux/of.h b/include/linux/of.h\nindex fa362867b453..f925f16ef1a8 100644\n--- a/include/linux/of.h\n+++ b/include/linux/of.h\n@@ -74,6 +74,18 @@ struct of_phandle_args {\n \tuint32_t args[MAX_PHANDLE_ARGS];\n };\n \n+/*\n+ * keep the state at iterating a list of phandles with variable number\n+ * of args\n+ */\n+struct of_phandle_iter {\n+\tconst __be32 *cur; /* current phandle */\n+\tconst __be32 *end; /* end of the last phandle */\n+\tconst char *cells_name;\n+\tint cell_count;\n+\tstruct of_phandle_args out_args;\n+};\n+\n extern int of_node_add(struct device_node *node);\n \n /* initialize a node */\n@@ -303,6 +315,12 @@ extern int of_parse_phandle_with_fixed_args(const struct device_node *np,\n extern int of_count_phandle_with_args(const struct device_node *np,\n \tconst char *list_name, const char *cells_name);\n \n+extern void of_phandle_iter_start(struct of_phandle_iter *iter,\n+\t\t\t\t const struct device_node *np,\n+\t\t\t\t const char *list_name,\n+\t\t\t\t const char *cells_name, int cell_count);\n+extern void of_phandle_iter_next(struct of_phandle_iter *iter);\n+\n extern void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align));\n extern int of_alias_get_id(struct device_node *np, const char *stem);\n \n@@ -554,6 +572,18 @@ static inline int of_count_phandle_with_args(struct device_node *np,\n \treturn -ENOSYS;\n }\n \n+static inline void of_phandle_iter_start(struct of_phandle_iter *iter,\n+\t\t\t\t\t const struct device_node *np,\n+\t\t\t\t\t const char *list_name,\n+\t\t\t\t\t const char *cells_name,\n+\t\t\t\t\t int cell_count);\n+{\n+}\n+\n+static inline void of_phandle_iter_next(struct of_phandle_iter *iter)\n+{\n+}\n+\n static inline int of_alias_get_id(struct device_node *np, const char *stem)\n {\n \treturn -ENOSYS;\n@@ -742,6 +772,12 @@ static inline int of_property_read_u32(const struct device_node *np,\n \tfor (dn = of_find_node_with_property(NULL, prop_name); dn; \\\n \t dn = of_find_node_with_property(dn, prop_name))\n \n+#define of_property_for_each_phandle_with_args(iter, np, list_name,\t\\\n+\t\t\t\t\t cells_name, cell_count)\t\\\n+\tfor (of_phandle_iter_start(&iter, np, list_name,\t\t\\\n+\t\t\t\t cells_name, cell_count);\t\t\\\n+\t iter.cur; of_phandle_iter_next(&iter))\n+\n static inline int of_get_child_count(const struct device_node *np)\n {\n \tstruct device_node *child;\n", "prefixes": [ "PATCHv8", "01/21" ] }