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>
This commit is contained in:
Xiang W
2024-06-11 19:19:32 +08:00
committed by Anup Patel
parent 179e00a320
commit 86bbe6c52f

View File

@@ -68,21 +68,21 @@ int fdt_serial_init(void)
for (pos = 0; pos < fdt_serial_drivers_size; pos++) { for (pos = 0; pos < fdt_serial_drivers_size; pos++) {
drv = fdt_serial_drivers[pos]; drv = fdt_serial_drivers[pos];
noff = fdt_find_match(fdt, -1, drv->match_table, &match); noff = -1;
if (noff < 0) while ((noff = fdt_find_match(fdt, noff,
continue; drv->match_table, &match)) >= 0) {
if (!fdt_node_is_enabled(fdt, noff))
continue;
if (!fdt_node_is_enabled(fdt, noff)) /* drv->init must not be NULL */
continue; if (drv->init == NULL)
return SBI_EFAIL;
/* drv->init must not be NULL */ rc = drv->init(fdt, noff, match);
if (drv->init == NULL) if (rc == SBI_ENODEV)
return SBI_EFAIL; continue;
return rc;
rc = drv->init(fdt, noff, match); }
if (rc == SBI_ENODEV)
continue;
return rc;
} }
return SBI_ENODEV; return SBI_ENODEV;