Skip to contentSkip to conversation

board: ti: common: board_detect: Fix EEPROM offset read for 1-byte

PATCH In review Prasanth Babu Mantena 3 participants 5 messages Oct 30, 2023 – Jan 25, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 board: ti: common: board_detect: Fix EEPROM offset read for 1-byte

EEPROM detection logic in ti_i2c_eeprom_get() involves reading the total size and the 1-byte size with an offset 1. The commit 9f393a2d7af8 ("board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte") that attempts to fix this uses a wrong pointer to compare.

The value with one offset is read into offset_test, but the pointer used to match was still ep, resulting in an invalid comparison of the values. The intent is to identify bad 2-byte addressing eeproms that get stuck on the successive reads.

Fixes 9f393a2d7af8 (board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte)

---
v3 <--> v2:
Improved and concise commit description.

v2 <--> v1:
Fix inplace for the else condition of CONFIG_IS_ENABLED(DM_I2C). Improved commit message.

 board/ti/common/board_detect.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
board/ti/common/board_detect.c +2 -2
index 9a53884c98..869f7a47f8 100644
@@ -128,7 +128,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
 
 	rc = dm_i2c_read(dev, 0x1, &offset_test, sizeof(offset_test));
 
-	if (*((u32 *)ep) != (header & 0xFF))
+	if (offset_test != ((header >> 8) & 0xFF))
 		one_byte_addressing = false;
 
 	/* Corrupted data??? */
@@ -180,7 +180,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
 
 	rc = i2c_read(dev_addr, 0x1, byte, &offset_test, sizeof(offset_test));
 
-	if (*((u32 *)ep) != (header & 0xFF))
+	if (offset_test != ((header >> 8) & 0xFF))
 		one_byte_addressing = false;
 
 	/* Corrupted data??? */
Signature · 1 line
2.39.0
Reviewed-by on v3 1/1
#1 lore raw

Hi Prasanth,

Quoted 39 lines · Prasanth Babu Mantena

EEPROM detection logic in ti_i2c_eeprom_get() involves reading the total size and the 1-byte size with an offset 1. The commit 9f393a2d7af8 ("board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte") that attempts to fix this uses a wrong pointer to compare.

The value with one offset is read into offset_test, but the pointer used to match was still ep, resulting in an invalid comparison of the values. The intent is to identify bad 2-byte addressing eeproms that get stuck on the successive reads.

Fixes 9f393a2d7af8 (board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte)

---
v3 <--> v2:
Improved and concise commit description.

v2 <--> v1:
Fix inplace for the else condition of CONFIG_IS_ENABLED(DM_I2C). Improved commit message.

  board/ti/common/board_detect.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
board/ti/common/board_detect.c +1 -1
index 9a53884c98..869f7a47f8 100644
@@ -128,7 +128,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
 
  	rc = dm_i2c_read(dev, 0x1, &offset_test, sizeof(offset_test));
 
-	if (*((u32 *)ep) != (header & 0xFF))
+	if (offset_test != ((header >> 8) & 0xFF))
  		one_byte_addressing = false;
 
  	/* Corrupted data??? */

board/ti/common/board_detect.c static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr, · line 186

Quoted 8 lines
board/ti/common/board_detect.c +1 -1
@@ -180,7 +180,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
 
  	rc = i2c_read(dev_addr, 0x1, byte, &offset_test, sizeof(offset_test));
 
-	if (*((u32 *)ep) != (header & 0xFF))
+	if (offset_test != ((header >> 8) & 0xFF))
  		one_byte_addressing = false;
 
  	/* Corrupted data??? */
Signature · 2 lines
Thanking You
Neha Malcom Francis
#2 lore raw
Quoted 38 lines · Neha Malcom Francis

Hi Prasanth,

Quoted 35 lines · Prasanth Babu Mantena

EEPROM detection logic in ti_i2c_eeprom_get() involves reading the total size and the 1-byte size with an offset 1. The commit 9f393a2d7af8 ("board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte") that attempts to fix this uses a wrong pointer to compare.

The value with one offset is read into offset_test, but the pointer used to match was still ep, resulting in an invalid comparison of the values. The intent is to identify bad 2-byte addressing eeproms that get stuck on the successive reads.

