mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-28 15:41:40 +00:00
xilinx: board: Update logic in xilinx_read_eeprom_legacy
When eeprom has random content printing random chars can stuck U-Boot. That's why update legacy eeprom format decoding algorithm to copy only maximum amount of chars allocated for fields. And also print them directly from desc structure. Previous algorithm was printing strings first directly from eeprom content and then copy them to desc structure. Signed-off-by: Michal Simek <michal.simek@amd.com> Link: https://lore.kernel.org/r/42065fcbb1a10581f9f4f091d64b43c01fe595c6.1674573561.git.michal.simek@amd.com
This commit is contained in:
parent
e6c62537db
commit
5563167e6e
1 changed files with 15 additions and 11 deletions
|
@ -141,22 +141,26 @@ static int xilinx_read_eeprom_legacy(struct udevice *dev, char *name,
|
||||||
|
|
||||||
xilinx_eeprom_legacy_cleanup((char *)eeprom_content, size);
|
xilinx_eeprom_legacy_cleanup((char *)eeprom_content, size);
|
||||||
|
|
||||||
printf("Xilinx I2C Legacy format at %s:\n", name);
|
/* Terminating \0 chars are the part of desc fields already */
|
||||||
printf(" Board name:\t%s\n", eeprom_content->board_name);
|
strlcpy(desc->name, eeprom_content->board_name,
|
||||||
printf(" Board rev:\t%s\n", eeprom_content->board_revision);
|
sizeof(eeprom_content->board_name) + 1);
|
||||||
printf(" Board SN:\t%s\n", eeprom_content->board_sn);
|
strlcpy(desc->revision, eeprom_content->board_revision,
|
||||||
|
sizeof(eeprom_content->board_revision) + 1);
|
||||||
|
strlcpy(desc->serial, eeprom_content->board_sn,
|
||||||
|
sizeof(eeprom_content->board_sn) + 1);
|
||||||
|
|
||||||
eth_valid = is_valid_ethaddr((const u8 *)eeprom_content->eth_mac);
|
eth_valid = is_valid_ethaddr((const u8 *)eeprom_content->eth_mac);
|
||||||
if (eth_valid)
|
|
||||||
printf(" Ethernet mac:\t%pM\n", eeprom_content->eth_mac);
|
|
||||||
|
|
||||||
/* Terminating \0 chars ensure end of string */
|
|
||||||
strcpy(desc->name, eeprom_content->board_name);
|
|
||||||
strcpy(desc->revision, eeprom_content->board_revision);
|
|
||||||
strcpy(desc->serial, eeprom_content->board_sn);
|
|
||||||
if (eth_valid)
|
if (eth_valid)
|
||||||
memcpy(desc->mac_addr[0], eeprom_content->eth_mac, ETH_ALEN);
|
memcpy(desc->mac_addr[0], eeprom_content->eth_mac, ETH_ALEN);
|
||||||
|
|
||||||
|
printf("Xilinx I2C Legacy format at %s:\n", name);
|
||||||
|
printf(" Board name:\t%s\n", desc->name);
|
||||||
|
printf(" Board rev:\t%s\n", desc->revision);
|
||||||
|
printf(" Board SN:\t%s\n", desc->serial);
|
||||||
|
|
||||||
|
if (eth_valid)
|
||||||
|
printf(" Ethernet mac:\t%pM\n", desc->mac_addr);
|
||||||
|
|
||||||
desc->header = EEPROM_HEADER_MAGIC;
|
desc->header = EEPROM_HEADER_MAGIC;
|
||||||
|
|
||||||
free(eeprom_content);
|
free(eeprom_content);
|
||||||
|
|
Loading…
Reference in a new issue