public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Muizelaar <muizelaar@rogers.com>
To: Jeff Muizelaar <muizelaar@rogers.com>
Cc: Jeff Garzik <jgarzik@pobox.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/4] NE2000 driver updates
Date: Thu, 01 May 2003 13:08:47 -0400	[thread overview]
Message-ID: <3EB1549F.9060202@rogers.com> (raw)
In-Reply-To: <3EB1528C.8090503@rogers.com>

[-- Attachment #1: Type: text/plain, Size: 61 bytes --]

Here is the correct patch, the previous one wasn't...

-Jeff

[-- Attachment #2: ne-legacy.patch --]
[-- Type: text/plain, Size: 8681 bytes --]

diff -u linux-2.5.66-nepnpid/drivers/net/ne.c linux-2.5.66-nelist/drivers/net/ne.c
--- linux-2.5.66-nepnpid/drivers/net/ne.c	2003-03-29 21:39:29.000000000 -0500
+++ linux-2.5.66-nelist/drivers/net/ne.c	2003-05-01 11:05:56.000000000 -0400
@@ -30,13 +30,14 @@
     Richard Guenther    : Added support for ISAPnP cards
     Paul Gortmaker	: Discontinued PCI support - use ne2k-pci.c instead.
     Jeff Muizelaar	: moved over to generic PnP api
+    Jeff Muizelaar	: changed init code to act more probe like 
 
 */
 
 /* Routines for the NatSemi-based designs (NE[12]000). */
 
 static const char version[] =
-"ne.c:v1.10a 1/26/03 Donald Becker (becker@scyld.com)\n";
+"ne.c:v1.10b 4/1/03 Donald Becker (becker@scyld.com)\n";
 
 
 #include <linux/module.h>
@@ -134,7 +135,6 @@
 #ifdef CONFIG_PNP
 static int ne_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id);
 static void ne_pnp_remove(struct pnp_dev *dev);
-
 static struct pnp_driver ne_pnp_driver = {
 	.name		= "ne",
 	.id_table 	= ne_pnp_table,
@@ -143,9 +143,14 @@
 };
 #endif
 
-int ne_probe(struct net_device *dev);
+static int ne_legacy_probe(unsigned long base_addr, unsigned long irq, unsigned long bad);
+
 static int ne_probe1(struct net_device *dev, int ioaddr);
 
+static int ne_create(struct net_device **ndev, unsigned long base_addr, 
+		unsigned long irq, unsigned long bad);
+static void ne_remove(struct net_device *dev);
+
 static int ne_open(struct net_device *dev);
 static int ne_close(struct net_device *dev);
 
@@ -179,73 +184,81 @@
 	E2010	 starts at 0x100 and ends at 0x4000.
 	E2010-x starts at 0x100 and ends at 0xffff.  */
 
-int __init ne_probe(struct net_device *dev)
+#ifdef CONFIG_PNP
+static int ne_pnp_probe(struct pnp_dev *idev, const struct pnp_device_id *dev_id)
 {
-	unsigned int base_addr = dev->base_addr;
-
-	SET_MODULE_OWNER(dev);
-
-	/* First check any supplied i/o locations. User knows best. <cough> */
-	if (base_addr > 0x1ff)	/* Check a single specified location. */
-		return ne_probe1(dev, base_addr);
-	else if (base_addr != 0)	/* Don't probe at all. */
-		return -ENXIO;
+	struct net_device *dev;
+	int err;
+	printk(KERN_INFO "ne.c: PnP reports %s at i/o %#lx, irq %ld\n",
+			idev->dev.name, pnp_port_start(idev, 0), pnp_irq(idev, 0));
+	err = ne_create(&dev, pnp_port_start(idev, 0), pnp_irq(idev, 0), 0);
+	if(dev)
+		pnp_set_drvdata(idev, dev);
+	return err;
+}
 
-#ifndef MODULE
-	/* Last resort. The semi-risky ISA auto-probe. */
-	for (base_addr = 0; netcard_portlist[base_addr] != 0; base_addr++) {
-		int ioaddr = netcard_portlist[base_addr];
-		if (ne_probe1(dev, ioaddr) == 0)
-			return 0;
-	}
+static void ne_pnp_remove(struct pnp_dev *idev)
+{
+	struct net_device *dev = pnp_get_drvdata(idev);	
+	ne_remove(dev);
+}
 #endif
+struct list_head ne_legacy_devs = LIST_HEAD_INIT(ne_legacy_devs);
 
-	return -ENODEV;
+struct ne_legacy{
+	struct net_device *dev;
+	struct list_head list;
+};
+
+static int ne_legacy_probe(unsigned long base_addr, unsigned long irq, unsigned long bad)
+{
+	struct ne_legacy *ne_card;
+	int err;
+	ne_card = kmalloc(sizeof(struct ne_legacy), GFP_KERNEL);
+	err = ne_create(&ne_card->dev, base_addr, irq,  bad);
+	if (!err) 
+		list_add(&ne_card->list, &ne_legacy_devs);
+	else
+		kfree(ne_card);
+	return err;
 }
 
-#ifdef CONFIG_PNP
-static int ne_pnp_probe(struct pnp_dev *idev, const struct pnp_device_id *dev_id)
+static int ne_create(struct net_device **ndev, unsigned long base_addr, unsigned long irq, unsigned long bad)
 {
-	struct net_device *dev;
 	int err;
 	
-	if ( !(dev = alloc_etherdev(0)) ){
+	if (!(*ndev = alloc_etherdev(0)) ){
 		err = -ENOMEM;
 		goto alloc_fail;
 	}
 	
-	dev->base_addr = pnp_port_start(idev, 0);
-	dev->irq = pnp_irq(idev, 0);
-	printk(KERN_INFO "ne.c: PnP reports %s at i/o %#lx, irq %d\n",
-			idev->dev.name, dev->base_addr, dev->irq);
-	
-	SET_MODULE_OWNER(dev);
+	(*ndev)->base_addr = base_addr;
+	(*ndev)->irq = irq;
+	(*ndev)->mem_end = bad;
+	SET_MODULE_OWNER(*ndev);
 	
-	if (ne_probe1(dev, dev->base_addr) != 0) {	/* Shouldn't happen. */
-		printk(KERN_ERR "ne.c: Probe of PnP card at %#lx failed\n", dev->base_addr);
+	if (ne_probe1(*ndev, (*ndev)->base_addr) != 0) {	/* Shouldn't happen. */
+		printk(KERN_ERR "ne.c: Probe at %#lx failed\n", (*ndev)->base_addr);
 		err = -ENXIO;
 		goto probe_fail;
 	}
 	
-	if ( (err = register_netdev(dev)) != 0)
+	if ( (err = register_netdev(*ndev)) != 0)
 		goto register_fail;
-
-	pnp_set_drvdata(idev, dev);
 	
 	return 0;
 	
 register_fail:
-		kfree(dev->priv);
-		release_region(dev->base_addr, NE_IO_EXTENT);
+	kfree((*ndev)->priv);
+	release_region((*ndev)->base_addr, NE_IO_EXTENT);
 probe_fail:
-		kfree(dev);
+	kfree(*ndev);
 alloc_fail:
-		return err;
+	return err;
 }
 
-static void ne_pnp_remove(struct pnp_dev *idev)
+static void ne_remove(struct net_device *dev)
 {
-	struct net_device *dev = pnp_get_drvdata(idev);	
 	if (dev) {
 		unregister_netdev(dev);
 		free_irq(dev->irq, dev);
@@ -254,7 +267,6 @@
 		kfree(dev);
 	}
 }
-#endif
 
 static int __init ne_probe1(struct net_device *dev, int ioaddr)
 {
@@ -751,10 +763,7 @@
 	return;
 }
 
-\f
-#ifdef MODULE
 #define MAX_NE_CARDS	4	/* Max number of NE cards per module */
-static struct net_device dev_ne[MAX_NE_CARDS];
 static int io[MAX_NE_CARDS];
 static int irq[MAX_NE_CARDS];
 static int bad[MAX_NE_CARDS];	/* 0xbad = bad sig or no reset ack */
@@ -773,60 +782,70 @@
 is at boot) and so the probe will get confused by any other 8390 cards.
 ISA device autoprobes on a running machine are not recommended anyway. */
 
-int init_module(void)
-{
-	int this_dev, found = 0;
 
+static int __init ne_init(void)
+{
+	int i, found = 0;
+	int err;
 #ifdef CONFIG_PNP	
 	found = pnp_register_driver(&ne_pnp_driver);
 	if (found < 0) {
-		return found;
+		err = found;
+		goto pnp_fail;
 	}
 #endif
+	/* First check any supplied i/o locations. User knows best. <cough> */
+	for (i = 0; i < MAX_NE_CARDS; i++) {
+		if (io[i] > 0x1ff) {
+			err = ne_legacy_probe(io[i], irq[i], bad[i]);
+			if (!err)
+				found++;
+			else
+				printk(KERN_WARNING "ne.c: No NE*000 card found at i/o = %#x\n", io[i]);
+		}
+	}
 
-	for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
-		struct net_device *dev = &dev_ne[this_dev];
-		dev->irq = irq[this_dev];
-		dev->mem_end = bad[this_dev];
-		dev->base_addr = io[this_dev];
-		dev->init = ne_probe;
-		if (register_netdev(dev) == 0) {
+#ifndef MODULE
+	/* Last resort. The semi-risky ISA auto-probe. */
+	printk(KERN_INFO "ne.c: auto-probing...\m");
+	for (i = 0; netcard_portlist[i] != 0; i++) {
+		err = ne_legacy_probe(netcard_portlist[i], 0,  0);
+		if (!err) {
 			found++;
-			continue;
-		}
-		if (found != 0) { 	/* Got at least one. */
-			return 0;
-		}
-		if (io[this_dev] != 0)
-			printk(KERN_WARNING "ne.c: No NE*000 card found at i/o = %#x\n", io[this_dev]);
-		else
-			printk(KERN_NOTICE "ne.c: You must supply \"io=0xNNN\" value(s) for ISA cards.\n");
+		} 
+	}
+#endif
+	if (found > 0) 	/* Got at least one. */
+		return 0;
+	else
+		printk(KERN_NOTICE "ne.c: You must supply \"io=0xNNN\" value(s) for ISA cards.\n");
+
 #ifdef CONFIG_PNP
-		pnp_unregister_driver(&ne_pnp_driver);
+	pnp_unregister_driver(&ne_pnp_driver);
+pnp_fail:
 #endif
-		return -ENXIO;
-	}
-	return 0;
+	return -ENODEV;
 }
 
-void cleanup_module(void)
+static void __exit ne_cleanup(void)
 {
-	int this_dev;
-
+	struct list_head *entry;
+	struct list_head *tmp;
 #ifdef CONFIG_PNP	
 	pnp_unregister_driver(&ne_pnp_driver);
 #endif
-	for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
-		struct net_device *dev = &dev_ne[this_dev];
-		if (dev->priv != NULL) {
-			unregister_netdev(dev);
-			free_irq(dev->irq, dev);
-			release_region(dev->base_addr, NE_IO_EXTENT);
-			kfree(dev->priv);
-		}
+	/* Cleanup legacy devices */
+	list_for_each_safe(entry, tmp, &ne_legacy_devs) {
+		struct ne_legacy *card;
+		card = list_entry(entry, struct ne_legacy, list);
+		ne_remove(card->dev);
+		list_del(entry);
+		kfree(card);
 	}
 }
-#endif /* MODULE */
+
+module_init(ne_init);
+module_exit(ne_cleanup);
 
 \f
 /*
diff -u linux-2.5.66-nepnpid/drivers/net/Space.c linux-2.5.66-nelist/drivers/net/Space.c
--- linux-2.5.66-nepnpid/drivers/net/Space.c	2003-04-01 12:56:08.000000000 -0500
+++ linux-2.5.66-nelist/drivers/net/Space.c	2003-04-01 12:54:53.000000000 -0500
@@ -233,7 +233,7 @@
 #ifdef CONFIG_E2100		/* Cabletron E21xx series. */
 	{e2100_probe, 0},
 #endif
-#if defined(CONFIG_NE2000) || defined(CONFIG_NE2K_CBUS)	/* ISA & PC-9800 CBUS (use ne2k-pci for PCI cards) */
+#ifdef CONFIG_NE2K_CBUS	/* ISA & PC-9800 CBUS (use ne2k-pci for PCI cards) */
 	{ne_probe, 0},
 #endif
 #ifdef CONFIG_LANCE		/* ISA/VLB (use pcnet32 for PCI cards) */

  reply	other threads:[~2003-05-01 16:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-01 16:53 [PATCH 0/4] NE2000 driver updates Jeff Muizelaar
2003-05-01 16:58 ` [PATCH 1/4] " Jeff Muizelaar
2003-05-01 16:59 ` [PATCH 2/4] " Jeff Muizelaar
2003-05-01 16:59 ` [PATCH 3/4] " Jeff Muizelaar
2003-05-01 17:08   ` Jeff Muizelaar [this message]
2003-05-01 17:47 ` [PATCH 4/4] " Jeff Muizelaar
2003-05-01 19:23 ` [PATCH 0/4] " Alan Cox
2003-05-01 23:29   ` Jeff Muizelaar
2003-05-02 14:01     ` Alan Cox
2003-05-02 15:57       ` Jeff Garzik
2003-05-02 15:24         ` Alan Cox
2003-05-02 16:29       ` Riley Williams
2003-05-14  2:01       ` Jeff Muizelaar
2003-05-14 21:51         ` Adam Belay
2003-05-15  3:01           ` Jeff Muizelaar

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=3EB1549F.9060202@rogers.com \
    --to=muizelaar@rogers.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@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