Re: [PATCH 2/2] ax88796: Add method to take MAC from platform data

Previous thread: Re: linux-next: driver-core tree build failure by Stephen Rothwell on Sunday, March 22, 2009 - 5:22 am. (2 messages)

Next thread: Re: [PATCH] e1000: fix loss of multicast packets by Dave Boutcher on Sunday, March 22, 2009 - 11:05 am. (5 messages)
From: Daniel Mack
Date: Sunday, March 22, 2009 - 9:12 am

This patch adds support to the ax88796 ethernet driver to take IRQ flags
given by the platform_device definition.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Ben Dooks <ben@simtec.co.uk>
Cc: David Miller <davem@davemloft.net>
---
 drivers/net/ax88796.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ax88796.c b/drivers/net/ax88796.c
index a4eb6c4..e7c9748 100644
--- a/drivers/net/ax88796.c
+++ b/drivers/net/ax88796.c
@@ -93,6 +93,7 @@ struct ax_device {
 
 	unsigned char		 running;
 	unsigned char		 resume_open;
+	unsigned int		 irqflags;
 
 	u32			 reg_offsets[0x20];
 };
@@ -474,7 +475,8 @@ static int ax_open(struct net_device *dev)
 
 	dev_dbg(&ax->dev->dev, "%s: open\n", dev->name);
 
-	ret = request_irq(dev->irq, ax_ei_interrupt, 0, dev->name, dev);
+	ret = request_irq(dev->irq, ax_ei_interrupt, ax->irqflags,
+			  dev->name, dev);
 	if (ret)
 		return ret;
 
@@ -829,7 +831,7 @@ static int ax_probe(struct platform_device *pdev)
 	struct ax_device  *ax;
 	struct resource   *res;
 	size_t size;
-	int ret;
+	int ret = 0;
 
 	dev = ax__alloc_ei_netdev(sizeof(struct ax_device));
 	if (dev == NULL)
@@ -850,12 +852,14 @@ static int ax_probe(struct platform_device *pdev)
 
 	/* find the platform resources */
 
-	ret  = platform_get_irq(pdev, 0);
-	if (ret < 0) {
+	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (res == NULL) {
 		dev_err(&pdev->dev, "no IRQ specified\n");
 		goto exit_mem;
 	}
-	dev->irq = ret;
+
+	dev->irq = res->start;
+	ax->irqflags = res->flags & IRQF_TRIGGER_MASK;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (res == NULL) {
-- 
1.6.2

--

From: Daniel Mack
Date: Sunday, March 22, 2009 - 9:12 am

Implement a way to provide the MAC address for ax88796 devices from
their platform data. Boards might decide to set the address
programmatically, taken from boot tags or other sources.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: David Miller <davem@davemloft.net>
Cc: Ben Dooks <ben@simtec.co.uk>
Cc: Matthias Meier <matthias.j.meier@gmx.net>
---
 drivers/net/ax88796.c |   17 ++++++++++++-----
 include/net/ax88796.h |   13 ++++++++-----
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ax88796.c b/drivers/net/ax88796.c
index e7c9748..62d9c9c 100644
--- a/drivers/net/ax88796.c
+++ b/drivers/net/ax88796.c
@@ -733,12 +733,19 @@ static int ax_init_dev(struct net_device *dev, int first_init)
 	/* load the mac-address from the device if this is the
 	 * first time we've initialised */
 
-	if (first_init && ax->plat->flags & AXFLG_MAC_FROMDEV) {
-		ei_outb(E8390_NODMA + E8390_PAGE1 + E8390_STOP,
-			ei_local->mem + E8390_CMD); /* 0x61 */
+	if (first_init) {
+		if (ax->plat->flags & AXFLG_MAC_FROMDEV) {
+			ei_outb(E8390_NODMA + E8390_PAGE1 + E8390_STOP,
+				ei_local->mem + E8390_CMD); /* 0x61 */
+			for (i = 0; i < ETHER_ADDR_LEN; i++)
+				dev->dev_addr[i] =
+					ei_inb(ioaddr + EN1_PHYS_SHIFT(i));
+		}
 
-		for (i = 0 ; i < ETHER_ADDR_LEN ; i++)
-			dev->dev_addr[i] = ei_inb(ioaddr + EN1_PHYS_SHIFT(i));
+		if ((ax->plat->flags & AXFLG_MAC_FROMPLATFORM) &&
+		     ax->plat->mac_addr)
+			memcpy(dev->dev_addr, ax->plat->mac_addr,
+				ETHER_ADDR_LEN);
 	}
 
 	ax_reset_8390(dev);
diff --git a/include/net/ax88796.h b/include/net/ax88796.h
index 51329da..b9a3bec 100644
--- a/include/net/ax88796.h
+++ b/include/net/ax88796.h
@@ -15,14 +15,17 @@
 #define AXFLG_HAS_EEPROM		(1<<0)
 #define AXFLG_MAC_FROMDEV		(1<<1)	/* device already has MAC */
 #define AXFLG_HAS_93CX6			(1<<2)	/* use eeprom_93cx6 driver */
+#define AXFLG_MAC_FROMPLATFORM		(1<<3)	/* MAC given by platform data */
 
 struct ax_plat_data {
 	unsigned int	 flags;
-	unsigned ...
From: David Miller
Date: Tuesday, March 24, 2009 - 11:32 pm

From: Daniel Mack <daniel@caiaq.de>

Also applied, thanks.
--

From: Daniel Mack
Date: Sunday, March 22, 2009 - 9:18 am

Please note that in contrast to the version I posted here previously,
this patch does not use platform_get_irq_flags() anymore. Nobody seemed
interested in the patch I sent along to implement that in
drivers/base/platform.c, so I gather the flags manually from this driver
now, using platform_get_resource().

Daniel

--

From: David Miller
Date: Tuesday, March 24, 2009 - 11:31 pm

From: Daniel Mack <daniel@caiaq.de>

Applied.
--

Previous thread: Re: linux-next: driver-core tree build failure by Stephen Rothwell on Sunday, March 22, 2009 - 5:22 am. (2 messages)

Next thread: Re: [PATCH] e1000: fix loss of multicast packets by Dave Boutcher on Sunday, March 22, 2009 - 11:05 am. (5 messages)