From: peter@hurleysoftware•com (Peter Hurley)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v3 2/3] of: add optional options parameter to of_find_node_by_path()
Date: Fri, 06 Mar 2015 13:11:52 -0500 [thread overview]
Message-ID: <54F9EDE8.1090902@hurleysoftware.com> (raw)
In-Reply-To: <20150306165253.GJ4278@bivouac.eciton.net>
On 03/06/2015 11:52 AM, Leif Lindholm wrote:
> Hi Peter,
>
> On Wed, Mar 04, 2015 at 10:45:02AM -0500, Peter Hurley wrote:
>> The path parsing gets lost if the string after ':' contains '/'.
>
> Doh!
Hardly.
I only noticed because I had to implement the corresponding algorithm
for earlycon and FDT, where the string scanning is obvious.
> Thanks for reporting (and sorry for slow response).
No worries :)
Rather, I'd like to thank you for implementing the options string so
that bootloader -> earlycon -> console works so seamlessly now.
Can't wait to see 3000000Mb/s console from boot.
And thanks for the quick patch. I'm still testing because, while there weren't
those failures, there were some other messages. So I just need to go back
and see if those are regressions.
>> The selftests below fail with:
>> [ 1.365528] ### dt-test ### FAIL of_selftest_find_node_by_name():99 option path test failed
>> [ 1.365610] ### dt-test ### FAIL of_selftest_find_node_by_name():115 option alias path test failed
>>
>> Regards,
>> Peter Hurley
>>
>>
>> --- >% ---
>> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
>> index 41a4a13..07ba5aa 100644
>> --- a/drivers/of/unittest.c
>> +++ b/drivers/of/unittest.c
>> @@ -94,6 +94,11 @@ static void __init of_selftest_find_node_by_name(void)
>> "option path test failed\n");
>> of_node_put(np);
>>
>> + np = of_find_node_opts_by_path("/testcase-data:test/option", &options);
>> + selftest(np && !strcmp("test/option", options),
>> + "option path test failed\n");
>> + of_node_put(np);
>> +
>> np = of_find_node_opts_by_path("/testcase-data:testoption", NULL);
>> selftest(np, "NULL option path test failed\n");
>> of_node_put(np);
>> @@ -104,6 +109,12 @@ static void __init of_selftest_find_node_by_name(void)
>> "option alias path test failed\n");
>> of_node_put(np);
>>
>> + np = of_find_node_opts_by_path("testcase-alias:test/alias/option",
>> + &options);
>> + selftest(np && !strcmp("test/alias/option", options),
>> + "option alias path test failed\n");
>> + of_node_put(np);
>> +
>> np = of_find_node_opts_by_path("testcase-alias:testaliasoption", NULL);
>> selftest(np, "NULL option alias path test failed\n");
>> of_node_put(np);
>
> Could you give the below a spin, and if it works for you, send me the
> above tests as a full patch so that I can post both as a series?
Will do as soon as I finish testing.
Regards,
Peter Hurley
> From bf4ab0b2e33902ba88809a3c4a2cdf07efd02dde Mon Sep 17 00:00:00 2001
> From: Leif Lindholm <leif.lindholm@linaro•org>
> Date: Fri, 6 Mar 2015 16:38:54 +0000
> Subject: [PATCH] of: fix handling of '/' in options for of_find_node_by_path()
>
> Ensure proper handling of paths with appended options (after ':'),
> where those options may contain a '/'.
>
> Fixes: 7914a7c5651a ("of: support passing console options with stdout-path")
> Reported-by: Peter Hurley <peter@hurleysoftware•com>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro•org>
> ---
> drivers/of/base.c | 23 +++++++++++++++--------
> 1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 0a8aeb8..8b904e5 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -714,16 +714,17 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent,
> const char *path)
> {
> struct device_node *child;
> - int len = strchrnul(path, '/') - path;
> - int term;
> + int len;
> + const char *end;
>
> + end = strchr(path, ':');
> + if (!end)
> + end = strchrnul(path, '/');
> +
> + len = end - path;
> if (!len)
> return NULL;
>
> - term = strchrnul(path, ':') - path;
> - if (term < len)
> - len = term;
> -
> __for_each_child_of_node(parent, child) {
> const char *name = strrchr(child->full_name, '/');
> if (WARN(!name, "malformed device_node %s\n", child->full_name))
> @@ -768,8 +769,12 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt
>
> /* The path could begin with an alias */
> if (*path != '/') {
> - char *p = strchrnul(path, '/');
> - int len = separator ? separator - path : p - path;
> + int len;
> + const char *p = separator;
> +
> + if (!p)
> + p = strchrnul(path, '/');
> + len = p - path;
>
> /* of_aliases must not be NULL */
> if (!of_aliases)
> @@ -794,6 +799,8 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt
> path++; /* Increment past '/' delimiter */
> np = __of_find_node_by_path(np, path);
> path = strchrnul(path, '/');
> + if (separator && separator < path)
> + break;
> }
> raw_spin_unlock_irqrestore(&devtree_lock, flags);
> return np;
>
next prev parent reply other threads:[~2015-03-06 18:11 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-27 17:56 [PATCH v3 0/3] of: support passing console options with stdout-path Leif Lindholm
2014-11-27 17:56 ` [PATCH v3 1/3] devicetree: of: Add bindings for chosen node, stdout-path Leif Lindholm
2014-11-27 18:41 ` Mark Rutland
2014-11-28 0:22 ` Grant Likely
2014-12-03 2:24 ` Frank Rowand
2014-12-03 15:12 ` Grant Likely
2014-12-03 19:46 ` Frank Rowand
2014-12-03 21:45 ` Grant Likely
2014-12-03 23:07 ` Frank Rowand
2014-12-04 10:39 ` Grant Likely
2014-11-27 17:56 ` [PATCH v3 2/3] of: add optional options parameter to of_find_node_by_path() Leif Lindholm
2014-11-28 0:44 ` Grant Likely
2014-11-28 11:34 ` Leif Lindholm
2014-11-28 15:25 ` Grant Likely
2014-11-28 15:33 ` Grant Likely
2014-11-28 16:38 ` [PATCH v3 2/3] of: add optional options parameter to? of_find_node_by_path() Leif Lindholm
2014-11-28 23:57 ` Grant Likely
2015-03-04 15:45 ` [PATCH v3 2/3] of: add optional options parameter to of_find_node_by_path() Peter Hurley
2015-03-06 16:52 ` Leif Lindholm
2015-03-06 18:11 ` Peter Hurley [this message]
2015-03-06 18:59 ` Peter Hurley
2015-03-13 15:23 ` Rob Herring
2014-11-27 17:56 ` [PATCH v3 3/3] of: support passing console options with stdout-path Leif Lindholm
2014-11-28 15:39 ` Grant Likely
2015-02-26 11:55 ` Peter Hurley
2015-02-26 13:46 ` Andrew Lunn
2015-02-26 14:09 ` Peter Hurley
2015-02-26 14:44 ` Andrew Lunn
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=54F9EDE8.1090902@hurleysoftware.com \
--to=peter@hurleysoftware$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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