From: Rob Herring <robherring2@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] pxe: get ethaddr from the current device instead of env
Date: Mon, 5 Dec 2011 18:04:33 -0600 [thread overview]
Message-ID: <1323129873-8786-1-git-send-email-robherring2@gmail.com> (raw)
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
next reply other threads:[~2011-12-06 0:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-06 0:04 Rob Herring [this message]
2011-12-06 3:50 ` [U-Boot] [PATCH] pxe: get ethaddr from the current device instead of env 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1323129873-8786-1-git-send-email-robherring2@gmail.com \
--to=robherring2@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox