From be245acfffa297b5ed4e0c7bb473a6bd55231bf8 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Date: Sat, 6 Nov 2021 10:54:51 +0100 Subject: lib: sbi: error handling in fdt_reset_init() The initialization of a reset driver may fail for various reasons, like a PMIC based reset driver not finding the required I2C driver. The return code of the init routine may take other error values than -ENODEV. If the initialization of a reset driver fails, this should not lead to the board hanging. It is enough that the reset driver does not call sbi_system_reset_add_device() to avoid invoking the driver for a device that could not be initialized. Change the return type of fdt_reset_init() to void. Print a message if an error occurs. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by: Anup Patel <anup.patel@wdc.com> --- lib/utils/reset/fdt_reset.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/utils/reset/fdt_reset.c b/lib/utils/reset/fdt_reset.c index 7d0aba6..f4befa2 100644 --- a/lib/utils/reset/fdt_reset.c +++ b/lib/utils/reset/fdt_reset.c @@ -7,6 +7,7 @@ * Anup Patel <anup.patel@wdc.com> */ +#include <sbi/sbi_console.h> #include <sbi/sbi_error.h> #include <sbi/sbi_scratch.h> #include <sbi_utils/fdt/fdt_helper.h> @@ -28,7 +29,7 @@ static struct fdt_reset *reset_drivers[] = { &fdt_reset_thead, }; -int fdt_reset_init(void) +void fdt_reset_init(void) { int pos, noff, rc; struct fdt_reset *drv; @@ -44,12 +45,10 @@ int fdt_reset_init(void) if (drv->init) { rc = drv->init(fdt, noff, match); - if (rc == SBI_ENODEV) - continue; - if (rc) - return rc; + if (rc && rc != SBI_ENODEV) { + sbi_printf("%s: %s init failed, %d\n", + __func__, match->compatible, rc); + } } } - - return 0; } -- cgit v1.2.3