All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Schultz <d.schultz@phytec.de>
To: <u-boot@lists.denx.de>, <upstream@lists.phytec.de>
Cc: Daniel Schultz <d.schultz@phytec.de>
Subject: [PATCH 2/6] board: phytec: common: Define PHYTEC_API2_DATA_LEN
Date: Tue, 21 May 2024 23:18:23 -0700	[thread overview]
Message-ID: <20240522061827.601699-3-d.schultz@phytec.de> (raw)
In-Reply-To: <20240522061827.601699-1-d.schultz@phytec.de>

The EEPROM image length for API v2 is fixed to 32 bytes. No need
to use sizeof while this value won't change. This value is
also be required for API v3 to know where the API v3 header starts.

Signed-off-by: Daniel Schultz <d.schultz@phytec.de>
---
 board/phytec/common/phytec_som_detection.c | 9 ++++-----
 board/phytec/common/phytec_som_detection.h | 2 ++
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/board/phytec/common/phytec_som_detection.c b/board/phytec/common/phytec_som_detection.c
index a089fe9bc90..f0e35d8d2ec 100644
--- a/board/phytec/common/phytec_som_detection.c
+++ b/board/phytec/common/phytec_som_detection.c
@@ -78,13 +78,12 @@ int phytec_eeprom_data_init(struct phytec_eeprom_data *data,
 	int ret, i;
 	unsigned int crc;
 	u8 *ptr;
-	const unsigned int payload_size = sizeof(struct phytec_eeprom_payload);
 
 	if (!data)
 		data = &eeprom_data;
 
 	ret = phytec_eeprom_read((u8 *)data, bus_num, addr,
-				 payload_size, 0);
+				 PHYTEC_API2_DATA_LEN, 0);
 	if (ret)
 		goto err;
 
@@ -95,11 +94,11 @@ int phytec_eeprom_data_init(struct phytec_eeprom_data *data,
 	}
 
 	ptr = (u8 *)data;
-	for (i = 0; i < payload_size; ++i)
+	for (i = 0; i < PHYTEC_API2_DATA_LEN; ++i)
 		if (ptr[i] != 0x0)
 			break;
 
-	if (i == payload_size) {
+	if (i == PHYTEC_API2_DATA_LEN) {
 		pr_err("%s: EEPROM data is all zero. Erased?\n", __func__);
 		ret = -EINVAL;
 		goto err;
@@ -111,7 +110,7 @@ int phytec_eeprom_data_init(struct phytec_eeprom_data *data,
 		return 0;
 	}
 
-	crc = crc8(0, (const unsigned char *)&data->payload, payload_size);
+	crc = crc8(0, (const unsigned char *)&data->payload, PHYTEC_API2_DATA_LEN);
 	debug("%s: crc: %x\n", __func__, crc);
 
 	if (crc) {
diff --git a/board/phytec/common/phytec_som_detection.h b/board/phytec/common/phytec_som_detection.h
index 0ad5c14ef4e..1ccf36c8e7a 100644
--- a/board/phytec/common/phytec_som_detection.h
+++ b/board/phytec/common/phytec_som_detection.h
@@ -10,6 +10,8 @@
 #define PHYTEC_MAX_OPTIONS	17
 #define PHYTEC_EEPROM_INVAL	0xff
 
+#define PHYTEC_API2_DATA_LEN	32
+
 #define PHYTEC_GET_OPTION(option) \
 	(((option) > '9') ? (option) - 'A' + 10 : (option) - '0')
 
-- 
2.25.1


  parent reply	other threads:[~2024-05-22 14:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-22  6:18 [PATCH 0/6] PHYTEC SOM Detection API v3 Daniel Schultz
2024-05-22  6:18 ` [PATCH 1/6] board: phytec: common: Move eeprom read to new function Daniel Schultz
2024-05-22  6:18 ` Daniel Schultz [this message]
2024-05-22  6:18 ` [PATCH 3/6] board: phytec: common: Move API v2 init " Daniel Schultz
2024-05-22  6:18 ` [PATCH 4/6] board: phytec: common: Add API v3 Daniel Schultz
2024-05-22  6:18 ` [PATCH 5/6] board: phytec: common: k3: Set MAC Daniel Schultz
2024-05-22  8:38   ` [Upstream] " Wadim Egorov
2024-05-22  6:18 ` [PATCH 6/6] configs: phycore_am62x_a53_defconfig: Enable CONFIG_ENV_OVERWRITE Daniel Schultz
2024-05-22  8:30   ` [Upstream] " Wadim Egorov
2024-05-22  8:46     ` Daniel Schultz
2024-05-22  8:28 ` [Upstream] [PATCH 0/6] PHYTEC SOM Detection API v3 Wadim Egorov
2024-06-07 22:03 ` 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=20240522061827.601699-3-d.schultz@phytec.de \
    --to=d.schultz@phytec.de \
    --cc=u-boot@lists.denx.de \
    --cc=upstream@lists.phytec.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.