* [PATCH V4 2/4] of: move documentation of of_parse_phandle_with_args
2013-08-09 16:57 [PATCH V4 1/4] gpio: clean up gpio-ranges documentation Stephen Warren
@ 2013-08-09 16:57 ` Stephen Warren
2013-08-09 16:57 ` [PATCH V4 3/4] of: introduce of_parse_phandle_with_fixed_args Stephen Warren
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Stephen Warren @ 2013-08-09 16:57 UTC (permalink / raw)
To: Linus Walleij, Rob Herring, Grant Likely
Cc: linux-gpio, devicetree, Pawel Moll, Mark Rutland, Ian Campbell,
Kumar Gala, Stephen Warren
From: Stephen Warren <swarren@nvidia.com>
Commit bd69f73 "of: Create function for counting number of phandles in
a property" renamed of_parse_phandle_with_args(), and created a wrapper
function that implemented the original name. However, the documentation
of the original function was not moved, leaving it apparently documenting
the newly renamed function.
Move the documentation so that it is adjacent to the function it
documents.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
---
Rob, Grant, Linus needs your ack on this so he can take the change through
the GPIO tree along with the others.
drivers/of/base.c | 64 +++++++++++++++++++++++++++----------------------------
1 file changed, 32 insertions(+), 32 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 5c54279..23e7073 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1104,38 +1104,6 @@ struct device_node *of_parse_phandle(const struct device_node *np,
}
EXPORT_SYMBOL(of_parse_phandle);
-/**
- * of_parse_phandle_with_args() - Find a node pointed by phandle in a list
- * @np: pointer to a device tree node containing a list
- * @list_name: property name that contains a list
- * @cells_name: property name that specifies phandles' arguments count
- * @index: index of a phandle to parse out
- * @out_args: optional pointer to output arguments structure (will be filled)
- *
- * This function is useful to parse lists of phandles and their arguments.
- * Returns 0 on success and fills out_args, on error returns appropriate
- * errno value.
- *
- * Caller is responsible to call of_node_put() on the returned out_args->node
- * pointer.
- *
- * Example:
- *
- * phandle1: node1 {
- * #list-cells = <2>;
- * }
- *
- * phandle2: node2 {
- * #list-cells = <1>;
- * }
- *
- * node3 {
- * list = <&phandle1 1 2 &phandle2 3>;
- * }
- *
- * To get a device_node of the `node2' node you may call this:
- * of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
- */
static int __of_parse_phandle_with_args(const struct device_node *np,
const char *list_name,
const char *cells_name, int index,
@@ -1238,6 +1206,38 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
return rc;
}
+/**
+ * of_parse_phandle_with_args() - Find a node pointed by phandle in a list
+ * @np: pointer to a device tree node containing a list
+ * @list_name: property name that contains a list
+ * @cells_name: property name that specifies phandles' arguments count
+ * @index: index of a phandle to parse out
+ * @out_args: optional pointer to output arguments structure (will be filled)
+ *
+ * This function is useful to parse lists of phandles and their arguments.
+ * Returns 0 on success and fills out_args, on error returns appropriate
+ * errno value.
+ *
+ * Caller is responsible to call of_node_put() on the returned out_args->node
+ * pointer.
+ *
+ * Example:
+ *
+ * phandle1: node1 {
+ * #list-cells = <2>;
+ * }
+ *
+ * phandle2: node2 {
+ * #list-cells = <1>;
+ * }
+ *
+ * node3 {
+ * list = <&phandle1 1 2 &phandle2 3>;
+ * }
+ *
+ * To get a device_node of the `node2' node you may call this:
+ * of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
+ */
int of_parse_phandle_with_args(const struct device_node *np, const char *list_name,
const char *cells_name, int index,
struct of_phandle_args *out_args)
--
1.8.1.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH V4 3/4] of: introduce of_parse_phandle_with_fixed_args
2013-08-09 16:57 [PATCH V4 1/4] gpio: clean up gpio-ranges documentation Stephen Warren
2013-08-09 16:57 ` [PATCH V4 2/4] of: move documentation of of_parse_phandle_with_args Stephen Warren
@ 2013-08-09 16:57 ` Stephen Warren
2013-08-09 16:57 ` [PATCH V4 4/4] gpio: implement gpio-ranges binding document fix Stephen Warren
2013-08-14 20:44 ` [PATCH V4 1/4] gpio: clean up gpio-ranges documentation Linus Walleij
3 siblings, 0 replies; 5+ messages in thread
From: Stephen Warren @ 2013-08-09 16:57 UTC (permalink / raw)
To: Linus Walleij, Rob Herring, Grant Likely
Cc: linux-gpio, devicetree, Pawel Moll, Mark Rutland, Ian Campbell,
Kumar Gala, Stephen Warren
From: Stephen Warren <swarren@nvidia.com>
This is identical to of_parse_phandle_with_args(), except that the
number of argument cells is fixed, rather than being parsed out of the
node referenced by each phandle.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
---
Rob, Grant, Linus needs your ack on this so he can take the change through
the GPIO tree along with the others.
v3: s/cells_count/cell_count, add missing braces per coding style
---
drivers/of/base.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++-------
include/linux/of.h | 10 +++++++++
2 files changed, 68 insertions(+), 8 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 23e7073..2c9a808 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1106,7 +1106,8 @@ EXPORT_SYMBOL(of_parse_phandle);
static int __of_parse_phandle_with_args(const struct device_node *np,
const char *list_name,
- const char *cells_name, int index,
+ const char *cells_name,
+ int cell_count, int index,
struct of_phandle_args *out_args)
{
const __be32 *list, *list_end;
@@ -1142,11 +1143,17 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
np->full_name);
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);
- goto err;
+
+ if (cells_name) {
+ 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);
+ goto err;
+ }
+ } else {
+ count = cell_count;
}
/*
@@ -1244,11 +1251,53 @@ int of_parse_phandle_with_args(const struct device_node *np, const char *list_na
{
if (index < 0)
return -EINVAL;
- return __of_parse_phandle_with_args(np, list_name, cells_name, index, out_args);
+ return __of_parse_phandle_with_args(np, list_name, cells_name, 0,
+ index, out_args);
}
EXPORT_SYMBOL(of_parse_phandle_with_args);
/**
+ * of_parse_phandle_with_fixed_args() - Find a node pointed by phandle in a list
+ * @np: pointer to a device tree node containing a list
+ * @list_name: property name that contains a list
+ * @cell_count: number of argument cells following the phandle
+ * @index: index of a phandle to parse out
+ * @out_args: optional pointer to output arguments structure (will be filled)
+ *
+ * This function is useful to parse lists of phandles and their arguments.
+ * Returns 0 on success and fills out_args, on error returns appropriate
+ * errno value.
+ *
+ * Caller is responsible to call of_node_put() on the returned out_args->node
+ * pointer.
+ *
+ * Example:
+ *
+ * phandle1: node1 {
+ * }
+ *
+ * phandle2: node2 {
+ * }
+ *
+ * node3 {
+ * list = <&phandle1 0 2 &phandle2 2 3>;
+ * }
+ *
+ * To get a device_node of the `node2' node you may call this:
+ * of_parse_phandle_with_fixed_args(node3, "list", 2, 1, &args);
+ */
+int of_parse_phandle_with_fixed_args(const struct device_node *np,
+ const char *list_name, int cell_count,
+ int index, struct of_phandle_args *out_args)
+{
+ if (index < 0)
+ return -EINVAL;
+ return __of_parse_phandle_with_args(np, list_name, NULL, cell_count,
+ index, out_args);
+}
+EXPORT_SYMBOL(of_parse_phandle_with_fixed_args);
+
+/**
* of_count_phandle_with_args() - Find the number of phandles references in a property
* @np: pointer to a device tree node containing a list
* @list_name: property name that contains a list
@@ -1266,7 +1315,8 @@ EXPORT_SYMBOL(of_parse_phandle_with_args);
int of_count_phandle_with_args(const struct device_node *np, const char *list_name,
const char *cells_name)
{
- return __of_parse_phandle_with_args(np, list_name, cells_name, -1, NULL);
+ return __of_parse_phandle_with_args(np, list_name, cells_name, 0, -1,
+ NULL);
}
EXPORT_SYMBOL(of_count_phandle_with_args);
diff --git a/include/linux/of.h b/include/linux/of.h
index 1fd08ca..0c457f5 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -280,6 +280,9 @@ extern struct device_node *of_parse_phandle(const struct device_node *np,
extern int of_parse_phandle_with_args(const struct device_node *np,
const char *list_name, const char *cells_name, int index,
struct of_phandle_args *out_args);
+extern int of_parse_phandle_with_fixed_args(const struct device_node *np,
+ const char *list_name, int cells_count, int index,
+ struct of_phandle_args *out_args);
extern int of_count_phandle_with_args(const struct device_node *np,
const char *list_name, const char *cells_name);
@@ -488,6 +491,13 @@ static inline int of_parse_phandle_with_args(struct device_node *np,
return -ENOSYS;
}
+static inline int of_parse_phandle_with_fixed_args(const struct device_node *np,
+ const char *list_name, int cells_count, int index,
+ struct of_phandle_args *out_args)
+{
+ return -ENOSYS;
+}
+
static inline int of_count_phandle_with_args(struct device_node *np,
const char *list_name,
const char *cells_name)
--
1.8.1.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH V4 1/4] gpio: clean up gpio-ranges documentation
2013-08-09 16:57 [PATCH V4 1/4] gpio: clean up gpio-ranges documentation Stephen Warren
` (2 preceding siblings ...)
2013-08-09 16:57 ` [PATCH V4 4/4] gpio: implement gpio-ranges binding document fix Stephen Warren
@ 2013-08-14 20:44 ` Linus Walleij
3 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2013-08-14 20:44 UTC (permalink / raw)
To: Stephen Warren
Cc: Rob Herring, Grant Likely, linux-gpio@vger.kernel.org,
devicetree@vger.kernel.org, Pawel Moll, Mark Rutland,
Ian Campbell, Kumar Gala, Stephen Warren
On Fri, Aug 9, 2013 at 6:57 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> From: Stephen Warren <swarren@nvidia.com>
>
> This change makes documentation of the the gpio-ranges property shorter
> and more succinct, more consistent with the style of the rest of the
> document, and not mention Linux-specifics such as the API
> pinctrl_request_gpio(); DT binding documents should be OS independant
> where at all possible. As part of this, the gpio-ranges property's format
> is described in BNF form, in order to match the rest of the document.
>
> This change also deprecates the #gpio-range-cells property. Such
> properties are useful when one node references a second node, and that
> second node dictates the format of the reference. However, that is not
> the case here; the definition of gpio-ranges itself always dictates its
> format entirely, and hence the value #gpio-range-cells must always be 3,
> and hence there is no point requiring any referenced node to include
> this property. The only remaining need for this property is to ensure
> compatibility of DTs with older SW that was written to support the
> previous version of the binding.
>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> Acked-by: Mark Rutland <mark.rutland@arm.com>
> ---
> v4:
Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread