diff --git a/CHANGES b/CHANGES index 792e577..59cbdd2 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,7 @@ i2c-tools CHANGES ----------------- 3.1.3 (work in progress) + eeprog: Increase delay after writes decode-dimms: Correctly check for out-of-bounds vendor ID README: Mention the current maintainer diff --git a/eepromer/24cXX.c b/eepromer/24cXX.c index c29defd..a7e5a2f 100644 --- a/eepromer/24cXX.c +++ b/eepromer/24cXX.c @@ -24,6 +24,13 @@ #include #include "24cXX.h" +/* + * EEPROMs need some time to process writes + * Ideally this value should either be settable with a command line parameter, + * or "guessed" at runtime using a retry loop. + */ +#define WRITE_DELAY_US 5000 + static int i2c_write_1b(struct eeprom *e, __u8 buf) { int r; @@ -31,7 +38,7 @@ static int i2c_write_1b(struct eeprom *e, __u8 buf) r = i2c_smbus_write_byte(e->fd, buf); if(r < 0) fprintf(stderr, "Error i2c_write_1b: %s\n", strerror(errno)); - usleep(10); + usleep(WRITE_DELAY_US); return r; } @@ -42,7 +49,7 @@ static int i2c_write_2b(struct eeprom *e, __u8 buf[2]) r = i2c_smbus_write_byte_data(e->fd, buf[0], buf[1]); if(r < 0) fprintf(stderr, "Error i2c_write_2b: %s\n", strerror(errno)); - usleep(10); + usleep(WRITE_DELAY_US); return r; } @@ -54,7 +61,7 @@ static int i2c_write_3b(struct eeprom *e, __u8 buf[3]) r = i2c_smbus_write_word_data(e->fd, buf[0], buf[2] << 8 | buf[1]); if(r < 0) fprintf(stderr, "Error i2c_write_3b: %s\n", strerror(errno)); - usleep(10); + usleep(WRITE_DELAY_US); return r; }