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

staging: comedi: ni_670x: 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 b64c0f51
...@@ -187,37 +187,36 @@ static int ni_670x_dio_insn_config(struct comedi_device *dev, ...@@ -187,37 +187,36 @@ static int ni_670x_dio_insn_config(struct comedi_device *dev,
return insn->n; return insn->n;
} }
static int ni_670x_find_device(struct comedi_device *dev, int bus, int slot) /* FIXME: remove this when dynamic MITE allocation implemented. */
static struct mite_struct *ni_670x_find_mite(struct pci_dev *pcidev)
{ {
struct ni_670x_private *devpriv = dev->private;
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;
} }
return NULL;
}
for (i = 0; i < ARRAY_SIZE(ni_670x_boards); i++) { static const struct ni_670x_board *
if (mite_device_id(mite) == ni_670x_boards[i].dev_id) { ni_670x_find_boardinfo(struct pci_dev *pcidev)
dev->board_ptr = ni_670x_boards + i; {
devpriv->mite = mite; unsigned int dev_id = pcidev->device;
unsigned int n;
return 0; for (n = 0; n < ARRAY_SIZE(ni_670x_boards); n++) {
const struct ni_670x_board *board = &ni_670x_boards[n];
if (board->dev_id == dev_id)
return board;
} }
} return NULL;
}
dev_warn(dev->class_dev, "no device found\n");
mite_list_devices();
return -EIO;
} }
static int ni_670x_attach(struct comedi_device *dev, static int __devinit ni_670x_attach_pci(struct comedi_device *dev,
struct comedi_devconfig *it) struct pci_dev *pcidev)
{ {
const struct ni_670x_board *thisboard; const struct ni_670x_board *thisboard;
struct ni_670x_private *devpriv; struct ni_670x_private *devpriv;
...@@ -229,10 +228,12 @@ static int ni_670x_attach(struct comedi_device *dev, ...@@ -229,10 +228,12 @@ static int ni_670x_attach(struct comedi_device *dev,
if (ret < 0) if (ret < 0)
return ret; return ret;
devpriv = dev->private; devpriv = dev->private;
dev->board_ptr = ni_670x_find_boardinfo(pcidev);
ret = ni_670x_find_device(dev, it->options[0], it->options[1]); if (!dev->board_ptr)
if (ret < 0) return -ENODEV;
return ret; devpriv->mite = ni_670x_find_mite(pcidev);
if (!devpriv->mite)
return -ENODEV;
thisboard = comedi_board(dev); thisboard = comedi_board(dev);
ret = mite_setup(devpriv->mite); ret = mite_setup(devpriv->mite);
...@@ -311,7 +312,7 @@ static void ni_670x_detach(struct comedi_device *dev) ...@@ -311,7 +312,7 @@ static void ni_670x_detach(struct comedi_device *dev)
static struct comedi_driver ni_670x_driver = { static struct comedi_driver ni_670x_driver = {
.driver_name = "ni_670x", .driver_name = "ni_670x",
.module = THIS_MODULE, .module = THIS_MODULE,
.attach = ni_670x_attach, .attach_pci = ni_670x_attach_pci,
.detach = ni_670x_detach, .detach = ni_670x_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