Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 337645
b: refs/heads/master
c: b91524e
h: refs/heads/master
i:
  337643: ab87379
v: v3
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Nov 6, 2012
1 parent 93a7947 commit 05aa12b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 40 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: 15358a7f777529500cb1fcb089c09fb792fecf30
refs/heads/master: b91524ee48771586b99bfbed9d4607c3e407d7cb
57 changes: 18 additions & 39 deletions trunk/drivers/staging/comedi/drivers/cb_pcidas64.c
Original file line number Diff line number Diff line change
Expand Up @@ -1645,57 +1645,38 @@ static inline void warn_external_queue(struct comedi_device *dev)
"Use internal AI channel queue (channels must be consecutive and use same range/aref)");
}

static struct pci_dev *cb_pcidas64_find_pci_dev(struct comedi_device *dev,
struct comedi_devconfig *it)
static const struct pcidas64_board
*cb_pcidas64_find_pci_board(struct pci_dev *pcidev)
{
struct pci_dev *pcidev = NULL;
int bus = it->options[0];
int slot = it->options[1];
int i;
unsigned int i;

for_each_pci_dev(pcidev) {
if (bus || slot) {
if (bus != pcidev->bus->number ||
slot != PCI_SLOT(pcidev->devfn))
continue;
}
if (pcidev->vendor != PCI_VENDOR_ID_CB)
continue;

for (i = 0; i < ARRAY_SIZE(pcidas64_boards); i++) {
if (pcidas64_boards[i].device_id != pcidev->device)
continue;
dev->board_ptr = pcidas64_boards + i;
return pcidev;
}
}
dev_err(dev->class_dev,
"No supported board found! (req. bus %d, slot %d)\n",
bus, slot);
for (i = 0; i < ARRAY_SIZE(pcidas64_boards); i++)
if (pcidev->device == pcidas64_boards[i].device_id)
return &pcidas64_boards[i];
return NULL;
}

/*
* Attach is called by the Comedi core to configure the driver
* for a particular board.
*/
static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
static int __devinit auto_attach(struct comedi_device *dev,
unsigned long context_unused)
{
struct pcidas64_private *devpriv;
struct pci_dev *pcidev;
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
uint32_t local_range, local_decode;
int retval;

dev->board_ptr = cb_pcidas64_find_pci_board(pcidev);
if (!dev->board_ptr) {
dev_err(dev->class_dev,
"cb_pcidas64: does not support pci %s\n",
pci_name(pcidev));
return -EINVAL;
}

devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;

pcidev = cb_pcidas64_find_pci_dev(dev, it);
if (!pcidev)
return -EIO;
comedi_set_hw_dev(dev, &pcidev->dev);

if (comedi_pci_enable(pcidev, dev->driver->driver_name)) {
dev_warn(dev->class_dev,
"failed to enable PCI device and request regions\n");
Expand Down Expand Up @@ -1838,8 +1819,6 @@ static void detach(struct comedi_device *dev)
if (pcidev) {
if (dev->iobase)
comedi_pci_disable(pcidev);

pci_dev_put(pcidev);
}
}

Expand Down Expand Up @@ -4240,7 +4219,7 @@ static void i2c_write(struct comedi_device *dev, unsigned int address,
static struct comedi_driver cb_pcidas64_driver = {
.driver_name = "cb_pcidas64",
.module = THIS_MODULE,
.attach = attach,
.auto_attach = auto_attach,
.detach = detach,
};

Expand Down

0 comments on commit 05aa12b

Please sign in to comment.