]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] PnP update - drivers
authorJaroslav Kysela <perex@suse.cz>
Sun, 12 Jan 2003 03:46:40 +0000 (19:46 -0800)
committerJaroslav Kysela <perex@suse.cz>
Sun, 12 Jan 2003 03:46:40 +0000 (19:46 -0800)
this patch must be applied after PnP patch v0.94. It contains my
small cleanups of PnP code and I tried to rewrite almost all ISA PnP
drivers to new PnP subsystem except sound drivers (ALSA & OSS).

  PnP update
    - separated dev->resource to dev->io_resource and dev->mem_resource
    - added pnp_*_valid() macros
    - added status member to pnp_card structure
    - added pnp_device_attach/detach functions
    - added pnpc_attach/detach functions
    - moved pnp_find_card() and pnp_find_dev() functions to isapnp.h
    - updated IDE/gameport/ISDN/network/scsi/radio/telephone drivers
      to latest PnP code

43 files changed:
drivers/ide/ide-pnp.c
drivers/input/gameport/gameport.c
drivers/input/gameport/ns558.c
drivers/isdn/hisax/asuscom.c
drivers/isdn/hisax/avm_pci.c
drivers/isdn/hisax/diva.c
drivers/isdn/hisax/elsa.c
drivers/isdn/hisax/hfc_sx.c
drivers/isdn/hisax/hfcscard.c
drivers/isdn/hisax/hisax_fcpcipnp.c
drivers/isdn/hisax/hisax_hfcpci.c
drivers/isdn/hisax/isurf.c
drivers/isdn/hisax/ix1_micro.c
drivers/isdn/hisax/niccy.c
drivers/isdn/hisax/sedlbauer.c
drivers/isdn/hisax/teles3.c
drivers/media/radio/radio-cadet.c
drivers/media/radio/radio-sf16fmi.c
drivers/net/3c509.c
drivers/net/3c515.c
drivers/net/aironet4500_card.c
drivers/net/ne.c
drivers/net/sb1000.c
drivers/net/smc-ultra.c
drivers/pcmcia/i82365.c
drivers/pnp/card.c
drivers/pnp/driver.c
drivers/pnp/interface.c
drivers/pnp/isapnp/compat.c
drivers/pnp/isapnp/core.c
drivers/pnp/isapnp/proc.c
drivers/pnp/pnpbios/core.c
drivers/pnp/resource.c
drivers/pnp/system.c
drivers/scsi/aha152x.c
drivers/scsi/aha1542.c
drivers/scsi/g_NCR5380.c
drivers/scsi/sym53c416.c
drivers/telephony/ixj.c
drivers/telephony/ixj.h
include/linux/ide.h
include/linux/isapnp.h
include/linux/pnp.h

index 6dcf255e7a7c20b840b4680e62fbe451f2b94479..380dee4313547e4b40214f4a39fceacf166102b7 100644 (file)
 
 #include <linux/isapnp.h>
 
-#define DEV_IO(dev, index) (dev->resource[index].start)
-#define DEV_IRQ(dev, index) (dev->irq_resource[index].start)
-
-#define DEV_NAME(dev) (dev->bus->name ? dev->bus->name : "ISA PnP")
+#define DEV_NAME(dev) (dev->name)
 
 #define GENERIC_HD_DATA                0
 #define GENERIC_HD_ERROR       1
@@ -44,12 +41,12 @@ static int generic_ide_offsets[IDE_NR_PORTS] __initdata = {
 /* ISA PnP device table entry */
 struct pnp_dev_t {
        unsigned short card_vendor, card_device, vendor, device;
-       int (*init_fn)(struct pci_dev *dev, int enable);
+       int (*init_fn)(struct pnp_dev *dev, int enable);
 };
 
 /* Generic initialisation function for ISA PnP IDE interface */
 
-static int __init pnpide_generic_init(struct pci_dev *dev, int enable)
+static int __init pnpide_generic_init(struct pnp_dev *dev, int enable)
 {
        hw_regs_t hw;
        ide_hwif_t *hwif;
@@ -58,21 +55,21 @@ static int __init pnpide_generic_init(struct pci_dev *dev, int enable)
        if (!enable)
                return 0;
 
-       if (!(DEV_IO(dev, 0) && DEV_IO(dev, 1) && DEV_IRQ(dev, 0)))
+       if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0)))
                return 1;
 
-       ide_setup_ports(&hw, (ide_ioreg_t) DEV_IO(dev, 0),
+       ide_setup_ports(&hw, (ide_ioreg_t) pnp_port_start(dev, 0),
                        generic_ide_offsets,
-                       (ide_ioreg_t) DEV_IO(dev, 1),
+                       (ide_ioreg_t) pnp_port_start(dev, 1),
                        0, NULL,
 //                     generic_pnp_ide_iops,
-                       DEV_IRQ(dev, 0));
+                       pnp_irq(dev, 0));
 
        index = ide_register_hw(&hw, &hwif);
 
        if (index != -1) {
                printk(KERN_INFO "ide%d: %s IDE interface\n", index, DEV_NAME(dev));
-               hwif->pci_dev = dev;
+               hwif->pnp_dev = dev;
                return 0;
        }
 
