]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: eth-uclass: Setup ROM source only when ROM reading passes
authorMichal Simek <michal.simek@amd.com>
Fri, 15 Sep 2023 14:10:06 +0000 (16:10 +0200)
committerTom Rini <trini@konsulko.com>
Sun, 5 Nov 2023 21:11:38 +0000 (16:11 -0500)
There is no reason to setup ROM source if read_rom_hwaddr hook doesn't
exist or reading mac address fails. It is ending up with confusion about
mac address source.

It is nicely visible if you put mac address to DT as
local-mac-address = [ff ff ff ff ff ff];
but also save ethaddr to variables
setenv -f ethaddr 02:18:31:7e:3e:01

Before this patch U-Boot prints that source is ROM
Address in ROM is ff:ff:ff:ff:ff:ff
Address in environment is 02:18:31:7e:3e:01

After that source is DT:
Address in DT is ff:ff:ff:ff:ff:ff
Address in environment is 02:18:31:7e:3e:01

Signed-off-by: Michal Simek <michal.simek@amd.com>
net/eth-uclass.c

index 4311f3fe6e8935625d1d3002e1f2e0ac3d16e17d..565db15b5a9b5b682ca741a7ad776f24ee3f0900 100644 (file)
@@ -562,10 +562,14 @@ static int eth_post_probe(struct udevice *dev)
        /* Check if the device has a valid MAC address in device tree */
        if (!eth_dev_get_mac_address(dev, pdata->enetaddr) ||
            !is_valid_ethaddr(pdata->enetaddr)) {
-               source = "ROM";
                /* Check if the device has a MAC address in ROM */
-               if (eth_get_ops(dev)->read_rom_hwaddr)
-                       eth_get_ops(dev)->read_rom_hwaddr(dev);
+               if (eth_get_ops(dev)->read_rom_hwaddr) {
+                       int ret;
+
+                       ret = eth_get_ops(dev)->read_rom_hwaddr(dev);
+                       if (!ret)
+                               source = "ROM";
+               }
        }
 
        eth_env_get_enetaddr_by_index("eth", dev_seq(dev), env_enetaddr);