/**
* comedi_pci_enable() - Enable the PCI device and request the regions.
- * @pcidev: pci_dev struct
- * @res_name: name for the requested reqource
+ * @dev: comedi_device struct
*/
-int comedi_pci_enable(struct pci_dev *pcidev, const char *res_name)
+int comedi_pci_enable(struct comedi_device *dev)
{
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
int rc;
+ if (!pcidev)
+ return -ENODEV;
+
rc = pci_enable_device(pcidev);
if (rc < 0)
return rc;
- rc = pci_request_regions(pcidev, res_name);
+ rc = pci_request_regions(pcidev, dev->board_name
+ ? dev->board_name
+ : dev->driver->driver_name);
if (rc < 0)
pci_disable_device(pcidev);
struct pci_dev *comedi_to_pci_dev(struct comedi_device *);
-int comedi_pci_enable(struct pci_dev *, const char *);
+int comedi_pci_enable(struct comedi_device *);
void comedi_pci_disable(struct comedi_device *);
int comedi_pci_auto_config(struct pci_dev *, struct comedi_driver *,
return NULL;
}
-static inline int comedi_pci_enable(struct pci_dev *dev, const char *name)
+static inline int comedi_pci_enable(struct comedi_device *dev)
{
return -ENOSYS;
}
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
iobase = pci_resource_start(pcidev, board->dio_badr);
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->board_ptr = board;
dev->board_name = board->name;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->board_name = dev->driver->driver_name;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = pci_resource_start(pcidev, 1);
dev->board_name = dev->driver->driver_name;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
pci_set_master(pcidev);
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = pci_resource_start(pcidev, 2);
dev->board_ptr = board;
dev->board_name = board->name;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = pci_resource_start(pcidev, 2);
dev->board_name = dev->driver->driver_name;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = pci_resource_start(pcidev, 2);
return -ENOMEM;
dev->private = dev_private;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev_private->lcr_io_base = pci_resource_start(pcidev, 1);
u16 u16w;
dev->board_name = this_board->name;
- ret = comedi_pci_enable(pcidev, dev->board_name);
- if (ret) {
- dev_err(dev->class_dev,
- "cannot enable PCI device %s\n", pci_name(pcidev));
+ ret = comedi_pci_enable(dev);
+ if (ret)
return ret;
- }
if (master)
pci_set_master(pcidev);
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = pci_resource_start(pcidev, 2);
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = pci_resource_start(pcidev, 2);
dev->board_name = dev->driver->driver_name;
- retval = comedi_pci_enable(pcidev, dev->board_name);
+ retval = comedi_pci_enable(dev);
if (retval)
return retval;
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = pci_resource_start(pcidev, this_board->main_pci_region);
return -EINVAL;
}
thisboard = comedi_board(dev);
- ret = comedi_pci_enable(pci_dev, DIO200_DRIVER_NAME);
- if (ret < 0) {
- dev_err(dev->class_dev,
- "error! cannot enable PCI device and request regions!\n");
+
+ ret = comedi_pci_enable(dev);
+ if (ret)
return ret;
- }
+
bar = thisboard->mainbar;
base = pci_resource_start(pci_dev, bar);
len = pci_resource_len(pci_dev, bar);
comedi_set_hw_dev(dev, &pci_dev->dev);
- ret = comedi_pci_enable(pci_dev, PC236_DRIVER_NAME);
- if (ret < 0) {
- dev_err(dev->class_dev,
- "error! cannot enable PCI device and request regions!\n");
+ ret = comedi_pci_enable(dev);
+ if (ret)
return ret;
- }
+
devpriv->lcr_iobase = pci_resource_start(pci_dev, 1);
iobase = pci_resource_start(pci_dev, 2);
return pc236_common_attach(dev, iobase, pci_dev->irq, IRQF_SHARED);
comedi_set_hw_dev(dev, &pci_dev->dev);
- ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME);
- if (ret < 0) {
- dev_err(dev->class_dev,
- "error! cannot enable PCI device and request regions!\n");
+ ret = comedi_pci_enable(dev);
+ if (ret)
return ret;
- }
iobase = pci_resource_start(pci_dev, 2);
+
return pc263_common_attach(dev, iobase);
}
comedi_set_hw_dev(dev, &pci_dev->dev);
- ret = comedi_pci_enable(pci_dev, DRIVER_NAME);
- if (ret < 0) {
- dev_err(dev->class_dev,
- "error! cannot enable PCI device and request regions!\n"
- );
+ ret = comedi_pci_enable(dev);
+ if (ret)
return ret;
- }
+
spin_lock_init(&devpriv->ao_spinlock);
devpriv->iobase1 = pci_resource_start(pci_dev, 2);
comedi_set_hw_dev(dev, &pci_dev->dev);
dev->board_name = thisboard->name;
- /* Enable PCI device and reserve I/O spaces. */
- if (comedi_pci_enable(pci_dev, "amplc_pci230") < 0) {
- dev_err(dev->class_dev,
- "failed to enable PCI device and request regions\n");
- return -EIO;
- }
+
+ rc = comedi_pci_enable(dev);
+ if (rc)
+ return rc;
+
/* Read base addresses of the PCI230's two I/O regions from PCI
* configuration register. */
iobase1 = pci_resource_start(pci_dev, 2);
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = 1;
return -ENOMEM;
dev->private = devpriv;
- if (comedi_pci_enable(pcidev, dev->driver->driver_name)) {
- dev_warn(dev->class_dev,
- "failed to enable PCI device and request regions\n");
- return -EIO;
- }
+ retval = comedi_pci_enable(dev);
+ if (retval)
+ return retval;
pci_set_master(pcidev);
/* Initialize dev->board_name */
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = pci_resource_start(pcidev, 3);
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = pci_resource_start(pcidev, 3);
dev->board_name = dev->driver->driver_name;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = pci_resource_start(pcidev, 0);
return -ENOMEM;
dev->private = devpriv;
- result = comedi_pci_enable(pcidev, dev->driver->driver_name);
- if (result < 0)
+ result = comedi_pci_enable(dev);
+ if (result)
return result;
dev->iobase = 1; /* the "detach" needs this */
/* The das08 driver needs the board_ptr */
dev->board_ptr = &das08_pci_boards[0];
- ret = comedi_pci_enable(pdev, dev->driver->driver_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = pci_resource_start(pdev, 2);
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret < 0)
return ret;
dev->iobase = 1; /* the "detach" needs this */
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = pci_resource_start(pcidev, 2);
return -ENOMEM;
dev->private = devpriv;
- if (comedi_pci_enable(pcidev, dev->board_name)) {
- dev_warn(dev->class_dev,
- "failed enable PCI device and request regions\n");
- return -EIO;
- }
+ retval = comedi_pci_enable(dev);
+ if (retval)
+ return retval;
dev->iobase = 1; /* the "detach" needs this */
pci_set_master(pcidev);
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
iobase = pci_resource_start(pcidev, 2);
}
dev->board_name = "jr3_pci";
- result = comedi_pci_enable(pcidev, "jr3_pci");
- if (result < 0)
+ result = comedi_pci_enable(dev);
+ if (result)
return result;
-
dev->iobase = 1; /* the "detach" needs this */
+
devpriv->iobase = ioremap(pci_resource_start(pcidev, 0),
offsetof(struct jr3_t,
channel[devpriv->n_channels]));
dev->board_name = dev->driver->driver_name;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = pci_resource_start(pcidev, 0);
return -ENOMEM;
dev->private = info;
- result = comedi_pci_enable(pcidev, dev->board_name);
+ result = comedi_pci_enable(dev);
if (result)
return result;
return -ENOMEM;
dev->private = dev_private;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = 1; /* detach needs this */
u32 csigr_bits;
unsigned unknown_dma_burst_bits;
- if (comedi_pci_enable(mite->pcidev, "mite")) {
- dev_err(&mite->pcidev->dev,
- "error enabling mite and requesting io regions\n");
- return -EIO;
- }
pci_set_master(mite->pcidev);
addr = pci_resource_start(mite->pcidev, 0);
dev->board_ptr = board;
dev->board_name = board->name;
+ ret = comedi_pci_enable(dev);
+ if (ret)
+ return ret;
+ dev->iobase = 1;
+
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev_err(dev->class_dev, "error setting up mite\n");
return ret;
}
- dev->iobase = 1;
dev_info(dev->class_dev, "board: %s, ID=0x%02x\n", dev->board_name,
readb(devpriv->mite->daq_io_addr + ID_Register));
dev->board_ptr = board;
dev->board_name = board->name;
+ ret = comedi_pci_enable(dev);
+ if (ret)
+ return ret;
+ dev->iobase = 1;
+
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev_warn(dev->class_dev, "error setting up mite\n");
return ret;
}
- dev->iobase = 1;
dev->irq = mite_irq(devpriv->mite);
dev_info(dev->class_dev, "board: %s, ID=0x%02x", dev->board_name,
dev->board_ptr = board;
dev->board_name = board->name;
+ ret = comedi_pci_enable(dev);
+ if (ret)
+ return ret;
+ dev->iobase = 1;
+
ret = ni_660x_allocate_private(dev);
if (ret < 0)
return ret;
dev_warn(dev->class_dev, "error setting up mite\n");
return ret;
}
- dev->iobase = 1;
ret = ni_660x_alloc_mite_rings(dev);
if (ret < 0)
dev->board_ptr = thisboard;
dev->board_name = thisboard->name;
+ ret = comedi_pci_enable(dev);
+ if (ret)
+ return ret;
+ dev->iobase = 1;
+
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev_warn(dev->class_dev, "error setting up mite\n");
return ret;
}
- dev->iobase = 1;
ret = comedi_alloc_subdevices(dev, 2);
if (ret)
if (!IS_ENABLED(CONFIG_COMEDI_PCI_DRIVERS))
return -ENODEV;
+ ret = comedi_pci_enable(dev);
+ if (ret)
+ return ret;
+ dev->iobase = 1;
+
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
ret = mite_setup(devpriv->mite);
if (ret < 0)
return ret;
- dev->iobase = 1;
iobase = (unsigned long)devpriv->mite->daq_io_addr;
irq = mite_irq(devpriv->mite);
return labpc_common_attach(dev, iobase, irq, 0);
dev->board_ptr = board;
dev->board_name = board->name;
+ ret = comedi_pci_enable(dev);
+ if (ret)
+ return ret;
+ dev->iobase = 1;
+
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev_warn(dev->class_dev, "error setting up mite\n");
return ret;
}
- dev->iobase = 1;
devpriv->di_mite_ring = mite_alloc_ring(devpriv->mite);
if (devpriv->di_mite_ring == NULL)
dev->board_ptr = board;
dev->board_name = board->name;
+ ret = comedi_pci_enable(dev);
+ if (ret)
+ return ret;
+ dev->iobase = 1;
+
ret = ni_alloc_private(dev);
if (ret)
return ret;
pr_warn("error setting up mite\n");
return ret;
}
- dev->iobase = 1;
devpriv->ai_mite_ring = mite_alloc_ring(devpriv->mite);
if (devpriv->ai_mite_ring == NULL)
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = 1; /* the "detach" needs this */
return -ENOMEM;
dev->private = devpriv;
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;
dev->iobase = 1; /* detach needs this */
dev->private = devpriv;
/* Enable the PCI device. */
- ret = comedi_pci_enable(pcidev, dev->board_name);
+ ret = comedi_pci_enable(dev);
if (ret)
return ret;