lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Mon, 06 Feb 2017 11:32:47 +0100 From: Philipp Zabel <p.zabel@...gutronix.de> To: Rob Herring <robh@...nel.org> Cc: David Airlie <airlied@...ux.ie>, Daniel Vetter <daniel.vetter@...el.com>, Sean Paul <seanpaul@...omium.org>, dri-devel@...ts.freedesktop.org, devicetree@...r.kernel.org, linux-kernel@...r.kernel.org, Frank Rowand <frowand.list@...il.com>, Boris Brezillon <boris.brezillon@...e-electrons.com>, Archit Taneja <architt@...eaurora.org>, Jingoo Han <jingoohan1@...il.com>, Inki Dae <inki.dae@...sung.com>, Joonyoung Shim <jy0922.shim@...sung.com>, Seung-Woo Kim <sw0312.kim@...sung.com>, Kyungmin Park <kyungmin.park@...sung.com>, Kukjin Kim <kgene@...nel.org>, Krzysztof Kozlowski <krzk@...nel.org>, Javier Martinez Canillas <javier@....samsung.com>, Stefan Agner <stefan@...er.ch>, Alison Wang <alison.wang@...escale.com>, Xinliang Liu <z.liuxinliang@...ilicon.com>, Rongrong Zou <zourongrong@...il.com>, Xinwei Kong <kong.kongxinwei@...ilicon.com>, Chen Feng <puck.chen@...ilicon.com>, CK Hu <ck.hu@...iatek.com>, Matthias Brugger <matthias.bgg@...il.com>, Marek Vasut <marex@...x.de>, Mark Yao <mark.yao@...k-chips.com>, Heiko Stuebner <heiko@...ech.de>, Maxime Ripard <maxime.ripard@...e-electrons.com>, Chen-Yu Tsai <wens@...e.org>, Liviu Dudau <liviu.dudau@....com>, Mali DP Maintainers <malidp@...s.arm.com>, Neil Armstrong <narmstrong@...libre.com>, Carlo Caione <carlo@...one.org>, Kevin Hilman <khilman@...libre.com>, Rob Clark <robdclark@...il.com>, Jyri Sarha <jsarha@...com>, Tomi Valkeinen <tomi.valkeinen@...com>, Eric Anholt <eric@...olt.net>, Russell King <rmk+kernel@...linux.org.uk> Subject: Re: [PATCH 1/5] of: introduce of_graph_get_remote_node Hi Rob, thanks for this clean-up series! I was not aware how far the duplication has spread over time. On Fri, 2017-02-03 at 21:36 -0600, Rob Herring wrote: > The OF graph API leaves too much of the graph walking to clients when > in many cases the driver doesn't care about accessing the port or > endpoint nodes. The drivers typically just want the device connected via > a particular graph connection. of_graph_get_remote_node provides this > functionality. > > Signed-off-by: Rob Herring <robh@...nel.org> > --- > drivers/of/base.c | 28 ++++++++++++++++++++++++++++ > include/linux/of_graph.h | 8 ++++++++ > 2 files changed, 36 insertions(+) > > diff --git a/drivers/of/base.c b/drivers/of/base.c > index d4bea3c797d6..ea18ab16b92c 100644 > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -2469,3 +2469,31 @@ struct device_node *of_graph_get_remote_port(const struct device_node *node) > return of_get_next_parent(np); > } > EXPORT_SYMBOL(of_graph_get_remote_port); > + > +struct device_node *of_graph_get_remote_node(const struct device_node *node, > + int port, int endpoint) I think this should have a documentation comment, similar to the of_graph_get_endpoint_by_regs one, as it is not really clear from the function name that the returned device node is the parent (or grandparent) device node containing the remote port to the specified node & port & endpoint. Also it might be interesting to the user that -1 is a wildcard value for port / endpoint. > +{ > + struct device_node *endpoint_node, *remote; > + > + endpoint_node = of_graph_get_endpoint_by_regs(node, port, endpoint); > + if (!endpoint_node) { > + pr_debug("no valid endpoint (%d, %d) for node %s\n", > + port, endpoint, node->full_name); > + return NULL; > + } > + > + remote = of_graph_get_remote_port_parent(endpoint_node); > + of_node_put(endpoint); Vladimir pointed this out already. With that fixed and the missing doc comment added, Acked-by: Philipp Zabel <p.zabel@...gutronix.de> > + if (!remote) { > + pr_debug("no valid remote node\n"); > + return NULL; > + } > + > + if (!of_device_is_available(remote)) { > + pr_debug("not available for remote node\n"); > + return NULL; > + } > + > + return remote; > +} > +EXPORT_SYMBOL(of_graph_get_remote_node); > diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h > index bb3a5a2cd570..7b71d3e09209 100644 > --- a/include/linux/of_graph.h > +++ b/include/linux/of_graph.h > @@ -51,6 +51,8 @@ struct device_node *of_graph_get_endpoint_by_regs( > struct device_node *of_graph_get_remote_port_parent( > const struct device_node *node); > struct device_node *of_graph_get_remote_port(const struct device_node *node); > +struct device_node *of_graph_get_remote_node(const struct device_node *node, > + int port, int endpoint); > #else > > static inline int of_graph_parse_endpoint(const struct device_node *node, > @@ -89,6 +91,12 @@ static inline struct device_node *of_graph_get_remote_port( > { > return NULL; > } > +static inline struct device_node *of_graph_get_remote_node( > + const struct device_node *node, > + int port, int endpoint) > +{ > + return NULL; > +} > > #endif /* CONFIG_OF */ regards Philipp
Powered by blists - more mailing lists