static int set_bytes(char *buf, const char *string, int *converted_accum);
static void show_tlv_devices(int current_dev);
-/* Set to 1 if we've read EEPROM into memory */
-static int has_been_read;
/* The EERPOM contents after being read into memory */
static u8 eeprom[TLV_INFO_MAX_LEN];
struct tlvinfo_header *eeprom_hdr = to_header(eeprom);
struct tlvinfo_tlv *eeprom_tlv = to_entry(&eeprom[HDR_SIZE]);
- if (has_been_read)
- return 0;
-
/* Read the header */
ret = read_tlv_eeprom((void *)eeprom_hdr, 0, HDR_SIZE, devnum);
/* If the header was successfully read, read the TLVs */
update_crc(eeprom);
}
- has_been_read = 1;
-
#ifdef DEBUG
- show_eeprom(eeprom);
+ show_eeprom(devnum, eeprom);
#endif
return ret;
char cmd;
struct tlvinfo_header *eeprom_hdr = to_header(eeprom);
static unsigned int current_dev;
+ /* Set to 1 if we've read EEPROM into memory */
+ static int has_been_read;
+ int ret;
// If no arguments, read the EERPOM and display its contents
if (argc == 1) {
- read_eeprom(current_dev, eeprom);
+ if (!has_been_read) {
+ if (read_eeprom(current_dev, eeprom) == 0)
+ has_been_read = 1;
+ }
show_eeprom(current_dev, eeprom);
return 0;
}
// Read the EEPROM contents
if (cmd == 'r') {
has_been_read = 0;
- if (!read_eeprom(current_dev, eeprom))
+ if (read_eeprom(current_dev, eeprom) == 0) {
printf("EEPROM data loaded from device to memory.\n");
+ has_been_read = 1;
+ }
return 0;
}