diff mbox series

ti: common: Remove additional i2c read for board detection

Message ID 81e11e128dca8a5715eb39d16f3736cc5c355d88.1598535825.git.michal.simek@xilinx.com
State Accepted
Commit b892b6d1e0afef8d47f256d5b3ca4687bed1bee3
Delegated to: Lokesh Vutla
Headers show
Series ti: common: Remove additional i2c read for board detection | expand

Commit Message

Michal Simek Aug. 27, 2020, 1:43 p.m. UTC
There shouldn't be a need to call additional i2c read if above failed
already. Based on comment it should be enough to try to detect legacy
boards which are mentioned in the comment.

Fixes: 2463f6728e82 ("ti: common: board_detect: Allow DM I2C without CONFIG_DM_I2C_COMPAT")
Fixes: 0bea813d0018 ("ARM: omap-common: Add standard access for board description EEPROM")
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Found based on reading the code. Untested on HW but also not explain why
additional same read should be called again.
---
 board/ti/common/board_detect.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

Comments

Lokesh Vutla Aug. 31, 2020, 2:01 p.m. UTC | #1
On 27/08/20 7:13 pm, Michal Simek wrote:
> There shouldn't be a need to call additional i2c read if above failed
> already. Based on comment it should be enough to try to detect legacy
> boards which are mentioned in the comment.
> 
> Fixes: 2463f6728e82 ("ti: common: board_detect: Allow DM I2C without CONFIG_DM_I2C_COMPAT")
> Fixes: 0bea813d0018 ("ARM: omap-common: Add standard access for board description EEPROM")
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>

Thanks for the patch. Merged into u-boot-ti.

Thanks and regards,
Lokesh
diff mbox series

Patch

diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index e09ecda4d7e6..8b3b4bc82539 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -113,18 +113,15 @@  static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
 
 	/* Corrupted data??? */
 	if (hdr_read != header) {
-		rc = dm_i2c_read(dev, 0, (uint8_t *)&hdr_read, 4);
 		/*
 		 * read the eeprom header using i2c again, but use only a
 		 * 1 byte address (some legacy boards need this..)
 		 */
-		if (rc) {
-			rc =  i2c_set_chip_offset_len(dev, 1);
-			if (rc)
-				return rc;
+		rc = i2c_set_chip_offset_len(dev, 1);
+		if (rc)
+			return rc;
 
-			rc = dm_i2c_read(dev, 0, (uint8_t *)&hdr_read, 4);
-		}
+		rc = dm_i2c_read(dev, 0, (uint8_t *)&hdr_read, 4);
 		if (rc)
 			return rc;
 	}
@@ -153,16 +150,13 @@  static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
 
 	/* Corrupted data??? */
 	if (hdr_read != header) {
-		rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read, 4);
 		/*
 		 * read the eeprom header using i2c again, but use only a
 		 * 1 byte address (some legacy boards need this..)
 		 */
 		byte = 1;
-		if (rc) {
-			rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read,
-				      4);
-		}
+		rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read,
+			      4);
 		if (rc)
 			return rc;
 	}