public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Daniel Schultz <d.schultz@phytec.de>
To: <u-boot@lists.denx.de>
Cc: Daniel Schultz <d.schultz@phytec.de>
Subject: [PATCH 4/5] board: phytec: common: Fix eepom is empty check
Date: Fri, 19 Apr 2024 08:55:39 -0700	[thread overview]
Message-ID: <20240419155540.2447006-5-d.schultz@phytec.de> (raw)
In-Reply-To: <20240419155540.2447006-1-d.schultz@phytec.de>

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>
---
 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


  parent reply	other threads:[~2024-04-19 16:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19 15:55 [PATCH 0/5] Update PHYTEC SOM Detection Daniel Schultz
2024-04-19 15:55 ` [PATCH 1/5] board: phytec: common: Generic "add extension" function Daniel Schultz
2024-04-23  7:30   ` Teresa Remmet
2024-04-19 15:55 ` [PATCH 2/5] board: phytec: introduce eeprom struct member 'valid' Daniel Schultz
2024-04-23  7:26   ` Teresa Remmet
2024-04-19 15:55 ` [PATCH 3/5] board: phytec: check eeprom_data validity Daniel Schultz
2024-04-23  7:27   ` Teresa Remmet
2024-04-19 15:55 ` Daniel Schultz [this message]
2024-04-23  7:26   ` [PATCH 4/5] board: phytec: common: Fix eepom is empty check Teresa Remmet
2024-04-19 15:55 ` [PATCH 5/5] board: phytec: Add SOM detection for AM6x Daniel Schultz
2024-04-29 23:04 ` [PATCH 0/5] Update PHYTEC SOM Detection Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240419155540.2447006-5-d.schultz@phytec.de \
    --to=d.schultz@phytec.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox