lib: utils/reset: Fix fdt_reset to search for 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:34 +08:00 committed by Anup Patel
parent b5c984bd08
commit a73ff043e9
1 changed files with 14 additions and 12 deletions

View File

@ -22,22 +22,24 @@ int fdt_reset_driver_init(void *fdt, struct fdt_reset *drv)
int noff, rc = SBI_ENODEV; int noff, rc = SBI_ENODEV;
const struct fdt_match *match; const struct fdt_match *match;
noff = fdt_find_match(fdt, -1, drv->match_table, &match); noff = -1;
if (noff < 0) while ((noff = fdt_find_match(fdt, noff,
return SBI_ENODEV; drv->match_table, &match)) >= 0) {
if (!fdt_node_is_enabled(fdt, noff))
continue;
if (!fdt_node_is_enabled(fdt, noff)) if (drv->init) {
return SBI_ENODEV; rc = drv->init(fdt, noff, match);
if (rc && rc != SBI_ENODEV) {
if (drv->init) { sbi_printf("%s: %s init failed, %d\n",
rc = drv->init(fdt, noff, match); __func__, match->compatible, rc);
if (rc && rc != SBI_ENODEV) { }
sbi_printf("%s: %s init failed, %d\n",
__func__, match->compatible, rc);
} }
return rc;
} }
return rc; return SBI_ENODEV;
} }
void fdt_reset_init(void) void fdt_reset_init(void)