diff mbox series

[3/3] net: eth-uclass: Add driver source possibility

Message ID 20240314144403.491850-4-detlev.casanova@collabora.com
State Changes Requested
Delegated to: Tom Rini
Headers show
Series net: Add a CONFIG_NET_BOARD_ETHADDR | expand

Commit Message

Detlev Casanova March 14, 2024, 2:43 p.m. UTC
Some net driver, like rtl8169, can set/get the MAC address from the
registers and store it in pdata->enetaddr.

When that happens, if there is a mismatch with the environment MAC
address, u-boot will show that the MAC address source is DT. This patch
ensures that the shown source is "driver" instead to avoid confusion.

Signed-off-by: Detlev Casanova <detlev.casanova@collabora.com>
---
 net/eth-uclass.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index f194df8512a..6e521955fa5 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -565,9 +565,13 @@  static int eth_post_probe(struct udevice *dev)
 	priv->state = ETH_STATE_INIT;
 	priv->running = false;
 
+	/* Check if the driver has already set a valid MAC address */
+	if (is_valid_ethaddr(pdata->enetaddr)) {
+		source = "driver";
+	}
 	/* 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)) {
+	else if (!eth_dev_get_mac_address(dev, pdata->enetaddr) ||
+		 !is_valid_ethaddr(pdata->enetaddr)) {
 		/* Check if the device has a MAC address in ROM */
 		int ret = -1;
 		if (eth_get_ops(dev)->read_rom_hwaddr) {