From: Mike Rapoport <mike@compulab.co.il>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] Add ability to take MAC address from the environment to DM9000 driver
Date: Sun, 12 Aug 2007 08:48:27 +0300 [thread overview]
Message-ID: <46BE9F2B.5000707@compulab.co.il> (raw)
In-Reply-To: <20070809211017.7FEBF353428@atlas.denx.de>
Wolfgang Denk wrote:
> In message <20070809210451.E4756353428@atlas.denx.de> you wrote:
>> In message <46B88FDD.4090708@compulab.co.il> you wrote:
>>> I've just cloned the mainline HEAD, and created the patch from there.
>>> This time the patch attached to avoid Thunderbird intervention.
>> Applied, thanks.
>
> Oops. There was later discussion on this, and probably a better patch
> coming?
Following the comments of the discussion, below is the updated patch.
> Undone. Sorry for the confusion.
>
> Best regards,
>
> Wolfgang Denk
>
Signed-off-by: Mike Rapoport <mike@compulab.co.il>
---
drivers/dm9000x.c | 15 +++++++++++++++
include/net.h | 23 +++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/drivers/dm9000x.c b/drivers/dm9000x.c
index 6877076..78acb09 100644
--- a/drivers/dm9000x.c
+++ b/drivers/dm9000x.c
@@ -302,6 +302,21 @@ eth_init(bd_t * bd)
/* Set Node address */
for (i = 0; i < 6; i++)
((u16 *) bd->bi_enetaddr)[i] = read_srom_word(i);
+
+ if (!is_zero_ether_addr(bd->bi_enetaddr) &&
+ !is_mutlicast_ether_addr(bd->bi_enetaddr)) {
+ /* try reading from environment */
+ u8 i;
+ char *s, *e;
+ s = getenv ("ethaddr");
+ for (i = 0; i < 6; ++i) {
+ bd->bi_enetaddr[i] = s ?
+ simple_strtoul (s, &e, 16) : 0;
+ if (s)
+ s = (*e) ? e + 1 : e;
+ }
+ }
+
printf("MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", bd->bi_enetaddr[0],
bd->bi_enetaddr[1], bd->bi_enetaddr[2], bd->bi_enetaddr[3],
bd->bi_enetaddr[4], bd->bi_enetaddr[5]);
diff --git a/include/net.h b/include/net.h
index 9671948..aa58e33 100644
--- a/include/net.h
+++ b/include/net.h
@@ -435,6 +435,29 @@ static inline void NetCopyLong(ulong *to, ulong *from)
memcpy((void*)to, (void*)from, sizeof(ulong));
}
+/**
+ * is_zero_ether_addr - Determine if give Ethernet address is all zeros.
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Return true if the address is all zeroes.
+ */
+static inline int is_zero_ether_addr(const u8 *addr)
+{
+ return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]);
+}
+
+/**
+ * is_multicast_ether_addr - Determine if the Ethernet address is a multicast.
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Return true if the address is a multicast address.
+ * By definition the broadcast address is also a multicast address.
+ */
+static inline int is_multicast_ether_addr(const u8 *addr)
+{
+ return (0x01 & addr[0]);
+}
+
/* Convert an IP address to a string */
extern void ip_to_string (IPaddr_t x, char *s);
--
next prev parent reply other threads:[~2007-08-12 5:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-07 10:32 [U-Boot-Users] [PATCH] Add ability to take MAC address from the environment to DM9000 driver Mike Rapoport
2007-08-07 14:56 ` Wolfgang Denk
2007-08-07 15:29 ` Mike Rapoport
2007-08-09 21:04 ` Wolfgang Denk
2007-08-09 21:10 ` Wolfgang Denk
2007-08-12 5:48 ` Mike Rapoport [this message]
2007-08-13 14:32 ` Ben Warren
2007-08-07 14:57 ` Wolfgang Denk
2007-08-07 16:07 ` Ben Warren
2007-08-08 5:35 ` Mike Rapoport
2007-08-08 6:48 ` Wolfgang Denk
2007-08-08 7:10 ` Mike Rapoport
2007-08-08 15:41 ` Ben Warren
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=46BE9F2B.5000707@compulab.co.il \
--to=mike@compulab.co.il \
--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 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.