staging: comedi: me4000: cleanup me4000_probe()
Move the non pci probe related code out of the me4000_probe function and back into the me4000_attach function in preparation of converting this driver to the 'attach_pci' callback. 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>
This commit is contained in:
parent
f4c772f0c3
commit
ba5cb4ba57
1 changed files with 31 additions and 36 deletions
|
@ -1737,18 +1737,11 @@ static int me4000_cnt_insn_write(struct comedi_device *dev,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
|
static struct pci_dev *me4000_probe(struct comedi_device *dev,
|
||||||
|
struct comedi_devconfig *it)
|
||||||
{
|
{
|
||||||
struct me4000_info *info;
|
|
||||||
struct pci_dev *pci_device = NULL;
|
struct pci_dev *pci_device = NULL;
|
||||||
int result, i;
|
int i;
|
||||||
const struct me4000_board *board;
|
|
||||||
|
|
||||||
/* Allocate private memory */
|
|
||||||
result = alloc_private(dev, sizeof(*info));
|
|
||||||
if (result)
|
|
||||||
return result;
|
|
||||||
info = dev->private;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Probe the device to determine what device in the series it is.
|
* Probe the device to determine what device in the series it is.
|
||||||
|
@ -1777,39 +1770,55 @@ static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dev->board_ptr = me4000_boards + i;
|
dev->board_ptr = me4000_boards + i;
|
||||||
board = comedi_board(dev);
|
return pci_device;
|
||||||
goto found;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -ENODEV;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
found:
|
static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||||
comedi_set_hw_dev(dev, &pci_device->dev);
|
{
|
||||||
dev->board_name = board->name;
|
const struct me4000_board *thisboard;
|
||||||
|
struct me4000_info *info;
|
||||||
|
struct pci_dev *pcidev;
|
||||||
|
struct comedi_subdevice *s;
|
||||||
|
int result;
|
||||||
|
|
||||||
result = comedi_pci_enable(pci_device, dev->board_name);
|
pcidev = me4000_probe(dev, it);
|
||||||
|
if (!pcidev)
|
||||||
|
return -ENODEV;
|
||||||
|
comedi_set_hw_dev(dev, &pcidev->dev);
|
||||||
|
thisboard = comedi_board(dev);
|
||||||
|
dev->board_name = thisboard->name;
|
||||||
|
|
||||||
|
result = alloc_private(dev, sizeof(*info));
|
||||||
|
if (result)
|
||||||
|
return result;
|
||||||
|
info = dev->private;
|
||||||
|
|
||||||
|
result = comedi_pci_enable(pcidev, dev->board_name);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
info->plx_regbase = pci_resource_start(pci_device, 1);
|
info->plx_regbase = pci_resource_start(pcidev, 1);
|
||||||
if (!info->plx_regbase)
|
if (!info->plx_regbase)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
dev->iobase = pci_resource_start(pci_device, 2);
|
dev->iobase = pci_resource_start(pcidev, 2);
|
||||||
if (!dev->iobase)
|
if (!dev->iobase)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
info->timer_regbase = pci_resource_start(pci_device, 3);
|
info->timer_regbase = pci_resource_start(pcidev, 3);
|
||||||
if (!info->timer_regbase)
|
if (!info->timer_regbase)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
info->program_regbase = pci_resource_start(pci_device, 5);
|
info->program_regbase = pci_resource_start(pcidev, 5);
|
||||||
if (!info->program_regbase)
|
if (!info->program_regbase)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
dev->irq = pci_device->irq;
|
dev->irq = pcidev->irq;
|
||||||
|
|
||||||
result = xilinx_download(dev);
|
result = xilinx_download(dev);
|
||||||
if (result)
|
if (result)
|
||||||
|
@ -1819,20 +1828,6 @@ found:
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
|
||||||
{
|
|
||||||
const struct me4000_board *thisboard;
|
|
||||||
struct comedi_subdevice *s;
|
|
||||||
int result;
|
|
||||||
|
|
||||||
result = me4000_probe(dev, it);
|
|
||||||
if (result)
|
|
||||||
return result;
|
|
||||||
thisboard = comedi_board(dev);
|
|
||||||
|
|
||||||
result = comedi_alloc_subdevices(dev, 4);
|
result = comedi_alloc_subdevices(dev, 4);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Add table
Reference in a new issue