[U-Boot] [PATCH 3/5] net: add eth_setenv_enetaddr_by_index()
Michael Walle
michael at walle.cc
Sat Mar 31 14:38:34 CEST 2012
Signed-off-by: Michael Walle <michael at walle.cc>
---
include/net.h | 12 ++++++++++++
net/eth.c | 8 ++++++++
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/include/net.h b/include/net.h
index 1fceb99..c57c6d8 100644
--- a/include/net.h
+++ b/include/net.h
@@ -118,6 +118,18 @@ extern int eth_getenv_enetaddr_by_index(const char *base_name, int index,
uchar *enetaddr);
/*
+ * Set the hardware address for an ethernet interface .
+ * Args:
+ * base_name - base name for device (normally "eth")
+ * index - device index number (0 for first)
+ * enetaddr - returns 6 byte hardware address
+ * Returns:
+ * 0 on success, else 1.
+ */
+extern int eth_setenv_enetaddr_by_index(const char *base_name, int index,
+ const uchar *enetaddr);
+
+/*
* The u-boot policy does not allow hardcoded ethernet addresses. Under the
* following circumstances a random generated address is allowed:
* - in emergency cases, where you need a working network connection to seti
diff --git a/net/eth.c b/net/eth.c
index 4441969..ab84821 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -62,6 +62,14 @@ int eth_getenv_enetaddr_by_index(const char *base_name, int index,
return eth_getenv_enetaddr(enetvar, enetaddr);
}
+int eth_setenv_enetaddr_by_index(const char *base_name, int index,
+ const uchar *enetaddr)
+{
+ char enetvar[32];
+ sprintf(enetvar, index ? "%s%daddr" : "%saddr", base_name, index);
+ return eth_setenv_enetaddr(enetvar, enetaddr);
+}
+
static int eth_mac_skip(int index)
{
char enetvar[15];
--
1.7.2.5
More information about the U-Boot
mailing list