@@ -90,7 +87,7 @@ struct pnp_dev_t idepnp_devices[] __initdata = {
 
 #define NR_PNP_DEVICES 8
 struct pnp_dev_inst {
-       struct pci_dev *dev;
+       struct pnp_dev *dev;
        struct pnp_dev_t *dev_type;
 };
 static struct pnp_dev_inst devices[NR_PNP_DEVICES];
@@ -102,7 +99,7 @@ static int pnp_ide_dev_idx = 0;
 
 void __init pnpide_init(int enable)
 {
-       struct pci_dev *dev = NULL;
+       struct pnp_dev *dev = NULL;
        struct pnp_dev_t *dev_type;
 
        if (!isapnp_present())
@@ -114,33 +111,26 @@ void __init pnpide_init(int enable)
                for (i = 0; i < pnp_ide_dev_idx; i++) {
                        dev = devices[i].dev;
                        devices[i].dev_type->init_fn(dev, 0);
-                       if (dev->deactivate)
-                               dev->deactivate(dev);
+                       pnp_device_detach(dev);
                }
                return;
        }
 
        for (dev_type = idepnp_devices; dev_type->vendor; dev_type++) {
-               while ((dev = isapnp_find_dev(NULL, dev_type->vendor,
+               while ((dev = pnp_find_dev(NULL, dev_type->vendor,
                        dev_type->device, dev))) {
-
-                       if (dev->active)
-                               continue;
-
-                               if (dev->prepare && dev->prepare(dev) < 0) {
-                               printk(KERN_ERR"ide-pnp: %s prepare failed\n", DEV_NAME(dev));
+                       
+                       if (pnp_device_attach(dev) < 0)
                                continue;
-                       }
-
-                       if (dev->activate && dev->activate(dev) < 0) {
+                               
+                       if (pnp_activate_dev(dev, NULL) < 0) {
                                printk(KERN_ERR"ide: %s activate failed\n", DEV_NAME(dev));
                                continue;
                        }
 
                        /* Call device initialization function */
                        if (dev_type->init_fn(dev, 1)) {
-                               if (dev->deactivate(dev))
-                                       dev->deactivate(dev);
+                               pnp_device_detach(dev);
                        } else {
 #ifdef MODULE
                                /*
index ab0b96f2d748d99a67aafad365ccf0891d255ff2..b60e92cec2a8dd809b4c747ce549dce23950af3c 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/init.h>
 #include <linux/gameport.h>
 #include <linux/slab.h>
-#include <linux/isapnp.h>
 #include <linux/stddef.h>
 #include <linux/delay.h>
 
index 8b5f75a27143552e0b08d1f326fbd81cd7f42705..ee58e2bb5eb239718179f069af4b053339700e67 100644 (file)
@@ -194,7 +194,7 @@ static int ns558_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
        int ioport, iolen;
        struct ns558 *port;
 
-       if (!(dev->resource[0].flags & IORESOURCE_IO)) {
+       if (!pnp_port_valid(dev, 0)) {
                printk(KERN_WARNING "ns558: No i/o ports on a gameport? Weird\n");
                return -ENODEV;
        }
index 84c146ba72b45609bc52f0b386d45dfcf5cfea45..83c0bbd5c930f77cbc5b7a242dc7f76f754bc2b2 100644 (file)
@@ -262,7 +262,7 @@ static struct isapnp_device_id asus_ids[] __initdata = {
 };
 
 static struct isapnp_device_id *adev = &asus_ids[0];
-static struct pci_bus *pnp_c __devinitdata = NULL;
+static struct pnp_card *pnp_c __devinitdata = NULL;
 #endif
 
 int __init
@@ -279,29 +279,38 @@ setup_asuscom(struct IsdnCard *card)
                return (0);
 #ifdef __ISAPNP__
        if (!card->para[1] && isapnp_present()) {
-               struct pci_bus *pb;
-               struct pci_dev *pd;
+               struct pnp_card *pb;
+               struct pnp_dev *pd;
 
                while(adev->card_vendor) {
-                       if ((pb = isapnp_find_card(adev->card_vendor,
-                               adev->card_device, pnp_c))) {
+                       if ((pb = pnp_find_card(adev->card_vendor,
+                                               adev->card_device,
+                                               pnp_c))) {
                                pnp_c = pb;
                                pd = NULL;
-                               if ((pd = isapnp_find_dev(pnp_c,
-                                       adev->vendor, adev->function, pd))) {
+                               if ((pd = pnp_find_dev(pnp_c,
+                                                      adev->vendor,
+                                                      adev->function,
+                                                      pd))) {
                                        printk(KERN_INFO "HiSax: %s detected\n",
                                                (char *)adev->driver_data);
-                                       pd->prepare(pd);
-                                       pd->deactivate(pd);
-                                       pd->activate(pd);
-                                       card->para[1] = pd->resource[0].start;
-                                       card->para[0] = pd->irq_resource[0].start;
-                                       if (!card->para[0] || !card->para[1]) {
+                                       if (pnp_device_attach(pd) < 0) {
+                                               printk(KERN_ERR "AsusPnP: attach failed\n");
+                                               return 0;
+                                       }
+                                       if (pnp_activate_dev(pd, NULL) < 0) {
+                                               printk(KERN_ERR "AsusPnP: activate failed\n");
+                                               pnp_device_detach(pd);
+                                               return 0;
+                                       }
+                                       if (!pnp_irq_valid(pd, 0) || !pnp_port_valid(pd, 0)) {
                                                printk(KERN_ERR "AsusPnP:some resources are missing %ld/%lx\n",
-                                               card->para[0], card->para[1]);
-                                               pd->deactivate(pd);
+                                                       pnp_irq(pd, 0), pnp_port_start(pd, 0));
+                                               pnp_device_detach(pd);
                                                return(0);
                                        }
+                                       card->para[1] = pnp_port_start(pd, 0);
+                                       card->para[0] = pnp_irq(pd, 0);
                                        break;
                                } else {
                                        printk(KERN_ERR "AsusPnP: PnP error card found, no device\n");
index 42b9d2fe45c8ff3d3a9adf8aba06964332d42390..29e97538a8428ed4483a28bfff06c2ce208d5d78 100644 (file)
@@ -604,8 +604,8 @@ static struct card_ops avm_pci_ops = {
 
 static struct pci_dev *dev_avm __initdata = NULL;
 #ifdef __ISAPNP__
-static struct pci_bus *bus_avm __initdata = NULL;
-static struct pci_dev *pnp_avm __initdata = NULL;
+static struct pnp_card *card_avm __initdata = NULL;
+static struct pnp_dev *pnp_avm __initdata = NULL;
 #endif
 
 int __init
@@ -627,32 +627,36 @@ setup_avm_pcipnp(struct IsdnCard *card)
        } else {
 #ifdef __ISAPNP__
                if (isapnp_present()) {
-                       struct pci_bus *ba;
-                       if ((ba = isapnp_find_card(
+                       struct pnp_card *ba;
+                       if ((ba = pnp_find_card(
                                ISAPNP_VENDOR('A', 'V', 'M'),
-                               ISAPNP_FUNCTION(0x0900), bus_avm))) {
-                               bus_avm = ba;
+                               ISAPNP_FUNCTION(0x0900), card_avm))) {
+                               card_avm = ba;
                                pnp_avm = NULL;
-                               if ((pnp_avm = isapnp_find_dev(bus_avm,
+                               if ((pnp_avm = pnp_find_dev(card_avm,
                                        ISAPNP_VENDOR('A', 'V', 'M'),
                                        ISAPNP_FUNCTION(0x0900), pnp_avm))) {
-                                       pnp_avm->prepare(pnp_avm);
-                                       pnp_avm->deactivate(pnp_avm);
-                                       pnp_avm->activate(pnp_avm);
-                                       cs->hw.avm.cfg_reg =
-                                               pnp_avm->resource[0].start;
-                                       cs->irq = 
-                                               pnp_avm->irq_resource[0].start;
-                                       if (!cs->irq) {
+                                       if (pnp_device_attach(pnp_avm) < 0) {
+                                               printk(KERN_ERR "FritzPnP: attach failed\n");
+                                               return 0;
+                                       }
+                                       if (pnp_activate_dev(pnp_avm, NULL) < 0) {
+                                               printk(KERN_ERR "FritzPnP: activate failed\n");
+                                               pnp_device_detach(pnp_avm);
+                                               return 0;
+                                       }
+                                       if (!pnp_irq_valid(pnp_avm, 0)) {
                                                printk(KERN_ERR "FritzPnP:No IRQ\n");
-                                               pnp_avm->deactivate(pnp_avm);
+                                               pnp_device_detach(pnp_avm);
                                                return(0);
                                        }
-                                       if (!cs->hw.avm.cfg_reg) {
+                                       if (!pnp_port_valid(pnp_avm, 0)) {
                                                printk(KERN_ERR "FritzPnP:No IO address\n");
-                                               pnp_avm->deactivate(pnp_avm);
+                                               pnp_device_detach(pnp_avm);
                                                return(0);
                                        }
+                                       cs->hw.avm.cfg_reg = pnp_port_start(pnp_avm, 0);
+                                       cs->irq = pnp_irq(pnp_avm, 0);
                                        cs->subtyp = AVM_FRITZ_PNP;
                                        goto ready;
                                }
index 766537762bab5927a10ae79ad84c72232c09f7e1..b5e7cf7bf5f3687014c3a1051b9a237348e90b1f 100644 (file)
@@ -606,7 +606,7 @@ static struct isapnp_device_id diva_ids[] __initdata = {
 };
 
 static struct isapnp_device_id *pdev = &diva_ids[0];
-static struct pci_bus *pnp_c __devinitdata = NULL;
+static struct pnp_card *pnp_c __devinitdata = NULL;
 #endif
 
 
@@ -648,31 +648,38 @@ setup_diva(struct IsdnCard *card)
        } else {
 #ifdef __ISAPNP__
                if (isapnp_present()) {
-                       struct pci_bus *pb;
-                       struct pci_dev *pd;
+                       struct pnp_card *pb;
+                       struct pnp_dev *pd;
 
                        while(pdev->card_vendor) {
-                               if ((pb = isapnp_find_card(pdev->card_vendor,
-                                       pdev->card_device, pnp_c))) {
+                               if ((pb = pnp_find_card(pdev->card_vendor,
+                                                       pdev->card_device,
+                                                       pnp_c))) {
                                        pnp_c = pb;
                                        pd = NULL;
-                                       if ((pd = isapnp_find_dev(pnp_c,
-                                               pdev->vendor, pdev->function, pd))) {
+                                       if ((pd = pnp_find_dev(pnp_c,
+                                                              pdev->vendor,
+                                                              pdev->function,
+                                                              pd))) {
                                                printk(KERN_INFO "HiSax: %s detected\n",
                                                        (char *)pdev->driver_data);
-                                               pd->prepare(pd);
-                                               pd->deactivate(pd);
-                                               pd->activate(pd);
-                                               card->para[1] =
-                                                       pd->resource[0].start;
-                                               card->para[0] =
-                                                       pd->irq_resource[0].start;
-                                               if (!card->para[0] || !card->para[1]) {
+                                               if (pnp_device_attach(pd) < 0) {
+                                                       printk(KERN_ERR "Diva PnP: attach failed\n");
+                                                       return 0;
+                                               }
+                                               if (pnp_activate_dev(pd, NULL) < 0) {
+                                                       printk(KERN_ERR "Diva PnP: activate failed\n");
+                                                       pnp_device_detach(pd);
+                                                       return 0;
+                                               }
+                                               if (!pnp_irq_valid(pd, 0) || !pnp_port_valid(pd, 0)) {
                                                        printk(KERN_ERR "Diva PnP:some resources are missing %ld/%lx\n",
-                                                               card->para[0], card->para[1]);
-                                                       pd->deactivate(pd);
+                                                               pnp_irq(pd, 0), pnp_port_start(pd, 0));
+                                                       pnp_device_detach(pd);
                                                        return(0);
                                                }
+                                               card->para[1] = pnp_port_start(pd, 0);
+                                               card->para[0] = pnp_irq(pd, 0);
                                                cs->hw.diva.cfg_reg  = card->para[1];
                                                cs->irq = card->para[0];
                                                if (pdev->function == ISAPNP_FUNCTION(0xA1)) {
index 8c4c70ec9ab03aa88676411486879eab3e6b51bd..b2917064c3cb748dd88ebe5e623b97cdb2cffe21 100644 (file)
@@ -825,7 +825,7 @@ static struct isapnp_device_id elsa_ids[] __initdata = {
 };
 
 static struct isapnp_device_id *pdev = &elsa_ids[0];
-static struct pci_bus *pnp_c __devinitdata = NULL;
+static struct pnp_card *pnp_c __devinitdata = NULL;
 #endif
 
 int __devinit
@@ -905,31 +905,39 @@ setup_elsa(struct IsdnCard *card)
        } else if (cs->typ == ISDN_CTYPE_ELSA_PNP) {
 #ifdef __ISAPNP__
                if (!card->para[1] && isapnp_present()) {
-                       struct pci_bus *pb;
-                       struct pci_dev *pd;
+                       struct pnp_card *pb;
+                       struct pnp_dev *pd;
 
                        while(pdev->card_vendor) {
-                               if ((pb = isapnp_find_card(pdev->card_vendor,
-                                       pdev->card_device, pnp_c))) {
+                               if ((pb = pnp_find_card(pdev->card_vendor,
+                                                       pdev->card_device,
+                                                       pnp_c))) {
                                        pnp_c = pb;
                                        pd = NULL;
-                                       if ((pd = isapnp_find_dev(pnp_c,
-                                               pdev->vendor, pdev->function, pd))) {
+                                       if ((pd = pnp_find_dev(pnp_c,
+                                                              pdev->vendor,
+                                                              pdev->function,
+                                                              pd))) {
                                                printk(KERN_INFO "HiSax: %s detected\n",
                                                        (char *)pdev->driver_data);
-                                               pd->prepare(pd);
-                                               pd->deactivate(pd);
-                                               pd->activate(pd);
-                                               card->para[1] =
-                                                       pd->resource[0].start;
-                                               card->para[0] =
-                                                       pd->irq_resource[0].start;
-                                               if (!card->para[0] || !card->para[1]) {
+                                               if (pnp_device_attach(pd) < 0) {
+                                                       printk(KERN_ERR "Elsa PnP: attach failed\n");
+                                                       return 0;
+                                               }
+                                               if (pnp_activate_dev(pd, NULL) < 0) {
+                                                       pnp_device_detach(pd);
+                                                       printk(KERN_ERR "Elsa PnP: activate failed\n");
+                                                       return 0;
+                                               }
+                                               if (!pnp_port_valid(pd, 0) ||
+                                                   !pnp_irq_valid(pd, 0)) {
                                                        printk(KERN_ERR "Elsa PnP:some resources are missing %ld/%lx\n",
-                                                               card->para[0], card->para[1]);
-                                                       pd->deactivate(pd);
+                                                              pnp_irq(pd, 0), pnp_port_start(pd, 0));
+                                                       pnp_device_detach(pd);
                                                        return(0);
                                                }
+                                               card->para[1] = pnp_port_start(pd, 0);
+                                               card->para[0] = pnp_irq(pd, 0);
                                                if (pdev->function == ISAPNP_FUNCTION(0x133))
                                                        cs->subtyp = ELSA_QS1000;
                                                else
index bc0cd86bf3345b24eaf9aee4230ed0aed83e3a22..611bedb5f3bd7d037e5aff46fa8aac3556a2fb78 100644 (file)
@@ -1179,7 +1179,7 @@ static struct isapnp_device_id hfc_ids[] __initdata = {
 };
 
 static struct isapnp_device_id *hdev = &hfc_ids[0];
-static struct pci_bus *pnp_c __devinitdata = NULL;
+static struct pnp_card *pnp_c __devinitdata = NULL;
 #endif
 
 int __devinit
@@ -1192,29 +1192,38 @@ setup_hfcsx(struct IsdnCard *card)
        printk(KERN_INFO "HiSax: HFC-SX driver Rev. %s\n", HiSax_getrev(tmp));
 #ifdef __ISAPNP__
        if (!card->para[1] && isapnp_present()) {
-               struct pci_bus *pb;
-               struct pci_dev *pd;
+               struct pnp_card *pb;
+               struct pnp_dev  *pd;
 
                while(hdev->card_vendor) {
-                       if ((pb = isapnp_find_card(hdev->card_vendor,
-                               hdev->card_device, pnp_c))) {
+                       if ((pb = pnp_find_card(hdev->card_vendor,
+                                               hdev->card_device,
+                                               pnp_c))) {
                                pnp_c = pb;
                                pd = NULL;
-                               if ((pd = isapnp_find_dev(pnp_c,
-                                       hdev->vendor, hdev->function, pd))) {
+                               if ((pd = pnp_find_dev(pnp_c,
+                                                      hdev->vendor,
+                                                      hdev->function,
+                                                      pd))) {
                                        printk(KERN_INFO "HiSax: %s detected\n",
                                                (char *)hdev->driver_data);
-                                       pd->prepare(pd);
-                                       pd->deactivate(pd);
-                                       pd->activate(pd);
-                                       card->para[1] = pd->resource[0].start;
-                                       card->para[0] = pd->irq_resource[0].start;
-                                       if (!card->para[0] || !card->para[1]) {
+                                       if (pnp_device_attach(pd) < 0) {
+                                               printk(KERN_ERR "HFC PnP: attach failed\n");
+                                               return 0;
+                                       }
+                                       if (pnp_activate_dev(pd, NULL) < 0) {
+                                               printk(KERN_ERR "HFC PnP: activate failed\n");
+                                               pnp_device_detach(pd);
+                                               return 0;
+                                       }
+                                       if (!pnp_irq_valid(pd, 0) || !pnp_port_valid(pd, 0)) {
                                                printk(KERN_ERR "HFC PnP:some resources are missing %ld/%lx\n",
-                                               card->para[0], card->para[1]);
-                                               pd->deactivate(pd);
+                                                       pnp_irq(pd, 0), pnp_port_start(pd, 0));
+                                               pnp_device_detach(pd);
                                                return(0);
                                        }
+                                       card->para[1] = pnp_port_start(pd, 0);
+                                       card->para[0] = pnp_irq(pd, 0);
                                        break;
                                } else {
                                        printk(KERN_ERR "HFC PnP: PnP error card found, no device\n");
index d6e824ec66012510e8f1c582026abc101a9a45be..e309c578df115e008f65c36c324a5fa92ddf825b 100644 (file)
@@ -167,7 +167,7 @@ static struct isapnp_device_id hfc_ids[] __initdata = {
 };
 
 static struct isapnp_device_id *hdev = &hfc_ids[0];
-static struct pci_bus *pnp_c __devinitdata = NULL;
+static struct pnp_card *pnp_c __devinitdata = NULL;
 #endif
 
 int __init
@@ -181,29 +181,38 @@ setup_hfcs(struct IsdnCard *card)
 
 #ifdef __ISAPNP__
        if (!card->para[1] && isapnp_present()) {
-               struct pci_bus *pb;
-               struct pci_dev *pd;
+               struct pnp_card *pb;
+               struct pnp_dev *pd;
 
                while(hdev->card_vendor) {
-                       if ((pb = isapnp_find_card(hdev->card_vendor,
-                               hdev->card_device, pnp_c))) {
+                       if ((pb = pnp_find_card(hdev->card_vendor,
+                                               hdev->card_device,
+                                               pnp_c))) {
                                pnp_c = pb;
                                pd = NULL;
-                               if ((pd = isapnp_find_dev(pnp_c,
-                                       hdev->vendor, hdev->function, pd))) {
+                               if ((pd = pnp_find_dev(pnp_c,
+                                                      hdev->vendor,
+                                                      hdev->function,
+                                                      pd))) {
                                        printk(KERN_INFO "HiSax: %s detected\n",
                                                (char *)hdev->driver_data);
-                                       pd->prepare(pd);
-                                       pd->deactivate(pd);
-                                       pd->activate(pd);
-                                       card->para[1] = pd->resource[0].start;
-                                       card->para[0] = pd->irq_resource[0].start;
-                                       if (!card->para[0] || !card->para[1]) {
+                                       if (pnp_device_attach(pd) < 0) {
+                                               printk(KERN_ERR "HFC PnP: attach failed\n");
+                                               return 0;
+                                       }
+                                       if (pnp_activate_dev(pd, NULL) < 0) {
+                                               printk(KERN_ERR "HFC PnP: activate failed\n");
+                                               pnp_device_detach(pd);
+                                               return 0;
+                                       }
+                                       if (!pnp_irq_valid(pd, 0) || !pnp_port_valid(pd, 0)) {
                                                printk(KERN_ERR "HFC PnP:some resources are missing %ld/%lx\n",
-                                               card->para[0], card->para[1]);
-                                               pd->deactivate(pd);
+                                                       pnp_irq(pd, 0), pnp_port_start(pd, 0));
+                                               pnp_device_detach(pd);
                                                return(0);
                                        }
+                                       card->para[1] = pnp_port_start(pd, 0);
+                                       card->para[0] = pnp_irq(pd, 0);
                                        break;
                                } else {
                                        printk(KERN_ERR "HFC PnP: PnP error card found, no device\n");
index 2010c8614bfb2f019d2595379a09626859f2d4e8..b50b715351edb8a3d3e0b118e359add9c2d36a61 100644 (file)
@@ -27,7 +27,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/pci.h>
-#include <linux/isapnp.h>
+#include <linux/pnp.h>
 #include <linux/kmod.h>
 #include <linux/slab.h>
 #include <linux/skbuff.h>
@@ -55,13 +55,11 @@ static struct pci_device_id fcpci_ids[] __devinitdata = {
 };
 MODULE_DEVICE_TABLE(pci, fcpci_ids);
 
-static struct isapnp_device_id fcpnp_ids[] __devinitdata = {
-       { ISAPNP_VENDOR('A', 'V', 'M'), ISAPNP_FUNCTION(0x0900),
-         ISAPNP_VENDOR('A', 'V', 'M'), ISAPNP_FUNCTION(0x0900), 
-         (unsigned long) "Fritz!Card PnP" },
-       { }
+static const struct pnp_card_id fcpnp_ids[] __devinitdata = {
+       { .id = "AVM0900", .driver_data = (unsigned long) "Fritz!Card PnP",
+         .devs = { { "AVM0900" } } }
 };
-MODULE_DEVICE_TABLE(isapnp, fcpnp_ids);
+MODULE_DEVICE_TABLE(pnpc, fcpnp_ids);
 
 static int protocol = 2;       /* EURO-ISDN Default */
 MODULE_PARM(protocol, "i");
@@ -908,50 +906,47 @@ static struct pci_driver fcpci_driver = {
 
 #ifdef __ISAPNP__
 
-static int __devinit fcpnp_probe(struct pci_dev *pdev,
-                                const struct isapnp_device_id *ent)
+static int __devinit fcpnp_probe(struct pnp_card *card,
+                                const struct pnp_card_id *card_id)
 {
        struct fritz_adapter *adapter;
-       int retval;
+       struct pnp_dev *pnp_dev;
+
+       pnp_dev = pnp_request_card_device(card, card_id->devs[0], NULL);
+       if (pnp_dev == NULL)
+               return;
 
-       retval = -ENOMEM;
        adapter = new_adapter(pdev);
        if (!adapter)
-               goto err;
+               return -ENOMEM;
 
        adapter->type = AVM_FRITZ_PNP;
 
-       pdev->prepare(pdev);
-       pdev->deactivate(pdev); // why?
-       pdev->activate(pdev);
-       adapter->io = pdev->resource[0].start;
-       adapter->irq = pdev->irq_resource[0].start;
+       if (!pnp_port_valid(pnp_dev, 0) || !pnp_irq_valid(pnp_dev, 0)) {
+               delete_adapter(adapter);
+       adapter->io = pnp_port_start(pnp_dev, 0);
+       adapter->irq = pnp_irq(pnp_dev, 0);
 
        printk(KERN_INFO "hisax_fcpcipnp: found adapter %s at IO %#x irq %d\n",
-              (char *) ent->driver_data, adapter->io, adapter->irq);
+               (char *) card_id->driver_data, adapter->io, adapter->irq);
 
        retval = fcpcipnp_setup(adapter);
-       if (retval)
-               goto err_free;
-
+       if (retval) {
+               delete_adapter(adapter);
+               return retval;
+       }
        return 0;
-       
- err_free:
-       delete_adapter(adapter);
- err:
-       return retval;
 }
 
-static void __devexit fcpnp_remove(struct pci_dev *pdev)
+static void __devexit fcpnp_remove(struct pnp_card *pcard)
 {
-       struct fritz_adapter *adapter = pci_get_drvdata(pdev);
+       struct fritz_adapter *adapter = pci_get_drvdata(pcard);
 
        fcpcipnp_release(adapter);
-       pdev->deactivate(pdev);
        delete_adapter(adapter);
 }
 
-static struct isapnp_driver fcpnp_driver = {
+static struct pnpc_driver fcpnp_driver = {
        .name     = "fcpnp",
        .probe    = fcpnp_probe,
        .remove   = __devexit_p(fcpnp_remove),
@@ -972,7 +967,7 @@ static int __init hisax_fcpcipnp_init(void)
        pci_nr_found = retval;
 
 #ifdef __ISAPNP__
-       retval = isapnp_register_driver(&fcpnp_driver);
+       retval = pnpc_register_driver(&fcpnp_driver);
 #else
        retval = 0;
 #endif
@@ -990,7 +985,7 @@ static int __init hisax_fcpcipnp_init(void)
 #if !defined(CONFIG_HOTPLUG) || defined(MODULE)
  out_unregister_isapnp:
 #ifdef __ISAPNP__
-       isapnp_unregister_driver(&fcpnp_driver);
+       pnpc_unregister_driver(&fcpnp_driver);
 #endif
 #endif
  out_unregister_pci:
index 3a244a3eda7acf8f2d1fe6e0a01f530e261c2c2f..d9ec6f26030db053cbd7a175c5f8fc214dc771be 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/pci.h>
-#include <linux/isapnp.h>
 #include <linux/kmod.h>
 #include <linux/slab.h>
 #include <linux/skbuff.h>
index 9a14493a92d68dd49127d246ef6445b2d48e7806..0166fc8a81109ee094c0fad8459ff00376c48aa4 100644 (file)
@@ -198,7 +198,7 @@ static struct card_ops isurf_ops = {
 };
 
 #ifdef __ISAPNP__
-static struct pci_bus *pnp_surf __devinitdata = NULL;
+static struct pnp_card *pnp_surf __devinitdata = NULL;
 #endif
 
 int __init
@@ -219,34 +219,40 @@ setup_isurf(struct IsdnCard *card)
                cs->irq = card->para[0];
        } else {
 #ifdef __ISAPNP__
-               struct pci_bus *pb;
-               struct pci_dev *pd;
+               struct pnp_card *pb;
+               struct pnp_dev *pd;
 
                if (isapnp_present()) {
                        cs->subtyp = 0;
-                       if ((pb = isapnp_find_card(
+                       if ((pb = pnp_find_card(
                                ISAPNP_VENDOR('S', 'I', 'E'),
                                ISAPNP_FUNCTION(0x0010), pnp_surf))) {
                                pnp_surf = pb;
                                pd = NULL;
-                               if (!(pd = isapnp_find_dev(pnp_surf,
+                               if (!(pd = pnp_find_dev(pnp_surf,
                                        ISAPNP_VENDOR('S', 'I', 'E'),
                                        ISAPNP_FUNCTION(0x0010), pd))) {
                                        printk(KERN_ERR "ISurfPnP: PnP error card found, no device\n");
                                        return (0);
                                }
-                               pd->prepare(pd);
-                               pd->deactivate(pd);
-                               pd->activate(pd);
-                               cs->hw.isurf.reset = pd->resource[0].start;
-                               cs->hw.isurf.phymem = pd->resource[1].start;
-                               cs->irq = pd->irq_resource[0].start;
-                               if (!cs->irq || !cs->hw.isurf.reset || !cs->hw.isurf.phymem) {
-                                       printk(KERN_ERR "ISurfPnP:some resources are missing %d/%x/%lx\n",
-                                               cs->irq, cs->hw.isurf.reset, cs->hw.isurf.phymem);
-                                       pd->deactivate(pd);
+                               if (pnp_device_attach(pd) < 0) {
+                                       printk(KERN_ERR "ISurfPnP: attach failed\n");
+                                       return 0;
+                               }
+                               if (pnp_activate_dev(pd, NULL) < 0) {
+                                       printk(KERN_ERR "ISurfPnP: activate failed\n");
+                                       pnp_device_detach(pd);
+                                       return 0;
+                               }
+                               if (!pnp_irq_valid(pd, 0) || !pnp_port_valid(pd, 0) || !pnp_port_valid(pd, 1)) {
+                                       printk(KERN_ERR "ISurfPnP:some resources are missing %ld/%lx/%lx\n",
+                                               pnp_irq(pd, 0), pnp_port_start(pd, 0), pnp_port_start(pd, 1));
+                                       pnp_device_detach(pd);
                                        return(0);
                                }
+                               cs->hw.isurf.reset = pnp_port_start(pd, 0);
+                               cs->hw.isurf.phymem = pnp_port_start(pd, 1);
+                               cs->irq = pnp_irq(pd, 0);
                        } else {
                                printk(KERN_INFO "ISurfPnP: no ISAPnP card found\n");
                                return(0);
index 168b2fd1fca16a377b6f05c6e1973de6008c2136..6697b8ff4b7004e42ac823b905eba4d49d91f0a8 100644 (file)
@@ -187,7 +187,7 @@ static struct isapnp_device_id itk_ids[] __initdata = {
 };
 
 static struct isapnp_device_id *idev = &itk_ids[0];
-static struct pci_bus *pnp_c __devinitdata = NULL;
+static struct pnp_card *pnp_c __devinitdata = NULL;
 #endif
 
 
@@ -204,29 +204,38 @@ setup_ix1micro(struct IsdnCard *card)
 
 #ifdef __ISAPNP__
        if (!card->para[1] && isapnp_present()) {
-               struct pci_bus *pb;
-               struct pci_dev *pd;
+               struct pnp_card *pb;
+               struct pnp_dev *pd;
 
                while(idev->card_vendor) {
-                       if ((pb = isapnp_find_card(idev->card_vendor,
-                               idev->card_device, pnp_c))) {
+                       if ((pb = pnp_find_card(idev->card_vendor,
+                                               idev->card_device,
+                                               pnp_c))) {
                                pnp_c = pb;
                                pd = NULL;
-                               if ((pd = isapnp_find_dev(pnp_c,
-                                       idev->vendor, idev->function, pd))) {
+                               if ((pd = pnp_find_dev(pnp_c,
+                                                      idev->vendor,
+                                                      idev->function,
+                                                      pd))) {
                                        printk(KERN_INFO "HiSax: %s detected\n",
                                                (char *)idev->driver_data);
-                                       pd->prepare(pd);
-                                       pd->deactivate(pd);
-                                       pd->activate(pd);
-                                       card->para[1] = pd->resource[0].start;
-                                       card->para[0] = pd->irq_resource[0].start;
-                                       if (!card->para[0] || !card->para[1]) {
+                                       if (pnp_device_attach(pd) < 0) {
+                                               printk(KERN_ERR "ITK PnP: attach failed\n");
+                                               return 0;
+                                       }
+                                       if (pnp_activate_dev(pd, NULL) < 0) {
+                                               printk(KERN_ERR "ITK PnP: activate failed\n");
+                                               pnp_device_detach(pd);
+                                               return 0;
+                                       }
+                                       if (!pnp_port_valid(pd, 0) || !pnp_irq_valid(pd, 0)) {
                                                printk(KERN_ERR "ITK PnP:some resources are missing %ld/%lx\n",
-                                               card->para[0], card->para[1]);
-                                               pd->deactivate(pd);
+                                                       pnp_irq(pd, 0), pnp_port_start(pd, 0));
+                                               pnp_device_detach(pd);
                                                return(0);
                                        }
+                                       card->para[1] = pnp_port_start(pd, 0);
+                                       card->para[0] = pnp_irq(pd, 0);
                                        break;
                                } else {
                                        printk(KERN_ERR "ITK PnP: PnP error card found, no device\n");
index c2df12b7ba0cee3af74b8e3d4c37acc0442f02e4..cb7d7194673fdd4e6e29c03414e5136d7af41c9e 100644 (file)
@@ -211,7 +211,7 @@ static struct card_ops niccy_ops = {
 
 static struct pci_dev *niccy_dev __initdata = NULL;
 #ifdef __ISAPNP__
-static struct pci_bus *pnp_c __devinitdata = NULL;
+static struct pnp_card *pnp_c __devinitdata = NULL;
 #endif
 
 int __init
@@ -226,32 +226,38 @@ setup_niccy(struct IsdnCard *card)
                return (0);
 #ifdef __ISAPNP__
        if (!card->para[1] && isapnp_present()) {
-               struct pci_bus *pb;
-               struct pci_dev *pd;
+               struct pnp_card *pb;
+               struct pnp_dev  *pd;
 
-               if ((pb = isapnp_find_card(
+               if ((pb = pnp_find_card(
                        ISAPNP_VENDOR('S', 'D', 'A'),
                        ISAPNP_FUNCTION(0x0150), pnp_c))) {
                        pnp_c = pb;
                        pd = NULL;
-                       if (!(pd = isapnp_find_dev(pnp_c,
+                       if (!(pd = pnp_find_dev(pnp_c,
                                ISAPNP_VENDOR('S', 'D', 'A'),
                                ISAPNP_FUNCTION(0x0150), pd))) {
                                printk(KERN_ERR "NiccyPnP: PnP error card found, no device\n");
                                return (0);
                        }
-                       pd->prepare(pd);
-                       pd->deactivate(pd);
-                       pd->activate(pd);
-                       card->para[1] = pd->resource[0].start;
-                       card->para[2] = pd->resource[1].start;
-                       card->para[0] = pd->irq_resource[0].start;
-                       if (!card->para[0] || !card->para[1] || !card->para[2]) {
+                       if (pnp_device_attach(pd) < 0) {
+                               printk(KERN_ERR "NiccyPnP: attach failed\n");
+                               return 0;
+                       }
+                       if (pnp_activate_dev(pd, NULL) < 0) {
+                               printk(KERN_ERR "NiccyPnP: activate failed\n");
+                               pnp_device_detach(pd);
+                               return 0;
+                       }
+                       if (!pnp_irq_valid(pd, 0) || !pnp_port_valid(pd, 0) || !pnp_port_valid(pd, 1)) {
                                printk(KERN_ERR "NiccyPnP:some resources are missing %ld/%lx/%lx\n",
-                                       card->para[0], card->para[1], card->para[2]);
-                               pd->deactivate(pd);
+                                       pnp_irq(pd, 0), pnp_port_start(pd, 0), pnp_port_start(pd, 1));
+                               pnp_device_detach(pd);
                                return(0);
                        }
+                       card->para[1] = pnp_port_start(pd, 0);
+                       card->para[2] = pnp_port_start(pd, 1);
+                       card->para[0] = pnp_irq(pd, 0);
                } else {
                        printk(KERN_INFO "NiccyPnP: no ISAPnP card found\n");
                }
index d85d37bee8ed5414040d52c5226bfb56ba849f56..218bb876c7bcf4b35b829a246a8fa3a57f854e54 100644 (file)
@@ -484,7 +484,7 @@ static struct isapnp_device_id sedl_ids[] __initdata = {
 };
 
 static struct isapnp_device_id *pdev = &sedl_ids[0];
-static struct pci_bus *pnp_c __devinitdata = NULL;
+static struct pnp_card *pnp_c __devinitdata = NULL;
 #endif
 
 int __devinit
@@ -523,31 +523,38 @@ setup_sedlbauer(struct IsdnCard *card)
        } else {
 #ifdef __ISAPNP__
                if (isapnp_present()) {
-                       struct pci_bus *pb;
-                       struct pci_dev *pd;
+                       struct pnp_card *pb;
+                       struct pnp_dev *pd;
 
                        while(pdev->card_vendor) {
-                               if ((pb = isapnp_find_card(pdev->card_vendor,
-                                       pdev->card_device, pnp_c))) {
+                               if ((pb = pnp_find_card(pdev->card_vendor,
+                                                       pdev->card_device,
+                                                       pnp_c))) {
                                        pnp_c = pb;
                                        pd = NULL;
-                                       if ((pd = isapnp_find_dev(pnp_c,
-                                               pdev->vendor, pdev->function, pd))) {
+                                       if ((pd = pnp_find_dev(pnp_c,
+                                                              pdev->vendor,
+                                                              pdev->function,
+                                                              pd))) {
                                                printk(KERN_INFO "HiSax: %s detected\n",
                                                        (char *)pdev->driver_data);
-                                               pd->prepare(pd);
-                                               pd->deactivate(pd);
-                                               pd->activate(pd);
-                                               card->para[1] =
-                                                       pd->resource[0].start;
-                                               card->para[0] =
-                                                       pd->irq_resource[0].start;
-                                               if (!card->para[0] || !card->para[1]) {
+                                               if (pnp_device_attach(pd) < 0) {
+                                                       printk(KERN_ERR "Sedlbauer PnP: attach failed\n");
+                                                       return 0;
+                                               }
+                                               if (pnp_activate_dev(pd, NULL) < 0) {
+                                                       printk(KERN_ERR "Sedlbauer PnP: activate failed\n");
+                                                       pnp_device_detach(pd);
+                                                       return 0;
+                                               }
+                                               if (!pnp_irq_valid(pd, 0) || !pnp_port_valid(pd, 0)) {
                                                        printk(KERN_ERR "Sedlbauer PnP:some resources are missing %ld/%lx\n",
-                                                               card->para[0], card->para[1]);
-                                                       pd->deactivate(pd);
+                                                               pnp_irq(pd, 0), pnp_port_start(pd, 0));
+                                                       pnp_device_detach(pd);
                                                        return(0);
                                                }
+                                               card->para[1] = pnp_port_start(pd, 0);
+                                               card->para[0] = pnp_irq(pd, 0);
                                                cs->hw.sedl.cfg_reg = card->para[1];
                                                cs->irq = card->para[0];
                                                if (pdev->function == ISAPNP_FUNCTION(0x2)) {
index 7821bc3a7017ac460a4a7481977150fc872f1282..6205f1efd34537eb8719e0197b74ee2a7f7a25e1 100644 (file)
@@ -225,7 +225,7 @@ static struct isapnp_device_id teles_ids[] __initdata = {
 };
 
 static struct isapnp_device_id *tdev = &teles_ids[0];
-static struct pci_bus *pnp_c __devinitdata = NULL;
+static struct pnp_card *pnp_c __devinitdata = NULL;
 #endif
 
 int __devinit
@@ -243,31 +243,41 @@ setup_teles3(struct IsdnCard *card)
 
 #ifdef __ISAPNP__
        if (!card->para[1] && isapnp_present()) {
-               struct pci_bus *pb;
-               struct pci_dev *pd;
+               struct pnp_card *pnp_card;
+               struct pnp_dev *pnp_dev;
 
                while(tdev->card_vendor) {
-                       if ((pb = isapnp_find_card(tdev->card_vendor,
-                               tdev->card_device, pnp_c))) {
-                               pnp_c = pb;
-                               pd = NULL;
-                               if ((pd = isapnp_find_dev(pnp_c,
-                                       tdev->vendor, tdev->function, pd))) {
+                       if ((pnp_card = pnp_find_card(tdev->card_vendor,
+                                                     tdev->card_device, pnp_c))) {
+                               pnp_c = pnp_card;
+                               pnp_dev = NULL;
+                               if ((pnp_dev = pnp_find_dev(pnp_card,
+                                                           tdev->vendor,
+                                                           tdev->function,
+                                                           pnp_dev))) {
                                        printk(KERN_INFO "HiSax: %s detected\n",
                                                (char *)tdev->driver_data);
-                                       pd->prepare(pd);
-                                       pd->deactivate(pd);
-                                       pd->activate(pd);
-                                       card->para[3] = pd->resource[2].start;
-                                       card->para[2] = pd->resource[1].start;
-                                       card->para[1] = pd->resource[0].start;
-                                       card->para[0] = pd->irq_resource[0].start;
-                                       if (!card->para[0] || !card->para[1] || !card->para[2]) {
-                                               printk(KERN_ERR "Teles PnP:some resources are missing %ld/%lx/%lx\n",
-                                               card->para[0], card->para[1], card->para[2]);
-                                               pd->deactivate(pd);
-                                               return(0);
+                                       if (pnp_device_attach(pnp_dev) < 0) {
+                                               printk(KERN_ERR "Teles PnP: attach failed\n");
+                                               return 0;
                                        }
+                                       if (pnp_activate_dev(pnp_dev, NULL) < 0) {
+                                               printk(KERN_ERR "Teles PnP: activate failed\n");
+                                               pnp_device_detach(pnp_dev);
+                                               return 0;
+                                       }
+                                       if (!pnp_irq_valid(pnp_dev, 0) ||
+                                           !pnp_port_valid(pnp_dev, 0) ||
+                                           !pnp_port_valid(pnp_dev, 1)) {
+                                               printk(KERN_ERR "Teles PnP: some resources are missing %ld/%lx/%lx\n",
+                                                       pnp_irq(pnp_dev, 0), pnp_port_start(pnp_dev, 0), pnp_port_start(pnp_dev, 1));
+                                               pnp_device_detach(pnp_dev);
+                                               return 0;
+                                       }
+                                       card->para[3] = pnp_port_start(pnp_dev, 2);
+                                       card->para[2] = pnp_port_start(pnp_dev, 1);
+                                       card->para[1] = pnp_port_start(pnp_dev, 0);
+                                       card->para[0] = pnp_irq(pnp_dev, 0);
                                        break;
                                } else {
                                        printk(KERN_ERR "Teles PnP: PnP error card found, no device\n");
index 8a2de2bb471c945eb7463e569dfbe74c357a9bf6..7ac2ad722baf120ea057f71b363fc185bc035586 100644 (file)
@@ -47,7 +47,7 @@ static unsigned char rdsbuf[RDS_BUFFER];
 static int cadet_lock=0;
 
 static int cadet_probe(void);
-static struct pci_dev *dev;
+static struct pnp_dev *dev = NULL;
 static int isapnp_cadet_probe(void);
 
 /*
@@ -543,23 +543,26 @@ static struct video_device cadet_radio=
 
 static int isapnp_cadet_probe(void)
 {
-       dev = isapnp_find_dev (NULL, ISAPNP_VENDOR('M','S','M'),
-                              ISAPNP_FUNCTION(0x0c24), NULL);
+       dev = pnp_find_dev (NULL, ISAPNP_VENDOR('M','S','M'),
+                           ISAPNP_FUNCTION(0x0c24), NULL);
 
        if (!dev)
                return -ENODEV;
-       if (dev->prepare(dev)<0)
+       if (pnp_device_attach(dev) < 0)
                return -EAGAIN;
-       if (!(dev->resource[0].flags & IORESOURCE_IO))
+       if (pnp_activate_dev(dev, NULL) < 0) {
+               printk ("radio-cadet: pnp configure failed (out of resources?)\n");
+               pnp_device_detach(dev);
+               return -EIO;
+       }
+       if (!pnp_port_valid(dev, 0)) {
+               pnp_device_detach(dev);
                return -ENODEV;
-       if (dev->activate(dev)<0) {
-               printk ("radio-cadet: isapnp configure failed (out of resources?)\n");
-               return -ENOMEM;
        }
 
-       io = dev->resource[0].start;
+       io = pnp_port_start(dev, 0);
 
-       printk ("radio-cadet: ISAPnP reports card at %#x\n", io);
+       printk ("radio-cadet: PnP reports device at %#x\n", io);
 
        return io;
 }
@@ -645,7 +648,7 @@ static void __exit cadet_cleanup_module(void)
        release_region(io,2);
 
        if (dev)
-               dev->deactivate(dev);
+               pnp_device_detach(dev);
 }
 
 module_init(cadet_init);
index 53c8509ba8f2add66e267d2efcf4d87e6e5fa661..4eae614b4b005c0c640f091f569a1527bb4259dd 100644 (file)
@@ -36,7 +36,7 @@ struct fmi_device
 
 static int io = -1; 
 static int radio_nr = -1;
-static struct pci_dev *dev = NULL;
+static struct pnp_dev *dev = NULL;
 static struct semaphore lock;
 
 /* freq is in 1/16 kHz to internal number, hw precision is 50 kHz */
@@ -253,24 +253,27 @@ static int isapnp_fmi_probe(void)
        int i = 0;
 
        while (id_table[i].card_vendor != 0 && dev == NULL) {
-               dev = isapnp_find_dev(NULL, id_table[i].vendor,
-                                     id_table[i].function, NULL);
+               dev = pnp_find_dev(NULL, id_table[i].vendor,
+                                  id_table[i].function, NULL);
                i++;
        }
 
        if (!dev)
                return -ENODEV;
-       if (dev->prepare(dev) < 0)
+       if (pnp_device_attach(dev) < 0)
                return -EAGAIN;
-       if (!(dev->resource[0].flags & IORESOURCE_IO))
-               return -ENODEV;
-       if (dev->activate(dev) < 0) {
-               printk ("radio-sf16fmi: ISAPnP configure failed (out of resources?)\n");
+       if (pnp_activate_dev(dev, NULL) < 0) {
+               printk ("radio-sf16fmi: PnP configure failed (out of resources?)\n");
+               pnp_device_detach(dev);
                return -ENOMEM;
        }
+       if (!pnp_port_valid(dev, 0)) {
+               pnp_device_detach(dev);
+               return -ENODEV;
+       }
 
-       i = dev->resource[0].start;
-       printk ("radio-sf16fmi: ISAPnP reports card at %#x\n", i);
+       i = pnp_port_start(dev, 0);
+       printk ("radio-sf16fmi: PnP reports card at %#x\n", i);
 
        return i;
 }
@@ -320,7 +323,7 @@ static void __exit fmi_cleanup_module(void)
        video_unregister_device(&fmi_radio);
        release_region(io, 2);
        if (dev)
-               dev->deactivate(dev);
+               pnp_device_detach(dev);
 }
 
 module_init(fmi_init);
index 50cb54c69fce99569a42ae5d64608206397d86d7..30940ceb3d78166049bbbda054134706dd8993d1 100644 (file)
@@ -167,6 +167,9 @@ struct el3_private {
 #ifdef CONFIG_PM
        struct pm_dev *pmdev;
 #endif
+#ifdef __ISAPNP__
+       struct pnp_dev *pnpdev;
+#endif
 };
 static int id_port __initdata = 0x110; /* Start with 0x110 to avoid new sound cards.*/
 static struct net_device *el3_root_dev;
@@ -247,6 +250,7 @@ int __init el3_probe(struct net_device *dev, int card_idx)
        int mca_slot = -1;
 #ifdef __ISAPNP__
        static int pnp_cards;
+       struct pnp_dev *idev = NULL;
 #endif /* __ISAPNP__ */
 
        if (dev) SET_MODULE_OWNER(dev);
@@ -356,23 +360,26 @@ int __init el3_probe(struct net_device *dev, int card_idx)
                goto no_pnp;
 
        for (i=0; el3_isapnp_adapters[i].vendor != 0; i++) {
-               struct pci_dev *idev = NULL;
                int j;
-               while ((idev = isapnp_find_dev(NULL,
-                                               el3_isapnp_adapters[i].vendor,
-                                               el3_isapnp_adapters[i].function,
-                                               idev))) {
-                       idev->prepare(idev);
-                       /* Deactivation is needed if the driver was called
-                          with "nopnp=1" before, does not harm if not. */
-                       idev->deactivate(idev);
-                       idev->activate(idev);
-                       if (!idev->resource[0].start || check_region(idev->resource[0].start, EL3_IO_EXTENT))
+               while ((idev = pnp_find_dev(NULL,
+                                           el3_isapnp_adapters[i].vendor,
+                                           el3_isapnp_adapters[i].function,
+                                           idev))) {
+                       if (pnp_device_attach(idev) < 0)
                                continue;
-                       ioaddr = idev->resource[0].start;
-                       if (!request_region(ioaddr, EL3_IO_EXTENT, "3c509 PnP"))
+                       if (pnp_activate_dev(idev, NULL) < 0) {
+                             __again:
+                               pnp_device_detach(idev);
+                               continue;
+                       }
+                       if (!pnp_port_valid(idev, 0) || !pnp_irq_valid(idev, 0))
+                               goto __again;
+                       ioaddr = pnp_port_start(idev, 0);
+                       if (!request_region(ioaddr, EL3_IO_EXTENT, "3c509 PnP")) {
+                               pnp_device_detach(idev);
                                return -EBUSY;
-                       irq = idev->irq_resource[0].start;
+                       }
+                       irq = pnp_irq(idev, 0);
                        if (el3_debug > 3)
                                printk ("ISAPnP reports %s at i/o 0x%x, irq %d\n",
                                        (char*) el3_isapnp_adapters[i].driver_data, ioaddr, irq);
@@ -531,6 +538,9 @@ no_pnp:
        memset(dev->priv, 0, sizeof(struct el3_private));
        
        lp = dev->priv;
+#ifdef __ISAPNP__
+       lp->pnpdev = idev;
+#endif
        lp->mca_slot = mca_slot;
        lp->next_dev = el3_root_dev;
        spin_lock_init(&lp->lock);
@@ -1466,6 +1476,10 @@ cleanup_module(void)
                next_dev = lp->next_dev;
                unregister_netdev(el3_root_dev);
                release_region(el3_root_dev->base_addr, EL3_IO_EXTENT);
+#ifdef __ISAPNP__
+               if (lp->pnpdev)
+                       pnp_device_detach(lp->pnpdev);
+#endif
                kfree(el3_root_dev);
                el3_root_dev = next_dev;
        }
index 0908e96a94176cdcec9bbbfa482aaab79c1a9e7b..727315f2660fbbdf3b76568c02fbdef4d17ab887 100644 (file)
@@ -460,33 +460,34 @@ static int corkscrew_scan(struct net_device *dev)
        if(nopnp == 1)
                goto no_pnp;
        for(i=0; corkscrew_isapnp_adapters[i].vendor != 0; i++) {
-               struct pci_dev *idev = NULL;
+               struct pnp_dev *idev = NULL;
                int irq;
-               while((idev = isapnp_find_dev(NULL,
-                                               corkscrew_isapnp_adapters[i].vendor,
-                                               corkscrew_isapnp_adapters[i].function,
-                                               idev))) {
+               while((idev = pnp_find_dev(NULL,
+                                          corkscrew_isapnp_adapters[i].vendor,
+                                          corkscrew_isapnp_adapters[i].function,
+                                          idev))) {
 
-                       if(idev->active) idev->deactivate(idev);
-
-                       if(idev->prepare(idev)<0)
-                               continue;
-                       if (!(idev->resource[0].flags & IORESOURCE_IO))
+                       if (pnp_device_attach(idev) < 0)
                                continue;
-                       if(idev->activate(idev)<0) {
-                               printk("isapnp configure failed (out of resources?)\n");
+                       if (pnp_activate_dev(idev, NULL) < 0) {
+                               printk("pnp activate failed (out of resources?)\n");
+                               pnp_device_detach(idev);
                                return -ENOMEM;
                        }
-                       if (!idev->resource[0].start || check_region(idev->resource[0].start,16))
+                       if (!pnp_port_valid(idev, 0) || !pnp_irq_valid(idev, 0)) {
+                               pnp_device_detach(idev);
                                continue;
-                       ioaddr = idev->resource[0].start;
-                       irq = idev->irq_resource[0].start;
+                       }
+                       ioaddr = pnp_port_start(idev, 0);
+                       irq = pnp_irq(idev, 0);
                        if(corkscrew_debug)
                                printk ("ISAPNP reports %s at i/o 0x%x, irq %d\n",
                                        (char*) corkscrew_isapnp_adapters[i].driver_data, ioaddr, irq);
                                        
-                       if ((inw(ioaddr + 0x2002) & 0x1f0) != (ioaddr & 0x1f0))
+                       if ((inw(ioaddr + 0x2002) & 0x1f0) != (ioaddr & 0x1f0)) {
+                               pnp_device_detach(idev);
                                continue;
+                       }
                        /* Verify by reading the device ID from the EEPROM. */
                        {
                                int timer;
@@ -498,8 +499,10 @@ static int corkscrew_scan(struct net_device *dev)
                                                == 0)
                                                        break;
                                }
-                               if (inw(ioaddr + Wn0EepromData) != 0x6d50)
+                               if (inw(ioaddr + Wn0EepromData) != 0x6d50) {
+                                       pnp_device_detach(idev);
                                        continue;
+                               }
                        }
                        printk(KERN_INFO "3c515 Resource configuration register %#4.4x, DCR %4.4x.\n",
                                inl(ioaddr + 0x2002), inw(ioaddr + 0x2000));
index 0cda08b07d9f5350114105b993c0fa8b19209081..13729421a3f930bc4604d2c607bba3b96f6f47f0 100644 (file)
@@ -273,16 +273,17 @@ static void awc_pci_release(void) {
 #include <linux/isapnp.h>
 #define AIRONET4X00_IO_SIZE    0x40
 
-#define isapnp_logdev pci_dev
-#define isapnp_dev    pci_bus
-#define isapnp_find_device isapnp_find_card
-#define isapnp_find_logdev isapnp_find_dev
-#define PNP_BUS bus
+#define isapnp_logdev pnp_dev
+#define isapnp_dev    pnp_card
+#define isapnp_find_device pnp_find_card
+#define isapnp_find_logdev pnp_find_dev
+#define PNP_BUS card
 #define PNP_BUS_NUMBER number
-#define PNP_DEV_NUMBER devfn
+#define PNP_DEV_NUMBER number
 
 
 int awc4500_pnp_hw_reset(struct net_device *dev){
+
        struct isapnp_logdev *logdev;
 
        DEBUG(0, "awc_pnp_reset \n");
@@ -299,23 +300,16 @@ int awc4500_pnp_hw_reset(struct net_device *dev){
                return -1;
        };
 
-       if (isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER)<0)
-               printk("isapnp cfg failed at release \n");
-       isapnp_deactivate(logdev->PNP_DEV_NUMBER);
-       isapnp_cfg_end();
+       pnp_disable_dev(logdev);
 
        udelay(100);
 
-
-       if (isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER) < 0) {
+       if (pnp_activate_dev(logdev, NULL) < 0) {
                printk("%s cfg begin failed in hw_reset for csn %x devnum %x \n",
                                dev->name, logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER);
                return -EAGAIN;
        }
 
-       isapnp_activate(logdev->PNP_DEV_NUMBER);        /* activate device */
-       isapnp_cfg_end();
-
        return 0;
 }
 
@@ -341,32 +335,33 @@ int awc4500_pnp_probe(struct net_device *dev)
                isa_index++;
 
                logdev = isapnp_find_logdev(pnp_dev, ISAPNP_VENDOR('A','W','L'),
-                                   ISAPNP_FUNCTION(1),
-                                   0);
+                                           ISAPNP_FUNCTION(1),
+                                           0);
                if (!logdev){
                        printk("No logical device found on Aironet board \n");
                        return -ENODEV;
                }
-               if (isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER) < 0) {
-                       printk("cfg begin failed for csn %x devnum %x \n",
+               if (pnp_device_attach(logdev) < 0) {
+                       printk("pnp_device_attach failed for csn %x devnum %x \n",
                                        logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER);
                        return -EAGAIN;
                }
-               isapnp_activate(logdev->PNP_DEV_NUMBER);        /* activate device */
-               isapnp_cfg_end();
+               if (pnp_activate_dev(logdev, NULL) < 0) {
+                       printk("pnp_activate_dev failed for csn %x devnum %x \n",
+                                       logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER);
+                       pnp_device_detach(logdev);
+                       return -EIO;
+               }
 
-               isa_irq_line = logdev->irq;
-               isa_ioaddr = logdev->resource[0].start;
+               isa_irq_line = pnp_irq(logdev, 0);
+               isa_ioaddr = pnp_port_start(logdev, 0);
                request_region(isa_ioaddr, AIRONET4X00_IO_SIZE, "aironet4x00 ioaddr");
 
                if (!dev) {
                        dev = init_etherdev(NULL, 0);   
                        if (!dev) {
                                release_region(isa_ioaddr, AIRONET4X00_IO_SIZE);
-                               isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER,
-                                                logdev->PNP_DEV_NUMBER);
-                               isapnp_deactivate(logdev->PNP_DEV_NUMBER);
-                               isapnp_cfg_end();
+                               pnp_device_detach(logdev);
                                return -ENOMEM;
                        }
                }
index 9f38a51949e58fac68a3707e6393f6928f0e4409..2feb50887300dc4852effa0aa9d232aafb79c4a2 100644 (file)
@@ -196,29 +196,31 @@ 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;
+               struct pnp_dev *idev = NULL;
 
-               while ((idev = isapnp_find_dev(NULL,
-                                              isapnp_clone_list[i].vendor,
-                                              isapnp_clone_list[i].function,
-                                              idev))) {
+               while ((idev = pnp_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;
-                       /* if no irq, search for next */
-                       if (idev->irq_resource[0].start == 0)
+                       if (pnp_device_attach(idev) < 0)
                                continue;
+                       if (pnp_activate_dev(idev, NULL) < 0) {
+                             __again:
+                               pnp_device_detach(idev);
+                       }
+                       /* if no io and irq, search for next */
+                       if (!pnp_port_valid(idev, 0) || !pnp_irq_valid(idev, 0))
+                               goto __again;
                        /* found it */
-                       dev->base_addr = idev->resource[0].start;
-                       dev->irq = idev->irq_resource[0].start;
+                       dev->base_addr = pnp_port_start(idev, 0);
+                       dev->irq = pnp_irq(idev, 0);
                        printk(KERN_INFO "ne.c: ISAPnP reports %s at i/o %#lx, irq %d.\n",
                                (char *) isapnp_clone_list[i].driver_data,
-
                                dev->base_addr, dev->irq);
                        if (ne_probe1(dev, dev->base_addr) != 0) {      /* Shouldn't happen. */
                                printk(KERN_ERR "ne.c: Probe of ISAPnP card at %#lx failed.\n", dev->base_addr);
+                               pnp_device_detach(idev);
                                return -ENXIO;
                        }
                        ei_status.priv = (unsigned long)idev;
index ffdb6dbd1bed03835b06c3d377b0ac064918223f..6f1e1dd56ff1d9d18e0af0b7c8a294ad3dbd50d0 100644 (file)
@@ -145,7 +145,7 @@ sb1000_probe(struct net_device *dev)
 {
 
        unsigned short ioaddr[2], irq;
-       struct pci_dev *idev=NULL;
+       struct pnp_dev *idev=NULL;
        unsigned int serial_number;
        
        while(1)
@@ -154,55 +154,58 @@ sb1000_probe(struct net_device *dev)
                 *      Find the card
                 */
                 
-               idev=isapnp_find_dev(NULL, ISAPNP_VENDOR('G','I','C'),
+               idev=pnp_find_dev(NULL, ISAPNP_VENDOR('G','I','C'),
                        ISAPNP_FUNCTION(0x1000), idev);
                        
                /*
                 *      No card
                 */
                 
-               if(idev==NULL)
+               if(idev==NULL || idev->card == NULL)
                        return -ENODEV;
                        
                /*
                 *      Bring it online
                 */
                 
-               idev->prepare(idev);
-               idev->activate(idev);
+               if (pnp_device_attach(idev) < 0)
+                       continue;
+               if (pnp_activate_dev(idev, NULL) < 0) {
+                     __again:
+                       pnp_device_detach(idev);
+                       continue;
+               }
                
                /*
                 *      Ports free ?
                 */
                 
-               if(!idev->resource[0].start || check_region(idev->resource[0].start, 16))
-                       continue;
-               if(!idev->resource[1].start || check_region(idev->resource[1].start, 16))
-                       continue;
+               if(!pnp_port_valid(idev, 0) || !pnp_port_valid(idev, 1) || !pnp_irq_valid(idev, 0))
+                       goto __again;
                
-               serial_number = idev->bus->serial;
+               serial_number = idev->card->serial;
                
-               ioaddr[0]=idev->resource[0].start;
-               ioaddr[1]=idev->resource[1].start;
+               ioaddr[0]=pnp_port_start(idev, 0);
+               ioaddr[1]=pnp_port_start(idev, 0);
                
-               irq = idev->irq_resource[0].start;
+               irq = pnp_irq(idev, 0);
 
                /* check I/O base and IRQ */
                if (dev->base_addr != 0 && dev->base_addr != ioaddr[0])
-                       continue;
+                       goto __again;
                if (dev->mem_start != 0 && dev->mem_start != ioaddr[1])
-                       continue;
+                       goto __again;
                if (dev->irq != 0 && dev->irq != irq)
-                       continue;
+                       goto __again;
                        
                /*
                 *      Ok set it up.
                 */
                if (!request_region(ioaddr[0], 16, dev->name))
-                       continue;
+                       goto __again;
                if (!request_region(ioaddr[1], 16, dev->name)) {
                        release_region(ioaddr[0], 16);
-                       continue;
+                       goto __again;
                }
                 
                dev->base_addr = ioaddr[0];
@@ -216,8 +219,12 @@ sb1000_probe(struct net_device *dev)
                                dev->mem_start, serial_number, dev->irq);
 
                dev = init_etherdev(dev, 0);
-               if (!dev)
+               if (!dev) {
+                       pnp_device_detach(idev);
+                       release_region(ioaddr[1], 16);
+                       release_region(ioaddr[0], 16);
                        return -ENOMEM;
+               }
                SET_MODULE_OWNER(dev);
 
                /* Make up a SB1000-specific-data structure. */
index b5b4f776c5fcedaf106b32f3c9ca73e38fb8ac3a..c40694e33e5f01e006a2d0d0ac6d7f9eb0924774 100644 (file)
@@ -284,29 +284,33 @@ static int __init ultra_probe_isapnp(struct net_device *dev)
         int i;
 
         for (i = 0; ultra_device_ids[i].vendor != 0; i++) {
-                struct pci_dev *idev = NULL;
+               struct pnp_dev *idev = NULL;
 
-                while ((idev = isapnp_find_dev(NULL,
-                                               ultra_device_ids[i].vendor,
-                                               ultra_device_ids[i].function,
-                                               idev))) {
+                while ((idev = pnp_find_dev(NULL,
+                                            ultra_device_ids[i].vendor,
+                                            ultra_device_ids[i].function,
+                                            idev))) {
                         /* Avoid already found cards from previous calls */
-                        if (idev->prepare(idev))
-                                continue;
-                        if (idev->activate(idev))
-                                continue;
-                        /* if no irq, search for next */
-                        if (idev->irq_resource[0].start == 0)
-                                continue;
+                        if (pnp_device_attach(idev) < 0)
+                               continue;
+                        if (pnp_activate_dev(idev, NULL) < 0) {
+                              __again:
+                               pnp_device_detach(idev);
+                               continue;
+                        }
+                       /* if no io and irq, search for next */
+                       if (!pnp_port_valid(idev, 0) || !pnp_irq_valid(idev, 0))
+                               goto __again;
                         /* found it */
-                        dev->base_addr = idev->resource[0].start;
-                        dev->irq = idev->irq_resource[0].start;
+                       dev->base_addr = pnp_port_start(idev, 0);
+                       dev->irq = pnp_irq(idev, 0);
                         printk(KERN_INFO "smc-ultra.c: ISAPnP reports %s at i/o %#lx, irq %d.\n",
                                 (char *) ultra_device_ids[i].driver_data,
-
                                 dev->base_addr, dev->irq);
                         if (ultra_probe1(dev, dev->base_addr) != 0) {      /* Shouldn't happen. */
-                                printk(KERN_ERR "smc-ultra.c: Probe of ISAPnP card at %#lx failed.\n", dev->base_addr);                                return -ENXIO;
+                                printk(KERN_ERR "smc-ultra.c: Probe of ISAPnP card at %#lx failed.\n", dev->base_addr);
+                                pnp_device_detach(idev);
+                               return -ENXIO;
                         }
                         ei_status.priv = (unsigned long)idev;
                         break;
index 893561738443b4fb608f7914949e74cfbfe37116..9a51006edceaf8598899cfc13035b4c54418587c 100644 (file)
@@ -839,18 +839,24 @@ static void __init isa_probe(void)
 
     for (devid = id_table; devid->vendor; devid++) {
        if ((dev = pnp_find_dev(NULL, devid->vendor, devid->function, NULL))) {
+       
+           if (pnp_device_attach(dev) < 0)
+               continue;
+       
            printk("PNP ");
-
+           
            if (pnp_activate_dev(dev, NULL) < 0) {
                printk("activate failed\n");
+               pnp_device_detach(dev);
                break;
            }
 
-           i365_base = pnp_port_start(dev, 0);
-           if (i365_base) {
-               printk("no resources ?\n");
+           if (pnp_port_valid(dev, 0)) {
+               printk("invalid resources ?\n");
+               pnp_device_detach(dev);
                break;
            }
+           i365_base = pnp_port_start(dev, 0);
            i82365_pnpdev = dev;
            break;
        }
index 75b289f6cd2f2ab6f90ba1df7605904e5b1cbf66..40caad83e440ad5e4c901c0c9da5cf433d7cb51a 100644 (file)
@@ -110,6 +110,7 @@ int pnpc_add_card(struct pnp_card *card)
        card->dev.parent = &card->protocol->dev;
        card->dev.bus = &pnpc_bus_type;
        card->dev.release = &pnp_release_card;
+       card->status = PNP_READY;
        error = device_register(&card->dev);
        if (error == 0){
                struct list_head *pos;
@@ -264,6 +265,27 @@ static void pnpc_recover_devices(struct pnp_card *card)
        }
 }
 
+int pnpc_attach(struct pnp_card *pnp_card)
+{
+       spin_lock(&pnp_lock);
+       if(pnp_card->status != PNP_READY){
+               spin_unlock(&pnp_lock);
+               return -EBUSY;
+       }
+       pnp_card->status = PNP_ATTACHED;
+       spin_unlock(&pnp_lock);
+       return 0;
+}
+void pnpc_detach(struct pnp_card *pnp_card)
+{
+       spin_lock(&pnp_lock);
+       if (pnp_card->status == PNP_ATTACHED)
+               pnp_card->status = PNP_READY;
+       spin_unlock(&pnp_lock);
+       pnpc_recover_devices(pnp_card);
+}
+
 static int pnpc_card_probe(struct device *dev)
 {
        int error = 0;
@@ -273,6 +295,9 @@ static int pnpc_card_probe(struct device *dev)
 
        pnp_dbg("pnp: match found with the PnP card '%s' and the driver '%s'", dev->bus_id,drv->name);
 
+       error = pnpc_attach(card);
+       if (error < 0)
+               return error;
        if (drv->probe) {
                card_id = match_card(drv, card);
                if (card_id != NULL)
@@ -281,7 +306,7 @@ static int pnpc_card_probe(struct device *dev)
                        card->driver = drv;
                        error = 0;
                } else
-                       pnpc_recover_devices(card);
+                       pnpc_detach(card);
        }
        return error;
 }
@@ -296,7 +321,7 @@ static int pnpc_card_remove(struct device *dev)
                        drv->remove(card);
                card->driver = NULL;
        }
-       pnpc_recover_devices(card);
+       pnpc_detach(card);
        return 0;
 }
 
@@ -359,3 +384,5 @@ EXPORT_SYMBOL(pnp_release_card_device);
 EXPORT_SYMBOL(pnpc_register_driver);
 EXPORT_SYMBOL(pnpc_unregister_driver);
 EXPORT_SYMBOL(pnpc_add_id);
+EXPORT_SYMBOL(pnpc_attach);
+EXPORT_SYMBOL(pnpc_detach);
index 2d77e6f44540d6f1a3c3c9e0c67b0e5e04e9e519..1c56e16bf49c6ef0899ad0989ac0fab5988a2d03 100644 (file)
@@ -65,6 +65,27 @@ static const struct pnp_device_id * match_device(struct pnp_driver *drv, struct
        return NULL;
 }
 
+int pnp_device_attach(struct pnp_dev *pnp_dev)
+{
+       spin_lock(&pnp_lock);
+       if(pnp_dev->status != PNP_READY){
+               spin_unlock(&pnp_lock);
+               return -EBUSY;
+       }
+       pnp_dev->status = PNP_ATTACHED;
+       spin_unlock(&pnp_lock);
+       return 0;
+}
+
+void pnp_device_detach(struct pnp_dev *pnp_dev)
+{
+       spin_lock(&pnp_lock);
+       if (pnp_dev->status == PNP_ATTACHED)
+               pnp_dev->status = PNP_READY;
+       spin_unlock(&pnp_lock);
+       pnp_disable_dev(pnp_dev);
+}
+
 static int pnp_device_probe(struct device *dev)
 {
        int error;
@@ -76,13 +97,9 @@ static int pnp_device_probe(struct device *dev)
 
        pnp_dbg("pnp: match found with the PnP device '%s' and the driver '%s'", dev->bus_id,pnp_drv->name);
 
-       spin_lock(&pnp_lock);
-       if(pnp_dev->status != PNP_READY){
-               spin_unlock(&pnp_lock);
-               return -EBUSY;
-       }
-       pnp_dev->status = PNP_ATTACHED;
-       spin_unlock(&pnp_lock);
+       error = pnp_device_attach(pnp_dev);
+       if (error < 0)
+               return error;
 
        if (pnp_dev->active == 0) {
                if (!(pnp_drv->flags & PNP_DRIVER_DO_NOT_ACTIVATE)) {
@@ -109,8 +126,7 @@ static int pnp_device_probe(struct device *dev)
        return error;
 
 fail:
-       pnp_dev->status = PNP_READY;
-       pnp_disable_dev(pnp_dev);
+       pnp_device_detach(pnp_dev);
        return error;
 }
 
@@ -124,11 +140,7 @@ static int pnp_device_remove(struct device *dev)
                        drv->remove(pnp_dev);
                pnp_dev->driver = NULL;
        }
-       spin_lock(&pnp_lock);
-       if (pnp_dev->status == PNP_ATTACHED)
-               pnp_dev->status = PNP_READY;
-       spin_unlock(&pnp_lock);
-       pnp_disable_dev(pnp_dev);
+       pnp_device_detach(pnp_dev);
        return 0;
 }
 
@@ -206,3 +218,5 @@ int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev)
 EXPORT_SYMBOL(pnp_register_driver);
 EXPORT_SYMBOL(pnp_unregister_driver);
 EXPORT_SYMBOL(pnp_add_id);
+EXPORT_SYMBOL(pnp_device_attach);
+EXPORT_SYMBOL(pnp_device_detach);
index 498a77b6a389680471e404bf603540c3be2f605c..7cce39ff52b1a09c51d36c170f3e157a8a213259 100644 (file)
@@ -251,29 +251,33 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, char *buf)
                str += sprintf(str,"DISABLED\n");
                goto done;
        }
-       for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
-                       if (dev->resource[i].flags & IORESOURCE_IO){
-                               str += sprintf(str,"io");
-                               str += sprintf(str," 0x%lx-0x%lx \n",
-                                              dev->resource[i].start,
-                                              dev->resource[i].end);
-                       }
-                       if (dev->resource[i].flags & IORESOURCE_MEM){
-                               str += sprintf(str,"mem");
-                               str += sprintf(str," 0x%lx-0x%lx \n",
-                                              dev->resource[i].start,
-                                              dev->resource[i].end);
-                       }
+       for (i = 0; i < DEVICE_COUNT_IO; i++) {
+               if (pnp_port_valid(dev, i)) {
+                       str += sprintf(str,"io");
+                       str += sprintf(str," 0x%lx-0x%lx \n",
+                                               pnp_port_start(dev, i),
+                                               pnp_port_end(dev, i));
+               }
        }
-       for (i = 0; i < DEVICE_COUNT_IRQ && dev->irq_resource[i].flags
-                        & IORESOURCE_IRQ; i++) {
+       for (i = 0; i < DEVICE_COUNT_MEM; i++) {
+               if (pnp_mem_valid(dev, i)) {
+                       str += sprintf(str,"mem");
+                       str += sprintf(str," 0x%lx-0x%lx \n",
+                                               pnp_mem_start(dev, i),
+                                               pnp_mem_end(dev, i));
+               }
+       }
+       for (i = 0; i < DEVICE_COUNT_IRQ; i++) {
+               if (pnp_irq_valid(dev, i)) {
                        str += sprintf(str,"irq");
-                       str += sprintf(str," %ld \n", dev->irq_resource[i].start);
+                       str += sprintf(str," %ld \n", pnp_irq(dev, i));
+               }
        }
-       for (i = 0; i < DEVICE_COUNT_DMA && dev->dma_resource[i].flags
-                        & IORESOURCE_DMA; i++) {
+       for (i = 0; i < DEVICE_COUNT_DMA; i++) {
+               if (pnp_dma_valid(dev, i)) {
                        str += sprintf(str,"dma");
-                       str += sprintf(str," %ld \n", dev->dma_resource[i].start);
+                       str += sprintf(str," %ld \n", pnp_dma(dev, i));
+               }
        }
        done:
        return (str - buf);
index 834a4ee8b4a9ebe454731cd5c97c9e4b25c61771..813a5b6486d2b86a8bfe0df9fb088b36567bc9cc 100644 (file)
@@ -8,10 +8,11 @@
  
 /* TODO: see if more isapnp functions are needed here */
 
-#include <linux/pnp.h>
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
 #include <linux/isapnp.h>
 #include <linux/string.h>
-#include <linux/module.h>
 
 static void pnp_convert_id(char *buf, unsigned short vendor, unsigned short device)
 {
@@ -29,8 +30,8 @@ struct pnp_card *pnp_find_card(unsigned short vendor,
                               unsigned short device,
                               struct pnp_card *from)
 {
-       char id[7];
-       char any[7];
+       char id[8];
+       char any[8];
        struct list_head *list;
        pnp_convert_id(id, vendor, device);
        pnp_convert_id(any, ISAPNP_ANY_ID, ISAPNP_ANY_ID);
@@ -51,8 +52,8 @@ struct pnp_dev *pnp_find_dev(struct pnp_card *card,
                             unsigned short function,
                             struct pnp_dev *from)
 {
-       char id[7];
-       char any[7];
+       char id[8];
+       char any[8];
        pnp_convert_id(id, vendor, function);
        pnp_convert_id(any, ISAPNP_ANY_ID, ISAPNP_ANY_ID);
        if (card == NULL) {     /* look for a logical device from all cards */
index 50532b0d24640c6a16fdaeedace53315c2d51454..25bbdce7a3a072076275073b121995f4460c2265 100644 (file)
@@ -960,19 +960,25 @@ static int isapnp_config_prepare(struct pnp_dev *dev)
                dev->irq_resource[idx].name = NULL;
                dev->irq_resource[idx].start = -1;
                dev->irq_resource[idx].end = -1;
-               dev->irq_resource[idx].flags = 0;
+               dev->irq_resource[idx].flags = IORESOURCE_IRQ|IORESOURCE_UNSET;
        }
        for (idx = 0; idx < DEVICE_COUNT_DMA; idx++) {
                dev->dma_resource[idx].name = NULL;
                dev->dma_resource[idx].start = -1;
                dev->dma_resource[idx].end = -1;
-               dev->dma_resource[idx].flags = 0;
+               dev->dma_resource[idx].flags = IORESOURCE_DMA|IORESOURCE_UNSET;
        }
-       for (idx = 0; idx < DEVICE_COUNT_RESOURCE; idx++) {
-               dev->resource[idx].name = NULL;
-               dev->resource[idx].start = 0;
-               dev->resource[idx].end = 0;
-               dev->resource[idx].flags = 0;
+       for (idx = 0; idx < DEVICE_COUNT_IO; idx++) {
+               dev->io_resource[idx].name = NULL;
+               dev->io_resource[idx].start = 0;
+               dev->io_resource[idx].end = 0;
+               dev->io_resource[idx].flags = IORESOURCE_IO|IORESOURCE_UNSET;
+       }
+       for (idx = 0; idx < DEVICE_COUNT_MEM; idx++) {
+               dev->mem_resource[idx].name = NULL;
+               dev->mem_resource[idx].start = 0;
+               dev->mem_resource[idx].end = 0;
+               dev->mem_resource[idx].flags = IORESOURCE_MEM|IORESOURCE_UNSET;
        }
        return 0;
 }
@@ -997,9 +1003,10 @@ EXPORT_SYMBOL(isapnp_device);
 static int isapnp_get_resources(struct pnp_dev *dev)
 {
        /* We don't need to do anything but this, the rest is taken care of */
-       if ((dev->resource[0].start == 0) &&
-           (dev->irq_resource[0].start == -1) &&
-           (dev->dma_resource[0].start == -1))
+       if (pnp_port_valid(dev, 0) == 0 &&
+           pnp_mem_valid(dev, 0) == 0 &&
+           pnp_irq_valid(dev, 0) == 0 &&
+           pnp_dma_valid(dev, 0) == 0)
                dev->active = 0;
        else
                dev->active = 1;
@@ -1015,21 +1022,22 @@ static int isapnp_set_resources(struct pnp_dev *dev, struct pnp_cfg *cfg)
        dev->irq_resource[1] = cfg->request.irq_resource[1];
        dev->dma_resource[0] = cfg->request.dma_resource[0];
        dev->dma_resource[1] = cfg->request.dma_resource[1];
-       for (tmp = 0; tmp < 12; tmp++) {
-               dev->resource[tmp] = cfg->request.resource[tmp];
-       }
-       for (tmp = 0; tmp < 8 && dev->resource[tmp].flags; tmp++)
-               isapnp_write_word(ISAPNP_CFG_PORT+(tmp<<1), dev->resource[tmp].start);
-       for (tmp = 0; tmp < 2 && dev->irq_resource[tmp].flags; tmp++) {
-               int irq = dev->irq_resource[tmp].start;
+       for (tmp = 0; tmp < DEVICE_COUNT_IO; tmp++)
+               dev->io_resource[tmp] = cfg->request.io_resource[tmp];
+       for (tmp = 0; tmp < DEVICE_COUNT_MEM; tmp++)
+               dev->mem_resource[tmp] = cfg->request.mem_resource[tmp];
+       for (tmp = 0; tmp < 8 && pnp_port_valid(dev, tmp); tmp++)
+               isapnp_write_word(ISAPNP_CFG_PORT+(tmp<<1), pnp_port_start(dev, tmp));
+       for (tmp = 0; tmp < 2 && pnp_irq_valid(dev, tmp); tmp++) {
+               int irq = pnp_irq(dev, tmp);
                if (irq == 2)
                        irq = 9;
                isapnp_write_byte(ISAPNP_CFG_IRQ+(tmp<<1), irq);
        }
-       for (tmp = 0; tmp < 2 && dev->dma_resource[tmp].flags; tmp++)
-               isapnp_write_byte(ISAPNP_CFG_DMA+tmp, dev->dma_resource[tmp].start);
-       for (tmp = 0; tmp < 4 && dev->resource[tmp+8].flags; tmp++)
-               isapnp_write_word(ISAPNP_CFG_MEM+(tmp<<2), (dev->resource[tmp + 8].start >> 8) & 0xffff);
+       for (tmp = 0; tmp < 2 && pnp_dma_valid(dev, tmp); tmp++)
+               isapnp_write_byte(ISAPNP_CFG_DMA+tmp, pnp_dma(dev, tmp));
+       for (tmp = 0; tmp < 4 && pnp_mem_valid(dev, tmp); tmp++)
+               isapnp_write_word(ISAPNP_CFG_MEM+(tmp<<2), (pnp_mem_start(dev, tmp) >> 8) & 0xffff);
        isapnp_activate(dev->number);
        isapnp_cfg_end();
        return 0;
index 2330ee03f808bdbf2e4ae9a151062f0d89da4da0..252ba4d03255020ecdd04d9411d6e4cc0bbef63e 100644 (file)
  *
  */
 
-
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
 #include <linux/isapnp.h>
-#include <linux/pnp.h>
 #include <linux/proc_fs.h>
 #include <linux/init.h>
-#include <linux/module.h>
 #include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 
index e3b8e0489e2d2d880f5d370c1b7579616eda02de..d9e2092dbbb9aef9730e3b19465380f9aedf8b45 100644 (file)
@@ -671,9 +671,10 @@ static int pnp_dock_thread(void * unused)
 static void add_irqresource(struct pnp_dev *dev, int irq)
 {
        int i = 0;
-       while (!(dev->irq_resource[i].flags & IORESOURCE_UNSET) && i < DEVICE_COUNT_IRQ) i++;
+       while (pnp_irq_valid(dev, i) && i < DEVICE_COUNT_IRQ) i++;
        if (i < DEVICE_COUNT_IRQ) {
-               dev->irq_resource[i].start = (unsigned long) irq;
+               dev->irq_resource[i].start = 
+               dev->irq_resource[i].end = (unsigned long) irq;
                dev->irq_resource[i].flags = IORESOURCE_IRQ;  // Also clears _UNSET flag
        }
 }
@@ -681,9 +682,10 @@ static void add_irqresource(struct pnp_dev *dev, int irq)
 static void add_dmaresource(struct pnp_dev *dev, int dma)
 {
        int i = 0;
-       while (!(dev->dma_resource[i].flags & IORESOURCE_UNSET) && i < DEVICE_COUNT_DMA) i++;
+       while (pnp_dma_valid(dev, i) && i < DEVICE_COUNT_DMA) i++;
        if (i < DEVICE_COUNT_DMA) {
-               dev->dma_resource[i].start = (unsigned long) dma;
+               dev->dma_resource[i].start =
+               dev->dma_resource[i].end = (unsigned long) dma;
                dev->dma_resource[i].flags = IORESOURCE_DMA;  // Also clears _UNSET flag
        }
 }
@@ -691,22 +693,22 @@ static void add_dmaresource(struct pnp_dev *dev, int dma)
 static void add_ioresource(struct pnp_dev *dev, int io, int len)
 {
        int i = 0;
-       while (!(dev->resource[i].flags & IORESOURCE_UNSET) && i < DEVICE_COUNT_RESOURCE) i++;
+       while (pnp_port_valid(dev, i) && i < DEVICE_COUNT_IO) i++;
        if (i < DEVICE_COUNT_RESOURCE) {
-               dev->resource[i].start = (unsigned long) io;
-               dev->resource[i].end = (unsigned long)(io + len - 1);
-               dev->resource[i].flags = IORESOURCE_IO;  // Also clears _UNSET flag
+               dev->io_resource[i].start = (unsigned long) io;
+               dev->io_resource[i].end = (unsigned long)(io + len - 1);
+               dev->io_resource[i].flags = IORESOURCE_IO;  // Also clears _UNSET flag
        }
 }
 
 static void add_memresource(struct pnp_dev *dev, int mem, int len)
 {
-       int i = 8;
-       while (!(dev->resource[i].flags & IORESOURCE_UNSET) && i < DEVICE_COUNT_RESOURCE) i++;
+       int i = 0;
+       while (pnp_mem_valid(dev, i) && i < DEVICE_COUNT_MEM) i++;
        if (i < DEVICE_COUNT_RESOURCE) {
-               dev->resource[i].start = (unsigned long) mem;
-               dev->resource[i].end = (unsigned long)(mem + len - 1);
-               dev->resource[i].flags = IORESOURCE_MEM;  // Also clears _UNSET flag
+               dev->mem_resource[i].start = (unsigned long) mem;
+               dev->mem_resource[i].end = (unsigned long)(mem + len - 1);
+               dev->mem_resource[i].flags = IORESOURCE_MEM;  // Also clears _UNSET flag
        }
 }
 
@@ -718,17 +720,25 @@ static unsigned char *node_current_resource_data_to_dev(struct pnp_bios_node *no
        /*
         * First, set resource info to default values
         */
-       for (i=0;i<DEVICE_COUNT_RESOURCE;i++) {
-               dev->resource[i].start = 0;  // "disabled"
-               dev->resource[i].flags = IORESOURCE_UNSET;
+       for (i=0;i<DEVICE_COUNT_IO;i++) {
+               dev->io_resource[i].start = 0;
+               dev->io_resource[i].end = 0;
+               dev->io_resource[i].flags = IORESOURCE_IO|IORESOURCE_UNSET;
+       }
+       for (i=0;i<DEVICE_COUNT_MEM;i++) {
+               dev->mem_resource[i].start = 0;
+               dev->mem_resource[i].end = 0;
+               dev->mem_resource[i].flags = IORESOURCE_MEM|IORESOURCE_UNSET;
        }
        for (i=0;i<DEVICE_COUNT_IRQ;i++) {
-               dev->irq_resource[i].start = (unsigned long)-1;  // "disabled"
-               dev->irq_resource[i].flags = IORESOURCE_UNSET;
+               dev->irq_resource[i].start = (unsigned long)-1;
+               dev->irq_resource[i].end = (unsigned long)-1;
+               dev->irq_resource[i].flags = IORESOURCE_IRQ|IORESOURCE_UNSET;
        }
        for (i=0;i<DEVICE_COUNT_DMA;i++) {
-               dev->dma_resource[i].start = (unsigned long)-1;  // "disabled"
-               dev->dma_resource[i].flags = IORESOURCE_UNSET;
+               dev->dma_resource[i].start = (unsigned long)-1;
+               dev->dma_resource[i].end = (unsigned long)-1;
+               dev->dma_resource[i].flags = IORESOURCE_DMA|IORESOURCE_UNSET;
        }
 
        /*
@@ -815,10 +825,10 @@ static unsigned char *node_current_resource_data_to_dev(struct pnp_bios_node *no
 
         } /* while */
        end:
-       if ((dev->resource[0].start == 0) &&
-           (dev->resource[8].start == 0) &&
-           (dev->irq_resource[0].start == -1) &&
-           (dev->dma_resource[0].start == -1))
+       if (pnp_port_valid(dev, 0) == 0 &&
+           pnp_mem_valid(dev, 0) == 0 &&
+           pnp_irq_valid(dev, 0) == 0 &&
+           pnp_dma_valid(dev, 0) == 0)
                dev->active = 0;
        else
                dev->active = 1;
index 7f1076f9c6f4f513ae84e2a56a98a1a0f7c57074..6d4b3d6bc18e872851064362e912f93300d7a7a2 100644 (file)
@@ -328,9 +328,9 @@ static int pnp_check_port(int port, int size, int idx, struct pnp_cfg *config)
        pnp_for_each_dev(dev) {
                if (dev->active) {
                        for (tmp = 0; tmp < 8; tmp++) {
-                               if (dev->resource[tmp].flags) {
-                                       rport = dev->resource[tmp].start;
-                                       rsize = (dev->resource[tmp].end - rport) + 1;
+                               if (pnp_port_valid(dev, tmp)) {
+                                       rport = pnp_port_start(dev, tmp);
+                                       rsize = pnp_port_len(dev, tmp);
                                        if (port >= rport && port < rport + rsize)
                                                return 1;
                                        if (port + size > rport && port + size < (rport + rsize) - 1)
@@ -340,9 +340,10 @@ static int pnp_check_port(int port, int size, int idx, struct pnp_cfg *config)
                }
        }
        for (tmp = 0; tmp < 8 && tmp != idx; tmp++) {
-               if (dev->resource[tmp].flags) {
-                       rport = config->request.resource[tmp].start;
-                       rsize = (config->request.resource[tmp].end - rport) + 1;
+               if (pnp_port_valid(dev, tmp) &&
+                   pnp_flags_valid(&config->request.io_resource[tmp])) {
+                       rport = config->request.io_resource[tmp].start;
+                       rsize = (config->request.io_resource[tmp].end - rport) + 1;
                        if (port >= rport && port < rport + rsize)
                                return 1;
                        if (port + size > rport && port + size < (rport + rsize) - 1)
@@ -371,9 +372,9 @@ static int pnp_check_mem(unsigned int addr, unsigned int size, int idx, struct p
        pnp_for_each_dev(dev) {
                if (dev->active) {
                        for (tmp = 0; tmp < 4; tmp++) {
-                               if (dev->resource[tmp + 8].flags) {
-                                       raddr = dev->resource[tmp + 8].start;
-                                       rsize = (dev->resource[tmp + 8].end - raddr) + 1;
+                               if (pnp_mem_valid(dev, tmp)) {
+                                       raddr = pnp_mem_start(dev, tmp);
+                                       rsize = pnp_mem_len(dev, tmp);
                                        if (addr >= raddr && addr < raddr + rsize)
                                                return 1;
                                        if (addr + size > raddr && addr + size < (raddr + rsize) - 1)
@@ -383,9 +384,10 @@ static int pnp_check_mem(unsigned int addr, unsigned int size, int idx, struct p
                }
        }
        for (tmp = 0; tmp < 4 && tmp != idx; tmp++) {
-               if (dev->resource[tmp + 8].flags) {
-                       raddr = config->request.resource[tmp + 8].start;
-                       rsize = (config->request.resource[tmp + 8].end - raddr) + 1;
+               if (pnp_mem_valid(dev, tmp) &&
+                   pnp_flags_valid(&config->request.mem_resource[tmp])) {
+                       raddr = config->request.mem_resource[tmp].start;
+                       rsize = (config->request.mem_resource[tmp].end - raddr) + 1;
                        if (addr >= raddr && addr < raddr + rsize)
                                return 1;
                        if (addr + size > raddr && addr + size < (raddr + rsize) - 1)
@@ -417,13 +419,14 @@ static int pnp_check_interrupt(int irq, struct pnp_cfg *config)
        }
        pnp_for_each_dev(dev) {
                if (dev->active) {
-                       if ((dev->irq_resource[0].flags && dev->irq_resource[0].start == irq) ||
-                           (dev->irq_resource[1].flags && dev->irq_resource[1].start == irq))
+                       if ((pnp_irq_valid(dev, 0) && dev->irq_resource[0].start == irq) ||
+                           (pnp_irq_valid(dev, 1) && dev->irq_resource[1].start == irq))
                                return 1;
                }
        }
-       if (config->request.irq_resource[0].flags && config->request.irq_resource[1].flags &&
-          (config->request.irq_resource[0].start == irq))
+       if (pnp_flags_valid(&config->request.irq_resource[0]) &&
+           pnp_flags_valid(&config->request.irq_resource[1]) &&
+           (config->request.irq_resource[0].start == irq))
                return 1;
 #ifdef CONFIG_PCI
        if (!pnp_skip_pci_scan) {
@@ -456,13 +459,14 @@ static int pnp_check_dma(int dma, struct pnp_cfg *config)
        }
        pnp_for_each_dev(dev) {
                if (dev->active) {
-                       if ((dev->dma_resource[0].flags && dev->dma_resource[0].start == dma) ||
-                           (dev->dma_resource[1].flags && dev->dma_resource[1].start == dma))
+                       if ((pnp_dma_valid(dev, 0) && pnp_dma(dev, 0) == dma) ||
+                           (pnp_dma_valid(dev, 1) && pnp_dma(dev, 1) == dma))
                                return 1;
                }
        }
-       if (config->request.dma_resource[0].flags && config->request.dma_resource[1].flags &&
-          (config->request.dma_resource[0].start == dma))
+       if (pnp_flags_valid(&config->request.dma_resource[0]) &&
+           pnp_flags_valid(&config->request.dma_resource[1]) &&
+           (config->request.dma_resource[0].start == dma))
                return 1;
        if (request_dma(dma, "pnp"))
                return 1;
@@ -481,11 +485,11 @@ static int pnp_generate_port(struct pnp_cfg *config, int num)
        port = config->port[num];
        if (!port)
                return 0;
-       value1 = &config->request.resource[num].start;
-       value2 = &config->request.resource[num].end;
-       value3 = &config->request.resource[num].flags;
+       value1 = &config->request.io_resource[num].start;
+       value2 = &config->request.io_resource[num].end;
+       value3 = &config->request.io_resource[num].flags;
        *value1 = port->min;
-       *value2 = *value1 + port->size -1;
+       *value2 = *value1 + port->size - 1;
        *value3 = port->flags | IORESOURCE_IO;
        while (pnp_check_port(*value1, port->size, num, config)) {
                *value1 += port->align;
@@ -505,11 +509,11 @@ static int pnp_generate_mem(struct pnp_cfg *config, int num)
        mem = config->mem[num];
        if (!mem)
                return 0;
-       value1 = &config->request.resource[num + 8].start;
-       value2 = &config->request.resource[num + 8].end;
-       value3 = &config->request.resource[num].flags;
+       value1 = &config->request.mem_resource[num].start;
+       value2 = &config->request.mem_resource[num].end;
+       value3 = &config->request.mem_resource[num].flags;
        *value1 = mem->min;
-       *value2 = *value1 + mem->size -1;
+       *value2 = *value1 + mem->size - 1;
        *value3 = mem->flags | IORESOURCE_MEM;
        if (!(mem->flags & IORESOURCE_MEM_WRITEABLE))
                *value3 |= IORESOURCE_READONLY;
@@ -597,19 +601,25 @@ int pnp_init_res_cfg(struct pnp_res_cfg *res_config)
        for (idx = 0; idx < DEVICE_COUNT_IRQ; idx++) {
                res_config->irq_resource[idx].start = -1;
                res_config->irq_resource[idx].end = -1;
-               res_config->irq_resource[idx].flags = 0;
+               res_config->irq_resource[idx].flags = IORESOURCE_IRQ|IORESOURCE_UNSET;
        }
        for (idx = 0; idx < DEVICE_COUNT_DMA; idx++) {
                res_config->dma_resource[idx].name = NULL;
                res_config->dma_resource[idx].start = -1;
                res_config->dma_resource[idx].end = -1;
-               res_config->dma_resource[idx].flags = 0;
+               res_config->dma_resource[idx].flags = IORESOURCE_DMA|IORESOURCE_UNSET;
        }
-       for (idx = 0; idx < DEVICE_COUNT_RESOURCE; idx++) {
-               res_config->resource[idx].name = NULL;
-               res_config->resource[idx].start = 0;
-               res_config->resource[idx].end = 0;
-               res_config->resource[idx].flags = 0;
+       for (idx = 0; idx < DEVICE_COUNT_IO; idx++) {
+               res_config->io_resource[idx].name = NULL;
+               res_config->io_resource[idx].start = 0;
+               res_config->io_resource[idx].end = 0;
+               res_config->io_resource[idx].flags = IORESOURCE_IO|IORESOURCE_UNSET;
+       }
+       for (idx = 0; idx < DEVICE_COUNT_MEM; idx++) {
+               res_config->mem_resource[idx].name = NULL;
+               res_config->mem_resource[idx].start = 0;
+               res_config->mem_resource[idx].end = 0;
+               res_config->mem_resource[idx].flags = IORESOURCE_MEM|IORESOURCE_UNSET;
        }
        return 0;
 }
@@ -629,14 +639,17 @@ static int pnp_prepare_request(struct pnp_dev *dev, struct pnp_cfg *config, stru
        if (!template)
                return 0;
        for (idx = 0; idx < DEVICE_COUNT_IRQ; idx++)
-               if (template->irq_resource[idx].start >= 0)
+               if (pnp_flags_valid(&template->irq_resource[idx]))
                        config->request.irq_resource[idx] = template->irq_resource[idx];
        for (idx = 0; idx < DEVICE_COUNT_DMA; idx++)
-               if (template->dma_resource[idx].start >= 0)
+               if (pnp_flags_valid(&template->dma_resource[idx]))
                        config->request.dma_resource[idx] = template->dma_resource[idx];
-       for (idx = 0; idx < DEVICE_COUNT_RESOURCE; idx++)
-               if (template->resource[idx].start > 0)
-                       config->request.resource[idx] = template->resource[idx];
+       for (idx = 0; idx < DEVICE_COUNT_IO; idx++)
+               if (pnp_flags_valid(&template->io_resource[idx]))
+                       config->request.io_resource[idx] = template->io_resource[idx];
+       for (idx = 0; idx < DEVICE_COUNT_MEM; idx++)
+               if (pnp_flags_valid(&template->io_resource[idx]))
+                       config->request.mem_resource[idx] = template->mem_resource[idx];
        return 0;
 }
 
@@ -874,7 +887,7 @@ void pnp_resource_change(struct resource *resource, unsigned long start, unsigne
 {
        if (resource == NULL)
                return;
-       resource->flags &= ~IORESOURCE_AUTO;
+       resource->flags &= ~(IORESOURCE_AUTO|IORESOURCE_UNSET);
        resource->start = start;
        resource->end = start + size - 1;
 }
index 33514fec99260239cce13fb48d12be3b1bf64686..d32e9b5805978ff0259d12f9c07a2c1954c84be9 100644 (file)
@@ -53,44 +53,33 @@ static void __init reserve_resources_of_dev( struct pnp_dev *dev )
 {
        int i;
 
-       for (i=0;i<DEVICE_COUNT_RESOURCE;i++) {
-               if ( dev->resource[i].flags & IORESOURCE_UNSET )
+       for (i=0;i<DEVICE_COUNT_IO;i++) {
+               if (pnp_port_valid(dev, i))
                        /* end of resources */
-                       break;
-               if (dev->resource[i].flags & IORESOURCE_IO) {
-                       /* ioport */
-                       if ( dev->resource[i].start == 0 )
-                               /* disabled */
-                               /* Do nothing */
-                               continue;
-                       if ( dev->resource[i].start < 0x100 )
-                               /*
-                                * Below 0x100 is only standard PC hardware
-                                * (pics, kbd, timer, dma, ...)
-                                * We should not get resource conflicts there,
-                                * and the kernel reserves these anyway
-                                * (see arch/i386/kernel/setup.c).
-                                * So, do nothing
-                                */
-                               continue;
-                       if ( dev->resource[i].end < dev->resource[i].start )
-                               /* invalid endpoint */
-                               /* Do nothing */
-                               continue;
-                       reserve_ioport_range(
-                               dev->dev.bus_id,
-                               dev->resource[i].start,
-                               dev->resource[i].end
-                       );
-               } else if (dev->resource[i].flags & IORESOURCE_MEM) {
-                       /* iomem */
-                       /* For now do nothing */
                        continue;
-               } else {
-                       /* Neither ioport nor iomem */
+               if (pnp_port_start(dev, i) == 0)
+                       /* disabled */
                        /* Do nothing */
                        continue;
-               }
+               if (pnp_port_start(dev, i) < 0x100)
+                       /*
+                        * Below 0x100 is only standard PC hardware
+                        * (pics, kbd, timer, dma, ...)
+                        * We should not get resource conflicts there,
+                        * and the kernel reserves these anyway
+                        * (see arch/i386/kernel/setup.c).
+                        * So, do nothing
+                        */
+                       continue;
+               if (pnp_port_end(dev, i) < pnp_port_start(dev, i))
+                       /* invalid endpoint */
+                       /* Do nothing */
+                       continue;
+               reserve_ioport_range(
+                       dev->dev.bus_id,
+                       pnp_port_start(dev, i),
+                       pnp_port_end(dev, i)
+               );
        }
 
        return;
index 56d12f37b7f380e14b91dea4392af08debb03c5e..b683dfef506c47ee387d6b9664d969d485d6f9df 100644 (file)
@@ -970,7 +970,7 @@ static void swintr(int irqno, void *dev_id, struct pt_regs *regs)
 }
 
 #ifdef __ISAPNP__
-static struct pci_dev *pnpdev[2];
+static struct pnp_dev *pnpdev[2];
 static int num_pnpdevs;
 #endif
 int aha152x_detect(Scsi_Host_Template * tpnt)
@@ -979,7 +979,7 @@ int aha152x_detect(Scsi_Host_Template * tpnt)
 #if defined(AUTOCONF)
        aha152x_config conf;
 #ifdef __ISAPNP__
-       struct pci_dev *dev = NULL;
+       struct pnp_dev *dev = NULL;
 #endif
 #endif
        tpnt->proc_name = "aha152x"; 
@@ -1128,22 +1128,23 @@ int aha152x_detect(Scsi_Host_Template * tpnt)
 #endif
 
 #ifdef __ISAPNP__
-       while ( setup_count<ARRAY_SIZE(setup) && (dev=isapnp_find_dev(NULL, ISAPNP_VENDOR('A','D','P'), ISAPNP_FUNCTION(0x1505), dev)) ) {
-               if (dev->prepare(dev) < 0)
+       while ( setup_count<ARRAY_SIZE(setup) && (dev=pnp_find_dev(NULL, ISAPNP_VENDOR('A','D','P'), ISAPNP_FUNCTION(0x1505), dev)) ) {
+               if (pnp_device_attach(dev) < 0)
                        continue;
-               if (dev->active)
+               if (pnp_activate_dev(dev, NULL) < 0) {
+                       pnp_device_detach(dev);
                        continue;
-               if (!(dev->resource[0].flags & IORESOURCE_IO))
-                       continue;
-               dev->resource[0].flags |= IORESOURCE_AUTO;
-               if (dev->activate(dev) < 0)
+               }
+               if (!pnp_port_valid(dev, 0)) {
+                       pnp_device_detach(dev);
                        continue;
-               if ( setup_count==1 && dev->resource[0].start==setup[0].io_port) {
-                       dev->deactivate(dev);
+               }
+               if (setup_count==1 && pnp_port_start(dev, 0)==setup[0].io_port) {
+                       pnp_device_detach(dev);
                        continue;
                }
-               setup[setup_count].io_port     = dev->resource[0].start;
-               setup[setup_count].irq         = dev->irq_resource[0].start;
+               setup[setup_count].io_port     = pnp_port_start(dev, 0);
+               setup[setup_count].irq         = pnp_irq(dev, 0);
                setup[setup_count].scsiid      = 7;
                setup[setup_count].reconnect   = 1;
                setup[setup_count].parity      = 1;
@@ -1421,7 +1422,7 @@ int aha152x_release(struct Scsi_Host *shpnt)
 
 #ifdef __ISAPNP__
        while (num_pnpdevs--)
-               pnpdev[num_pnpdevs]->deactivate(pnpdev[num_pnpdevs]);
+               pnp_device_detach(pnpdev[num_pnpdevs]);
 #endif
        scsi_unregister(shpnt);
 
index 5b6593f6a259a7964f0be597000ca34633b7ca45..b786cc3a84ab657df235615b21c41a5182dcf5f8 100644 (file)
@@ -1144,12 +1144,12 @@ static int __init aha1542_detect(Scsi_Host_Template * tpnt)
         
        if(isapnp)
        {
-               struct pci_dev *pdev = NULL;
+               struct pnp_dev *pdev = NULL;
                for(indx = 0; indx <sizeof(bases)/sizeof(bases[0]);indx++)
                {
                        if(bases[indx])
                                continue;
-                       pdev = isapnp_find_dev(NULL, ISAPNP_VENDOR('A', 'D', 'P'), 
+                       pdev = pnp_find_dev(NULL, ISAPNP_VENDOR('A', 'D', 'P'), 
                                ISAPNP_FUNCTION(0x1542), pdev);
                        if(pdev==NULL)
                                break;
@@ -1157,18 +1157,20 @@ static int __init aha1542_detect(Scsi_Host_Template * tpnt)
                         *      Activate the PnP card
                         */
                         
-                       if(pdev->prepare(pdev)<0)
+                       if(pnp_device_attach(pdev)<0)
                                continue;
-                               
-                       if(!(pdev->resource[0].flags&IORESOURCE_IO))
+                       
+                       if(pnp_activate_dev(pdev, NULL)<0) {
+                               pnp_device_detach(pdev);
                                continue;
-                               
-                       pdev->resource[0].flags|=IORESOURCE_AUTO;
-
-                       if(pdev->activate(pdev)<0)
+                       }
+                       
+                       if(!pnp_port_valid(pdev, 0)) {
+                               pnp_device_detach(pdev);
                                continue;
+                       }
                                
-                       bases[indx] = pdev->resource[0].start;
+                       bases[indx] = pnp_port_start(pdev, 0);
                        
                        /* The card can be queried for its DMA, we have 
                           the DMA set up that is enough */
index d326e96325e952cad614142587d1816e4b685283..a5e2d27310c08447a5eb66cc0f28392e586eef59 100644 (file)
@@ -314,30 +314,34 @@ int __init generic_NCR5380_detect(Scsi_Host_Template * tpnt)
                overrides[0].board = BOARD_DTC3181E;
 
        if (!current_override && isapnp_present()) {
-               struct pci_dev *dev = NULL;
+               struct pnp_dev *dev = NULL;
                count = 0;
-               while ((dev = isapnp_find_dev(NULL, ISAPNP_VENDOR('D', 'T', 'C'), ISAPNP_FUNCTION(0x436e), dev))) {
+               while ((dev = pnp_find_dev(NULL, ISAPNP_VENDOR('D', 'T', 'C'), ISAPNP_FUNCTION(0x436e), dev))) {
                        if (count >= NO_OVERRIDES)
                                break;
-                       if (!dev->active && dev->prepare(dev) < 0) {
-                               printk(KERN_ERR "dtc436e probe: prepare failed\n");
+                       if (pnp_device_attach(dev) < 0) {
+                               printk(KERN_ERR "dtc436e probe: attach failed\n");
                                continue;
                        }
-                       if (!(dev->resource[0].flags & IORESOURCE_IO))
-                               continue;
-                       if (!dev->active && dev->activate(dev) < 0) {
+                       if (pnp_activate_dev(dev, NULL) < 0) {
                                printk(KERN_ERR "dtc436e probe: activate failed\n");
+                               pnp_device_detach(dev);
+                               continue;
+                       }
+                       if (!pnp_port_valid(dev, 0)) {
+                               printk(KERN_ERR "dtc436e probe: no valid port\n");
+                               pnp_device_detach(dev);
                                continue;
                        }
-                       if (dev->irq_resource[0].flags & IORESOURCE_IRQ)
-                               overrides[count].irq = dev->irq_resource[0].start;
+                       if (pnp_irq_valid(dev, 0))
+                               overrides[count].irq = pnp_irq(dev, 0);
                        else
                                overrides[count].irq = IRQ_NONE;
-                       if (dev->dma_resource[0].flags & IORESOURCE_DMA)
-                               overrides[count].dma = dev->dma_resource[0].start;
+                       if (pnp_dma_valid(dev, 0))
+                               overrides[count].dma = pnp_dma(dev, 0);
                        else
                                overrides[count].dma = DMA_NONE;
-                       overrides[count].NCR5380_map_name = (NCR5380_map_type) dev->resource[0].start;
+                       overrides[count].NCR5380_map_name = (NCR5380_map_type) pnp_port_start(dev, 0);
                        overrides[count].board = BOARD_DTC3181E;
                        count++;
                }
index 6353641c4556eb6c985fbfa6bd71203c7b3dbb27..5d87231fca00d88f47004e076308ff11c716ef9a 100644 (file)
@@ -635,7 +635,7 @@ int __init sym53c416_detect(Scsi_Host_Template *tpnt)
        struct Scsi_Host * shpnt = NULL;
        int i;
        int count;
-       struct pci_dev *idev = NULL;
+       struct pnp_dev *idev = NULL;
        
 #ifdef MODULE
        int ints[3];
@@ -669,26 +669,27 @@ int __init sym53c416_detect(Scsi_Host_Template *tpnt)
        printk(KERN_INFO "sym53c416.c: %s\n", VERSION_STRING);
 
        for (i=0; id_table[i].vendor != 0; i++) {
-               while((idev=isapnp_find_dev(NULL, id_table[i].vendor,
+               while((idev=pnp_find_dev(NULL, id_table[i].vendor,
                                        id_table[i].function, idev))!=NULL)
                {
                        int i[3];
 
-                       if(idev->prepare(idev)<0)
+                       if(pnp_device_attach(idev)<0)
                        {
-                               printk(KERN_WARNING "sym53c416: unable to prepare PnP card.\n");
+                               printk(KERN_WARNING "sym53c416: unable to attach PnP device.\n");
                                continue;
                        }
-                       if(idev->activate(idev)<0)
+                       if(pnp_activate_dev(idev, NULL)<0)
                        {
-                               printk(KERN_WARNING "sym53c416: unable to activate PnP card.\n");
+                               printk(KERN_WARNING "sym53c416: unable to activate PnP device.\n");
+                               pnp_device_detach(idev);
                                continue;
                        
                        }
 
                        i[0] = 2;
-                       i[1] = idev->resource[0].start;
-                       i[2] = idev->irq_resource[0].start;
+                       i[1] = pnp_port_start(idev, 0);
+                       i[2] = pnp_irq(idev, 0);
 
                        printk(KERN_INFO "sym53c416: ISAPnP card found and configured at 0x%X, IRQ %d.\n",
                                i[1], i[2]);
index e206645d0929c0172fb4ed0b77d010881b5428db..cfc22ade454787822506e4f0fc51c60c7a6cfb2e 100644 (file)
@@ -7574,8 +7574,8 @@ static void cleanup(void)
                                kfree(j->read_buffer);
                        if (j->write_buffer)
                                kfree(j->write_buffer);
-                       if (j->dev && j->dev->deactivate)
-                               j->dev->deactivate(j->dev);
+                       if (j->dev)
+                               pnp_device_detach(j->dev);
                        if (ixjdebug & 0x0002)
                                printk(KERN_INFO "IXJ: Unregistering /dev/phone%d from LTAPI\n", cnt);
                        phone_unregister_device(&j->p);
@@ -7700,7 +7700,7 @@ int __init ixj_probe_isapnp(int *cnt)
 {               
        int probe = 0;
        int func = 0x110;
-        struct pci_dev *dev = NULL, *old_dev = NULL;
+        struct pnp_dev *dev = NULL, *old_dev = NULL;
 
        while (1) {
                do {
@@ -7708,30 +7708,29 @@ int __init ixj_probe_isapnp(int *cnt)
                        int result;
 
                        old_dev = dev;
-                       dev = isapnp_find_dev(NULL, ISAPNP_VENDOR('Q', 'T', 'I'),
+                       dev = pnp_find_dev(NULL, ISAPNP_VENDOR('Q', 'T', 'I'),
                                         ISAPNP_FUNCTION(func), old_dev);
-                       if (!dev)
+                       if (!dev || !dev->card)
                                break;
-                       result = dev->prepare(dev);
+                       result = pnp_device_attach(dev);
                        if (result < 0) {
-                               printk("preparing failed %d \n", result);
+                               printk("pnp attach failed %d \n", result);
                                break;
                        }
+                       if (pnp_activate_dev(dev, NULL) < 0) {
+                               printk("pnp activate failed (out of resources?)\n");
+                               pnp_device_detach(dev);
+                               return -ENOMEM;
+                       }
 
-                       if (!(dev->resource[0].flags & IORESOURCE_IO))
+                       if (!pnp_port_valid(dev, 0)) {
+                               pnp_device_detach(dev);
                                return -ENODEV;
-
-                       dev->resource[0].flags |= IORESOURCE_AUTO;
-                       if (func != 0x110)
-                               dev->resource[1].flags |= IORESOURCE_AUTO;
-                       if (dev->activate(dev) < 0) {
-                               printk("isapnp configure failed (out of resources?)\n");
-                               return -ENOMEM;
                        }
 
-                       result = check_region(dev->resource[0].start, 16);
+                       result = check_region(pnp_port_start(dev, 0), 16);
                        if (result) {
-                               printk(KERN_INFO "ixj: can't get I/O address 0x%lx\n", dev->resource[0].start);
+                               printk(KERN_INFO "ixj: can't get I/O address 0x%lx\n", pnp_port_start(dev, 0));
                                break;
                        }
 
@@ -7739,7 +7738,7 @@ int __init ixj_probe_isapnp(int *cnt)
                        request_region(j->DSPbase, 16, "ixj DSP");
 
                        if (func != 0x110)
-                               j->XILINXbase = dev->resource[1].start; /* get real port */
+                               j->XILINXbase = pnp_port_start(dev, 1); /* get real port */
 
                        switch (func) {
                        case (0x110):
@@ -7755,7 +7754,7 @@ int __init ixj_probe_isapnp(int *cnt)
                        j->board = *cnt;
                        probe = ixj_selfprobe(j);
                        if(!probe) {
-                               j->serial = dev->bus->serial;
+                               j->serial = dev->card->serial;
                                j->dev = dev;
                                switch (func) {
                                case 0x110:
index f6e490c462c0a8a38c7a6a83350f092613b3ad7a..44ebbce3443c2f8aa33738ed6ab35aa093aa4e6f 100644 (file)
@@ -1182,11 +1182,7 @@ typedef struct {
        atomic_t DSPWrite;
        struct phone_capability caplist[30];
        unsigned int caps;
-#if LINUX_VERSION_CODE < 0x020400
        struct pnp_dev *dev;
-#else
-       struct pci_dev *dev;
-#endif
        unsigned int cardtype;
        unsigned int rec_codec;
        unsigned int cid_rec_codec;
index 2e2718ebfd9866fe7685adda8f2a0c4e41465e69..9aec5972244184ca96d5b6dd690e6f06293d43d2 100644 (file)
@@ -916,6 +916,8 @@ typedef struct hwif_s {
 
        struct pci_dev  *pci_dev;       /* for pci chipsets */
        struct ide_pci_device_s *cds;   /* chipset device struct */
+       
+       struct pnp_dev  *pnp_dev;       /* for PnP devices */
 
 #if 0
        ide_hwif_ops_t  *hwifops;
index 3e03c39fbc4052a6641647cdd672521ca6150c9b..9582944ab25c618e21018c3342184fa18701f56e 100644 (file)
@@ -122,6 +122,15 @@ static inline isapnp_proc_done(void) { return 0; }
 /* init/main.c */
 int isapnp_init(void);
 
+/* compat */
+struct pnp_card *pnp_find_card(unsigned short vendor,
+                              unsigned short device,
+                              struct pnp_card *from);
+struct pnp_dev *pnp_find_dev(struct pnp_card *card,
+                            unsigned short vendor,
+                            unsigned short function,
+                            struct pnp_dev *from);
+
 #else /* !CONFIG_ISAPNP */
 
 /* lowlevel configuration */
@@ -139,6 +148,14 @@ static inline void isapnp_device(unsigned char device) { ; }
 static inline void isapnp_activate(unsigned char device) { ; }
 static inline void isapnp_deactivate(unsigned char device) { ; }
 
+static inline struct pnp_card *pnp_find_card(unsigned short vendor,
+                                            unsigned short device,
+                                            struct pnp_card *from) { return NULL; }
+static inline struct pnp_dev *pnp_find_dev(struct pnp_card *card,
+                                          unsigned short vendor,
+                                          unsigned short function,
+                                          struct pnp_dev *from) { return NULL; }
+
 #endif /* CONFIG_ISAPNP */
 
 #endif /* __KERNEL__ */
index c4b120c8727bdb05997e07586772f5e57b289982..b97e8f64122f3527e1cf117fd2bfa0d46e03665b 100644 (file)
@@ -20,7 +20,8 @@
 
 #define DEVICE_COUNT_IRQ       2
 #define DEVICE_COUNT_DMA       2
-#define DEVICE_COUNT_RESOURCE  12
+#define DEVICE_COUNT_IO                8
+#define DEVICE_COUNT_MEM       4
 #define MAX_DEVICES            8
 
 struct pnp_resource;
@@ -30,6 +31,7 @@ struct pnp_cfg;
 
 struct pnp_card {
        char name[80];
+       int status;                     /* status of the card */
        unsigned char number;           /* card number */
        struct list_head global_list;   /* node in global list of cards */
        struct list_head protocol_list; /* node in protocol's list of cards */
@@ -101,7 +103,8 @@ struct pnp_dev {
        
        struct pnp_resources *res;      /* possible resource information */
        int lock_resources;             /* resources are locked */
-       struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */
+       struct resource io_resource[DEVICE_COUNT_IO];   /* port regions */
+       struct resource mem_resource[DEVICE_COUNT_MEM]; /* memory regions + expansion ROMs */
        struct resource dma_resource[DEVICE_COUNT_DMA];
        struct resource irq_resource[DEVICE_COUNT_IRQ];
 
@@ -227,10 +230,14 @@ struct pnpc_driver {
  * Resource Management
  */
 
+#define pnp_flags_valid(resrc) (((resrc)->flags & IORESOURCE_UNSET) == 0 && \
+                                ((resrc)->flags & (IORESOURCE_IO|IORESOURCE_MEM|IORESOURCE_IRQ|IORESOURCE_DMA)) != 0)
+
 /* Use these instead of directly reading pnp_dev to get resource information */
-#define pnp_port_start(dev,bar)   ((dev)->resource[(bar)].start)
-#define pnp_port_end(dev,bar)     ((dev)->resource[(bar)].end)
-#define pnp_port_flags(dev,bar)   ((dev)->resource[(bar)].flags)
+#define pnp_port_start(dev,bar)        ((dev)->io_resource[(bar)].start)
+#define pnp_port_end(dev,bar)  ((dev)->io_resource[(bar)].end)
+#define pnp_port_flags(dev,bar)        ((dev)->io_resource[(bar)].flags)
+#define pnp_port_valid(dev,bar)        pnp_flags_valid(&(dev)->io_resource[(bar)])
 #define pnp_port_len(dev,bar) \
        ((pnp_port_start((dev),(bar)) == 0 &&   \
          pnp_port_end((dev),(bar)) ==          \
@@ -239,9 +246,10 @@ struct pnpc_driver {
         (pnp_port_end((dev),(bar)) -           \
          pnp_port_start((dev),(bar)) + 1))
 
-#define pnp_mem_start(dev,bar)   ((dev)->resource[(bar+8)].start)
-#define pnp_mem_end(dev,bar)     ((dev)->resource[(bar+8)].end)
-#define pnp_mem_flags(dev,bar)   ((dev)->resource[(bar+8)].flags)
+#define pnp_mem_start(dev,bar) ((dev)->mem_resource[(bar)].start)
+#define pnp_mem_end(dev,bar)   ((dev)->mem_resource[(bar)].end)
+#define pnp_mem_flags(dev,bar) ((dev)->mem_resource[(bar)].flags)
+#define pnp_mem_valid(dev,bar) pnp_flags_valid(&(dev)->mem_resource[(bar)])
 #define pnp_mem_len(dev,bar) \
        ((pnp_mem_start((dev),(bar)) == 0 &&    \
          pnp_mem_end((dev),(bar)) ==           \
@@ -250,11 +258,13 @@ struct pnpc_driver {
         (pnp_mem_end((dev),(bar)) -            \
          pnp_mem_start((dev),(bar)) + 1))
 
-#define pnp_irq(dev,bar)        ((dev)->irq_resource[(bar)].start)
-#define pnp_irq_flags(dev,bar)  ((dev)->irq_resource[(bar)].flags)
+#define pnp_irq(dev,bar)       ((dev)->irq_resource[(bar)].start)
+#define pnp_irq_flags(dev,bar) ((dev)->irq_resource[(bar)].flags)
+#define pnp_irq_valid(dev,bar) pnp_flags_valid(&(dev)->irq_resource[(bar)])
 
-#define pnp_dma(dev,bar)        ((dev)->dma_resource[(bar)].start)
-#define pnp_dma_flags(dev,bar)  ((dev)->dma_resource[(bar)].flags)
+#define pnp_dma(dev,bar)       ((dev)->dma_resource[(bar)].start)
+#define pnp_dma_flags(dev,bar) ((dev)->dma_resource[(bar)].flags)
+#define pnp_dma_valid(dev,bar) pnp_flags_valid(&(dev)->dma_resource[(bar)])
 
 #define PNP_PORT_FLAG_16BITADDR        (1<<0)
 #define PNP_PORT_FLAG_FIXED    (1<<1)
@@ -320,7 +330,8 @@ struct pnp_resources {
 };
 
 struct pnp_res_cfg {
-       struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */
+       struct resource io_resource[DEVICE_COUNT_IO];   /* I/O ports */
+       struct resource mem_resource[DEVICE_COUNT_MEM]; /* memory regions + expansion ROMs */
        struct resource dma_resource[DEVICE_COUNT_DMA];
        struct resource irq_resource[DEVICE_COUNT_IRQ];
 };
@@ -394,6 +405,8 @@ int compare_pnp_id(struct pnp_id * pos, const char * id);
 int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev);
 int pnp_register_driver(struct pnp_driver *drv);
 void pnp_unregister_driver(struct pnp_driver *drv);
+int pnp_device_attach(struct pnp_dev *pnp_dev);
+void pnp_device_detach(struct pnp_dev *pnp_dev);
 
 #else
 
@@ -415,11 +428,15 @@ static inline int pnp_init_res_cfg(struct pnp_res_cfg *template) { return -ENODE
 static inline int pnp_activate_dev(struct pnp_dev *dev, struct pnp_res_cfg *template) { return -ENODEV; }
 static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_raw_set_dev(struct pnp_dev *dev, int depnum, struct pnp_res_cfg *template) { return -ENODEV; }
+static inline void pnp_resource_change(struct resource *resource, unsigned long start, unsigned long size) { ; }
 static inline int compare_pnp_id(struct list_head * id_list, const char * id) { return -ENODEV; }
 static inline int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
 static inline void pnp_unregister_driver(struct pnp_driver *drv) { ; }
 
+static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; }
+static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { ; }
+
 #endif /* CONFIG_PNP */
 
 
@@ -436,6 +453,8 @@ int pnpc_register_driver(struct pnpc_driver * drv);
 void pnpc_unregister_driver(struct pnpc_driver *drv);
 int pnpc_add_id(struct pnp_id *id, struct pnp_card *card);
 extern struct list_head pnp_cards;
+int pnpc_attach(struct pnp_card *card);
+void pnpc_detach(struct pnp_card *card);
 
 #else
 
@@ -448,34 +467,12 @@ static inline void pnp_release_card_device(struct pnp_dev *dev) { ; }
 static inline int pnpc_register_driver(struct pnpc_driver *drv) { return -ENODEV; }
 static inline void pnpc_unregister_driver(struct pnpc_driver *drv) { ; }
 static inline int pnpc_add_id(struct pnp_id *id, struct pnp_card *card) { return -ENODEV; }
+static inline int pnpc_attach(struct pnp_card *card) { return -ENODEV; }
+static inline void pnpc_detach(struct pnp_card *card) { ; }
 
 #endif /* CONFIG_PNP_CARD */
 
 
-#if defined(CONFIG_ISAPNP)
-
-/* compat */
-struct pnp_card *pnp_find_card(unsigned short vendor,
-                                unsigned short device,
-                                struct pnp_card *from);
-struct pnp_dev *pnp_find_dev(struct pnp_card *card,
-                               unsigned short vendor,
-                               unsigned short function,
-                               struct pnp_dev *from);
-
-#else
-
-static inline struct pnp_card *pnp_find_card(unsigned short vendor,
-                                unsigned short device,
-                                struct pnp_card *from) { return NULL; }
-static inline struct pnp_dev *pnp_find_dev(struct pnp_card *card,
-                               unsigned short vendor,
-                               unsigned short function,
-                               struct pnp_dev *from) { return NULL; }
-
-#endif /* CONFIG_ISAPNP */
-
-
 #ifdef DEBUG
 #define pnp_dbg(format, arg...) printk(KERN_DEBUG "pnp: " format "\n" , ## arg)
 #else