xilinx: common: Fix MAC address read from EEPROM

The upper-to-lowercase character conversion now avoids altering the
MAC address field. In the previous version, this alteration corrupted
the MAC address.

Signed-off-by: Petr Zejdl <petr.zejdl@cern.ch>
Link: https://lore.kernel.org/r/20240404114422.2905194-1-petr.zejdl@cern.ch
Signed-off-by: Michal Simek <michal.simek@amd.com>
This commit is contained in:
Petr Zejdl
2024-04-10 15:16:57 +02:00
committed by Michal Simek
parent 3a6f440dd3
commit f03f962c60
+8 -4
View File
@@ -105,10 +105,14 @@ static void xilinx_eeprom_legacy_cleanup(char *eeprom, int size)
for (i = 0; i < size; i++) {
byte = eeprom[i];
/* Remove all non printable chars but ignore MAC address */
if ((i < offsetof(struct xilinx_legacy_format, eth_mac) ||
i >= offsetof(struct xilinx_legacy_format, unused1)) &&
(byte < '!' || byte > '~')) {
/* Ignore MAC address */
if (i >= offsetof(struct xilinx_legacy_format, eth_mac) &&
i < offsetof(struct xilinx_legacy_format, unused1)) {
continue;
}
/* Remove all non printable chars */
if (byte < '!' || byte > '~') {
eeprom[i] = 0;
continue;
}