From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jan Weitzel <j.weitzel@phytec.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v3] of: find also nodes by mixture of alias and path
Date: Fri, 10 Jan 2014 10:40:22 +0100 [thread overview]
Message-ID: <20140110094021.GD6750@pengutronix.de> (raw)
In-Reply-To: <1389012343-20503-1-git-send-email-j.weitzel@phytec.de>
On Mon, Jan 06, 2014 at 01:45:43PM +0100, Jan Weitzel wrote:
> Let of_find_node_by_path_or_alias also find a node starting with an alias
> followed by a path like "i2c0/tps@24"
>
> Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
Applied, thanks
Sascha
> ---
> v2: rename ret to node
> v3: use strchr
> drivers/of/base.c | 23 ++++++++++++++++++++++-
> 1 files changed, 22 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index ea2d879..6e5e7d6 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -1378,11 +1378,32 @@ EXPORT_SYMBOL(of_find_node_by_path);
> struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
> const char *str)
> {
> + struct device_node *node;
> + const char *slash;
> + char *alias;
> + size_t len = 0;
> +
> if (*str == '/')
> return of_find_node_by_path_from(root, str);
> - else
> +
> + slash = strchr(str, '/');
> +
> + if (!slash)
> return of_find_node_by_alias(root, str);
>
> + len = slash - str + 1;
> + alias = xmalloc(len);
> + strlcpy(alias, str, len);
> +
> + node = of_find_node_by_alias(root, alias);
> +
> + if (!node)
> + goto out;
> +
> + node = of_find_node_by_path_from(node, slash);
> +out:
> + free(alias);
> + return node;
> }
> EXPORT_SYMBOL(of_find_node_by_path_or_alias);
>
> --
> 1.7.0.4
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-01-10 9:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-19 8:39 [PATCH] " Jan Weitzel
2013-12-20 13:24 ` [PATCH v2] " Jan Weitzel
2014-01-06 9:32 ` Sascha Hauer
2014-01-06 10:26 ` Jan Weitzel
2014-01-06 10:50 ` Sascha Hauer
2014-01-06 12:45 ` [PATCH v3] " Jan Weitzel
2014-01-10 9:40 ` Sascha Hauer [this message]
2014-01-06 12:46 ` [PATCH v2] " Jan Weitzel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140110094021.GD6750@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=j.weitzel@phytec.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox