[U-Boot] [PATCH v4 3/3] net: add eth_setenv_enetaddr_by_index()
Michael Walle
michael at walle.cc
Thu May 10 19:32:14 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 0da5679..eec846b 100644
--- a/include/net.h
+++ b/include/net.h
@@ -119,6 +119,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 set
diff --git a/net/eth.c b/net/eth.c
index 3623825..79b81a2 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