Fixes 9f393a2d7af8 (board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte)

---
v3 <--> v2:
Improved and concise commit description.

v2 <--> v1:
Fix inplace for the else condition of CONFIG_IS_ENABLED(DM_I2C). Improved commit message.

  board/ti/common/board_detect.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
board/ti/common/board_detect.c +1 -1
index 9a53884c98..869f7a47f8 100644
@@ -128,7 +128,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
  	rc = dm_i2c_read(dev, 0x1, &offset_test, sizeof(offset_test));
-	if (*((u32 *)ep) != (header & 0xFF))
+	if (offset_test != ((header >> 8) & 0xFF))
  		one_byte_addressing = false;
  	/* Corrupted data??? */
Quoted 9 lines

board/ti/common/board_detect.c static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr, · line 183

Quoted 6 lines
board/ti/common/board_detect.c +1 -1
@@ -180,7 +180,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
  	rc = i2c_read(dev_addr, 0x1, byte, &offset_test, sizeof(offset_test));
-	if (*((u32 *)ep) != (header & 0xFF))
+	if (offset_test != ((header >> 8) & 0xFF))
  		one_byte_addressing = false;
  	/* Corrupted data??? */

Can this patch be considered for merge considering no further comments.

Regards,
Prasanth

Quoted 3 lines
Signature · 2 lines
Thanking You
Neha Malcom Francis
#3 lore raw
Quoted 49 lines · Prasanth Mantena
Quoted 38 lines · Neha Malcom Francis

Hi Prasanth,

Quoted 35 lines · Prasanth Babu Mantena

EEPROM detection logic in ti_i2c_eeprom_get() involves reading the total size and the 1-byte size with an offset 1. The commit 9f393a2d7af8 ("board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte") that attempts to fix this uses a wrong pointer to compare.

The value with one offset is read into offset_test, but the pointer used to match was still ep, resulting in an invalid comparison of the values. The intent is to identify bad 2-byte addressing eeproms that get stuck on the successive reads.

Fixes 9f393a2d7af8 (board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte)

---
v3 <--> v2:
Improved and concise commit description.

v2 <--> v1:
Fix inplace for the else condition of CONFIG_IS_ENABLED(DM_I2C). Improved commit message.

  board/ti/common/board_detect.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
board/ti/common/board_detect.c +1 -1
index 9a53884c98..869f7a47f8 100644
@@ -128,7 +128,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
  	rc = dm_i2c_read(dev, 0x1, &offset_test, sizeof(offset_test));
-	if (*((u32 *)ep) != (header & 0xFF))
+	if (offset_test != ((header >> 8) & 0xFF))
  		one_byte_addressing = false;
  	/* Corrupted data??? */
Quoted 9 lines

board/ti/common/board_detect.c static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr, · line 183

Quoted 6 lines
board/ti/common/board_detect.c +1 -1
@@ -180,7 +180,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
  	rc = i2c_read(dev_addr, 0x1, byte, &offset_test, sizeof(offset_test));
-	if (*((u32 *)ep) != (header & 0xFF))
+	if (offset_test != ((header >> 8) & 0xFF))
  		one_byte_addressing = false;
  	/* Corrupted data??? */
Quoted 1 line

Can this patch be considered for merge considering no further comments.

Given the "fun" of the various beagle families I think I was still hoping for a tested-by on some of the corner cases they have.

Signature · 1 line
Tom
#4 lore raw
In reply to Prasanth Babu Mantena
Quoted 11 lines · Prasanth Babu Mantena

EEPROM detection logic in ti_i2c_eeprom_get() involves reading the total size and the 1-byte size with an offset 1. The commit 9f393a2d7af8 ("board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte") that attempts to fix this uses a wrong pointer to compare.

The value with one offset is read into offset_test, but the pointer used to match was still ep, resulting in an invalid comparison of the values. The intent is to identify bad 2-byte addressing eeproms that get stuck on the successive reads.

Quoted 4 lines
Fixes 9f393a2d7af8 (board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte)

Applied to u-boot/master, thanks!

Signature · 1 line
Tom