Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 324585
b: refs/heads/master
c: b41bf58
h: refs/heads/master
i:
  324583: 6482abd
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Aug 17, 2012
1 parent f3ddff8 commit 94b1e9c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 46 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d1438d4158ed9650e8beffb4eac22e6ae62a0200
refs/heads/master: b41bf58f3a088008d856b02faedfdf23167833a2
62 changes: 17 additions & 45 deletions trunk/drivers/staging/comedi/drivers/cb_pcimdda.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,61 +213,38 @@ 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,
struct comedi_devconfig *it)
{
const struct cb_pcimdda_board *thisboard;
struct cb_pcimdda_private *devpriv;
struct pci_dev *pcidev;
struct comedi_subdevice *s;
int err;

Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 94b1e9c

Please sign in to comment.