]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
lan78xx: Ignore DT MAC address if already valid
authorPhil Elwell <phil@raspberrypi.org>
Wed, 28 Mar 2018 11:18:13 +0000 (12:18 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 15 Aug 2018 17:23:12 +0000 (19:23 +0200)
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 <phil@raspberrypi.org>
(cherry picked from commit 9b4a35d48f1a0740a0f6b974872d146a8ec6eb41
https://github.com/raspberrypi/linux raspi/rpi-4.15.y)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/net/usb/lan78xx.c

index d58fedeea30e8ffb6b4833e0c1918487cba32b0c..204f805783e83460f3442d35c3c9358177aa50b4 100644 (file)
@@ -1641,14 +1641,6 @@ static void lan78xx_init_mac_address(struct lan78xx_net *dev)
        u32 addr_lo, addr_hi;
        int ret;
        u8 addr[6];
-       const u8 *mac_addr;
-
-       /* maybe the boot loader passed the MAC address in devicetree */
-       mac_addr = of_get_mac_address(dev->udev->dev.of_node);
-       if (mac_addr) {
-               ether_addr_copy(addr, mac_addr);
-               goto set_mac_addr;
-       }
 
        ret = lan78xx_read_reg(dev, RX_ADDRL, &addr_lo);
        ret = lan78xx_read_reg(dev, RX_ADDRH, &addr_hi);
@@ -1661,6 +1653,15 @@ static void lan78xx_init_mac_address(struct lan78xx_net *dev)
        addr[5] = (addr_hi >> 8) & 0xFF;
 
        if (!is_valid_ether_addr(addr)) {
+               const u8 *mac_addr;
+
+               /* maybe the boot loader passed the MAC address in devicetree */
+               mac_addr = of_get_mac_address(dev->udev->dev.of_node);
+               if (mac_addr) {
+                       ether_addr_copy(addr, mac_addr);
+                       goto set_mac_addr;
+               }
+
                /* reading mac address from EEPROM or OTP */
                if ((lan78xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
                                         addr) == 0) ||