From: David Gibson <david@gibson.dropbear.id.au>
To: Kumar Gala <galak@kernel.crashing.org>
Cc: linuxppc-dev@ozlabs.org, devicetree-discuss@ozlabs.org
Subject: Re: [PATCH v2] libfdt: Add support for using aliases in fdt_path_offset()
Date: Thu, 14 Aug 2008 23:21:42 +1000 [thread overview]
Message-ID: <20080814132142.GE32158@yookeroo.seuss> (raw)
In-Reply-To: <Pine.LNX.4.64.0808140750550.22943@blarg.am.freescale.net>
On Thu, Aug 14, 2008 at 07:51:47AM -0500, Kumar Gala wrote:
> If the path doesn't start with '/' check to see if it matches some alias
> under "/aliases" and substitute the matching alias value in the path
> and retry the lookup.
>
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> ---
>
> Fixed the bug pointed out by David Gibson and added tests.
Glad you spotted it in the end :)
[snip[]
> diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
> index ebd1260..2f3ff48 100644
> --- a/libfdt/fdt_ro.c
> +++ b/libfdt/fdt_ro.c
> @@ -139,8 +139,25 @@ int fdt_path_offset(const void *fdt, const char *path)
>
> FDT_CHECK_HEADER(fdt);
>
> - if (*path != '/')
> - return -FDT_ERR_BADPATH;
> + /* see if we have an alias */
> + if (*path != '/') {
> + const char *q;
> + int aliasoffset = fdt_path_offset(fdt, "/aliases");
> +
> + if (aliasoffset < 0)
> + return -FDT_ERR_BADPATH;
> +
> + q = strchr(path, '/');
> + if (!q)
> + q = end;
> +
> + p = fdt_getprop_namelen(fdt, aliasoffset, path, q - p, NULL);
> + if (!p)
> + return -FDT_ERR_BADPATH;
> + offset = fdt_path_offset(fdt, p);
> +
> + p = q;
> + }
Much better. It would be quite nice to have an explicit way of
retreiving the aliases too, but I can factor that out easily enough in
a later patch.
[snip]
> --- /dev/null
> +++ b/tests/aliases.dts
> @@ -0,0 +1,31 @@
> +/dts-v1/;
> +
> +/memreserve/ 0xdeadbeef00000000 0x100000;
> +/memreserve/ 123456789 010000;
I'd drop these /memreserve/s, they're not relevant to the test.
> +
> +/ {
> + compatible = "test_tree1";
> + prop-int = <0xdeadbeef>;
> + prop-str = "hello world";
Likewise the various prop-int and prop-str properties.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
prev parent reply other threads:[~2008-08-14 13:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-14 12:51 [PATCH v2] libfdt: Add support for using aliases in fdt_path_offset() Kumar Gala
2008-08-14 13:21 ` David Gibson [this message]
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=20080814132142.GE32158@yookeroo.seuss \
--to=david@gibson.dropbear.id.au \
--cc=devicetree-discuss@ozlabs.org \
--cc=galak@kernel.crashing.org \
--cc=linuxppc-dev@ozlabs.org \
/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