*/
#include <linux/pci.h>
+#include <linux/interrupt.h>
#include "comedidev.h"
}
EXPORT_SYMBOL_GPL(comedi_pci_disable);
+/**
+ * comedi_pci_detach() - A generic (*detach) function for PCI drivers.
+ * @dev: comedi_device struct
+ */
+void comedi_pci_detach(struct comedi_device *dev)
+{
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+ if (!pcidev || !dev->ioenabled)
+ return;
+
+ if (dev->irq) {
+ free_irq(dev->irq, dev);
+ dev->irq = 0;
+ }
+ if (dev->mmio) {
+ iounmap(dev->mmio);
+ dev->mmio = NULL;
+ }
+ comedi_pci_disable(dev);
+}
+EXPORT_SYMBOL_GPL(comedi_pci_detach);
+
/**
* comedi_pci_auto_config() - Configure/probe a comedi PCI driver.
* @pcidev: pci_dev struct
int comedi_pci_enable(struct comedi_device *);
void comedi_pci_disable(struct comedi_device *);
+void comedi_pci_detach(struct comedi_device *);
int comedi_pci_auto_config(struct pci_dev *, struct comedi_driver *,
unsigned long context);
{
}
+static inline void comedi_pci_detach(struct comedi_device *dev)
+{
+}
+
#endif /* CONFIG_COMEDI_PCI_DRIVERS */
#ifdef CONFIG_COMEDI_PCMCIA_DRIVERS
return 0;
}
-static void pci_8255_detach(struct comedi_device *dev)
-{
- if (dev->mmio)
- iounmap(dev->mmio);
- comedi_pci_disable(dev);
-}
-
static struct comedi_driver pci_8255_driver = {
.driver_name = "8255_pci",
.module = THIS_MODULE,
.auto_attach = pci_8255_auto_attach,
- .detach = pci_8255_detach,
+ .detach = comedi_pci_detach,
};
static int pci_8255_pci_probe(struct pci_dev *dev,
static void i_ADDI_Detach(struct comedi_device *dev)
{
- struct addi_private *devpriv = dev->private;
-
- if (devpriv) {
- if (dev->iobase)
- i_ADDI_Reset(dev);
- if (dev->irq)
- free_irq(dev->irq, dev);
- }
- comedi_pci_disable(dev);
+ if (dev->iobase)
+ i_ADDI_Reset(dev);
+ comedi_pci_detach(dev);
}
{
if (dev->iobase)
apci1032_reset(dev);
- if (dev->irq)
- free_irq(dev->irq, dev);
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver apci1032_driver = {
{
if (dev->iobase)
apci1516_reset(dev);
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver apci1516_driver = {
{
if (dev->iobase)
apci1564_reset(dev);
- if (dev->irq)
- free_irq(dev->irq, dev);
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver apci1564_driver = {
.driver_name = "addi_apci_16xx",
.module = THIS_MODULE,
.auto_attach = apci16xx_auto_attach,
- .detach = comedi_pci_disable,
+ .detach = comedi_pci_detach,
};
static int apci16xx_pci_probe(struct pci_dev *dev,
{
if (dev->iobase)
apci2032_reset(dev);
- if (dev->irq)
- free_irq(dev->irq, dev);
+ comedi_pci_detach(dev);
if (dev->read_subdev)
kfree(dev->read_subdev->private);
- comedi_pci_disable(dev);
}
static struct comedi_driver apci2032_driver = {
{
if (dev->iobase)
apci2200_reset(dev);
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver apci2200_driver = {
{
struct addi_private *devpriv = dev->private;
+ if (dev->iobase)
+ apci3120_reset(dev);
+ comedi_pci_detach(dev);
if (devpriv) {
- if (dev->iobase)
- apci3120_reset(dev);
- if (dev->irq)
- free_irq(dev->irq, dev);
if (devpriv->ul_DmaBufferVirtual[0]) {
free_pages((unsigned long)devpriv->
ul_DmaBufferVirtual[0],
devpriv->ui_DmaBufferPages[1]);
}
}
- comedi_pci_disable(dev);
}
static struct comedi_driver apci3120_driver = {
{
if (dev->iobase)
apci3501_reset(dev);
- if (dev->irq)
- free_irq(dev->irq, dev);
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver apci3501_driver = {
static void apci3xxx_detach(struct comedi_device *dev)
{
- struct apci3xxx_private *devpriv = dev->private;
-
- if (devpriv) {
- if (dev->iobase)
- apci3xxx_reset(dev);
- if (dev->irq)
- free_irq(dev->irq, dev);
- if (dev->mmio)
- iounmap(dev->mmio);
- }
- comedi_pci_disable(dev);
+ if (dev->iobase)
+ apci3xxx_reset(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver apci3xxx_driver = {
.driver_name = "adl_pci6208",
.module = THIS_MODULE,
.auto_attach = pci6208_auto_attach,
- .detach = comedi_pci_disable,
+ .detach = comedi_pci_detach,
};
static int adl_pci6208_pci_probe(struct pci_dev *dev,
.driver_name = "adl_pci7x3x",
.module = THIS_MODULE,
.auto_attach = adl_pci7x3x_auto_attach,
- .detach = comedi_pci_disable,
+ .detach = comedi_pci_detach,
};
static int adl_pci7x3x_pci_probe(struct pci_dev *dev,
.driver_name = "adl_pci8164",
.module = THIS_MODULE,
.auto_attach = adl_pci8164_auto_attach,
- .detach = comedi_pci_disable,
+ .detach = comedi_pci_detach,
};
static int adl_pci8164_pci_probe(struct pci_dev *dev,
{
if (dev->iobase)
pci9111_reset(dev);
- if (dev->irq != 0)
- free_irq(dev->irq, dev);
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver adl_pci9111_driver = {
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
struct pci9118_private *devpriv = dev->private;
+ if (dev->iobase)
+ pci9118_reset(dev);
+ comedi_pci_detach(dev);
if (devpriv) {
- if (dev->iobase)
- pci9118_reset(dev);
- if (dev->irq)
- free_irq(dev->irq, dev);
if (devpriv->dmabuf_virt[0])
free_pages((unsigned long)devpriv->dmabuf_virt[0],
devpriv->dmabuf_pages[0]);
free_pages((unsigned long)devpriv->dmabuf_virt[1],
devpriv->dmabuf_pages[1]);
}
- comedi_pci_disable(dev);
if (pcidev)
pci_dev_put(pcidev);
}
{
if (dev->iobase)
pci1710_reset(dev);
- if (dev->irq)
- free_irq(dev->irq, dev);
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver adv_pci1710_driver = {
{
if (dev->iobase)
pci1723_reset(dev);
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver adv_pci1723_driver = {
.driver_name = "adv_pci1724",
.module = THIS_MODULE,
.auto_attach = adv_pci1724_auto_attach,
- .detach = comedi_pci_disable,
+ .detach = comedi_pci_detach,
};
static int adv_pci1724_pci_probe(struct pci_dev *dev,
if (devpriv->valid)
pci_dio_reset(dev);
}
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver adv_pci_dio_driver = {
return amplc_dio200_common_attach(dev, pci_dev->irq, IRQF_SHARED);
}
-static void dio200_pci_detach(struct comedi_device *dev)
-{
- if (dev->irq)
- free_irq(dev->irq, dev);
- if (dev->mmio)
- iounmap(dev->mmio);
- comedi_pci_disable(dev);
-}
-
static struct comedi_driver dio200_pci_comedi_driver = {
.driver_name = "amplc_dio200_pci",
.module = THIS_MODULE,
.auto_attach = dio200_pci_auto_attach,
- .detach = dio200_pci_detach,
+ .detach = comedi_pci_detach,
};
static const struct pci_device_id dio200_pci_table[] = {
{
struct pci224_private *devpriv = dev->private;
- if (dev->irq)
- free_irq(dev->irq, dev);
+ comedi_pci_detach(dev);
if (devpriv) {
kfree(devpriv->ao_scan_vals);
kfree(devpriv->ao_scan_order);
}
- comedi_pci_disable(dev);
}
static struct comedi_driver amplc_pci224_driver = {
{
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
- if (dev->irq)
- free_irq(dev->irq, dev);
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
if (pcidev)
pci_dev_put(pcidev);
}
IRQF_SHARED);
}
-static void pci236_detach(struct comedi_device *dev)
-{
- if (dev->irq)
- free_irq(dev->irq, dev);
- comedi_pci_disable(dev);
-}
-
static struct comedi_driver amplc_pci236_driver = {
.driver_name = "amplc_pci236",
.module = THIS_MODULE,
.auto_attach = pci236_auto_attach,
- .detach = pci236_detach,
+ .detach = comedi_pci_detach,
};
static const struct pci_device_id pci236_pci_table[] = {
.driver_name = "amplc_pci263",
.module = THIS_MODULE,
.auto_attach = pci263_auto_attach,
- .detach = comedi_pci_disable,
+ .detach = comedi_pci_detach,
};
static const struct pci_device_id pci263_pci_table[] = {
{
struct cb_pcidas_private *devpriv = dev->private;
- if (devpriv) {
- if (devpriv->s5933_config) {
- outl(INTCSR_INBOX_INTR_STATUS,
- devpriv->s5933_config + AMCC_OP_REG_INTCSR);
- }
+ if (devpriv && devpriv->s5933_config) {
+ outl(INTCSR_INBOX_INTR_STATUS,
+ devpriv->s5933_config + AMCC_OP_REG_INTCSR);
}
- if (dev->irq)
- free_irq(dev->irq, dev);
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver cb_pcidas_driver = {
.driver_name = "cb_pcidda",
.module = THIS_MODULE,
.auto_attach = cb_pcidda_auto_attach,
- .detach = comedi_pci_disable,
+ .detach = comedi_pci_detach,
};
static int cb_pcidda_pci_probe(struct pci_dev *dev,
return 0;
}
-static void cb_pcimdas_detach(struct comedi_device *dev)
-{
- if (dev->irq)
- free_irq(dev->irq, dev);
- comedi_pci_disable(dev);
-}
-
static struct comedi_driver cb_pcimdas_driver = {
.driver_name = "cb_pcimdas",
.module = THIS_MODULE,
.auto_attach = cb_pcimdas_auto_attach,
- .detach = cb_pcimdas_detach,
+ .detach = comedi_pci_detach,
};
static int cb_pcimdas_pci_probe(struct pci_dev *dev,
.driver_name = "cb_pcimdda",
.module = THIS_MODULE,
.auto_attach = cb_pcimdda_auto_attach,
- .detach = comedi_pci_disable,
+ .detach = comedi_pci_detach,
};
static int cb_pcimdda_pci_probe(struct pci_dev *dev,
.driver_name = "contec_pci_dio",
.module = THIS_MODULE,
.auto_attach = contec_auto_attach,
- .detach = comedi_pci_disable,
+ .detach = comedi_pci_detach,
};
static int contec_pci_dio_pci_probe(struct pci_dev *dev,
{
struct daqboard2000_private *devpriv = dev->private;
- if (dev->irq)
- free_irq(dev->irq, dev);
- if (devpriv) {
- if (dev->mmio)
- iounmap(dev->mmio);
- if (devpriv->plx)
- iounmap(devpriv->plx);
- }
- comedi_pci_disable(dev);
+ if (devpriv && devpriv->plx)
+ iounmap(devpriv->plx);
+ comedi_pci_detach(dev);
}
static struct comedi_driver daqboard2000_driver = {
.driver_name = "pci-das08",
.module = THIS_MODULE,
.auto_attach = das08_pci_auto_attach,
- .detach = comedi_pci_disable,
+ .detach = comedi_pci_detach,
};
static int das08_pci_probe(struct pci_dev *dev,
return 0;
}
-static void dt3000_detach(struct comedi_device *dev)
-{
- if (dev->irq)
- free_irq(dev->irq, dev);
- if (dev->mmio)
- iounmap(dev->mmio);
- comedi_pci_disable(dev);
-}
-
static struct comedi_driver dt3000_driver = {
.driver_name = "dt3000",
.module = THIS_MODULE,
.auto_attach = dt3000_auto_attach,
- .detach = dt3000_detach,
+ .detach = comedi_pci_detach,
};
static int dt3000_pci_probe(struct pci_dev *dev,
{
struct dyna_pci10xx_private *devpriv = dev->private;
+ comedi_pci_detach(dev);
if (devpriv)
mutex_destroy(&devpriv->mutex);
- comedi_pci_disable(dev);
}
static struct comedi_driver dyna_pci10xx_driver = {
if (devpriv)
if (devpriv->valid)
icp_multi_reset(dev);
- if (dev->irq)
- free_irq(dev->irq, dev);
- if (dev->mmio)
- iounmap(dev->mmio);
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver icp_multi_driver = {
.driver_name = "ke_counter",
.module = THIS_MODULE,
.auto_attach = ke_counter_auto_attach,
- .detach = comedi_pci_disable,
+ .detach = comedi_pci_detach,
};
static int ke_counter_pci_probe(struct pci_dev *dev,
static void me4000_detach(struct comedi_device *dev)
{
- if (dev->irq)
- free_irq(dev->irq, dev);
if (dev->iobase)
me4000_reset(dev);
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver me4000_driver = {
struct me_private_data *dev_private = dev->private;
if (dev_private) {
- if (dev->mmio) {
+ if (dev->mmio)
me_reset(dev);
- iounmap(dev->mmio);
- }
if (dev_private->plx_regbase)
iounmap(dev_private->plx_regbase);
}
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver me_daq_driver = {
{
struct mf6x4_private *devpriv = dev->private;
- if (devpriv->bar0_mem)
- iounmap(devpriv->bar0_mem);
- if (dev->mmio)
- iounmap(dev->mmio);
- if (devpriv->bar2_mem)
- iounmap(devpriv->bar2_mem);
-
- comedi_pci_disable(dev);
+ if (devpriv) {
+ if (devpriv->bar0_mem)
+ iounmap(devpriv->bar0_mem);
+ if (devpriv->bar2_mem)
+ iounmap(devpriv->bar2_mem);
+ }
+ comedi_pci_detach(dev);
}
static struct comedi_driver mf6x4_driver = {
{
if (dev->mmio)
ni6527_reset(dev);
- if (dev->irq)
- free_irq(dev->irq, dev);
- if (dev->mmio)
- iounmap(dev->mmio);
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver ni6527_driver = {
static void ni_65xx_detach(struct comedi_device *dev)
{
- if (dev->mmio) {
+ if (dev->mmio)
writeb(0x00, dev->mmio + NI_65XX_CTRL_REG);
- iounmap(dev->mmio);
- }
- if (dev->irq)
- free_irq(dev->irq, dev);
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
}
static struct comedi_driver ni_65xx_driver = {
{
struct comedi_subdevice *s;
+ comedi_pci_detach(dev);
if (dev->n_subdevices) {
s = &dev->subdevices[0];
if (s)
kfree(s->range_table_list);
}
- if (dev->mmio)
- iounmap(dev->mmio);
- comedi_pci_disable(dev);
}
static struct comedi_driver ni_670x_driver = {
return labpc_common_attach(dev, pcidev->irq, IRQF_SHARED);
}
-static void labpc_pci_detach(struct comedi_device *dev)
-{
- if (dev->mmio)
- iounmap(dev->mmio);
- if (dev->irq)
- free_irq(dev->irq, dev);
- comedi_pci_disable(dev);
-}
-
static struct comedi_driver labpc_pci_comedi_driver = {
.driver_name = "labpc_pci",
.module = THIS_MODULE,
.auto_attach = labpc_pci_auto_attach,
- .detach = labpc_pci_detach,
+ .detach = comedi_pci_detach,
};
static const struct pci_device_id labpc_pci_table[] = {
* If PCI device enabled by _auto_attach() (or _attach()),
* disable it here.
*/
- comedi_pci_disable(dev);
+ comedi_pci_detach(dev);
} else {
/*
* ISA board