Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 318112
b: refs/heads/master
c: 1f20b97
h: refs/heads/master
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Jul 19, 2012
1 parent 7b11dd6 commit ad2bb89
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 34 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: 9e9e13f53f739c86070a4ad09e49a4e7543dd31d
refs/heads/master: 1f20b973f68346af2712e5d014932d984b6f5387
71 changes: 38 additions & 33 deletions trunk/drivers/staging/comedi/drivers/dyna_pci10xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,36 +229,15 @@ static int dyna_pci10xx_do_insn_bits(struct comedi_device *dev,
return insn->n;
}

/******************************************************************************/
/*********************** INITIALIZATION FUNCTIONS *****************************/
/******************************************************************************/

static int dyna_pci10xx_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
static struct pci_dev *dyna_pci10xx_find_pci_dev(struct comedi_device *dev,
struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
struct pci_dev *pcidev;
unsigned int opt_bus, opt_slot;
int board_index, i;
int ret;

mutex_lock(&start_stop_sem);

if (alloc_private(dev, sizeof(struct dyna_pci10xx_private)) < 0) {
printk(KERN_ERR "comedi: dyna_pci10xx: "
"failed to allocate memory!\n");
mutex_unlock(&start_stop_sem);
return -ENOMEM;
}

opt_bus = it->options[0];
opt_slot = it->options[1];
dev->board_name = thisboard->name;
dev->irq = 0;
struct pci_dev *pcidev = NULL;
int opt_bus = it->options[0];
int opt_slot = it->options[1];
int board_index;
int i;

/*
* Probe the PCI bus and located the matching device
*/
for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
pcidev != NULL;
pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
Expand All @@ -285,8 +264,7 @@ static int dyna_pci10xx_attach(struct comedi_device *dev,
goto found;
}
printk(KERN_ERR "comedi: dyna_pci10xx: no supported device found!\n");
mutex_unlock(&start_stop_sem);
return -EIO;
return NULL;

found:

Expand All @@ -299,9 +277,38 @@ static int dyna_pci10xx_attach(struct comedi_device *dev,
printk(KERN_ERR "comedi: dyna_pci10xx: "
"invalid PCI device\n");
}
return NULL;
}

dev->board_ptr = &boardtypes[board_index];
return pcidev;
}

static int dyna_pci10xx_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
struct pci_dev *pcidev;
struct comedi_subdevice *s;
int ret;

mutex_lock(&start_stop_sem);

if (alloc_private(dev, sizeof(struct dyna_pci10xx_private)) < 0) {
printk(KERN_ERR "comedi: dyna_pci10xx: "
"failed to allocate memory!\n");
mutex_unlock(&start_stop_sem);
return -ENOMEM;
}

pcidev = dyna_pci10xx_find_pci_dev(dev, it);
if (!pcidev) {
mutex_unlock(&start_stop_sem);
return -EIO;
}
devpriv->pci_dev = pcidev;

dev->board_name = thisboard->name;
dev->irq = 0;

if (comedi_pci_enable(pcidev, DRV_NAME)) {
printk(KERN_ERR "comedi: dyna_pci10xx: "
Expand All @@ -311,8 +318,6 @@ static int dyna_pci10xx_attach(struct comedi_device *dev,
}

mutex_init(&devpriv->mutex);
dev->board_ptr = &boardtypes[board_index];
devpriv->pci_dev = pcidev;

printk(KERN_INFO "comedi: dyna_pci10xx: device found!\n");

Expand Down Expand Up @@ -375,7 +380,7 @@ static int dyna_pci10xx_attach(struct comedi_device *dev,
mutex_unlock(&start_stop_sem);

printk(KERN_INFO "comedi: dyna_pci10xx: %s - device setup completed!\n",
boardtypes[board_index].name);
thisboard->name);

return 1;
}
Expand Down

0 comments on commit ad2bb89

Please sign in to comment.