[PATCH] lib: utils: Fix fdt_mpxy_init() not returning error code

Alvin Chang alvinga at andestech.com
Wed Apr 30 02:10:07 PDT 2025


It seems that current implementation doesn't fail on fdt_mpxy_init(),
because platforms might not have any MPXY devices. In fact, if there are
no MPXY devices, fdt_driver_init_all() will return SBI_OK.

More importantly, if there is any MPXY device which fails the
initialization, OpenSBI must check the error code and stop the booting.
Thus, this commit adds the return value for fdt_mpxy_init().

Signed-off-by: Alvin Chang <alvinga at andestech.com>
---
 include/sbi_utils/mpxy/fdt_mpxy.h | 4 ++--
 lib/utils/mpxy/fdt_mpxy.c         | 8 ++------
 platform/generic/platform.c       | 3 +--
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/include/sbi_utils/mpxy/fdt_mpxy.h b/include/sbi_utils/mpxy/fdt_mpxy.h
index 2ba9d28..57e0b24 100644
--- a/include/sbi_utils/mpxy/fdt_mpxy.h
+++ b/include/sbi_utils/mpxy/fdt_mpxy.h
@@ -15,11 +15,11 @@
 
 #ifdef CONFIG_FDT_MPXY
 
-void fdt_mpxy_init(const void *fdt);
+int fdt_mpxy_init(const void *fdt);
 
 #else
 
-static inline void fdt_mpxy_init(const void *fdt) { }
+static inline int fdt_mpxy_init(const void *fdt) { return 0; }
 
 #endif
 
diff --git a/lib/utils/mpxy/fdt_mpxy.c b/lib/utils/mpxy/fdt_mpxy.c
index 6984ec7..e6e2614 100644
--- a/lib/utils/mpxy/fdt_mpxy.c
+++ b/lib/utils/mpxy/fdt_mpxy.c
@@ -12,11 +12,7 @@
 /* List of FDT MPXY drivers generated at compile time */
 extern const struct fdt_driver *const fdt_mpxy_drivers[];
 
-void fdt_mpxy_init(const void *fdt)
+int fdt_mpxy_init(const void *fdt)
 {
-	/*
-	 * Platforms might have multiple MPXY devices or might not
-	 * have any MPXY devices so don't fail.
-	 */
-	fdt_driver_init_all(fdt, fdt_mpxy_drivers);
+	return fdt_driver_init_all(fdt, fdt_mpxy_drivers);
 }
diff --git a/platform/generic/platform.c b/platform/generic/platform.c
index 2e85664..47e771a 100644
--- a/platform/generic/platform.c
+++ b/platform/generic/platform.c
@@ -324,8 +324,7 @@ int generic_mpxy_init(void)
 {
 	const void *fdt = fdt_get_address();
 
-	fdt_mpxy_init(fdt);
-	return 0;
+	return fdt_mpxy_init(fdt);
 }
 
 struct sbi_platform_operations generic_platform_ops = {
-- 
2.43.0




More information about the opensbi mailing list