All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] pxe: get ethaddr from the current device instead of env
@ 2011-12-06  0:04 Rob Herring
  2011-12-06  3:50 ` Mike Frysinger
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Rob Herring @ 2011-12-06  0:04 UTC (permalink / raw)
  To: u-boot

From: Rob Herring <rob.herring@calxeda.com>

The env variable "ethaddr" may not be set, so get the address from the
eth_device struct instead. This also enables pxe for secondary ethernet
devices.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 common/cmd_pxe.c |   31 ++++++++++++-------------------
 1 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
index 3efd700..f14ef89 100644
--- a/common/cmd_pxe.c
+++ b/common/cmd_pxe.c
@@ -56,38 +56,31 @@ static char *from_env(char *envvar)
  */
 static int format_mac_pxe(char *outbuf, size_t outbuf_len)
 {
-	size_t ethaddr_len;
-	char *p, *ethaddr;
-
-	ethaddr = from_env("ethaddr");
-
-	if (!ethaddr)
-		return -ENOENT;
-
-	ethaddr_len = strlen(ethaddr);
+	char *p;
+	struct eth_device *dev;
 
 	/*
 	 * ethaddr_len + 4 gives room for "01-", ethaddr, and a NUL byte at
 	 * the end.
 	 */
-	if (outbuf_len < ethaddr_len + 4) {
-		printf("outbuf is too small (%d < %d)\n",
-				outbuf_len, ethaddr_len + 4);
-
+	if (outbuf_len < 21) {
+		printf("outbuf is too small (%d < 21)\n", outbuf_len);
 		return -EINVAL;
 	}
 
-	strcpy(outbuf, "01-");
+	eth_set_current();
+	dev = eth_get_dev();
+	if (!dev)
+		return -ENODEV;
 
-	for (p = outbuf + 3; *ethaddr; ethaddr++, p++) {
-		if (*ethaddr == ':')
+	sprintf(outbuf, "01-%pM", dev->enetaddr);
+	for (p = outbuf + 3; *p; p++) {
+		if (*p == ':')
 			*p = '-';
 		else
-			*p = tolower(*ethaddr);
+			*p = tolower(*p);
 	}
 
-	*p = '\0';
-
 	return 1;
 }
 
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-07-11 18:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-06  0:04 [U-Boot] [PATCH] pxe: get ethaddr from the current device instead of env Rob Herring
2011-12-06  3:50 ` Mike Frysinger
2011-12-06 10:41 ` Wolfgang Denk
2011-12-06 19:24 ` [U-Boot] [PATCH v2] net: allow setting env enetaddr from net device setting Rob Herring
2012-01-13 20:36   ` Wolfgang Denk
2012-02-01 23:27   ` [U-Boot] [PATCH v3] " Rob Herring
2012-03-06 13:37     ` Rob Herring
2012-03-06 19:30     ` Wolfgang Denk
2012-03-06 20:01       ` Rob Herring
2012-03-06 20:33         ` Wolfgang Denk
2012-03-07  3:03     ` [U-Boot] [PATCH v4] " Rob Herring
2012-04-04 15:06       ` Joe Hershberger
2012-04-15  4:06 ` [U-Boot] [PATCH v5] " Rob Herring
2012-07-11 18:30   ` Joe Hershberger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.