All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch] fdt: Use phandle to distinguish DT nodes with same name
@ 2020-11-11 14:26 Aswath Govindraju
  2020-11-16 23:53 ` Simon Glass
  0 siblings, 1 reply; 2+ messages in thread
From: Aswath Govindraju @ 2020-11-11 14:26 UTC (permalink / raw)
  To: u-boot

While assigning the sequence number to subsystem instances by reading the
aliases property, only DT nodes names are compared and not the complete
path. This causes a problem when there are two DT nodes with same name but
have different paths. 

Fix it by comparing the phandles of DT nodes after the node names match.

Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
---
 lib/fdtdec.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 2015907dee7d..9e1bfe0b519e 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -478,6 +478,11 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int offset,
 		slash = strrchr(prop, '/');
 		if (strcmp(slash + 1, find_name))
 			continue;
+
+		if (fdt_get_phandle(blob, offset) !=
+		    fdt_get_phandle(blob, fdt_path_offset(blob, prop)))
+			continue;
+
 		val = trailing_strtol(name);
 		if (val != -1) {
 			*seqp = val;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Patch] fdt: Use phandle to distinguish DT nodes with same name
  2020-11-11 14:26 [Patch] fdt: Use phandle to distinguish DT nodes with same name Aswath Govindraju
@ 2020-11-16 23:53 ` Simon Glass
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2020-11-16 23:53 UTC (permalink / raw)
  To: u-boot

Hi Aswath,

On Wed, 11 Nov 2020 at 07:26, Aswath Govindraju <a-govindraju@ti.com> wrote:
>
> While assigning the sequence number to subsystem instances by reading the
> aliases property, only DT nodes names are compared and not the complete
> path. This causes a problem when there are two DT nodes with same name but
> have different paths.
>
> Fix it by comparing the phandles of DT nodes after the node names match.
>
> Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
> ---
>  lib/fdtdec.c | 5 +++++
>  1 file changed, 5 insertions(+)

fdt_path_offset() is slow. Could we just add this for the livetree
case perhaps, thus avoiding the speed penalty?

Can you also add a case where this causes a problem?

>
> diff --git a/lib/fdtdec.c b/lib/fdtdec.c
> index 2015907dee7d..9e1bfe0b519e 100644
> --- a/lib/fdtdec.c
> +++ b/lib/fdtdec.c
> @@ -478,6 +478,11 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int offset,
>                 slash = strrchr(prop, '/');
>                 if (strcmp(slash + 1, find_name))
>                         continue;
> +
> +               if (fdt_get_phandle(blob, offset) !=
> +                   fdt_get_phandle(blob, fdt_path_offset(blob, prop)))
> +                       continue;
> +
>                 val = trailing_strtol(name);
>                 if (val != -1) {
>                         *seqp = val;
> --
> 2.17.1
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-16 23:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11 14:26 [Patch] fdt: Use phandle to distinguish DT nodes with same name Aswath Govindraju
2020-11-16 23:53 ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.