aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <[email protected]>2014-11-20 15:10:46 -0700
committerGreg Kroah-Hartman <[email protected]>2014-11-26 15:36:40 -0800
commit5081162d6c6b93ace4039da13571149268ba74ba (patch)
tree383701d105a0d9866f9510686bdfd5e45e7617af
parent38020b55e7ced8398378b9023e41e9e1470b64cc (diff)
staging: comedi: adv_pci1724: use subdevice readback for 'gain_value'
Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the write-only gain calib subdevice. Remove the then unused 'gain_value' member from the private data. The private data is now unnecessary. Remove it and the allocation. Signed-off-by: H Hartley Sweeten <[email protected]> Reviewed-by: Ian Abbott <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r--drivers/staging/comedi/drivers/adv_pci1724.c46
1 files changed, 6 insertions, 40 deletions
diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c
index 4aa1631de547..735522876c80 100644
--- a/drivers/staging/comedi/drivers/adv_pci1724.c
+++ b/drivers/staging/comedi/drivers/adv_pci1724.c
@@ -125,11 +125,6 @@ static const struct comedi_lrange ao_ranges_1724 = {
}
};
-/* this structure is for data unique to this hardware driver. */
-struct adv_pci1724_private {
- int gain_value[NUM_AO_CHANNELS];
-};
-
static int wait_for_dac_idle(struct comedi_device *dev)
{
static const int timeout = 10000;
@@ -209,7 +204,6 @@ static int gain_write_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- struct adv_pci1724_private *devpriv = dev->private;
int channel = CR_CHAN(insn->chanspec);
int retval;
int i;
@@ -221,27 +215,8 @@ static int gain_write_insn(struct comedi_device *dev,
retval = set_dac(dev, DAC_GAIN_MODE, channel, data[i]);
if (retval < 0)
return retval;
- devpriv->gain_value[channel] = data[i];
- }
-
- return insn->n;
-}
-
-static int gain_read_insn(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data)
-{
- struct adv_pci1724_private *devpriv = dev->private;
- unsigned int channel = CR_CHAN(insn->chanspec);
- int i;
-
- if (devpriv->gain_value[channel] < 0) {
- dev_err(dev->class_dev,
- "Cannot read back channels which have not yet been written to\n");
- return -EIO;
+ s->readback[channel] = data[i];
}
- for (i = 0; i < insn->n; i++)
- data[i] = devpriv->gain_value[channel];
return insn->n;
}
@@ -287,9 +262,12 @@ static int setup_subdevices(struct comedi_device *dev)
s->type = COMEDI_SUBD_CALIB;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
s->n_chan = NUM_AO_CHANNELS;
- s->insn_read = gain_read_insn;
- s->insn_write = gain_write_insn;
s->maxdata = 0x3fff;
+ s->insn_write = gain_write_insn;
+
+ ret = comedi_alloc_subdev_readback(s);
+ if (ret)
+ return ret;
return 0;
}
@@ -298,21 +276,9 @@ static int adv_pci1724_auto_attach(struct comedi_device *dev,
unsigned long context_unused)
{
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
- struct adv_pci1724_private *devpriv;
- int i;
int retval;
unsigned int board_id;
- devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
- if (!devpriv)
- return -ENOMEM;
-
- /* init software copies of output values to indicate we don't know
- * what the output value is since it has never been written. */
- for (i = 0; i < NUM_AO_CHANNELS; ++i) {
- devpriv->gain_value[i] = -1;
- }
-
retval = comedi_pci_enable(dev);
if (retval)
return retval;