From: Ian Abbott Date: Thu, 1 Nov 2007 15:39:26 +0000 (+0000) Subject: New wrapper functions in comedi/drivers/comedi_pci.h: X-Git-Tag: v0_7_76~107 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4ea1070bee939cb1bc159013d917c63513a6c245;p=comedi.git New wrapper functions in comedi/drivers/comedi_pci.h: comedi_pci_enable() combines pci_enable_device() and pci_request_regions(). comedi_pci_disable() combines pci_release_regions() and pci_disable_device(). Does the right thing for reference-counted PCI enables in 2.6.20 onwards. --- diff --git a/comedi/drivers/Makefile.am b/comedi/drivers/Makefile.am index 1588d0f3..83a7bb55 100644 --- a/comedi/drivers/Makefile.am +++ b/comedi/drivers/Makefile.am @@ -39,6 +39,7 @@ EXTRA_DIST = \ am9513.h \ amcc_s5933.h \ comedi_fc.h \ + comedi_pci.h \ das08.h \ dt9812.h \ icp_multi.h \ diff --git a/comedi/drivers/adl_pci6208.c b/comedi/drivers/adl_pci6208.c index b1b21714..19a62aa8 100644 --- a/comedi/drivers/adl_pci6208.c +++ b/comedi/drivers/adl_pci6208.c @@ -52,7 +52,7 @@ References: * options that are used with comedi_config. */ #include -#include /* for PCI devices */ +#include "comedi_pci.h" #define PCI6208_DRIVER_NAME "adl_pci6208" @@ -207,8 +207,7 @@ static int pci6208_detach(comedi_device *dev) if(devpriv && devpriv->pci_dev){ if(dev->iobase) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } @@ -363,9 +362,9 @@ pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr, int dev_m { unsigned long io_base, io_range, lcr_io_base, lcr_io_range; - // Enable PCI device - if (pci_enable_device(pci_dev) < 0) { - printk("comedi%d: Failed to enable PCI device\n", dev_minor); + // Enable PCI device and request regions + if (comedi_pci_enable(pci_dev, PCI6208_DRIVER_NAME) < 0) { + printk("comedi%d: Failed to enable PCI device and request regions\n", dev_minor); return -EIO; } @@ -387,12 +386,6 @@ pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr, int dev_m io_base, io_range); - // Allocate IO ressources - if (pci_request_regions(pci_dev, PCI6208_DRIVER_NAME) < 0) { - printk("comedi%d: I/O port conflict\n",dev_minor); - return -EIO; - } - *io_base_ptr = io_base; //devpriv->io_range = io_range; //devpriv->is_valid=0; diff --git a/comedi/drivers/adl_pci7296.c b/comedi/drivers/adl_pci7296.c index fcd60c3c..f136acda 100644 --- a/comedi/drivers/adl_pci7296.c +++ b/comedi/drivers/adl_pci7296.c @@ -33,8 +33,8 @@ Configuration Options: #include #include -#include +#include "comedi_pci.h" #include "8255.h" // #include "8253.h" @@ -109,12 +109,9 @@ static int adl_pci7296_attach(comedi_device *dev,comedi_devconfig *it) if ( pcidev->vendor == PCI_VENDOR_ID_ADLINK && pcidev->device == PCI_DEVICE_ID_PCI7296 ) { devpriv->pci_dev = pcidev; - if (pci_enable_device(pcidev) < 0) { - printk("comedi%d: Failed to enable PCI device\n", dev->minor); - return -EIO; - } - if (pci_request_regions(pcidev, "adl_pci7296") < 0) { - printk("comedi%d: I/O port conflict\n", dev->minor); + if (comedi_pci_enable(pcidev, "adl_pci7296") < 0) { + printk("comedi%d: Failed to enable PCI device and request regions\n", + dev->minor); return -EIO; } @@ -152,8 +149,7 @@ static int adl_pci7296_detach(comedi_device *dev) if (devpriv && devpriv->pci_dev) { if (dev->iobase) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } diff --git a/comedi/drivers/adl_pci7432.c b/comedi/drivers/adl_pci7432.c index 592c4211..c6a4c227 100644 --- a/comedi/drivers/adl_pci7432.c +++ b/comedi/drivers/adl_pci7432.c @@ -32,7 +32,7 @@ Configuration Options: #include #include -#include +#include "comedi_pci.h" #define PCI7432_DI 0x00 #define PCI7432_DO 0x00 @@ -109,12 +109,8 @@ static int adl_pci7432_attach(comedi_device *dev,comedi_devconfig *it) if ( pcidev->vendor == PCI_VENDOR_ID_ADLINK && pcidev->device == PCI_DEVICE_ID_PCI7432 ) { devpriv->pci_dev = pcidev; - if (pci_enable_device(pcidev) < 0) { - printk("comedi%d: Failed to enable PCI device\n", dev->minor); - return -EIO; - } - if (pci_request_regions(pcidev, "adl_pci7432") < 0) { - printk("comedi%d: I/O port conflict\n", dev->minor); + if (comedi_pci_enable(pcidev, "adl_pci7432") < 0) { + printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor); return -EIO; } dev->iobase = pci_resource_start ( pcidev, 2 ); @@ -158,8 +154,7 @@ static int adl_pci7432_detach(comedi_device *dev) if (devpriv && devpriv->pci_dev) { if (dev->iobase) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } diff --git a/comedi/drivers/adl_pci8164.c b/comedi/drivers/adl_pci8164.c index c1c36666..391e2298 100644 --- a/comedi/drivers/adl_pci8164.c +++ b/comedi/drivers/adl_pci8164.c @@ -31,9 +31,9 @@ Configuration Options: */ #include -#include #include #include "comedi_fc.h" +#include "comedi_pci.h" #include "8253.h" #define PCI8164_AXIS_X 0x00 @@ -127,12 +127,8 @@ static int adl_pci8164_attach(comedi_device *dev,comedi_devconfig *it) if ( pcidev->vendor == PCI_VENDOR_ID_ADLINK && pcidev->device == PCI_DEVICE_ID_PCI8164 ) { devpriv->pci_dev = pcidev; - if (pci_enable_device(pcidev) < 0) { - printk("comedi%d: Failed to enable PCI device\n", dev->minor); - return -EIO; - } - if (pci_request_regions(pcidev, "adl_pci8164") < 0) { - printk("comedi%d: I/O port conflict\n", dev->minor); + if (comedi_pci_enable(pcidev, "adl_pci8164") < 0) { + printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor); return -EIO; } dev->iobase = pci_resource_start ( pcidev, 2 ); @@ -196,8 +192,7 @@ static int adl_pci8164_detach(comedi_device *dev) if (devpriv && devpriv->pci_dev) { if (dev->iobase) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } diff --git a/comedi/drivers/adl_pci9111.c b/comedi/drivers/adl_pci9111.c index 575b9207..f76b0589 100644 --- a/comedi/drivers/adl_pci9111.c +++ b/comedi/drivers/adl_pci9111.c @@ -77,9 +77,9 @@ TODO: #include #include -#include #include "8253.h" +#include "comedi_pci.h" #include "comedi_fc.h" #define PCI9111_DRIVER_NAME "adl_pci9111" @@ -1350,10 +1350,10 @@ found: lcr_io_base, lcr_io_range); - // Enable PCI device - if(pci_enable_device (pci_device) < 0) + // Enable PCI device and request regions + if(comedi_pci_enable (pci_device, PCI9111_DRIVER_NAME) < 0) { - printk("comedi%d: Failed to enable PCI device\n", dev->minor); + printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor); return -EIO; } @@ -1367,13 +1367,6 @@ found: io_base, io_range); - // Allocate IO ressources - if(pci_request_regions(pci_device, PCI9111_DRIVER_NAME)) - { - printk("comedi%d: I/O port conflict\n",dev->minor); - return -EIO; - } - dev->iobase=io_base; dev->board_name = board->name; dev_private->io_range = io_range; @@ -1487,8 +1480,7 @@ static int pci9111_detach(comedi_device *dev) { if(dev->iobase) { - pci_release_regions(dev_private->pci_device); - pci_disable_device(dev_private->pci_device); + comedi_pci_disable(dev_private->pci_device); } pci_dev_put(dev_private->pci_device); } diff --git a/comedi/drivers/adl_pci9118.c b/comedi/drivers/adl_pci9118.c index f2b56880..582df2a2 100644 --- a/comedi/drivers/adl_pci9118.c +++ b/comedi/drivers/adl_pci9118.c @@ -63,12 +63,12 @@ Configuration options: */ #include -#include #include #include "amcc_s5933.h" #include "8253.h" +#include "comedi_pci.h" #include "comedi_fc.h" /* paranoid checks are broken */ @@ -1711,12 +1711,8 @@ static int pci9118_attach(comedi_device *dev,comedi_devconfig *it) * Look for device that isn't in use. * Enable PCI device and request regions. */ - if (pci_enable_device(pcidev)) { - errstr = "failed to enable PCI device!"; - continue; - } - if (pci_request_regions(pcidev, "adl_pci9118")) { - errstr = "in use or I/O port conflict!"; + if (comedi_pci_enable(pcidev, "adl_pci9118")) { + errstr = "failed to enable PCI device and request regions!"; continue; } break; @@ -1898,8 +1894,7 @@ static int pci9118_detach(comedi_device *dev) if(dev->irq) comedi_free_irq(dev->irq,dev); if (devpriv->pcidev) { if (dev->iobase) { - pci_release_regions(devpriv->pcidev); - pci_disable_device(devpriv->pcidev); + comedi_pci_disable(devpriv->pcidev); } pci_dev_put(devpriv->pcidev); } diff --git a/comedi/drivers/adv_pci1710.c b/comedi/drivers/adv_pci1710.c index 5e7e1c13..b23404e4 100644 --- a/comedi/drivers/adv_pci1710.c +++ b/comedi/drivers/adv_pci1710.c @@ -43,7 +43,7 @@ Configuration options: #include -#include +#include "comedi_pci.h" #include "8253.h" #include "amcc_s5933.h" @@ -1256,12 +1256,8 @@ static int pci1710_attach(comedi_device *dev,comedi_devconfig *it) * Look for device that isn't in use. * Enable PCI device and request regions. */ - if (pci_enable_device(pcidev)) { - errstr = "failed to enable PCI device!"; - continue; - } - if (pci_request_regions(pcidev, "adl_pci9118")) { - errstr = "in use or I/O port conflict!"; + if (comedi_pci_enable(pcidev, "adv_pci1710")) { + errstr = "failed to enable PCI device and request regions!"; continue; } break; @@ -1423,8 +1419,7 @@ static int pci1710_detach(comedi_device *dev) if (dev->irq) comedi_free_irq(dev->irq,dev); if (devpriv->pcidev) { if (dev->iobase) { - pci_release_regions(devpriv->pcidev); - pci_disable_device(devpriv->pcidev); + comedi_pci_disable(devpriv->pcidev); } pci_dev_put(devpriv->pcidev); } diff --git a/comedi/drivers/adv_pci_dio.c b/comedi/drivers/adv_pci_dio.c index 3951d1dc..858937a3 100644 --- a/comedi/drivers/adv_pci_dio.c +++ b/comedi/drivers/adv_pci_dio.c @@ -30,9 +30,9 @@ Configuration options: #include -#include #include +#include "comedi_pci.h" #include "8255.h" #undef PCI_DIO_EXTDEBUG /* if defined, enable extensive debug logging */ @@ -908,12 +908,8 @@ static int pci_dio_attach(comedi_device *dev, comedi_devconfig *it) return -EIO; } - if (pci_enable_device(pcidev)) { - rt_printk(", Error: Can't enable PCI device!\n"); - return -EIO; - } - if (pci_request_regions(pcidev, driver_pci_dio.driver_name)) { - rt_printk(", Error: Can't allocate PCI device!\n"); + if (comedi_pci_enable(pcidev, driver_pci_dio.driver_name)) { + rt_printk(", Error: Can't enable PCI device and request regions!\n"); return -EIO; } iobase=pci_resource_start(pcidev, this_board->main_pci_region); @@ -1027,8 +1023,7 @@ static int pci_dio_detach(comedi_device *dev) if (devpriv->pcidev) { if (dev->iobase) { - pci_release_regions(devpriv->pcidev); - pci_disable_device(devpriv->pcidev); + comedi_pci_disable(devpriv->pcidev); } pci_dev_put(devpriv->pcidev); } diff --git a/comedi/drivers/amplc_dio200.c b/comedi/drivers/amplc_dio200.c index e3770ff7..588a14a9 100644 --- a/comedi/drivers/amplc_dio200.c +++ b/comedi/drivers/amplc_dio200.c @@ -210,7 +210,7 @@ order they appear in the channel list. #include -#include +#include "comedi_pci.h" #include "8255.h" #include "8253.h" @@ -1251,20 +1251,14 @@ dio200_attach(comedi_device *dev,comedi_devconfig *it) /* Enable device and reserve I/O spaces. */ if (pci_dev) { - ret = pci_enable_device(pci_dev); + ret = comedi_pci_enable(pci_dev, DIO200_DRIVER_NAME); if (ret < 0) { - printk(KERN_ERR "comedi%d: error! cannot enable PCI device!\n", + printk(KERN_ERR "comedi%d: error! cannot enable PCI device and request regions!\n", dev->minor); return ret; } iobase = pci_resource_start(pci_dev, 2); irq = pci_dev->irq; - ret = pci_request_regions(pci_dev, DIO200_DRIVER_NAME); - if (ret < 0) { - printk(KERN_ERR "comedi%d: I/O port conflict (PCI)!\n", - dev->minor); - return ret; - } } else { ret = dio200_request_region(dev->minor, iobase, DIO200_IO_SIZE); if (ret < 0) { @@ -1399,8 +1393,7 @@ dio200_detach(comedi_device *dev) if (devpriv->pci_dev) { if(dev->iobase) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } else if (dev->iobase) { diff --git a/comedi/drivers/amplc_pc236.c b/comedi/drivers/amplc_pc236.c index 0814cc43..dc762726 100644 --- a/comedi/drivers/amplc_pc236.c +++ b/comedi/drivers/amplc_pc236.c @@ -54,7 +54,7 @@ unused. #include -#include +#include "comedi_pci.h" #include "8255.h" #include "plx9052.h" @@ -266,12 +266,8 @@ static int pc236_attach(comedi_device *dev,comedi_devconfig *it) /* Enable device and reserve I/O spaces. */ if (pci_dev) { - if ((ret=pci_enable_device(pci_dev)) < 0) { - printk("error enabling PCI device!\n"); - return ret; - } - if ((ret=pci_request_regions(pci_dev, PC236_DRIVER_NAME)) < 0) { - printk("I/O port conflict (PCI)!\n"); + if ((ret=comedi_pci_enable(pci_dev, PC236_DRIVER_NAME)) < 0) { + printk("error enabling PCI device and requesting regions!\n"); return ret; } devpriv->lcr_iobase = pci_resource_start(pci_dev, 1); @@ -359,8 +355,7 @@ static int pc236_detach(comedi_device *dev) if (devpriv->pci_dev) { if(dev->iobase) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } else if (dev->iobase) { diff --git a/comedi/drivers/amplc_pc263.c b/comedi/drivers/amplc_pc263.c index 48fc83bd..ab85aa88 100644 --- a/comedi/drivers/amplc_pc263.c +++ b/comedi/drivers/amplc_pc263.c @@ -46,7 +46,7 @@ The state of the outputs can be read. #include -#include +#include "comedi_pci.h" #define PC263_DRIVER_NAME "amplc_pc263" @@ -221,12 +221,8 @@ static int pc263_attach(comedi_device *dev,comedi_devconfig *it) /* Enable device and reserve I/O spaces. */ if (pci_dev) { - if ((ret=pci_enable_device(pci_dev)) < 0) { - printk("error enabling PCI device!\n"); - return ret; - } - if ((ret=pci_request_regions(pci_dev, PC263_DRIVER_NAME)) < 0) { - printk("I/O port conflict (PCI)!\n"); + if ((ret=comedi_pci_enable(pci_dev, PC263_DRIVER_NAME)) < 0) { + printk("error enabling PCI device and requesting regions!\n"); return ret; } iobase = pci_resource_start(pci_dev, 2); @@ -289,8 +285,7 @@ static int pc263_detach(comedi_device *dev) if (devpriv->pci_dev) { if(dev->iobase) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } else if (dev->iobase) { diff --git a/comedi/drivers/amplc_pci224.c b/comedi/drivers/amplc_pci224.c index 530b42cd..4b5548d9 100644 --- a/comedi/drivers/amplc_pci224.c +++ b/comedi/drivers/amplc_pci224.c @@ -104,7 +104,7 @@ Caveats: #include -#include +#include "comedi_pci.h" #include "comedi_fc.h" #include "8253.h" @@ -1343,16 +1343,11 @@ pci224_attach(comedi_device *dev,comedi_devconfig *it) return ret; devpriv->pci_dev = pci_dev; - if ((ret=pci_enable_device(pci_dev)) < 0) { - printk(KERN_ERR "comedi%d: error! cannot enable PCI device!\n", + if ((ret=comedi_pci_enable(pci_dev, DRIVER_NAME)) < 0) { + printk(KERN_ERR "comedi%d: error! cannot enable PCI device and request regions!\n", dev->minor); return ret; } - if (pci_request_regions(pci_dev, DRIVER_NAME)) { - printk(KERN_ERR "comedi%d: error! cannot allocate PCI regions!\n", - dev->minor); - return -EIO; - } spin_lock_init(&devpriv->ao_spinlock); devpriv->iobase1 = pci_resource_start(pci_dev, 2); @@ -1539,8 +1534,7 @@ pci224_detach(comedi_device *dev) if (devpriv->pci_dev) { if(dev->iobase) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } diff --git a/comedi/drivers/amplc_pci230.c b/comedi/drivers/amplc_pci230.c index adaebd6d..2ca26dd0 100644 --- a/comedi/drivers/amplc_pci230.c +++ b/comedi/drivers/amplc_pci230.c @@ -42,8 +42,8 @@ extra triggered scan functionality, interrupt bug-fix added by Steve Sharples #include #include -#include +#include "comedi_pci.h" #include "8253.h" #include "8255.h" @@ -453,20 +453,16 @@ static int pci230_attach(comedi_device *dev,comedi_devconfig *it) */ dev->board_name = thisboard->name; - /* Read base addresses of the PCI230's two I/O regions from PCI configuration register. */ - if(pci_enable_device(pci_dev)<0){ + /* Enable PCI device and reserve I/O spaces. */ + if(comedi_pci_enable(pci_dev, "amplc_pci230")<0){ + printk("comedi%d: failed to enable PCI device and request regions\n",dev->minor); return -EIO; } + /* Read base addresses of the PCI230's two I/O regions from PCI configuration register. */ pci_iobase = pci_resource_start(pci_dev, 2); iobase = pci_resource_start(pci_dev, 3); - /* Reserve I/O spaces. */ - if(pci_request_regions(pci_dev,"amplc_pci230")<0){ - printk("comedi%d: I/O space conflict\n",dev->minor); - return -EIO; - } - printk("comedi%d: %s I/O region 1 0x%04lx I/O region 2 0x%04lx\n", dev->minor, dev->board_name, pci_iobase, iobase); @@ -606,8 +602,7 @@ static int pci230_detach(comedi_device *dev) if(devpriv->pci_dev){ if(dev->iobase) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } diff --git a/comedi/drivers/cb_pcidas.c b/comedi/drivers/cb_pcidas.c index 9f9e83e9..cae0fe09 100644 --- a/comedi/drivers/cb_pcidas.c +++ b/comedi/drivers/cb_pcidas.c @@ -63,11 +63,11 @@ analog triggering on 1602 series #include #include -#include #include "8253.h" #include "8255.h" #include "amcc_s5933.h" +#include "comedi_pci.h" #include "comedi_fc.h" #undef CB_PCIDAS_DEBUG // disable debugging code @@ -561,14 +561,9 @@ found: /* * Enable PCI device and reserve I/O ports. */ - if(pci_enable_device(pcidev)) + if(comedi_pci_enable(pcidev, "cb_pcidas")) { - printk(" Failed to enable PCI device\n"); - return -EIO; - } - if(pci_request_regions(pcidev, "cb_pcidas")) - { - printk(" I/O port conflict\n"); + printk(" Failed to enable PCI device and request regions\n"); return -EIO; } /* @@ -745,8 +740,7 @@ static int cb_pcidas_detach(comedi_device *dev) { if(devpriv->s5933_config) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } diff --git a/comedi/drivers/cb_pcidas64.c b/comedi/drivers/cb_pcidas64.c index 1271614c..96f07bdd 100644 --- a/comedi/drivers/cb_pcidas64.c +++ b/comedi/drivers/cb_pcidas64.c @@ -85,9 +85,9 @@ TODO: #include #include -#include #include +#include "comedi_pci.h" #include "8253.h" #include "8255.h" #include "plx9080.h" @@ -1695,15 +1695,9 @@ static int attach(comedi_device *dev, comedi_devconfig *it) printk("Found %s on bus %i, slot %i\n", board(dev)->name, pcidev->bus->number, PCI_SLOT(pcidev->devfn)); - if( pci_enable_device( pcidev ) ) + if( comedi_pci_enable( pcidev, driver_cb_pcidas.driver_name ) ) { - printk(KERN_WARNING " failed to enable PCI device\n"); - return -EIO; - } - if( pci_request_regions( pcidev, driver_cb_pcidas.driver_name ) ) - { - /* Couldn't allocate io space */ - printk(KERN_WARNING " failed to allocate io memory\n"); + printk(KERN_WARNING " failed to enable PCI device and request regions\n"); return -EIO; } pci_set_master( pcidev ); @@ -1820,8 +1814,7 @@ static int detach(comedi_device *dev) priv(dev)->ao_dma_desc, priv(dev)->ao_dma_desc_bus_addr ); if(priv(dev)->main_phys_iobase) { - pci_release_regions(priv(dev)->hw_dev); - pci_disable_device(priv(dev)->hw_dev); + comedi_pci_disable(priv(dev)->hw_dev); } pci_dev_put(priv(dev)->hw_dev); } diff --git a/comedi/drivers/cb_pcidda.c b/comedi/drivers/cb_pcidda.c index b31bc277..2b16a28e 100644 --- a/comedi/drivers/cb_pcidda.c +++ b/comedi/drivers/cb_pcidda.c @@ -47,8 +47,8 @@ Please report sucess/failure with other different cards to */ #include -#include +#include "comedi_pci.h" #include "8255.h" #define PCI_VENDOR_ID_CB 0x1307 // PCI vendor number of ComputerBoards @@ -310,23 +310,17 @@ found: printk("Found %s at requested position\n",thisboard->name); /* - * Initialize devpriv->control_status and devpriv->adc_fifo to point to - * their base address. + * Enable PCI device and request regions. */ - if(pci_enable_device(pcidev)) + if (comedi_pci_enable(pcidev, thisboard->name)) { - printk("cb_pcidda: failed to enable PCI device\n"); + printk("cb_pcidda: failed to enable PCI device and request regions\n"); return -EIO; } /* * Allocate the I/O ports. */ - if (pci_request_regions(pcidev, thisboard->name)) - { - printk("cb_pcidda: I/O port conflict\n"); - return -EIO; - } devpriv->digitalio = pci_resource_start(devpriv->pci_dev, DIGITALIO_BADRINDEX); devpriv->dac = pci_resource_start(devpriv->pci_dev, DAC_BADRINDEX); @@ -402,8 +396,7 @@ static int cb_pcidda_detach(comedi_device *dev) { if(devpriv->dac) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } diff --git a/comedi/drivers/cb_pcidio.c b/comedi/drivers/cb_pcidio.c index f5d881cd..53ccf7d9 100644 --- a/comedi/drivers/cb_pcidio.c +++ b/comedi/drivers/cb_pcidio.c @@ -41,7 +41,7 @@ Passing a zero for an option is the same as leaving it unspecified. /*------------------------------ HEADER FILES ---------------------------------*/ #include -#include /* for PCI devices */ +#include "comedi_pci.h" #include "8255.h" @@ -245,12 +245,8 @@ found: devpriv->pci_dev = pcidev; printk("Found %s on bus %i, slot %i\n", thisboard->name, devpriv->pci_dev->bus->number, PCI_SLOT(devpriv->pci_dev->devfn)); - if(pci_enable_device(pcidev)) { - printk("cb_pcidio: failed to enable PCI device\n"); - return -EIO; - } - if(pci_request_regions(pcidev, thisboard->name)) { - printk("cb_pcidio: I/O port conflict\n"); + if(comedi_pci_enable(pcidev, thisboard->name)) { + printk("cb_pcidio: failed to enable PCI device and request regions\n"); return -EIO; } devpriv->dio_reg_base @@ -288,8 +284,7 @@ static int pcidio_detach(comedi_device *dev) if(devpriv) { if(devpriv->pci_dev) { if(devpriv->dio_reg_base) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } diff --git a/comedi/drivers/cb_pcimdas.c b/comedi/drivers/cb_pcimdas.c index ee7ac4e2..39bba14f 100644 --- a/comedi/drivers/cb_pcimdas.c +++ b/comedi/drivers/cb_pcimdas.c @@ -42,9 +42,9 @@ See http://www.measurementcomputing.com/PDFManuals/pcim-das1602_16.pdf for more #include -#include #include +#include "comedi_pci.h" #include "plx9052.h" #include "8255.h" @@ -260,14 +260,9 @@ found: "PLEASE REPORT USAGE TO \n"); }; - if(pci_enable_device(pcidev)) + if(comedi_pci_enable(pcidev, "cb_pcimdas")) { - printk(" Failed to enable PCI device\n"); - return -EIO; - } - if(pci_request_regions(pcidev, "cb_pcimdas")) - { - printk(" I/O port conflict\n"); + printk(" Failed to enable PCI device and request regions\n"); return -EIO; } @@ -371,8 +366,7 @@ static int cb_pcimdas_detach(comedi_device *dev) { if(devpriv->BADR0) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } diff --git a/comedi/drivers/cb_pcimdda.c b/comedi/drivers/cb_pcimdda.c index 044a4221..635a8bd2 100644 --- a/comedi/drivers/cb_pcimdda.c +++ b/comedi/drivers/cb_pcimdda.c @@ -87,7 +87,7 @@ Configuration Options: #include -#include +#include "comedi_pci.h" #include "8255.h" @@ -344,8 +344,7 @@ static int detach(comedi_device *dev) if (devpriv->pci_dev) { if(devpriv->registers) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } @@ -467,14 +466,9 @@ static int probe(comedi_device *dev, const comedi_devconfig *it) devpriv->pci_dev = pcidev; dev->board_ptr = boards + index; - if (pci_enable_device(pcidev)) + if (comedi_pci_enable(pcidev, thisboard->name)) { - printk("cb_pcimdda: Failed to enable PCI device\n"); - return -EIO; - } - if (pci_request_regions(pcidev, thisboard->name)) - { - printk("cb_pcimdda: I/O port conflict\n"); + printk("cb_pcimdda: Failed to enable PCI device and request regions\n"); return -EIO; } registers = pci_resource_start(devpriv->pci_dev, REGS_BADRINDEX); diff --git a/comedi/drivers/comedi_pci.h b/comedi/drivers/comedi_pci.h new file mode 100644 index 00000000..14078783 --- /dev/null +++ b/comedi/drivers/comedi_pci.h @@ -0,0 +1,89 @@ +/* + comedi/drivers/comedi_pci.h + Various PCI functions for drivers. + + Copyright (C) 2007 MEV Ltd. + + COMEDI - Linux Control and Measurement Device Interface + Copyright (C) 2000 David A. Schleef + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef _COMEDI_PCI_H_ +#define _COMEDI_PCI_H_ + +#include +#include + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) +#define PCI_ENABLE_IS_REFCOUNTED +#endif + +/* + * Enables PCI device without requesting regions. Just a simple wrapper + * for pci_enable_device(). + */ +static inline int comedi_pci_enable_no_regions(struct pci_dev *pdev) +{ + return pci_enable_device(pdev); +} + +/* + * Called to disable PCI device if PCI device has been enabled, but + * PCI regions have not been reserved. + * + * It only disables the PCI device if the kernel supports reference + * counting of PCI enables, otherwise it might stop the device working + * in another driver instance. + */ +static inline void comedi_pci_disable_no_regions(struct pci_dev *pdev) +{ +#ifdef PCI_ENABLE_IS_REFCOUNTED + pci_disable_device(pdev); +#endif +} + +/* + * Enable the PCI device and request the regions. + */ +static inline int comedi_pci_enable(struct pci_dev *pdev, const char *res_name) +{ + int rc; + + rc = pci_enable_device(pdev); + if (rc < 0) { + return rc; + } + rc = pci_request_regions(pdev, res_name); + if (rc < 0) { + comedi_pci_disable_no_regions(pdev); + } + return rc; +} + +/* + * Release the regions and disable the PCI device. + * + * This must be matched with a previous successful call to comedi_pci_enable(). + */ +static inline void comedi_pci_disable(struct pci_dev *pdev) +{ + pci_release_regions(pdev); + pci_disable_device(pdev); +} + +#endif diff --git a/comedi/drivers/contec_pci_dio.c b/comedi/drivers/contec_pci_dio.c index 5b182f4e..138cf85e 100644 --- a/comedi/drivers/contec_pci_dio.c +++ b/comedi/drivers/contec_pci_dio.c @@ -36,7 +36,7 @@ Configuration Options: #include -#include +#include "comedi_pci.h" typedef enum contec_model { PIO1616L =0, @@ -124,12 +124,8 @@ static int contec_attach(comedi_device *dev,comedi_devconfig *it) } } devpriv->pci_dev = pcidev; - if (pci_enable_device(pcidev)) { - printk("error enabling PCI device!\n"); - return -EIO; - } - if (pci_request_regions(pcidev, "contec_pci_dio")) { - printk("I/O port conflict!\n"); + if (comedi_pci_enable(pcidev, "contec_pci_dio")) { + printk("error enabling PCI device and request regions!\n"); return -EIO; } dev->iobase = pci_resource_start ( pcidev, 0 ); @@ -173,8 +169,7 @@ static int contec_detach(comedi_device *dev) if (devpriv && devpriv->pci_dev) { if(dev->iobase) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } diff --git a/comedi/drivers/daqboard2000.c b/comedi/drivers/daqboard2000.c index 7ef41a35..550b597a 100644 --- a/comedi/drivers/daqboard2000.c +++ b/comedi/drivers/daqboard2000.c @@ -115,8 +115,8 @@ Configuration options: #include #include -#include +#include "comedi_pci.h" #include "8255.h" #define DAQBOARD2000_SUBSYSTEM_IDS2 0x00021616 /* Daqboard/2000 - 2 Dacs */ @@ -719,10 +719,8 @@ static int daqboard2000_attach(comedi_device *dev, comedi_devconfig *it) } - if((result = pci_enable_device(card))<0){ - return -EIO; - } - if((result = pci_request_regions(card, "daqboard2000")) < 0) { + if((result = comedi_pci_enable(card, "daqboard2000")) < 0) { + printk(" failed to enable PCI device and request regions\n"); return -EIO; } devpriv->got_regions = 1; @@ -814,8 +812,7 @@ static int daqboard2000_detach(comedi_device * dev) { if(devpriv->got_regions) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } diff --git a/comedi/drivers/das08.c b/comedi/drivers/das08.c index f8495212..9623127c 100644 --- a/comedi/drivers/das08.c +++ b/comedi/drivers/das08.c @@ -56,8 +56,8 @@ driver. #include #include -#include +#include "comedi_pci.h" #include "8255.h" #include "das08.h" @@ -956,14 +956,9 @@ static int das08_attach(comedi_device *dev,comedi_devconfig *it) return -EIO; } devpriv->pdev = pdev; - // enable PCI device - if(pci_enable_device(pdev)){ - printk(" Error enabling PCI device\n"); - return -EIO; - } - // reserve I/O spaces - if(pci_request_regions(pdev, "das08")){ - printk(" I/O port conflict\n"); + // enable PCI device and reserve I/O spaces + if(comedi_pci_enable(pdev, "das08")){ + printk(" Error enabling PCI device and requesting regions\n"); return -EIO; } // read base addresses @@ -1008,8 +1003,7 @@ int das08_common_detach(comedi_device *dev) if(devpriv->pdev){ if(devpriv->pci_iobase) { - pci_release_regions(devpriv->pdev); - pci_disable_device(devpriv->pdev); + comedi_pci_disable(devpriv->pdev); } pci_dev_put(devpriv->pdev); } diff --git a/comedi/drivers/dt3000.c b/comedi/drivers/dt3000.c index aab9e58e..78f14d71 100644 --- a/comedi/drivers/dt3000.c +++ b/comedi/drivers/dt3000.c @@ -53,10 +53,9 @@ AO commands are not supported. #define DEBUG 1 #include - #include -#include +#include "comedi_pci.h" #define PCI_VENDOR_ID_DT 0x1116 @@ -869,8 +868,7 @@ static int dt3000_detach(comedi_device *dev) { if(devpriv->phys_addr) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } @@ -908,10 +906,7 @@ static int setup_pci(comedi_device *dev) resource_size_t addr; int ret; - ret = pci_enable_device(devpriv->pci_dev); - if(ret<0)return ret; - - ret = pci_request_regions(devpriv->pci_dev, "dt3000"); + ret = comedi_pci_enable(devpriv->pci_dev, "dt3000"); if(ret<0)return ret; addr=pci_resource_start(devpriv->pci_dev,0); diff --git a/comedi/drivers/gsc_hpdi.c b/comedi/drivers/gsc_hpdi.c index d26a8339..4af15bb7 100644 --- a/comedi/drivers/gsc_hpdi.c +++ b/comedi/drivers/gsc_hpdi.c @@ -47,8 +47,8 @@ support could be added to this driver. #include #include -#include +#include "comedi_pci.h" #include "plx9080.h" #include "comedi_fc.h" @@ -577,15 +577,9 @@ static int hpdi_attach(comedi_device *dev, comedi_devconfig *it) printk("gsc_hpdi: found %s on bus %i, slot %i\n", board( dev )->name, pcidev->bus->number, PCI_SLOT(pcidev->devfn)); - if( pci_enable_device( pcidev ) ) + if( comedi_pci_enable( pcidev, driver_hpdi.driver_name ) ) { - printk(KERN_WARNING " failed enable PCI device\n"); - return -EIO; - } - if( pci_request_regions( pcidev, driver_hpdi.driver_name ) ) - { - /* Couldn't allocate io space */ - printk(KERN_WARNING " failed to allocate io memory\n"); + printk(KERN_WARNING " failed enable PCI device and request regions\n"); return -EIO; } pci_set_master( pcidev ); @@ -684,8 +678,7 @@ static int hpdi_detach(comedi_device *dev) NUM_DMA_DESCRIPTORS, priv(dev)->dma_desc, priv(dev)->dma_desc_phys_addr ); if(priv(dev)->hpdi_phys_iobase) { - pci_release_regions( priv(dev)->hw_dev ); - pci_disable_device( priv(dev)->hw_dev ); + comedi_pci_disable( priv(dev)->hw_dev ); } pci_dev_put(priv(dev)->hw_dev); } diff --git a/comedi/drivers/icp_multi.h b/comedi/drivers/icp_multi.h index 5ab59b04..769b0d2a 100644 --- a/comedi/drivers/icp_multi.h +++ b/comedi/drivers/icp_multi.h @@ -11,7 +11,7 @@ #define _ICP_MULTI_H_ #include -#include +#include "comedi_pci.h" @@ -162,19 +162,14 @@ static int pci_card_alloc(struct pcilst_struct *inova) } if (inova->used) return 1; - if(pci_enable_device(inova->pcidev)) { - rt_printk(" - Can't enable PCI device!\n"); + if (comedi_pci_enable(inova->pcidev, "icp_multi")) { + rt_printk(" - Can't enable PCI device and request regions!\n"); return -1; } /* Resources will be accurate now. */ for (i=0;i<5;i++) inova->io_addr[i]=pci_resource_start(inova->pcidev, i); inova->irq=inova->pcidev->irq; - /* Request regions on behalf of client. */ - if (pci_request_regions(inova->pcidev, "icp_multi")) { - rt_printk(" - I/O port conflict!\n"); - return -1; - } inova->used=1; return 0; } @@ -187,8 +182,7 @@ static int pci_card_free(struct pcilst_struct *inova) if (!inova->used) return 1; inova->used=0; - pci_release_regions(inova->pcidev); - pci_disable_device(inova->pcidev); + comedi_pci_disable(inova->pcidev); return 0; } diff --git a/comedi/drivers/jr3_pci.c b/comedi/drivers/jr3_pci.c index d392917d..497b74dd 100644 --- a/comedi/drivers/jr3_pci.c +++ b/comedi/drivers/jr3_pci.c @@ -43,10 +43,10 @@ Devices: [JR3] PCI force sensor board (jr3_pci) #include #include -#include #include #include #include +#include "comedi_pci.h" #include "jr3_pci.h" /* Hotplug firmware loading stuff */ @@ -131,6 +131,7 @@ MODULE_DEVICE_TABLE(pci, jr3_pci_pci_table); typedef struct { struct pci_dev *pci_dev; + int pci_enabled; volatile jr3_t *iobase; int n_channels; struct timer_list timer; @@ -756,12 +757,10 @@ static int jr3_pci_attach(comedi_device *dev, comedi_devconfig *it) devpriv->pci_dev = card; dev->board_name = "jr3_pci"; } - if((result = pci_enable_device(card))<0){ - return -EIO; - } - if((result = pci_request_regions(card, "jr3_pci")) < 0) { + if((result = comedi_pci_enable(card, "jr3_pci")) < 0) { return -EIO; } + devpriv->pci_enabled = 1; devpriv->iobase = ioremap(pci_resource_start(card,0), sizeof(jr3_t)); result = alloc_subdevices(dev, devpriv->n_channels); if(result < 0) goto out; @@ -867,9 +866,9 @@ static int jr3_pci_detach(comedi_device * dev) if(devpriv->iobase) { iounmap((void*)devpriv->iobase); - - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + } + if(devpriv->pci_enabled) { + comedi_pci_disable(devpriv->pci_dev); } if (devpriv->pci_dev) { diff --git a/comedi/drivers/ke_counter.c b/comedi/drivers/ke_counter.c index 6a0ee63d..3f2d2942 100644 --- a/comedi/drivers/ke_counter.c +++ b/comedi/drivers/ke_counter.c @@ -34,7 +34,7 @@ Kolter Electronic PCI Counter Card. #include -#include +#include "comedi_pci.h" #define CNT_DRIVER_NAME "ke_counter" #define PCI_VENDOR_ID_KOLTER 0x1001 @@ -192,15 +192,11 @@ found: devpriv->pcidev = pci_device; dev->board_name = board->name; - /* enable PCI device */ - if((error = pci_enable_device(pci_device)) < 0) - { - return error; - } - - /* request PCI regions */ - if((error = pci_request_regions(pci_device, CNT_DRIVER_NAME)) < 0) + /* enable PCI device and request regions */ + if((error = comedi_pci_enable(pci_device, CNT_DRIVER_NAME)) < 0) { + printk("comedi%d: failed to enable PCI device and request regions!\n", + dev->minor); return error; } @@ -244,8 +240,7 @@ static int cnt_detach(comedi_device *dev) { if(dev->iobase) { - pci_release_regions(devpriv->pcidev); - pci_disable_device(devpriv->pcidev); + comedi_pci_disable(devpriv->pcidev); } pci_dev_put(devpriv->pcidev); } diff --git a/comedi/drivers/me4000.c b/comedi/drivers/me4000.c index aa586436..7553b2d8 100644 --- a/comedi/drivers/me4000.c +++ b/comedi/drivers/me4000.c @@ -53,11 +53,11 @@ broken. #include -#include #include #include #include +#include "comedi_pci.h" #include "me4000.h" #if 0 /* file removed due to GPL incompatibility */ @@ -442,19 +442,13 @@ found: /* Set data in device structure */ dev->board_name = board->name; - /* Enable PCI device */ - result = pci_enable_device(pci_device); + /* Enable PCI device and request regions */ + result = comedi_pci_enable(pci_device, dev->board_name); if(result){ - printk(KERN_ERR"comedi%d: me4000: me4000_probe(): Cannot enable PCI device\n", dev->minor); + printk(KERN_ERR"comedi%d: me4000: me4000_probe(): Cannot enable PCI device and request I/O regions\n", dev->minor); return result; } - /* Request the PCI register regions */ - result = pci_request_regions(pci_device, dev->board_name); - if (result < 0){ - printk(KERN_ERR"comedi%d: me4000: me4000_probe(): Cannot request I/O regions\n", dev->minor); - return result; - } /* Get the PCI base registers */ result = get_registers(dev, pci_device); if(result){ @@ -853,8 +847,7 @@ static int me4000_detach(comedi_device *dev){ reset_board(dev); if(info->plx_regbase) { - pci_release_regions(info->pci_dev_p); - pci_disable_device(info->pci_dev_p); + comedi_pci_disable(info->pci_dev_p); } pci_dev_put(info->pci_dev_p); } diff --git a/comedi/drivers/me_daq.c b/comedi/drivers/me_daq.c index b5963bd6..82fdd9c8 100644 --- a/comedi/drivers/me_daq.c +++ b/comedi/drivers/me_daq.c @@ -52,7 +52,7 @@ from http://www.comedi.org #include -#include +#include "comedi_pci.h" //#include "me2600_fw.h" @@ -736,17 +736,10 @@ found: dev->minor, me_boards[i].name, pci_device->bus->number, PCI_SLOT(pci_device->devfn)); - // Enable PCI device - if(pci_enable_device(pci_device) < 0) + // Enable PCI device and request PCI regions + if(comedi_pci_enable(pci_device, ME_DRIVER_NAME) < 0) { - printk("comedi%d: Failed to enable PCI device\n", dev->minor); - return -EIO; - } - - // Request PCI regions - if(pci_request_regions(pci_device, ME_DRIVER_NAME) < 0) - { - printk("comedi%d: I/O memory conflict\n", dev->minor); + printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor); return -EIO; } @@ -899,8 +892,7 @@ static int me_detach(comedi_device *dev) { if(dev_private->plx_regbase_size) { - pci_release_regions(dev_private->pci_device); - pci_disable_device(dev_private->pci_device); + comedi_pci_disable(dev_private->pci_device); } pci_dev_put(dev_private->pci_device); } diff --git a/comedi/drivers/mite.c b/comedi/drivers/mite.c index acdd0d35..0cee3743 100644 --- a/comedi/drivers/mite.c +++ b/comedi/drivers/mite.c @@ -53,9 +53,9 @@ #include "mite.h" #include "comedi_fc.h" +#include "comedi_pci.h" #include -#include #include @@ -118,15 +118,11 @@ int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1) u32 csigr_bits; unsigned unknown_dma_burst_bits; - if(pci_enable_device(mite->pcidev)){ - printk("error enabling mite\n"); + if(comedi_pci_enable( mite->pcidev, "mite" ) ) { + printk("error enabling mite and requesting io regions\n"); return -EIO; } pci_set_master(mite->pcidev); - if( pci_request_regions( mite->pcidev, "mite" ) ) { - printk("failed to request mite io regions\n"); - return -EIO; - }; addr = pci_resource_start(mite->pcidev, 0); mite->mite_phys_addr = addr; @@ -220,8 +216,7 @@ void mite_unsetup(struct mite_struct *mite) mite->daq_io_addr=NULL; } if( mite->mite_phys_addr ){ - pci_release_regions( mite->pcidev ); - pci_disable_device( mite->pcidev ); + comedi_pci_disable( mite->pcidev ); mite->mite_phys_addr = 0; } diff --git a/comedi/drivers/rtd520.c b/comedi/drivers/rtd520.c index 7fd11aea..1684fe6e 100644 --- a/comedi/drivers/rtd520.c +++ b/comedi/drivers/rtd520.c @@ -102,9 +102,9 @@ Configuration options: */ #include - #include -#include + +#include "comedi_pci.h" @@ -804,10 +804,8 @@ static int rtd_attach ( } dev->board_name = thisboard->name; - if((ret=pci_enable_device(pcidev))<0){ - return ret; - } - if((ret=pci_request_regions(pcidev, "rtd520"))<0){ + if((ret=comedi_pci_enable(pcidev, "rtd520"))<0){ + printk("Failed to enable PCI device and request regions.\n"); return ret; } devpriv->got_regions = 1; @@ -1156,8 +1154,7 @@ static int rtd_detach ( if (devpriv->pci_dev) { if(devpriv->got_regions) { - pci_release_regions(devpriv->pci_dev); - pci_disable_device(devpriv->pci_dev); + comedi_pci_disable(devpriv->pci_dev); } pci_dev_put(devpriv->pci_dev); } diff --git a/comedi/drivers/s626.c b/comedi/drivers/s626.c index 31a37348..e8d2dc89 100644 --- a/comedi/drivers/s626.c +++ b/comedi/drivers/s626.c @@ -67,7 +67,7 @@ Status: experimental #include -#include /* for PCI devices */ +#include "comedi_pci.h" #include "comedi_fc.h" #include "s626.h" @@ -495,13 +495,8 @@ static int s626_attach(comedi_device *dev,comedi_devconfig *it) return -ENODEV; } - if((result = pci_enable_device(pdev))<0){ - printk("s626_attach: pci_enable_device fails\n"); - return -ENODEV; - } - - if((result = pci_request_regions(pdev, "s626"))<0){ - printk("s626_attach: pci_request_regions fails\n"); + if((result = comedi_pci_enable(pdev, "s626"))<0){ + printk("s626_attach: comedi_pci_enable fails\n"); return -ENODEV; } devpriv->got_regions = 1; @@ -1231,8 +1226,7 @@ static int s626_detach(comedi_device *dev) if(devpriv->pdev){ if(devpriv->got_regions) { - pci_release_regions(devpriv->pdev); - pci_disable_device(devpriv->pdev); + comedi_pci_disable(devpriv->pdev); } pci_dev_put(devpriv->pdev); }