2008-06-04 17:53:25

by Sven Schnelle

[permalink] [raw]
Subject: [PATCH] macb: use random mac if stored address in EEPROM is invalid


We should use a random mac address if the EEPROM doesn't contain a valid
one. This makes life on Boards with unprogrammed EEPROM devices easier.

Signed-off-by: Sven Schnelle <[email protected]>

---
drivers/net/macb.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 92dccd4..e346302 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -80,8 +80,12 @@ static void __init macb_get_hwaddr(struct macb *bp)
addr[4] = top & 0xff;
addr[5] = (top >> 8) & 0xff;

- if (is_valid_ether_addr(addr))
+ if (is_valid_ether_addr(addr)) {
memcpy(bp->dev->dev_addr, addr, sizeof(addr));
+ } else {
+ dev_info(&bp->pdev->dev, "invalid hw address, using
random\n");
+ random_ether_addr(bp->dev->dev_addr);
+ }
}

static int macb_mdio_read(struct mii_bus *bus, int mii_id, int regnum)


2008-06-08 21:10:36

by Haavard Skinnemoen

[permalink] [raw]
Subject: Re: [PATCH] macb: use random mac if stored address in EEPROM is invalid

On Wed, 04 Jun 2008 19:44:20 +0200
Sven Schnelle <[email protected]> wrote:

> We should use a random mac address if the EEPROM doesn't contain a valid
> one. This makes life on Boards with unprogrammed EEPROM devices easier.
>
> Signed-off-by: Sven Schnelle <[email protected]>

Hmm. I don't know. How common is this on properly configured boards?

Btw, the macb driver doesn't read any EEPROM. It reads the hardware
registers of the controller because ARM for some bizarre reason insists
on the boot loader passing the MAC address through hardware registers
(despite the fact that the maintainer of the boot loader insists on
_not_ doing that.)

But if assigning a random mac address when a real mac address isn't
available is common practice in netdev-land, I guess this patch fine
with me.

Haavard