[PATCH] ARM: i.MX50: Amazon Kindle: Add missing compatibility checks

Sascha Hauer s.hauer at pengutronix.de
Wed May 10 23:02:07 PDT 2017


Add the checks to prevent Kindle specific code on other machines.
This also adds compatible strings for the Kindle machines as they
currently lack them.

Reported-by: Stefan Riedmüller <S.Riedmueller at phytec.de>
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/boards/kindle-mx50/board.c  | 19 +++++++++++++++++++
 arch/arm/dts/imx50-kindle-d01100.dts |  2 +-
 arch/arm/dts/imx50-kindle-d01200.dts |  2 +-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boards/kindle-mx50/board.c b/arch/arm/boards/kindle-mx50/board.c
index fa4beb7f3c..7bd4f91e0b 100644
--- a/arch/arm/boards/kindle-mx50/board.c
+++ b/arch/arm/boards/kindle-mx50/board.c
@@ -120,8 +120,17 @@ static void kindle_rev_init(void)
 	free(buf);
 }
 
+static int is_mx50_kindle(void)
+{
+	return of_machine_is_compatible("amazon,kindle-d01100") ||
+		of_machine_is_compatible("amazon,kindle-d01200");
+}
+
 static int kindle_mx50_late_init(void)
 {
+	if (!is_mx50_kindle())
+		return 0;
+
 	armlinux_set_revision(0x50000 | imx_silicon_revision());
 	/* Compatibility ATAGs for original kernel */
 	armlinux_set_atag_appender(kindle_mx50_append_atags);
@@ -134,6 +143,9 @@ late_initcall(kindle_mx50_late_init);
 
 static int kindle_mx50_mem_init(void)
 {
+	if (!is_mx50_kindle())
+		return 0;
+
 	arm_add_mem_device("ram0", MX50_CSD0_BASE_ADDR, SZ_256M);
 	return 0;
 }
@@ -142,6 +154,10 @@ mem_initcall(kindle_mx50_mem_init);
 static int kindle_mx50_devices_init(void)
 {
 	struct device_d *dev;
+
+	if (!is_mx50_kindle())
+		return 0;
+
 	/* Probe the eMMC to allow reading the board serial and revision */
 	dev = get_device_by_name("mci0");
 	if (dev)
@@ -155,6 +171,9 @@ device_initcall(kindle_mx50_devices_init);
 
 static int kindle_mx50_postcore_init(void)
 {
+	if (!is_mx50_kindle())
+		return 0;
+
 	imx50_init_lowlevel(800);
 
 	return 0;
diff --git a/arch/arm/dts/imx50-kindle-d01100.dts b/arch/arm/dts/imx50-kindle-d01100.dts
index edbc929120..23bfbb5d24 100644
--- a/arch/arm/dts/imx50-kindle-d01100.dts
+++ b/arch/arm/dts/imx50-kindle-d01100.dts
@@ -17,7 +17,7 @@
 
 / {
 	model = "Amazon Kindle D01100";
-	compatible = "fsl,imx50";
+	compatible = "amazon,kindle-d01100", "fsl,imx50";
 
 	chosen {
 		linux,stdout-path = &uart1;
diff --git a/arch/arm/dts/imx50-kindle-d01200.dts b/arch/arm/dts/imx50-kindle-d01200.dts
index 8f93c1b520..d8e5ed3283 100644
--- a/arch/arm/dts/imx50-kindle-d01200.dts
+++ b/arch/arm/dts/imx50-kindle-d01200.dts
@@ -17,7 +17,7 @@
 
 / {
 	model = "Amazon Kindle D01200";
-	compatible = "fsl,imx50";
+	compatible = "amazon,kindle-d01200", "fsl,imx50";
 
 	chosen {
 		linux,stdout-path = &uart1;
-- 
2.11.0




More information about the barebox mailing list