]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - net/eth.c
net: warn about spaces in device names
[karo-tx-uboot.git] / net / eth.c
index 9b503124fb637dea1accad08f890c4b5d1a25c11..de6d5c6040ddeb2fc126779fed944e54834e84c6 100644 (file)
--- a/net/eth.c
+++ b/net/eth.c
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2001-2004
+ * (C) Copyright 2001-2010
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * See file CREDITS for list of people who contributed to this
@@ -26,7 +26,6 @@
 #include <net.h>
 #include <miiphy.h>
 
-#ifdef CONFIG_CMD_NET
 void eth_parse_enetaddr(const char *addr, uchar *enetaddr)
 {
        char *end;
@@ -60,9 +59,16 @@ int eth_getenv_enetaddr_by_index(int index, uchar *enetaddr)
        sprintf(enetvar, index ? "eth%daddr" : "ethaddr", index);
        return eth_getenv_enetaddr(enetvar, enetaddr);
 }
-#endif
 
-#if defined(CONFIG_CMD_NET) && defined(CONFIG_NET_MULTI)
+#ifdef CONFIG_NET_MULTI
+
+static int eth_mac_skip(int index)
+{
+       char enetvar[15];
+       char *skip_state;
+       sprintf(enetvar, index ? "eth%dmacskip" : "ethmacskip", index);
+       return ((skip_state = getenv(enetvar)) != NULL);
+}
 
 /*
  * CPU and board-specific Ethernet initializations.  Aliased function
@@ -175,7 +181,8 @@ int eth_register(struct eth_device* dev)
                }
 #endif
        } else {
-               for (d=eth_devices; d->next!=eth_devices; d=d->next);
+               for (d=eth_devices; d->next!=eth_devices; d=d->next)
+                       ;
                d->next = dev;
        }
 
@@ -227,6 +234,9 @@ int eth_initialize(bd_t *bis)
                                puts (" [PRIME]");
                        }
 
+                       if (strchr(dev->name, ' '))
+                               puts("\nWarning: eth device name has a space!\n");
+
                        eth_getenv_enetaddr_by_index(eth_number, env_enetaddr);
 
                        if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
@@ -243,6 +253,11 @@ int eth_initialize(bd_t *bis)
 
                                memcpy(dev->enetaddr, env_enetaddr, 6);
                        }
+                       if (dev->write_hwaddr &&
+                               !eth_mac_skip(eth_number) &&
+                               is_valid_ether_addr(dev->enetaddr)) {
+                               dev->write_hwaddr(dev);
+                       }
 
                        eth_number++;
                        dev = dev->next;
@@ -492,7 +507,8 @@ char *eth_get_name (void)
 {
        return (eth_current ? eth_current->name : "unknown");
 }
-#elif defined(CONFIG_CMD_NET) && !defined(CONFIG_NET_MULTI)
+
+#else /* !CONFIG_NET_MULTI */
 
 #warning Ethernet driver is deprecated.  Please update to use CONFIG_NET_MULTI