netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] drivers/net/ax88796.c: take IRQ flags from platform_device
@ 2009-03-22 16:12 Daniel Mack
  2009-03-22 16:12 ` [PATCH 2/2] ax88796: Add method to take MAC from platform data Daniel Mack
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Daniel Mack @ 2009-03-22 16:12 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel, Daniel Mack, Ben Dooks, David Miller

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


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

* [PATCH 2/2] ax88796: Add method to take MAC from platform data
  2009-03-22 16:12 [PATCH 1/2] drivers/net/ax88796.c: take IRQ flags from platform_device Daniel Mack
@ 2009-03-22 16:12 ` Daniel Mack
  2009-03-25  6:32   ` David Miller
  2009-03-22 16:18 ` [PATCH 1/2] drivers/net/ax88796.c: take IRQ flags from platform_device Daniel Mack
  2009-03-25  6:31 ` David Miller
  2 siblings, 1 reply; 5+ messages in thread
From: Daniel Mack @ 2009-03-22 16:12 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel, Daniel Mack, David Miller, Ben Dooks,
	Matthias Meier

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 char	 wordlength;		/* 1 or 2 */
-	unsigned char	 dcr_val;		/* default value for DCR */
-	unsigned char	 rcr_val;		/* default value for RCR */
-	unsigned char	 gpoc_val;		/* default value for GPOC */
-	u32		*reg_offsets;		/* register offsets */
+	unsigned char	 wordlength;	/* 1 or 2 */
+	unsigned char	 dcr_val;	/* default value for DCR */
+	unsigned char	 rcr_val;	/* default value for RCR */
+	unsigned char	 gpoc_val;	/* default value for GPOC */
+	u32		*reg_offsets;	/* register offsets */
+	u8		*mac_addr;	/* MAC addr (only used when
+					   AXFLG_MAC_FROMPLATFORM is used */
 };
 
 #endif /* __NET_AX88796_PLAT_H */
-- 
1.6.2


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

* Re: [PATCH 1/2] drivers/net/ax88796.c: take IRQ flags from platform_device
  2009-03-22 16:12 [PATCH 1/2] drivers/net/ax88796.c: take IRQ flags from platform_device Daniel Mack
  2009-03-22 16:12 ` [PATCH 2/2] ax88796: Add method to take MAC from platform data Daniel Mack
@ 2009-03-22 16:18 ` Daniel Mack
  2009-03-25  6:31 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Daniel Mack @ 2009-03-22 16:18 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel, Ben Dooks, David Miller

On Sun, Mar 22, 2009 at 05:12:40PM +0100, Daniel Mack wrote:
> This patch adds support to the ax88796 ethernet driver to take IRQ flags
> given by the platform_device definition.

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


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

* Re: [PATCH 1/2] drivers/net/ax88796.c: take IRQ flags from platform_device
  2009-03-22 16:12 [PATCH 1/2] drivers/net/ax88796.c: take IRQ flags from platform_device Daniel Mack
  2009-03-22 16:12 ` [PATCH 2/2] ax88796: Add method to take MAC from platform data Daniel Mack
  2009-03-22 16:18 ` [PATCH 1/2] drivers/net/ax88796.c: take IRQ flags from platform_device Daniel Mack
@ 2009-03-25  6:31 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2009-03-25  6:31 UTC (permalink / raw)
  To: daniel; +Cc: netdev, linux-kernel, ben

From: Daniel Mack <daniel@caiaq.de>
Date: Sun, 22 Mar 2009 17:12:40 +0100

> 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>

Applied.

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

* Re: [PATCH 2/2] ax88796: Add method to take MAC from platform data
  2009-03-22 16:12 ` [PATCH 2/2] ax88796: Add method to take MAC from platform data Daniel Mack
@ 2009-03-25  6:32   ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2009-03-25  6:32 UTC (permalink / raw)
  To: daniel; +Cc: netdev, linux-kernel, ben, matthias.j.meier

From: Daniel Mack <daniel@caiaq.de>
Date: Sun, 22 Mar 2009 17:12:41 +0100

> 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>

Also applied, thanks.

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

end of thread, other threads:[~2009-03-25  6:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-22 16:12 [PATCH 1/2] drivers/net/ax88796.c: take IRQ flags from platform_device Daniel Mack
2009-03-22 16:12 ` [PATCH 2/2] ax88796: Add method to take MAC from platform data Daniel Mack
2009-03-25  6:32   ` David Miller
2009-03-22 16:18 ` [PATCH 1/2] drivers/net/ax88796.c: take IRQ flags from platform_device Daniel Mack
2009-03-25  6:31 ` David Miller

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).