public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] net, fec_mxc: init mac address before using network commands
Date: Tue, 30 Mar 2010 07:38:33 +0200	[thread overview]
Message-ID: <4BB18E59.5000004@denx.de> (raw)

initialize mac address with the value from "ethaddr", before
doing some network commands. This is not in line with u-boot
design principle "not to initalize not used devices", and
maybe should go away, if there is a solution for passing
the mac address to arm linux kernels.

Tested on the magnesium board.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
posting this patch as a result of this discussion:

http://lists.denx.de/pipermail/u-boot/2010-March/069025.html

 drivers/net/fec_mxc.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 5af9cdb..9029490 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -749,11 +749,18 @@ static int fec_probe(bd_t *bd)

 	eth_register(edev);

-	if (fec_get_hwaddr(edev, ethaddr) == 0) {
-		printf("got MAC address from EEPROM: %pM\n", ethaddr);
-		memcpy(edev->enetaddr, ethaddr, 6);
-		fec_set_hwaddr(edev);
+	if (!eth_getenv_enetaddr("ethaddr", ethaddr)) {	
+		/* "ethaddr" is not set in the environment */
+		if (fec_get_hwaddr(edev, ethaddr) == 0) {
+			printf("got MAC address from EEPROM: %pM\n", ethaddr);
+			eth_setenv_enetaddr("ethaddr", ethaddr);
+		} else {
+			printf ("no MAC found\n");
+			return -1;
+		}
 	}
+	memcpy(edev->enetaddr, ethaddr, 6);
+	fec_set_hwaddr(edev);

 	return 0;
 }
-- 
1.6.2.5

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

             reply	other threads:[~2010-03-30  5:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-30  5:38 Heiko Schocher [this message]
2010-03-30  7:33 ` [U-Boot] net, fec_mxc: init mac address before using network commands Mike Frysinger
2010-03-30  7:49 ` Wolfgang Denk
2010-03-30  7:53 ` Detlev Zundel

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=4BB18E59.5000004@denx.de \
    --to=hs@denx.de \
    --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