mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-08-14 19:26:58 +02:00
cmd: tlv_eeprom: handle -ENODEV error from read_eeprom function
When tlv eeprom does not exist, return error code instead of quietly making up tlv structure in memory. Signed-off-by: Josua Mayer <josua@solid-run.com> Reviewed-by: Stefan Roese <sr@denx.de> Cc: Stefan Roese <sr@denx.de> Cc: Baruch Siach <baruch@tkos.co.il> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
parent
425d963dac
commit
f6eff35b8c
@ -134,6 +134,8 @@ static int read_eeprom(int devnum, u8 *eeprom)
|
|||||||
if (ret == 0 && is_valid_tlvinfo_header(eeprom_hdr))
|
if (ret == 0 && is_valid_tlvinfo_header(eeprom_hdr))
|
||||||
ret = read_tlv_eeprom((void *)eeprom_tlv, HDR_SIZE,
|
ret = read_tlv_eeprom((void *)eeprom_tlv, HDR_SIZE,
|
||||||
be16_to_cpu(eeprom_hdr->totallen), devnum);
|
be16_to_cpu(eeprom_hdr->totallen), devnum);
|
||||||
|
else if (ret == -ENODEV)
|
||||||
|
return ret;
|
||||||
|
|
||||||
// If the contents are invalid, start over with default contents
|
// If the contents are invalid, start over with default contents
|
||||||
if (!is_valid_tlvinfo_header(eeprom_hdr) ||
|
if (!is_valid_tlvinfo_header(eeprom_hdr) ||
|
||||||
@ -432,7 +434,12 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|||||||
// If no arguments, read the EERPOM and display its contents
|
// If no arguments, read the EERPOM and display its contents
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
if (!has_been_read) {
|
if (!has_been_read) {
|
||||||
if (read_eeprom(current_dev, eeprom) == 0)
|
ret = read_eeprom(current_dev, eeprom);
|
||||||
|
if (ret) {
|
||||||
|
printf("Failed to read EEPROM data from device.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
has_been_read = 1;
|
has_been_read = 1;
|
||||||
}
|
}
|
||||||
show_eeprom(current_dev, eeprom);
|
show_eeprom(current_dev, eeprom);
|
||||||
@ -446,12 +453,15 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|||||||
// Read the EEPROM contents
|
// Read the EEPROM contents
|
||||||
if (cmd == 'r') {
|
if (cmd == 'r') {
|
||||||
has_been_read = 0;
|
has_been_read = 0;
|
||||||
if (read_eeprom(current_dev, eeprom) == 0) {
|
ret = read_eeprom(current_dev, eeprom);
|
||||||
|
if (ret) {
|
||||||
|
printf("Failed to read EEPROM data from device.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
printf("EEPROM data loaded from device to memory.\n");
|
printf("EEPROM data loaded from device to memory.\n");
|
||||||
has_been_read = 1;
|
has_been_read = 1;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Subsequent commands require that the EEPROM has already been read.
|
// Subsequent commands require that the EEPROM has already been read.
|
||||||
if (!has_been_read) {
|
if (!has_been_read) {
|
||||||
|
Loading…
Reference in New Issue
Block a user