diff options
-rw-r--r-- | lib/Kconfig | 8 | ||||
-rw-r--r-- | lib/fdtdec.c | 11 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/Kconfig b/lib/Kconfig index 06eb8d07dc..a704568443 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -699,3 +699,11 @@ config LIB_ELF This supports fir 32 bit and 64 bit versions. endmenu + +config PHANDLE_CHECK_SEQ + bool "Enable phandle check while getting sequence number" + default n + help + When there are multiple device tree nodes with same name, + enable this config option to distinguish them using + phandles in fdtdec_get_alias_seq() function. diff --git a/lib/fdtdec.c b/lib/fdtdec.c index ee1bd41b08..0ab7105fef 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -500,6 +500,17 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int offset, slash = strrchr(prop, '/'); if (strcmp(slash + 1, find_name)) continue; + + /* + * Adding an extra check to distinguish DT nodes with + * same name + */ + if (IS_ENABLED(CONFIG_PHANDLE_CHECK_SEQ)) { + 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; |