mirror of
https://github.com/torvalds/linux.git
synced 2024-12-20 01:52:13 +00:00
staging: comedi: adv_pci1724: absorb setup_subdevices()
For aesthetics, absorb this function into the (*auto_attach). Add some whitespace to the subdevice init. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
70adf763ba
commit
27de4358f9
@ -130,79 +130,66 @@ static int adv_pci1724_insn_write(struct comedi_device *dev,
|
|||||||
return insn->n;
|
return insn->n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate and initialize the subdevice structures.
|
|
||||||
*/
|
|
||||||
static int setup_subdevices(struct comedi_device *dev)
|
|
||||||
{
|
|
||||||
struct comedi_subdevice *s;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = comedi_alloc_subdevices(dev, 3);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
/* analog output subdevice */
|
|
||||||
s = &dev->subdevices[0];
|
|
||||||
s->type = COMEDI_SUBD_AO;
|
|
||||||
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND;
|
|
||||||
s->n_chan = 32;
|
|
||||||
s->maxdata = 0x3fff;
|
|
||||||
s->range_table = &ao_ranges_1724;
|
|
||||||
s->insn_write = adv_pci1724_insn_write;
|
|
||||||
s->private = (void *)PCI1724_DAC_CTRL_MODE_NORMAL;
|
|
||||||
|
|
||||||
ret = comedi_alloc_subdev_readback(s);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
/* offset calibration */
|
|
||||||
s = &dev->subdevices[1];
|
|
||||||
s->type = COMEDI_SUBD_CALIB;
|
|
||||||
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
|
|
||||||
s->n_chan = 32;
|
|
||||||
s->maxdata = 0x3fff;
|
|
||||||
s->insn_write = adv_pci1724_insn_write;
|
|
||||||
s->private = (void *)PCI1724_DAC_CTRL_MODE_OFFSET;
|
|
||||||
|
|
||||||
ret = comedi_alloc_subdev_readback(s);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
/* gain calibration */
|
|
||||||
s = &dev->subdevices[2];
|
|
||||||
s->type = COMEDI_SUBD_CALIB;
|
|
||||||
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
|
|
||||||
s->n_chan = 32;
|
|
||||||
s->maxdata = 0x3fff;
|
|
||||||
s->insn_write = adv_pci1724_insn_write;
|
|
||||||
s->private = (void *)PCI1724_DAC_CTRL_MODE_GAIN;
|
|
||||||
|
|
||||||
ret = comedi_alloc_subdev_readback(s);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int adv_pci1724_auto_attach(struct comedi_device *dev,
|
static int adv_pci1724_auto_attach(struct comedi_device *dev,
|
||||||
unsigned long context_unused)
|
unsigned long context_unused)
|
||||||
{
|
{
|
||||||
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
|
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
|
||||||
int retval;
|
struct comedi_subdevice *s;
|
||||||
unsigned int board_id;
|
unsigned int board_id;
|
||||||
|
int ret;
|
||||||
|
|
||||||
retval = comedi_pci_enable(dev);
|
ret = comedi_pci_enable(dev);
|
||||||
if (retval)
|
if (ret)
|
||||||
return retval;
|
return ret;
|
||||||
|
|
||||||
dev->iobase = pci_resource_start(pcidev, 2);
|
dev->iobase = pci_resource_start(pcidev, 2);
|
||||||
board_id = inl(dev->iobase + PCI1724_BOARD_ID_REG);
|
board_id = inl(dev->iobase + PCI1724_BOARD_ID_REG);
|
||||||
dev_info(dev->class_dev, "board id: %d\n",
|
dev_info(dev->class_dev, "board id: %d\n",
|
||||||
board_id & PCI1724_BOARD_ID_MASK);
|
board_id & PCI1724_BOARD_ID_MASK);
|
||||||
|
|
||||||
retval = setup_subdevices(dev);
|
ret = comedi_alloc_subdevices(dev, 3);
|
||||||
if (retval < 0)
|
if (ret)
|
||||||
return retval;
|
return ret;
|
||||||
|
|
||||||
|
/* Analog Output subdevice */
|
||||||
|
s = &dev->subdevices[0];
|
||||||
|
s->type = COMEDI_SUBD_AO;
|
||||||
|
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND;
|
||||||
|
s->n_chan = 32;
|
||||||
|
s->maxdata = 0x3fff;
|
||||||
|
s->range_table = &ao_ranges_1724;
|
||||||
|
s->insn_write = adv_pci1724_insn_write;
|
||||||
|
s->private = (void *)PCI1724_DAC_CTRL_MODE_NORMAL;
|
||||||
|
|
||||||
|
ret = comedi_alloc_subdev_readback(s);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
/* Offset Calibration subdevice */
|
||||||
|
s = &dev->subdevices[1];
|
||||||
|
s->type = COMEDI_SUBD_CALIB;
|
||||||
|
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
|
||||||
|
s->n_chan = 32;
|
||||||
|
s->maxdata = 0x3fff;
|
||||||
|
s->insn_write = adv_pci1724_insn_write;
|
||||||
|
s->private = (void *)PCI1724_DAC_CTRL_MODE_OFFSET;
|
||||||
|
|
||||||
|
ret = comedi_alloc_subdev_readback(s);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
/* Gain Calibration subdevice */
|
||||||
|
s = &dev->subdevices[2];
|
||||||
|
s->type = COMEDI_SUBD_CALIB;
|
||||||
|
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
|
||||||
|
s->n_chan = 32;
|
||||||
|
s->maxdata = 0x3fff;
|
||||||
|
s->insn_write = adv_pci1724_insn_write;
|
||||||
|
s->private = (void *)PCI1724_DAC_CTRL_MODE_GAIN;
|
||||||
|
|
||||||
|
ret = comedi_alloc_subdev_readback(s);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
dev_info(dev->class_dev, "%s (pci %s) attached, board id: %u\n",
|
dev_info(dev->class_dev, "%s (pci %s) attached, board id: %u\n",
|
||||||
dev->board_name, pci_name(pcidev), board_id);
|
dev->board_name, pci_name(pcidev), board_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user