From: David Gibson <david@gibson.dropbear.id.au>
To: Ayush Singh <ayush@beagleboard.org>
Cc: d-gole@ti.com, lorforlinux@beagleboard.org,
jkridner@beagleboard.org, robertcnelson@beagleboard.org,
nenad.marinkovic@mikroe.com, Andrew Davis <afd@ti.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Robert Nelson <robertcnelson@gmail.com>,
devicetree-compiler@vger.kernel.org
Subject: Re: [PATCH 1/2] libfdt: overlay: Allow resolving phandle symbols
Date: Mon, 9 Sep 2024 15:03:30 +1000 [thread overview]
Message-ID: <Zt6Bog4Fqcb89ivO@zatzit.fritz.box> (raw)
In-Reply-To: <20240902-symbol-phandle-v1-1-683efb2a944b@beagleboard.org>
[-- Attachment #1: Type: text/plain, Size: 2002 bytes --]
On Mon, Sep 02, 2024 at 05:47:55PM +0530, Ayush Singh wrote:
> Add ability to resolve symbols pointing to phandles instead of strings.
>
> Combining this with existing fixups infrastructure allows creating
> symbols in overlays that refer to undefined phandles. This is planned to
> be used for addon board chaining [1].
I don't think this "autodetection" of whether the value is a phandle
or path is a good idea. Yes, it's probably unlikely to get it wrong
in practice, but sloppy cases like this have a habit of coming back to
bite you later on. If you want this, I think you need to design a new
way of encoding the new options.
>
> [1] https://lore.kernel.org/linux-arm-kernel/20240702164403.29067-1-afd@ti.com/
>
> Signed-off-by: Ayush Singh <ayush@beagleboard.org>
> ---
> libfdt/fdt_overlay.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/libfdt/fdt_overlay.c b/libfdt/fdt_overlay.c
> index 28b667f..10127be 100644
> --- a/libfdt/fdt_overlay.c
> +++ b/libfdt/fdt_overlay.c
> @@ -395,12 +395,16 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
> symbol_path = fdt_getprop(fdt, symbols_off, label, &prop_len);
> if (!symbol_path)
> return prop_len;
> -
> - symbol_off = fdt_path_offset(fdt, symbol_path);
> - if (symbol_off < 0)
> - return symbol_off;
> -
> - phandle = fdt_get_phandle(fdt, symbol_off);
> +
> + if (prop_len == sizeof(uint32_t) && symbol_path[0] != '/') {
> + phandle = fdt32_ld((const fdt32_t *)symbol_path);
> + } else {
> + symbol_off = fdt_path_offset(fdt, symbol_path);
> + if (symbol_off < 0)
> + return symbol_off;
> + phandle = fdt_get_phandle(fdt, symbol_off);
> + }
> +
> if (!phandle)
> return -FDT_ERR_NOTFOUND;
>
>
--
David Gibson (he or they) | 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-09-09 5:26 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 12:17 [PATCH 0/2] Add support for phandle in symbols Ayush Singh
2024-09-02 12:17 ` [PATCH 1/2] libfdt: overlay: Allow resolving phandle symbols Ayush Singh
2024-09-09 5:03 ` David Gibson [this message]
2024-09-09 7:24 ` Ayush Singh
2024-09-12 3:38 ` David Gibson
2024-09-16 9:40 ` Ayush Singh
2024-09-18 2:36 ` David Gibson
2024-09-20 16:34 ` Ayush Singh
2024-09-23 3:41 ` David Gibson
2024-09-23 8:22 ` Geert Uytterhoeven
2024-09-23 8:38 ` David Gibson
2024-09-23 9:12 ` Geert Uytterhoeven
2024-09-23 9:48 ` David Gibson
2024-11-13 9:46 ` Ayush Singh
2024-10-06 5:13 ` Ayush Singh
2024-09-24 6:41 ` Ayush Singh
2024-09-25 7:28 ` David Gibson
2024-09-25 7:58 ` Geert Uytterhoeven
2024-09-26 3:51 ` David Gibson
2024-10-03 7:35 ` Ayush Singh
2024-09-02 12:17 ` [PATCH 2/2] tests: Add test for symbol resolution Ayush Singh
2024-09-05 14:37 ` Andrew Davis
2024-09-05 14:35 ` [PATCH 0/2] Add support for phandle in symbols Andrew Davis
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=Zt6Bog4Fqcb89ivO@zatzit.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=afd@ti.com \
--cc=ayush@beagleboard.org \
--cc=d-gole@ti.com \
--cc=devicetree-compiler@vger.kernel.org \
--cc=geert@linux-m68k.org \
--cc=jkridner@beagleboard.org \
--cc=lorforlinux@beagleboard.org \
--cc=nenad.marinkovic@mikroe.com \
--cc=robertcnelson@beagleboard.org \
--cc=robertcnelson@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).