[U-Boot] [PATCH 01/20] dm: net: Support usbethaddr environment variable

Simon Glass sjg at chromium.org
Wed Jul 8 04:53:33 CEST 2015


For USB Ethernet devices we need to use the usbethaddr environment variable
(instead of ethaddr) the Ethernet hardware address. Add this to the uclass
so that it happens automatically.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 net/eth.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/eth.c b/net/eth.c
index d3ec8d6..1f5e8ee 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -519,6 +519,7 @@ static int eth_post_probe(struct udevice *dev)
 	struct eth_device_priv *priv = dev->uclass_priv;
 	struct eth_pdata *pdata = dev->platdata;
 	unsigned char env_enetaddr[6];
+	const char *prefix;
 
 	priv->state = ETH_STATE_INIT;
 
@@ -526,7 +527,11 @@ static int eth_post_probe(struct udevice *dev)
 	if (eth_get_ops(dev)->read_rom_hwaddr)
 		eth_get_ops(dev)->read_rom_hwaddr(dev);
 
-	eth_getenv_enetaddr_by_index("eth", dev->seq, env_enetaddr);
+	prefix = device_get_uclass_id(dev->parent) == UCLASS_USB_HUB ?
+			"usbeth" : "eth";
+	debug("prefix=%s, uclass=%d\n", prefix,
+	      device_get_uclass_id(dev->parent));
+	eth_getenv_enetaddr_by_index(prefix, dev->seq, env_enetaddr);
 	if (!is_zero_ethaddr(env_enetaddr)) {
 		if (!is_zero_ethaddr(pdata->enetaddr) &&
 		    memcmp(pdata->enetaddr, env_enetaddr, 6)) {
-- 
2.4.3.573.g4eafbef



More information about the U-Boot mailing list