[PATCH 33/50] ARM: omap: Make multi-arch safe

Sascha Hauer s.hauer at pengutronix.de
Fri Mar 3 01:21:14 PST 2023


Make sure the initcalls do not execute on foreign SoCs.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-omap/omap_generic.c | 8 +++++++-
 arch/arm/mach-omap/xload.c        | 3 +++
 include/mach/omap/generic.h       | 6 ++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap/omap_generic.c b/arch/arm/mach-omap/omap_generic.c
index 59c1ce7666..36f2e80af2 100644
--- a/arch/arm/mach-omap/omap_generic.c
+++ b/arch/arm/mach-omap/omap_generic.c
@@ -113,6 +113,9 @@ static struct image_handler omap_barebox_handler = {
 
 static int omap_bootm_barebox(void)
 {
+	if (!cpu_is_omap())
+		return 0;
+
 	return register_image_handler(&omap_barebox_handler);
 }
 device_initcall(omap_bootm_barebox);
@@ -141,6 +144,9 @@ static int omap_env_init(void)
 	struct cdev *cdev;
 	const char *rootpath;
 
+	if (!cpu_is_omap())
+		return 0;
+
 	if (bootsource_get() != BOOTSOURCE_MMC)
 		return 0;
 
@@ -203,7 +209,7 @@ static int omap_init(void)
 	if (root) {
 		__omap_cpu_type = omap_soc_from_dt();
 		if (!__omap_cpu_type)
-			hang();
+			return 0;
 	}
 
 	if (cpu_is_omap3())
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index e61e2ce652..e632b53788 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -355,6 +355,9 @@ int omap_set_barebox_part(struct omap_barebox_part *part)
 
 static int omap_set_xload(void)
 {
+	if (!cpu_is_omap())
+		return 0;
+
 	barebox_main = omap_xload;
 
 	return 0;
diff --git a/include/mach/omap/generic.h b/include/mach/omap/generic.h
index 8b2b7a4f0c..cb54b88211 100644
--- a/include/mach/omap/generic.h
+++ b/include/mach/omap/generic.h
@@ -54,6 +54,12 @@ extern unsigned int __omap_cpu_type;
 # define cpu_is_am33xx()	(0)
 #endif
 
+#ifdef omap_cpu_type
+#define cpu_is_omap()			(omap_cpu_type > 0)
+#else
+#define cpu_is_omap()			(0)
+#endif
+
 struct omap_barebox_part {
 	unsigned int nand_offset;
 	unsigned int nand_size;
-- 
2.30.2




More information about the barebox mailing list