netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] DM9000: platform dependent fill_ether_addr method
@ 2008-04-18 10:02 Enrico Scholz
  2008-04-18 15:21 ` Ben Dooks
  0 siblings, 1 reply; 2+ messages in thread
From: Enrico Scholz @ 2008-04-18 10:02 UTC (permalink / raw)
  To: netdev; +Cc: Enrico Scholz

This patch adds a fill_ether_addr() method to the DM9000 platform data
which can be used to fill in the MAC address in a platform specific manner
(e.g. calculate it out of the serial number).

This method will be called only, when MAC was not set previously (e.g. by
bootloader) or can be read out of the EEPROM.

Having a valid MAC address in early bootstage is necessary e.g. for booting
from network.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
---
 drivers/net/dm9000.c   |    4 ++++
 include/linux/dm9000.h |    5 +++++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index d63cc93..e668b37 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -702,6 +702,10 @@ dm9000_probe(struct platform_device *pdev)
 			ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
 	}
 
+	if (pdata && pdata->fill_ether_addr &&
+	    !is_valid_ether_addr(ndev->dev_addr))
+		pdata->fill_ether_addr(ndev->dev_addr);
+
 	if (!is_valid_ether_addr(ndev->dev_addr))
 		dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
 			 "set using ifconfig\n", ndev->name);
diff --git a/include/linux/dm9000.h b/include/linux/dm9000.h
index a375046..f763507 100644
--- a/include/linux/dm9000.h
+++ b/include/linux/dm9000.h
@@ -32,6 +32,11 @@ struct dm9000_plat_data {
 	void	(*inblk)(void __iomem *reg, void *data, int len);
 	void	(*outblk)(void __iomem *reg, void *data, int len);
 	void	(*dumpblk)(void __iomem *reg, int len);
+
+	/* An optional method which fills in the MAC address when it could not
+	 * be read from EEPROM. The used method should/can be tagged as
+	 * __devinit. */
+	void 	(*fill_ether_addr)(unsigned char mac[6]);
 };
 
 #endif /* __DM9000_PLATFORM_DATA */
-- 
1.5.4.1


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

end of thread, other threads:[~2008-04-18 15:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-18 10:02 [PATCH] DM9000: platform dependent fill_ether_addr method Enrico Scholz
2008-04-18 15:21 ` Ben Dooks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).