public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
From: Finn Thain <fthain@telegraphics.com.au>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-m68k@vger.kernel.org, David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org
Subject: [PATCH 03/16] mac_sonic: add irq resources and cleanup
Date: Mon, 24 Oct 2011 01:11:11 +1100	[thread overview]
Message-ID: <20111023141124.538715283@telegraphics.com.au> (raw)
In-Reply-To: 20111023141108.856998818@telegraphics.com.au

[-- Attachment #1: macsonic-platform-irq-rsrc --]
[-- Type: text/plain, Size: 6140 bytes --]

Make better use of the SONIC platform device by adding irq resources. This moves the via_type logic out of the NIC device driver which improves modularity.

Since interrupt handlers now run with CPU interrupts disabled, we don't need the macsonic_interrupt() wrapper. Remove it.

For consistency, rename retval as err.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

Index: linux-m68k/arch/m68k/mac/config.c
===================================================================
--- linux-m68k.orig/arch/m68k/mac/config.c	2011-10-22 23:02:22.000000000 +1100
+++ linux-m68k/arch/m68k/mac/config.c	2011-10-23 00:51:11.000000000 +1100
@@ -936,9 +936,16 @@ static struct platform_device esp_1_pdev
 	.id		= 1,
 };
 
+static struct resource sonic_rsrcs[] = {
+	{ .flags = IORESOURCE_IRQ },
+	{ .flags = IORESOURCE_IRQ },
+};
+
 static struct platform_device sonic_pdev = {
 	.name		= "macsonic",
 	.id		= -1,
+	.num_resources  = ARRAY_SIZE(sonic_rsrcs),
+	.resource       = sonic_rsrcs,
 };
 
 static struct platform_device mace_pdev = {
@@ -1002,6 +1009,10 @@ int __init mac_platform_init(void)
 
 	switch (macintosh_config->ether_type) {
 	case MAC_ETHER_SONIC:
+		sonic_rsrcs[0].start = sonic_rsrcs[0].end = IRQ_NUBUS_9;
+		if (via_alt_mapping)
+			sonic_rsrcs[1].start = sonic_rsrcs[1].end = IRQ_AUTO_3;
+
 		platform_device_register(&sonic_pdev);
 		break;
 	case MAC_ETHER_MACE:
Index: linux-m68k/drivers/net/macsonic.c
===================================================================
--- linux-m68k.orig/drivers/net/macsonic.c	2011-10-22 23:02:38.000000000 +1100
+++ linux-m68k/drivers/net/macsonic.c	2011-10-22 23:02:38.000000000 +1100
@@ -60,7 +60,6 @@
 #include <asm/dma.h>
 #include <asm/macintosh.h>
 #include <asm/macints.h>
-#include <asm/mac_via.h>
 
 static char mac_sonic_string[] = "macsonic";
 
@@ -127,61 +126,49 @@ static inline void bit_reverse_addr(unsi
 		addr[i] = bitrev8(addr[i]);
 }
 
-static irqreturn_t macsonic_interrupt(int irq, void *dev_id)
-{
-	irqreturn_t result;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	result = sonic_interrupt(irq, dev_id);
-	local_irq_restore(flags);
-	return result;
-}
-
 static int macsonic_open(struct net_device* dev)
 {
-	int retval;
+	struct sonic_local *lp = netdev_priv(dev);
+	int err;
 
-	retval = request_irq(dev->irq, sonic_interrupt, 0, "sonic", dev);
-	if (retval) {
-		printk(KERN_ERR "%s: unable to get IRQ %d.\n",
-				dev->name, dev->irq);
-		goto err;
-	}
-	/* Under the A/UX interrupt scheme, the onboard SONIC interrupt comes
-	 * in at priority level 3. However, we sometimes get the level 2 inter-
-	 * rupt as well, which must prevent re-entrance of the sonic handler.
-	 */
-	if (dev->irq == IRQ_AUTO_3) {
-		retval = request_irq(IRQ_NUBUS_9, macsonic_interrupt, 0,
-				     "sonic", dev);
-		if (retval) {
-			printk(KERN_ERR "%s: unable to get IRQ %d.\n",
-					dev->name, IRQ_NUBUS_9);
-			goto err_irq;
+	err = request_irq(dev->irq, sonic_interrupt, 0, "SONIC", dev);
+	if (err) {
+		pr_err("%s: unable to get IRQ %d\n", dev->name, dev->irq);
+		goto out;
+	}
+	if (lp->irq1) {
+		err = request_irq(lp->irq1, sonic_interrupt, 0, "SONIC", dev);
+		if (err) {
+			pr_err("%s: unable to get IRQ %d\n",
+			       dev->name, lp->irq1);
+			goto out_irq;
 		}
 	}
-	retval = sonic_open(dev);
-	if (retval)
-		goto err_irq_nubus;
+	err = sonic_open(dev);
+	if (err)
+		goto out_irq1;
+
 	return 0;
 
-err_irq_nubus:
-	if (dev->irq == IRQ_AUTO_3)
-		free_irq(IRQ_NUBUS_9, dev);
-err_irq:
+out_irq1:
+	if (lp->irq1)
+		free_irq(lp->irq1, dev);
+out_irq:
 	free_irq(dev->irq, dev);
-err:
-	return retval;
+out:
+	return err;
 }
 
 static int macsonic_close(struct net_device* dev)
 {
+	struct sonic_local *lp = netdev_priv(dev);
 	int err;
+
 	err = sonic_close(dev);
+
+	if (lp->irq1)
+		free_irq(lp->irq1, dev);
 	free_irq(dev->irq, dev);
-	if (dev->irq == IRQ_AUTO_3)
-		free_irq(IRQ_NUBUS_9, dev);
 	return err;
 }
 
@@ -310,8 +297,9 @@ static void __devinit mac_onboard_sonic_
 	random_ether_addr(dev->dev_addr);
 }
 
-static int __devinit mac_onboard_sonic_probe(struct net_device *dev)
+static int __devinit mac_onboard_sonic_probe(struct platform_device *pdev)
 {
+	struct net_device *dev = platform_get_drvdata(pdev);
 	struct sonic_local* lp = netdev_priv(dev);
 	int sr;
 	int commslot = 0;
@@ -348,10 +336,12 @@ static int __devinit mac_onboard_sonic_p
 	/* Danger!  My arms are flailing wildly!  You *must* set lp->reg_offset
 	 * and dev->base_addr before using SONIC_READ() or SONIC_WRITE() */
 	dev->base_addr = ONBOARD_SONIC_REGISTERS;
-	if (via_alt_mapping)
-		dev->irq = IRQ_AUTO_3;
-	else
-		dev->irq = IRQ_NUBUS_9;
+
+	dev->irq = platform_get_irq(pdev, 0);
+	lp->irq1 = platform_get_irq(pdev, 1);
+
+	if (!dev->irq)
+		return -ENODEV;
 
 	if (!sonic_version_printed) {
 		printk(KERN_INFO "%s", version);
@@ -590,7 +580,7 @@ static int __devinit mac_sonic_probe(str
 	platform_set_drvdata(pdev, dev);
 
 	/* This will catch fatal stuff like -ENOMEM as well as success */
-	err = mac_onboard_sonic_probe(dev);
+	err = mac_onboard_sonic_probe(pdev);
 	if (err == 0)
 		goto found;
 	if (err != -ENODEV)
Index: linux-m68k/drivers/net/sonic.h
===================================================================
--- linux-m68k.orig/drivers/net/sonic.h	2011-10-22 23:02:22.000000000 +1100
+++ linux-m68k/drivers/net/sonic.h	2011-10-22 23:02:38.000000000 +1100
@@ -318,6 +318,9 @@ struct sonic_local {
 	unsigned int eol_rx;
 	unsigned int eol_tx;           /* last unacked transmit packet */
 	unsigned int next_tx;          /* next free TD */
+#ifdef CONFIG_MAC
+	int irq1;                      /* Second IRQ for Mac Quadras */
+#endif
 	struct device *device;         /* generic device */
 	struct net_device_stats stats;
 };
Index: linux-m68k/arch/m68k/mac/via.c
===================================================================
--- linux-m68k.orig/arch/m68k/mac/via.c	2011-10-22 23:02:38.000000000 +1100
+++ linux-m68k/arch/m68k/mac/via.c	2011-10-23 00:51:10.000000000 +1100
@@ -40,7 +40,6 @@
 volatile __u8 *via1, *via2;
 int rbv_present;
 int via_alt_mapping;
-EXPORT_SYMBOL(via_alt_mapping);
 static __u8 rbv_clear;
 
 /*

  parent reply	other threads:[~2011-10-23 14:11 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-23 14:11 [PATCH 00/16] more mac68k fixes and cleanup Finn Thain
2011-10-23 14:11 ` [PATCH 01/16] pmac_zilog: fix unexpected irq Finn Thain
2011-11-24 14:34   ` Finn Thain
2011-11-24 14:56     ` Alan Cox
2011-11-24 20:41       ` Benjamin Herrenschmidt
2011-11-25  3:15       ` Finn Thain
2011-11-28  0:30         ` Benjamin Herrenschmidt
2011-11-24 15:28     ` David Laight
2011-11-24 20:43       ` Benjamin Herrenschmidt
2011-12-06 15:13   ` [PATCH 01/16 v2] " Finn Thain
2011-12-06 15:27     ` Geert Uytterhoeven
2011-12-07  1:26       ` Finn Thain
2011-12-06 15:39     ` Alan Cox
2011-12-07  3:49     ` [PATCH 01/16 v3] " Finn Thain
2011-12-08  3:17       ` Benjamin Herrenschmidt
2011-12-08  4:20       ` Benjamin Herrenschmidt
2011-12-08  4:30         ` Benjamin Herrenschmidt
2011-12-08 11:26           ` Finn Thain
2011-12-08 11:54             ` Geert Uytterhoeven
2011-12-08 19:44             ` Benjamin Herrenschmidt
2011-12-11 23:48             ` Benjamin Herrenschmidt
2011-12-11 23:55               ` Benjamin Herrenschmidt
2011-12-12 13:34               ` Finn Thain
2011-12-12 20:06                 ` Benjamin Herrenschmidt
2011-12-13  1:24                   ` Finn Thain
2011-10-23 14:11 ` [PATCH 02/16] macfb: fix black and white modes Finn Thain
2011-12-10  5:23   ` Finn Thain
2011-10-23 14:11 ` Finn Thain [this message]
2011-11-13 10:28   ` [PATCH 03/16] mac_sonic: add irq resources and cleanup Geert Uytterhoeven
2011-11-13 14:30     ` Finn Thain
2011-11-13 17:36       ` Geert Uytterhoeven
2011-12-10  5:23   ` Finn Thain
2011-10-23 14:11 ` [PATCH 04/16] m68k/mac: early console Finn Thain
2011-10-23 14:11 ` [PATCH 05/16] m68k/mac: cleanup mac_clear_irq Finn Thain
2011-10-23 14:11 ` [PATCH 06/16] m68k/mac: cleanup mac_irq_pending Finn Thain
2011-12-10  5:24   ` Finn Thain
2011-10-23 14:11 ` [PATCH 07/16] m68k/mac: cleanup forward declarations Finn Thain
2011-10-23 14:11 ` [PATCH 08/16] m68k/mac: enable via_alt_mapping on performa 580 Finn Thain
2011-10-23 14:11 ` [PATCH 09/16] m68k/mac: fix nubus slot irq disable and shutdown Finn Thain
2011-10-23 14:11 ` [PATCH 10/16] m68k/mac: oss irq fixes Finn Thain
2011-10-23 14:11 ` [PATCH 11/16] m68k/mac: fix baboon irq disable and shutdown Finn Thain
2011-10-23 14:11 ` [PATCH 12/16] m68k/mac: fix powerbook 150 adb_type Finn Thain
2011-10-23 14:11 ` [PATCH 13/16] mac_scsi: fix mac_scsi on some powerbooks Finn Thain
2011-12-10  5:24   ` Finn Thain
2011-10-23 14:11 ` [PATCH 14/16] m68k/mac: cleanup macro case Finn Thain
2011-10-23 14:11 ` [PATCH 15/16] mac_scsi: dont enable mac_scsi irq before requesting it Finn Thain
2011-12-10  5:24   ` Finn Thain
2011-10-23 14:11 ` [PATCH 16/16] mac_esp: rename irq Finn Thain
2011-12-10  5:24   ` Finn Thain
2011-10-31 18:35 ` [PATCH 00/16] more mac68k fixes and cleanup Geert Uytterhoeven
2011-10-31 19:16   ` Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111023141124.538715283@telegraphics.com.au \
    --to=fthain@telegraphics.com.au \
    --cc=davem@davemloft.net \
    --cc=geert@linux-m68k.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox