Commit 21b74c27 authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: ni_pcidio: use comedi attach_pci callback

Convert this PCI driver to use the comedi `attach_pci` callback instead
of the `attach` callback for PCI auto-configuration.  There is no need
to support manual attachment of PCI devices supported by this driver, so
remove the `attach` callback altogether.

Note that this driver still uses the list of PCI "mite" devices created
by the "mite" module.  This will be dealt with by a later patch once
dynamic allocation of "mite" structures has been implemented.
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Reviewed-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9fb5c14c
...@@ -1103,34 +1103,36 @@ static int pci_6534_upload_firmware(struct comedi_device *dev) ...@@ -1103,34 +1103,36 @@ static int pci_6534_upload_firmware(struct comedi_device *dev)
return ret; return ret;
} }
static int nidio_find_device(struct comedi_device *dev, int bus, int slot) /* FIXME: remove this when dynamic MITE allocation implemented. */
static struct mite_struct *nidio_find_mite(struct pci_dev *pcidev)
{ {
struct mite_struct *mite; struct mite_struct *mite;
int i;
for (mite = mite_devices; mite; mite = mite->next) { for (mite = mite_devices; mite; mite = mite->next) {
if (mite->used) if (mite->used)
continue; continue;
if (bus || slot) { if (mite->pcidev == pcidev)
if (bus != mite->pcidev->bus->number || return mite;
slot != PCI_SLOT(mite->pcidev->devfn))
continue;
} }
for (i = 0; i < n_nidio_boards; i++) { return NULL;
if (mite_device_id(mite) == nidio_boards[i].dev_id) { }
dev->board_ptr = nidio_boards + i;
devpriv->mite = mite;
return 0; static const struct nidio_board *
} nidio_find_boardinfo(struct pci_dev *pcidev)
} {
unsigned int dev_id = pcidev->device;
unsigned int n;
for (n = 0; n < ARRAY_SIZE(nidio_boards); n++) {
const struct nidio_board *board = &nidio_boards[n];
if (board->dev_id == dev_id)
return board;
} }
dev_warn(dev->class_dev, "no device found\n"); return NULL;
mite_list_devices();
return -EIO;
} }
static int nidio_attach(struct comedi_device *dev, struct comedi_devconfig *it) static int __devinit nidio_attach_pci(struct comedi_device *dev,
struct pci_dev *pcidev)
{ {
struct comedi_subdevice *s; struct comedi_subdevice *s;
int ret; int ret;
...@@ -1141,9 +1143,12 @@ static int nidio_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1141,9 +1143,12 @@ static int nidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return ret; return ret;
spin_lock_init(&devpriv->mite_channel_lock); spin_lock_init(&devpriv->mite_channel_lock);
ret = nidio_find_device(dev, it->options[0], it->options[1]); dev->board_ptr = nidio_find_boardinfo(pcidev);
if (ret < 0) if (!dev->board_ptr)
return ret; return -ENODEV;
devpriv->mite = nidio_find_mite(pcidev);
if (!devpriv->mite)
return -ENODEV;
ret = mite_setup(devpriv->mite); ret = mite_setup(devpriv->mite);
if (ret < 0) { if (ret < 0) {
...@@ -1226,7 +1231,7 @@ static void nidio_detach(struct comedi_device *dev) ...@@ -1226,7 +1231,7 @@ static void nidio_detach(struct comedi_device *dev)
static struct comedi_driver ni_pcidio_driver = { static struct comedi_driver ni_pcidio_driver = {
.driver_name = "ni_pcidio", .driver_name = "ni_pcidio",
.module = THIS_MODULE, .module = THIS_MODULE,
.attach = nidio_attach, .attach_pci = nidio_attach_pci,
.detach = nidio_detach, .detach = nidio_detach,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment