From: H Hartley Sweeten Date: Thu, 20 Nov 2014 22:07:34 +0000 (-0700) Subject: staging: comedi: ni_labpc_common: use subdevice readback for analog outputs X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=c82f0e6b364890df25f2d9cd05dd4103dcc02d15;p=linux-beck.git staging: comedi: ni_labpc_common: use subdevice readback for analog outputs Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the analog output subdevice. Remove the then unused 'ao_value' member from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h index 3261e226cc3d..e6a95f94774c 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.h +++ b/drivers/staging/comedi/drivers/ni_labpc.h @@ -37,8 +37,6 @@ struct labpc_boardinfo { struct labpc_private { /* number of data points left to be taken */ unsigned long long count; - /* software copy of analog output values */ - unsigned int ao_value[NUM_AO_CHAN]; /* software copys of bits written to command registers */ unsigned int cmd1; unsigned int cmd2; diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c index 354c33e6f21c..a6c63b511a66 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_common.c +++ b/drivers/staging/comedi/drivers/ni_labpc_common.c @@ -927,7 +927,7 @@ static void labpc_ao_write(struct comedi_device *dev, devpriv->write_byte(dev, val & 0xff, DAC_LSB_REG(chan)); devpriv->write_byte(dev, (val >> 8) & 0xff, DAC_MSB_REG(chan)); - devpriv->ao_value[chan] = val; + s->readback[chan] = val; } static int labpc_ao_insn_write(struct comedi_device *dev, @@ -966,18 +966,6 @@ static int labpc_ao_insn_write(struct comedi_device *dev, return 1; } -static int labpc_ao_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct labpc_private *devpriv = dev->private; - - data[0] = devpriv->ao_value[CR_CHAN(insn->chanspec)]; - - return 1; -} - /* lowlevel write to eeprom/dac */ static void labpc_serial_out(struct comedi_device *dev, unsigned int value, unsigned int value_width) @@ -1301,9 +1289,12 @@ int labpc_common_attach(struct comedi_device *dev, s->n_chan = NUM_AO_CHAN; s->maxdata = 0x0fff; s->range_table = &range_labpc_ao; - s->insn_read = labpc_ao_insn_read; s->insn_write = labpc_ao_insn_write; + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + /* initialize analog outputs to a known value */ for (i = 0; i < s->n_chan; i++) labpc_ao_write(dev, s, i, s->maxdata / 2);