Skip to content

Commit

Permalink
net: eth-uclass: Setup ROM source only when ROM reading passes
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
michalsimek authored and trini committed Nov 5, 2023
1 parent 6b5c8d9 commit d71e7f4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions net/eth-uclass.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d71e7f4

Please sign in to comment.