aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@amd.com>2023-09-15 16:10:06 +0200
committerTom Rini <trini@konsulko.com>2023-11-05 16:11:38 -0500
commitd71e7f41bfc3f68e259b8070706c586d95a49157 (patch)
treeb3589a0610dc090e3a28e86b0aaaaebae529b333 /net
parent6b5c8d98e2043d321216961ba67edb757a1a16eb (diff)
downloadu-boot-d71e7f41bfc3f68e259b8070706c586d95a49157.zip
u-boot-d71e7f41bfc3f68e259b8070706c586d95a49157.tar.gz
u-boot-d71e7f41bfc3f68e259b8070706c586d95a49157.tar.bz2
net: eth-uclass: Setup ROM source only when ROM reading passes
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>
Diffstat (limited to 'net')
-rw-r--r--net/eth-uclass.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 4311f3f..565db15 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -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);