Skip to content

Commit 75f7f0c

Browse files
Phil Elwellpopcornmix
Phil Elwell
authored andcommitted
lan78xx: Ignore DT MAC address if already valid
The patch to set the lan78xx MAC address from DT does so regardless of whether or not the interface already has a valid address. As the initialisation function is called from the reset handler when the interface is brought up, it is impossible to change the MAC address in a way that persists across the interface being brought up. Fix the problem by moving the DT reading code after the check for a valid address. See: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=209309 Signed-off-by: Phil Elwell <[email protected]>
1 parent d019158 commit 75f7f0c

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/net/usb/lan78xx.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,14 +1640,6 @@ static void lan78xx_init_mac_address(struct lan78xx_net *dev)
16401640
u32 addr_lo, addr_hi;
16411641
int ret;
16421642
u8 addr[6];
1643-
const u8 *mac_addr;
1644-
1645-
/* maybe the boot loader passed the MAC address in devicetree */
1646-
mac_addr = of_get_mac_address(dev->udev->dev.of_node);
1647-
if (mac_addr) {
1648-
ether_addr_copy(addr, mac_addr);
1649-
goto set_mac_addr;
1650-
}
16511643

16521644
ret = lan78xx_read_reg(dev, RX_ADDRL, &addr_lo);
16531645
ret = lan78xx_read_reg(dev, RX_ADDRH, &addr_hi);
@@ -1660,6 +1652,15 @@ static void lan78xx_init_mac_address(struct lan78xx_net *dev)
16601652
addr[5] = (addr_hi >> 8) & 0xFF;
16611653

16621654
if (!is_valid_ether_addr(addr)) {
1655+
const u8 *mac_addr;
1656+
1657+
/* maybe the boot loader passed the MAC address in devicetree */
1658+
mac_addr = of_get_mac_address(dev->udev->dev.of_node);
1659+
if (mac_addr) {
1660+
ether_addr_copy(addr, mac_addr);
1661+
goto set_mac_addr;
1662+
}
1663+
16631664
/* reading mac address from EEPROM or OTP */
16641665
if ((lan78xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
16651666
addr) == 0) ||

0 commit comments

Comments
 (0)