aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiang W <wxjstz@126.com>2024-06-11 19:19:32 +0800
committerAnup Patel <anup@brainfault.org>2024-06-13 18:39:37 +0530
commit86bbe6c52faf48a5bcca2e3073d47d501408bee0 (patch)
tree5cd5a7a77c264c6e6c52b2c00514ee9b381ed7b0
parent179e00a320df905f22cf2788880d5e1455795bf7 (diff)
downloadopensbi-86bbe6c52faf48a5bcca2e3073d47d501408bee0.zip
opensbi-86bbe6c52faf48a5bcca2e3073d47d501408bee0.tar.gz
opensbi-86bbe6c52faf48a5bcca2e3073d47d501408bee0.tar.bz2
lib: utils/serial: Fix fdt_serial to match more dt nodes
If there are multiple dt nodes, the previous code only tries to match the first one, which may lose initialization. Signed-off-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org>
-rw-r--r--lib/utils/serial/fdt_serial.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/utils/serial/fdt_serial.c b/lib/utils/serial/fdt_serial.c
index 8b6e6b9..798ac74 100644
--- a/lib/utils/serial/fdt_serial.c
+++ b/lib/utils/serial/fdt_serial.c
@@ -68,21 +68,21 @@ int fdt_serial_init(void)
for (pos = 0; pos < fdt_serial_drivers_size; pos++) {
drv = fdt_serial_drivers[pos];
- noff = fdt_find_match(fdt, -1, drv->match_table, &match);
- if (noff < 0)
- continue;
-
- if (!fdt_node_is_enabled(fdt, noff))
- continue;
+ noff = -1;
+ while ((noff = fdt_find_match(fdt, noff,
+ drv->match_table, &match)) >= 0) {
+ if (!fdt_node_is_enabled(fdt, noff))
+ continue;
- /* drv->init must not be NULL */
- if (drv->init == NULL)
- return SBI_EFAIL;
+ /* drv->init must not be NULL */
+ if (drv->init == NULL)
+ return SBI_EFAIL;
- rc = drv->init(fdt, noff, match);
- if (rc == SBI_ENODEV)
- continue;
- return rc;
+ rc = drv->init(fdt, noff, match);
+ if (rc == SBI_ENODEV)
+ continue;
+ return rc;
+ }
}
return SBI_ENODEV;