Message ID | 1394011242-16783-5-git-send-email-p.zabel@pengutronix.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi Philipp, Thank you for the patch. I've submitted a fix for the of_graph_get_next_endpoint() function, but it hasn't been applied yet due to the patch series that contained it needing more work. The patch is available at https://patchwork.linuxtv.org/patch/21946/. I can rebase it on top of this series, but I still wanted to let you know about it in case you would like to integrate it. On Wednesday 05 March 2014 10:20:38 Philipp Zabel wrote: > A 'return endpoint;' at the end of the (!prev) case allows to > reduce the indentation level of the (prev) case. > > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> > --- > drivers/of/base.c | 42 ++++++++++++++++++++++-------------------- > 1 file changed, 22 insertions(+), 20 deletions(-) > > diff --git a/drivers/of/base.c b/drivers/of/base.c > index b5e690b..a8e47d3 100644 > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -2026,32 +2026,34 @@ struct device_node *of_graph_get_next_endpoint(const > struct device_node *parent, pr_err("%s(): no endpoint nodes specified for > %s\n", > __func__, parent->full_name); > of_node_put(node); > - } else { > - port = of_get_parent(prev); > - if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n", > - __func__, prev->full_name)) > - return NULL; > > - /* Avoid dropping prev node refcount to 0. */ > - of_node_get(prev); > - endpoint = of_get_next_child(port, prev); > - if (endpoint) { > - of_node_put(port); > - return endpoint; > - } > + return endpoint; > + } > > - /* No more endpoints under this port, try the next one. */ > - do { > - port = of_get_next_child(parent, port); > - if (!port) > - return NULL; > - } while (of_node_cmp(port->name, "port")); > + port = of_get_parent(prev); > + if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n", > + __func__, prev->full_name)) > + return NULL; > > - /* Pick up the first endpoint in this port. */ > - endpoint = of_get_next_child(port, NULL); > + /* Avoid dropping prev node refcount to 0. */ > + of_node_get(prev); > + endpoint = of_get_next_child(port, prev); > + if (endpoint) { > of_node_put(port); > + return endpoint; > } > > + /* No more endpoints under this port, try the next one. */ > + do { > + port = of_get_next_child(parent, port); > + if (!port) > + return NULL; > + } while (of_node_cmp(port->name, "port")); > + > + /* Pick up the first endpoint in this port. */ > + endpoint = of_get_next_child(port, NULL); > + of_node_put(port); > + > return endpoint; > } > EXPORT_SYMBOL(of_graph_get_next_endpoint);
Hi Laurent, Am Freitag, den 07.03.2014, 01:12 +0100 schrieb Laurent Pinchart: > Hi Philipp, > > Thank you for the patch. > > I've submitted a fix for the of_graph_get_next_endpoint() function, but it > hasn't been applied yet due to the patch series that contained it needing more > work. > > The patch is available at https://patchwork.linuxtv.org/patch/21946/. I can > rebase it on top of this series, but I still wanted to let you know about it > in case you would like to integrate it. Thank you for the pointer. A pity about the timing, this will mostly revert my indentation patch. I'd be glad if you could rebase on top of the merged series. While we look at of_graph_get_next_endpoint(), could you explain the reason behind the extra reference count increase on the prev node: /* * Avoid dropping prev node refcount to 0 when getting the next * child below. */ of_node_get(prev); This unfortunately makes using the function in for_each style macros a hassle. If that part wasn't there and all users that want to keep using prev after the call were expected to increase refcount themselves, we could have a #define of_graph_for_each_endpoint(parent, endpoint) \ for (endpoint = of_graph_get_next_endpoint(parent, NULL); \ endpoint != NULL; \ endpoint = of_graph_get_next_endpoint(parent, endpoint)) regards Philipp -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, 5 Mar 2014 10:20:38 +0100, Philipp Zabel <p.zabel@pengutronix.de> wrote: > A 'return endpoint;' at the end of the (!prev) case allows to > reduce the indentation level of the (prev) case. > > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Grant Likely <grant.likely@linaro.org> > --- > drivers/of/base.c | 42 ++++++++++++++++++++++-------------------- > 1 file changed, 22 insertions(+), 20 deletions(-) > > diff --git a/drivers/of/base.c b/drivers/of/base.c > index b5e690b..a8e47d3 100644 > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -2026,32 +2026,34 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, > pr_err("%s(): no endpoint nodes specified for %s\n", > __func__, parent->full_name); > of_node_put(node); > - } else { > - port = of_get_parent(prev); > - if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n", > - __func__, prev->full_name)) > - return NULL; > > - /* Avoid dropping prev node refcount to 0. */ > - of_node_get(prev); > - endpoint = of_get_next_child(port, prev); > - if (endpoint) { > - of_node_put(port); > - return endpoint; > - } > + return endpoint; > + } > > - /* No more endpoints under this port, try the next one. */ > - do { > - port = of_get_next_child(parent, port); > - if (!port) > - return NULL; > - } while (of_node_cmp(port->name, "port")); > + port = of_get_parent(prev); > + if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n", > + __func__, prev->full_name)) > + return NULL; > > - /* Pick up the first endpoint in this port. */ > - endpoint = of_get_next_child(port, NULL); > + /* Avoid dropping prev node refcount to 0. */ > + of_node_get(prev); > + endpoint = of_get_next_child(port, prev); > + if (endpoint) { > of_node_put(port); > + return endpoint; > } > > + /* No more endpoints under this port, try the next one. */ > + do { > + port = of_get_next_child(parent, port); > + if (!port) > + return NULL; > + } while (of_node_cmp(port->name, "port")); > + > + /* Pick up the first endpoint in this port. */ > + endpoint = of_get_next_child(port, NULL); > + of_node_put(port); > + > return endpoint; > } > EXPORT_SYMBOL(of_graph_get_next_endpoint); > -- > 1.9.0.rc3 > -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Philipp, On Friday 07 March 2014 18:40:54 Philipp Zabel wrote: > Am Freitag, den 07.03.2014, 01:12 +0100 schrieb Laurent Pinchart: > > Hi Philipp, > > > > Thank you for the patch. > > > > I've submitted a fix for the of_graph_get_next_endpoint() function, but it > > hasn't been applied yet due to the patch series that contained it needing > > more work. > > > > The patch is available at https://patchwork.linuxtv.org/patch/21946/. I > > can rebase it on top of this series, but I still wanted to let you know > > about it in case you would like to integrate it. > > Thank you for the pointer. A pity about the timing, this will mostly > revert my indentation patch. I'd be glad if you could rebase on top of > the merged series. > > While we look at of_graph_get_next_endpoint(), could you explain the > reason behind the extra reference count increase on the prev node: > > /* > * Avoid dropping prev node refcount to 0 when getting the next > * child below. > */ > of_node_get(prev); > > This unfortunately makes using the function in for_each style macros a > hassle. If that part wasn't there and all users that want to keep using > prev after the call were expected to increase refcount themselves, > we could have a > > #define of_graph_for_each_endpoint(parent, endpoint) \ > for (endpoint = of_graph_get_next_endpoint(parent, NULL); \ > endpoint != NULL; \ > endpoint = of_graph_get_next_endpoint(parent, endpoint)) I don't know what the exact design decision was (Sylwester might know), but I suspect it's mostly about historical reasons. I see no reason that would prevent modifying the current behaviour to make a for-each loop easier to implement.
Hi Laurent, Am Montag, den 10.03.2014, 20:19 +0100 schrieb Laurent Pinchart: > On Friday 07 March 2014 18:40:54 Philipp Zabel wrote: > > While we look at of_graph_get_next_endpoint(), could you explain the > > reason behind the extra reference count increase on the prev node: > > > > /* > > * Avoid dropping prev node refcount to 0 when getting the next > > * child below. > > */ > > of_node_get(prev); > > > > This unfortunately makes using the function in for_each style macros a > > hassle. If that part wasn't there and all users that want to keep using > > prev after the call were expected to increase refcount themselves, > > we could have a > > > > #define of_graph_for_each_endpoint(parent, endpoint) \ > > for (endpoint = of_graph_get_next_endpoint(parent, NULL); \ > > endpoint != NULL; \ > > endpoint = of_graph_get_next_endpoint(parent, endpoint)) > > I don't know what the exact design decision was (Sylwester might know), but I > suspect it's mostly about historical reasons. I see no reason that would > prevent modifying the current behaviour to make a for-each loop easier to > implement. Thanks, I'll include a patch to change this in the next round, then. regards Philipp -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/of/base.c b/drivers/of/base.c index b5e690b..a8e47d3 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2026,32 +2026,34 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, pr_err("%s(): no endpoint nodes specified for %s\n", __func__, parent->full_name); of_node_put(node); - } else { - port = of_get_parent(prev); - if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n", - __func__, prev->full_name)) - return NULL; - /* Avoid dropping prev node refcount to 0. */ - of_node_get(prev); - endpoint = of_get_next_child(port, prev); - if (endpoint) { - of_node_put(port); - return endpoint; - } + return endpoint; + } - /* No more endpoints under this port, try the next one. */ - do { - port = of_get_next_child(parent, port); - if (!port) - return NULL; - } while (of_node_cmp(port->name, "port")); + port = of_get_parent(prev); + if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n", + __func__, prev->full_name)) + return NULL; - /* Pick up the first endpoint in this port. */ - endpoint = of_get_next_child(port, NULL); + /* Avoid dropping prev node refcount to 0. */ + of_node_get(prev); + endpoint = of_get_next_child(port, prev); + if (endpoint) { of_node_put(port); + return endpoint; } + /* No more endpoints under this port, try the next one. */ + do { + port = of_get_next_child(parent, port); + if (!port) + return NULL; + } while (of_node_cmp(port->name, "port")); + + /* Pick up the first endpoint in this port. */ + endpoint = of_get_next_child(port, NULL); + of_node_put(port); + return endpoint; } EXPORT_SYMBOL(of_graph_get_next_endpoint);
A 'return endpoint;' at the end of the (!prev) case allows to reduce the indentation level of the (prev) case. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> --- drivers/of/base.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-)