[PATCH 4/5] board: phytec: common: Fix eepom is empty check

Daniel Schultz d.schultz at phytec.de
Fri Apr 19 17:55:39 CEST 2024


The ptr variable is currently defined as int and sizeof
returns the size of the eeprom data struct as Byte (32 in total).

In case the eeprom is empty, the check, if the eeprom is empty,
will most likely stop after 8 iterations because it will continue
with the stack which should contain some data. Therefore, the
init function will detect an empty EEPROM as API0 and return with
the valid flag set to True.

Fixes: dc22188cdc8 ("board: phytec: Add common PHYTEC SoM detection")

Signed-off-by: Daniel Schultz <d.schultz at phytec.de>
---
 board/phytec/common/phytec_som_detection.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/board/phytec/common/phytec_som_detection.c b/board/phytec/common/phytec_som_detection.c
index 5a4cc9e8b02..78c173df20d 100644
--- a/board/phytec/common/phytec_som_detection.c
+++ b/board/phytec/common/phytec_som_detection.c
@@ -53,7 +53,7 @@ int phytec_eeprom_data_init(struct phytec_eeprom_data *data,
 {
 	int ret, i;
 	unsigned int crc;
-	int *ptr;
+	u8 *ptr;
 	const unsigned int payload_size = sizeof(struct phytec_eeprom_payload);
 
 	if (!data)
@@ -85,7 +85,7 @@ int phytec_eeprom_data_init(struct phytec_eeprom_data *data,
 		goto err;
 	}
 
-	ptr = (int *)data;
+	ptr = (u8 *)data;
 	for (i = 0; i < payload_size; ++i)
 		if (ptr[i] != 0x0)
 			break;
-- 
2.25.1



More information about the U-Boot mailing list