Skip to contentSkip to conversation

xilinx: common: Fix MAC address read from EEPROM

PATCH Applied Petr Zejdl 2 participants 2 messages Apr 4, 2024 – Apr 10, 2024 Arm/Zynq architecture

lore
Share & tools
lore

Petr Zejdl

author
#0 lore raw

PATCH 1/1 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.

---
 board/xilinx/common/board.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
board/xilinx/common/board.c +8 -4
index 66edf857f1..49dc5d10cc 100644
@@ -101,10 +101,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;
 		}
Signature · 1 line
2.31.1
Applied
#1 lore raw

čt 4. 4. 2024 v 14:23 odesílatel Petr Zejdl <[email protected]> napsal:

Quoted 35 lines

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

---
 board/xilinx/common/board.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
board/xilinx/common/board.c +0 -3
index 66edf857f1..49dc5d10cc 100644
@@ -101,10 +101,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))

&&

board/xilinx/common/board.c +8 -2
-                    (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;
                }
--
Quoted 3 lines

2.31.1

Applied.
M

Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs