diff mbox series

board: siemens: iot2050: Fix M.2 detection

Message ID 31bb24cb-2d84-4524-bb25-263f8fbe16ab@siemens.com
State Accepted
Commit 33e8020fd198926a5cc35f5834d99c324f094b71
Delegated to: Tom Rini
Headers show
Series board: siemens: iot2050: Fix M.2 detection | expand

Commit Message

Jan Kiszka Oct. 17, 2023, 5:20 a.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

The "simpler" the logic, the higher the probability to not test and get
things wrong, again: The absence of a "-PG2" suffix is not sufficient to
derive that we are on PG1. There is also "IOT2050-ADVANCED-M2".

Finally fix that by exactly matching against the two PG1 device names.

While changing this, we can also drop the not really needed check for
!board_is_sr1 in board_is_m2 and call the boards by their names
("board_is_pg1").

Reported-and-tested-by: Bao Cheng Su <baocheng.su@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 board/siemens/iot2050/board.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Tom Rini Oct. 28, 2023, 1:26 p.m. UTC | #1
On Tue, Oct 17, 2023 at 07:20:14AM +0200, Jan Kiszka wrote:

> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> The "simpler" the logic, the higher the probability to not test and get
> things wrong, again: The absence of a "-PG2" suffix is not sufficient to
> derive that we are on PG1. There is also "IOT2050-ADVANCED-M2".
> 
> Finally fix that by exactly matching against the two PG1 device names.
> 
> While changing this, we can also drop the not really needed check for
> !board_is_sr1 in board_is_m2 and call the boards by their names
> ("board_is_pg1").
> 
> Reported-and-tested-by: Bao Cheng Su <baocheng.su@siemens.com>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/board/siemens/iot2050/board.c b/board/siemens/iot2050/board.c
index e35e55fb5de..0b0686e2628 100644
--- a/board/siemens/iot2050/board.c
+++ b/board/siemens/iot2050/board.c
@@ -155,19 +155,20 @@  static bool board_is_advanced(void)
 		strstr((char *)info->name, "IOT2050-ADVANCED") != NULL;
 }
 
-static bool board_is_sr1(void)
+static bool board_is_pg1(void)
 {
 	struct iot2050_info *info = IOT2050_INFO_DATA;
 
 	return info->magic == IOT2050_INFO_MAGIC &&
-		strstr((char *)info->name, "-PG2") == NULL;
+		(strcmp((char *)info->name, "IOT2050-BASIC") == 0 ||
+		 strcmp((char *)info->name, "IOT2050-ADVANCED") == 0);
 }
 
 static bool board_is_m2(void)
 {
 	struct iot2050_info *info = IOT2050_INFO_DATA;
 
-	return !board_is_sr1() && info->magic == IOT2050_INFO_MAGIC &&
+	return info->magic == IOT2050_INFO_MAGIC &&
 		strcmp((char *)info->name, "IOT2050-ADVANCED-M2") == 0;
 }
 
@@ -217,14 +218,14 @@  void set_board_info_env(void)
 	}
 
 	if (board_is_advanced()) {
-		if (board_is_sr1())
+		if (board_is_pg1())
 			fdtfile = "ti/k3-am6548-iot2050-advanced.dtb";
 		else if(board_is_m2())
 			fdtfile = "ti/k3-am6548-iot2050-advanced-m2.dtb";
 		else
 			fdtfile = "ti/k3-am6548-iot2050-advanced-pg2.dtb";
 	} else {
-		if (board_is_sr1())
+		if (board_is_pg1())
 			fdtfile = "ti/k3-am6528-iot2050-basic.dtb";
 		else
 			fdtfile = "ti/k3-am6528-iot2050-basic-pg2.dtb";