From: Daniel Schultz Date: Wed, 22 May 2024 06:18:23 +0000 (-0700) Subject: board: phytec: common: Define PHYTEC_API2_DATA_LEN X-Git-Url: http://git.dujemihanovic.xyz/%22/img/sics.gif/%22/static/git-favicon.png?a=commitdiff_plain;h=38b96407f69469702b60a22aa847bf7675a1f9b7;p=u-boot.git board: phytec: common: Define PHYTEC_API2_DATA_LEN 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 Tested-by: Wadim Egorov --- diff --git a/board/phytec/common/phytec_som_detection.c b/board/phytec/common/phytec_som_detection.c index a089fe9bc9..f0e35d8d2e 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 0ad5c14ef4..1ccf36c8e7 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')