Change in simtrace2[master]: I2C: return error after failed write

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Kévin Redon gerrit-no-reply at lists.osmocom.org
Tue Jul 24 08:00:01 UTC 2018


Kévin Redon has uploaded this change for review. ( https://gerrit.osmocom.org/10124


Change subject: I2C: return error after failed write
......................................................................

I2C: return error after failed write

The previous mechanism of retrying a failed write could become a
infinite blocking loop (until watchdog tiemout).

Also the array size is used to know how much data to write and verify
instead of a constant.

Change-Id: I8d2d090c5f4d1195f4c7eb29b3958a7bb05f56ec
---
M firmware/libboard/qmod/source/board_qmod.c
1 file changed, 7 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/24/10124/1

diff --git a/firmware/libboard/qmod/source/board_qmod.c b/firmware/libboard/qmod/source/board_qmod.c
index 7ae1978..47a4cb6 100644
--- a/firmware/libboard/qmod/source/board_qmod.c
+++ b/firmware/libboard/qmod/source/board_qmod.c
@@ -70,8 +70,6 @@
 #include "i2c.h"
 static int write_hub_eeprom(void)
 {
-	const unsigned int __eeprom_bin_len = 256;
-
 	int i;
 
 	/* wait */
@@ -79,16 +77,18 @@
 
 	TRACE_INFO("Writing EEPROM...\n\r");
 	/* write the EEPROM once */
-	for (i = 0; i < 256; i++) {
+	for (i = 0; i < ARRAY_SIZE(__eeprom_bin); i++) {
 		int rc = eeprom_write_byte(0x50, i, __eeprom_bin[i]);
-		/* if the result was negative, repeat that write */
-		if (rc < 0)
-			i--;
+		if (rc < 0) {
+			TRACE_ERROR("Writing EEPROM failed at byte %u: 0x%02x\n\r",
+				i, __eeprom_bin[i]);
+			return 1;
+		}
 	}
 
 	/* then pursue re-reading it again and again */
 	TRACE_INFO("Verifying EEPROM...\n\r");
-	for (i = 0; i < 256; i++) {
+	for (i = 0; i < ARRAY_SIZE(__eeprom_bin); i++) {
 		int byte = eeprom_read_byte(0x50, i);
 		TRACE_INFO("0x%02x: %02x\n\r", i, byte);
 		if (byte != __eeprom_bin[i])

-- 
To view, visit https://gerrit.osmocom.org/10124
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8d2d090c5f4d1195f4c7eb29b3958a7bb05f56ec
Gerrit-Change-Number: 10124
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon <kredon at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180724/7ab7878f/attachment.htm>


More information about the gerrit-log mailing list