aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schultz <d.schultz@phytec.de>2024-04-19 08:55:39 -0700
committerTom Rini <trini@konsulko.com>2024-04-29 10:55:58 -0600
commite8fc2effdae535766704900f2b9cef64e90c4111 (patch)
tree756661a38bc5fe057658913dfcb5033502dd118b
parent1e5de690f305ea719ecd906b757b378b412128a3 (diff)
downloadu-boot-e8fc2effdae535766704900f2b9cef64e90c4111.zip
u-boot-e8fc2effdae535766704900f2b9cef64e90c4111.tar.gz
u-boot-e8fc2effdae535766704900f2b9cef64e90c4111.tar.bz2
board: phytec: common: Fix eepom is empty check
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@phytec.de> Reviewed-by: Teresa Remmet <t.remmet@phytec.de>
-rw-r--r--board/phytec/common/phytec_som_detection.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/board/phytec/common/phytec_som_detection.c b/board/phytec/common/phytec_som_detection.c
index 5a4cc9e..78c173d 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;