Skip to contentSkip to conversation

drivers/net/ax88796.c: take IRQ flags from platform_device

PATCH Applied Daniel Mack 2 participants 5 messages Mar 22, 2009 – Mar 25, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drivers/net/ax88796.c: take IRQ flags from platform_device

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

Cc Ben Dooks <[email protected]>
Cc David Miller <[email protected]>
---
 drivers/net/ax88796.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
drivers/net/ax88796.c +9 -5
index a4eb6c4..e7c9748 100644
@@ -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) {
Signature · 1 line
1.6.2
#1 lore raw

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

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.

Cc David Miller <[email protected]>
Cc Ben Dooks <[email protected]>
Cc Matthias Meier <[email protected]>
---
 drivers/net/ax88796.c |   17 ++++++++++++-----
 include/net/ax88796.h |   13 ++++++++-----
 2 files changed, 20 insertions(+), 10 deletions(-)
drivers/net/ax88796.c +12 -5
index e7c9748..62d9c9c 100644
@@ -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);
include/net/ax88796.h +8 -5
index 51329da..b9a3bec 100644
@@ -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 */
Signature · 1 line
1.6.2
maintainer
#2 lore raw

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

From: Daniel Mack <[email protected]>
Date: Sun, 22 Mar 2009 17:12:41 +0100

Quoted 5 lines

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.

Also applied, thanks.

#3 lore raw
In reply to Daniel Mack
Quoted 2 lines · Daniel Mack

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