From: H Hartley Sweeten Date: Thu, 20 Nov 2014 22:07:19 +0000 (-0700) Subject: staging: comedi: cb_pcidas64: use subdevice readback for 'caldac_state' X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=37318bdb14aba8145644c7ca4b76b1ba3efbdcae;p=linux-beck.git staging: comedi: cb_pcidas64: use subdevice readback for 'caldac_state' Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the write-only calibration subdevice. Remove the then unused 'caldac_state' 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/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 4762e6a5f1b9..c641778f3464 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1107,7 +1107,6 @@ struct pcidas64_private { unsigned int ext_trig_falling; /* states of various devices stored to enable read-back */ unsigned int ad8402_state[2]; - unsigned int caldac_state[8]; short ai_cmd_running; unsigned int ai_fifo_segment_length; struct ext_clock_info ext_clock; @@ -3550,9 +3549,6 @@ static void caldac_write(struct comedi_device *dev, unsigned int channel, unsigned int value) { const struct pcidas64_board *thisboard = dev->board_ptr; - struct pcidas64_private *devpriv = dev->private; - - devpriv->caldac_state[channel] = value; switch (thisboard->layout) { case LAYOUT_60XX: @@ -3571,27 +3567,15 @@ static int calib_write_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct pcidas64_private *devpriv = dev->private; int channel = CR_CHAN(insn->chanspec); /* return immediately if setting hasn't changed, since * programming these things is slow */ - if (devpriv->caldac_state[channel] == data[0]) + if (s->readback[channel] == data[0]) return 1; caldac_write(dev, channel, data[0]); - - return 1; -} - -static int calib_read_insn(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, - unsigned int *data) -{ - struct pcidas64_private *devpriv = dev->private; - unsigned int channel = CR_CHAN(insn->chanspec); - - data[0] = devpriv->caldac_state[channel]; + s->readback[channel] = data[0]; return 1; } @@ -3864,10 +3848,16 @@ static int setup_subdevices(struct comedi_device *dev) s->maxdata = 0xfff; else s->maxdata = 0xff; - s->insn_read = calib_read_insn; s->insn_write = calib_write_insn; - for (i = 0; i < s->n_chan; i++) + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + + for (i = 0; i < s->n_chan; i++) { caldac_write(dev, i, s->maxdata / 2); + s->readback[i] = s->maxdata / 2; + } /* 2 channel ad8402 potentiometer */ s = &dev->subdevices[7];