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.
am9513.h \
amcc_s5933.h \
comedi_fc.h \
+ comedi_pci.h \
das08.h \
dt9812.h \
icp_multi.h \
* options that are used with comedi_config.
*/
#include <linux/comedidev.h>
-#include <linux/pci.h> /* for PCI devices */
+#include "comedi_pci.h"
#define PCI6208_DRIVER_NAME "adl_pci6208"
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);
}
{
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;
}
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;
#include <linux/comedidev.h>
#include <linux/kernel.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
#include "8255.h"
// #include "8253.h"
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;
}
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);
}
#include <linux/comedidev.h>
#include <linux/kernel.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
#define PCI7432_DI 0x00
#define PCI7432_DO 0x00
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 );
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);
}
*/
#include <linux/comedidev.h>
-#include <linux/pci.h>
#include <linux/delay.h>
#include "comedi_fc.h"
+#include "comedi_pci.h"
#include "8253.h"
#define PCI8164_AXIS_X 0x00
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 );
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);
}
#include <linux/comedidev.h>
#include <linux/delay.h>
-#include <linux/pci.h>
#include "8253.h"
+#include "comedi_pci.h"
#include "comedi_fc.h"
#define PCI9111_DRIVER_NAME "adl_pci9111"
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;
}
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;
{
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);
}
*/
#include <linux/comedidev.h>
-#include <linux/pci.h>
#include <linux/delay.h>
#include "amcc_s5933.h"
#include "8253.h"
+#include "comedi_pci.h"
#include "comedi_fc.h"
/* paranoid checks are broken */
* 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;
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);
}
#include <linux/comedidev.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
#include "8253.h"
#include "amcc_s5933.h"
* 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;
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);
}
#include <linux/comedidev.h>
-#include <linux/pci.h>
#include <linux/delay.h>
+#include "comedi_pci.h"
#include "8255.h"
#undef PCI_DIO_EXTDEBUG /* if defined, enable extensive debug logging */
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);
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);
}
#include <linux/comedidev.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
#include "8255.h"
#include "8253.h"
/* 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) {
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) {
#include <linux/comedidev.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
#include "8255.h"
#include "plx9052.h"
/* 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);
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) {
#include <linux/comedidev.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
#define PC263_DRIVER_NAME "amplc_pc263"
/* 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);
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) {
#include <linux/comedidev.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
#include "comedi_fc.h"
#include "8253.h"
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);
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);
}
#include <linux/comedidev.h>
#include <linux/delay.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
#include "8253.h"
#include "8255.h"
*/
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);
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);
}
#include <linux/comedidev.h>
#include <linux/delay.h>
-#include <linux/pci.h>
#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
/*
* 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;
}
/*
{
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);
}
#include <linux/comedidev.h>
#include <linux/delay.h>
-#include <linux/pci.h>
#include <asm/system.h>
+#include "comedi_pci.h"
#include "8253.h"
#include "8255.h"
#include "plx9080.h"
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 );
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);
}
*/
#include <linux/comedidev.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
#include "8255.h"
#define PCI_VENDOR_ID_CB 0x1307 // PCI vendor number of ComputerBoards
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);
{
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);
}
/*------------------------------ HEADER FILES ---------------------------------*/
#include <linux/comedidev.h>
-#include <linux/pci.h> /* for PCI devices */
+#include "comedi_pci.h"
#include "8255.h"
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
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);
}
#include <linux/comedidev.h>
-#include <linux/pci.h>
#include <linux/delay.h>
+#include "comedi_pci.h"
#include "plx9052.h"
#include "8255.h"
"PLEASE REPORT USAGE TO <mocelet@sucs.org>\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;
}
{
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);
}
#include <linux/comedidev.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
#include "8255.h"
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);
}
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);
--- /dev/null
+/*
+ comedi/drivers/comedi_pci.h
+ Various PCI functions for drivers.
+
+ Copyright (C) 2007 MEV Ltd. <http://www.mev.co.uk/>
+
+ COMEDI - Linux Control and Measurement Device Interface
+ Copyright (C) 2000 David A. Schleef <ds@schleef.org>
+
+ 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 <linux/version.h>
+#include <linux/pci.h>
+
+#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
#include <linux/comedidev.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
typedef enum contec_model {
PIO1616L =0,
}
}
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 );
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);
}
#include <linux/comedidev.h>
#include <linux/delay.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
#include "8255.h"
#define DAQBOARD2000_SUBSYSTEM_IDS2 0x00021616 /* Daqboard/2000 - 2 Dacs */
}
- 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;
{
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);
}
#include <linux/comedidev.h>
#include <linux/delay.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
#include "8255.h"
#include "das08.h"
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
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);
}
#define DEBUG 1
#include <linux/comedidev.h>
-
#include <linux/delay.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
#define PCI_VENDOR_ID_DT 0x1116
{
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);
}
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);
#include <linux/comedidev.h>
#include <linux/delay.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
#include "plx9080.h"
#include "comedi_fc.h"
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 );
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);
}
#define _ICP_MULTI_H_
#include <linux/comedidev.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
}
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;
}
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;
}
#include <linux/comedidev.h>
#include <linux/delay.h>
-#include <linux/pci.h>
#include <linux/ctype.h>
#include <linux/firmware.h>
#include <linux/firmware.h>
+#include "comedi_pci.h"
#include "jr3_pci.h"
/* Hotplug firmware loading stuff */
typedef struct {
struct pci_dev *pci_dev;
+ int pci_enabled;
volatile jr3_t *iobase;
int n_channels;
struct timer_list timer;
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;
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) {
#include <linux/comedidev.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
#define CNT_DRIVER_NAME "ke_counter"
#define PCI_VENDOR_ID_KOLTER 0x1001
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;
}
{
if(dev->iobase)
{
- pci_release_regions(devpriv->pcidev);
- pci_disable_device(devpriv->pcidev);
+ comedi_pci_disable(devpriv->pcidev);
}
pci_dev_put(devpriv->pcidev);
}
#include <linux/comedidev.h>
-#include <linux/pci.h>
#include <linux/delay.h>
#include <linux/list.h>
#include <linux/spinlock.h>
+#include "comedi_pci.h"
#include "me4000.h"
#if 0
/* file removed due to GPL incompatibility */
/* 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){
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);
}
#include <linux/comedidev.h>
-#include <linux/pci.h>
+#include "comedi_pci.h"
//#include "me2600_fw.h"
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;
}
{
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);
}
#include "mite.h"
#include "comedi_fc.h"
+#include "comedi_pci.h"
#include <linux/comedidev.h>
-#include <linux/pci.h>
#include <asm/system.h>
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;
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;
}
*/
#include <linux/comedidev.h>
-
#include <linux/delay.h>
-#include <linux/pci.h>
+
+#include "comedi_pci.h"
}
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;
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);
}
#include <linux/comedidev.h>
-#include <linux/pci.h> /* for PCI devices */
+#include "comedi_pci.h"
#include "comedi_fc.h"
#include "s626.h"
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;
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);
}