diff options
author | H Hartley Sweeten <hartleys@visionengravers.com> | 2012-08-16 19:48:56 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-17 08:14:33 -0700 |
commit | b41bf58f3a088008d856b02faedfdf23167833a2 (patch) | |
tree | eb7f007fba61204f3a86a83f943fbbe0adfb1ed4 | |
parent | d1438d4158ed9650e8beffb4eac22e6ae62a0200 (diff) |
staging: comedi: cb_pcimdda: cleanup pci probe
Make cb_pcimdda_probe() return the pointer to the found pci_dev
and move the comedi_pci_enable() call into the 'attach' function.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/comedi/drivers/cb_pcimdda.c | 62 |
1 files changed, 17 insertions, 45 deletions
diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index edce2756c706..0c6d941946fa 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c @@ -213,54 +213,30 @@ static int cb_pcimdda_ao_rinsn(struct comedi_device *dev, return i; } -static int cb_pcimdda_probe(struct comedi_device *dev, - const struct comedi_devconfig *it) +static struct pci_dev *cb_pcimdda_probe(struct comedi_device *dev, + struct comedi_devconfig *it) { - const struct cb_pcimdda_board *thisboard; - struct cb_pcimdda_private *devpriv = dev->private; struct pci_dev *pcidev = NULL; int index; - unsigned long registers; for_each_pci_dev(pcidev) { - /* is it not a computer boards card? */ if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS) continue; - /* loop through cards supported by this driver */ for (index = 0; index < ARRAY_SIZE(cb_pcimdda_boards); index++) { if (cb_pcimdda_boards[index].device_id != pcidev->device) continue; - /* was a particular bus/slot requested? */ if (it->options[0] || it->options[1]) { - /* are we on the wrong bus/slot? */ if (pcidev->bus->number != it->options[0] || PCI_SLOT(pcidev->devfn) != it->options[1]) { continue; } } - /* found ! */ - devpriv->pci_dev = pcidev; dev->board_ptr = cb_pcimdda_boards + index; - thisboard = comedi_board(dev); - if (comedi_pci_enable(pcidev, thisboard->name)) { - printk - ("cb_pcimdda: Failed to enable PCI device and request regions\n"); - return -EIO; - } - registers = - pci_resource_start(devpriv->pci_dev, - thisboard->regs_badrindex); - devpriv->registers = registers; - devpriv->dio_registers - = devpriv->registers + thisboard->dio_offset; - return 0; + return pcidev; } } - - printk("cb_pcimdda: No supported ComputerBoards/MeasurementComputing " - "card found at the requested position\n"); - return -ENODEV; + return NULL; } static int cb_pcimdda_attach(struct comedi_device *dev, @@ -268,6 +244,7 @@ static int cb_pcimdda_attach(struct comedi_device *dev, { const struct cb_pcimdda_board *thisboard; struct cb_pcimdda_private *devpriv; + struct pci_dev *pcidev; struct comedi_subdevice *s; int err; @@ -276,25 +253,20 @@ static int cb_pcimdda_attach(struct comedi_device *dev, return err; devpriv = dev->private; -/* - * If you can probe the device to determine what device in a series - * it is, this is the place to do it. Otherwise, dev->board_ptr - * should already be initialized. - */ - err = cb_pcimdda_probe(dev, it); - if (err) - return err; + pcidev = cb_pcimdda_probe(dev, it); + if (!pcidev) + return -EIO; + devpriv->pci_dev = pcidev; thisboard = comedi_board(dev); - -/* Output some info */ - printk("comedi%d: %s: ", dev->minor, thisboard->name); - -/* - * Initialize dev->board_name. Note that we can use the "thisboard" - * macro now, since we just initialized it in the last line. - */ dev->board_name = thisboard->name; + err = comedi_pci_enable(pcidev, dev->board_name); + if (err) + return err; + devpriv->registers = pci_resource_start(devpriv->pci_dev, + thisboard->regs_badrindex); + devpriv->dio_registers = devpriv->registers + thisboard->dio_offset; + err = comedi_alloc_subdevices(dev, 2); if (err) return err; @@ -336,7 +308,7 @@ static int cb_pcimdda_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } - printk("attached\n"); + dev_info(dev->class_dev, "%s attached\n", dev->board_name); return 1; } |