diff mbox series

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

Message ID 20240422135927.23582-4-detlev.casanova@collabora.com
State Changes Requested
Delegated to: Marek Vasut
Headers show
Series Introduce NET_PREFER_ROM_MAC_ADDR config | expand

Commit Message

Detlev Casanova April 22, 2024, 1:56 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 682de3ec7bd..3caf03eaef6 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -559,9 +559,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 */
 		if (eth_get_ops(dev)->read_rom_hwaddr) {
 			int ret;