lkml.org 
[lkml]   [1999]   [Sep]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] support for ISAPnP code with ne2000 network driver
On Sat, 11 Sep 1999, Alan Cox wrote:

> > Attached is a patch to support initializing a ISAPnP ne2k clone
> > with the ne.c driver.
> The ne driver uses the 8390 driver so its priv field is taken up by
> ei_local. However, ei_device has a priv field too, so you an use
>
> struct ei_device *my_sub_dev = dev->private;
> my_sub_dev->priv = (whatever)

Ok, attached is the final version that does deactivation of the
card at module unload time. Please apply, as it works for me(TM)

Richard.

--
Richard Guenther <richard.guenther@student.uni-tuebingen.de>
PGP: 2E829319 - 2F 83 FC 93 E9 E4 19 E2 93 7A 32 42 45 37 23 57
WWW: http://www.anatom.uni-tuebingen.de/~richi/

--- linux-2.3.16/drivers/net/ne.c.original Fri Sep 10 21:27:46 1999
+++ linux-2.3.16/drivers/net/ne.c Sat Sep 11 19:35:42 1999
@@ -28,7 +28,8 @@
rjohnson@analogic.com : Changed init order so an interrupt will only
occur after memory is allocated for dev->priv. Deallocated memory
last in cleanup_modue()
-
+ Richard Guenther : Added support for ISAPnP cards
+
*/

/* Routines for the NatSemi-based designs (NE[12]000). */
@@ -43,6 +44,7 @@
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/pci.h>
+#include <linux/isapnp.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <asm/system.h>
@@ -90,6 +92,13 @@
static int probe_pci = 1;
#endif

+static struct { unsigned short vendor, function; char *name; }
+isapnp_clone_list[] __initdata = {
+ {ISAPNP_VENDOR('E','D','I'), ISAPNP_FUNCTION(0x0216), "NN NE2000" },
+ {ISAPNP_VENDOR('P','N','P'), ISAPNP_FUNCTION(0x80d6), "Generic PNP" },
+ {0,}
+};
+
#ifdef SUPPORT_NE_BAD_CLONES
/* A list of bad clones that we none-the-less recognize. */
static struct { const char *name8, *name16; unsigned char SAprefix[4];}
@@ -128,6 +137,7 @@

int ne_probe(struct net_device *dev);
static int ne_probe1(struct net_device *dev, int ioaddr);
+static int ne_probe_isapnp(struct net_device *dev);
#ifdef CONFIG_PCI
static int ne_probe_pci(struct net_device *dev);
#endif
@@ -193,6 +203,10 @@
return 0;
#endif

+ /* Then look for any installed ISAPnP clones */
+ if (isapnp_present() && (ne_probe_isapnp(dev) == 0))
+ return 0;
+
#ifndef MODULE
/* Last resort. The semi-risky ISA auto-probe. */
for (base_addr = 0; netcard_portlist[base_addr] != 0; base_addr++) {
@@ -243,6 +257,46 @@
}
#endif /* CONFIG_PCI */

+static int __init ne_probe_isapnp(struct net_device *dev)
+{
+ int i;
+
+ for (i = 0; isapnp_clone_list[i].vendor != 0; i++) {
+ struct pci_dev *idev = NULL;
+
+ while ((idev = isapnp_find_dev(NULL,
+ isapnp_clone_list[i].vendor,
+ isapnp_clone_list[i].function,
+ idev))) {
+ /* Avoid already found cards from previous calls */
+ if (idev->prepare(idev))
+ continue;
+ if (idev->activate(idev))
+ continue;
+ pci_irq_line = idev->irq_resource[0].start;
+ /* if no irq, search for next */
+ if (!pci_irq_line)
+ continue;
+ /* found it */
+ if (ne_probe1(dev, idev->resource[0].start) != 0) { /* Shouldn't happen. */
+ printk(KERN_ERR "ne.c: Probe of ISAPnP card at %#lx failed.\n",
+ idev->resource[0].start);
+ return -ENXIO;
+ }
+ ei_status.priv = (unsigned long)idev;
+ break;
+ }
+ if (!idev)
+ continue;
+ printk(KERN_INFO "ne.c: ISAPnP reports %s at i/o %#lx, irq %d.\n",
+ isapnp_clone_list[i].name,
+ dev->base_addr, dev->irq);
+ return 0;
+ }
+
+ return -ENODEV;
+}
+
static int __init ne_probe1(struct net_device *dev, int ioaddr)
{
int i;
@@ -491,6 +545,7 @@
ei_status.block_input = &ne_block_input;
ei_status.block_output = &ne_block_output;
ei_status.get_8390_hdr = &ne_get_8390_hdr;
+ ei_status.priv = 0;
dev->open = &ne_open;
dev->stop = &ne_close;
NS8390_init(dev, 0);
@@ -819,6 +874,9 @@
struct net_device *dev = &dev_ne[this_dev];
if (dev->priv != NULL) {
void *priv = dev->priv;
+ struct pci_dev *idev = (struct pci_dev *)ei_status.priv;
+ if (idev)
+ idev->deactivate(idev);
free_irq(dev->irq, dev);
release_region(dev->base_addr, NE_IO_EXTENT);
unregister_netdev(dev);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:0.027 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site