From: H Hartley Sweeten Date: Thu, 20 Nov 2014 22:07:31 +0000 (-0700) Subject: staging: comedi: ni_labpc_common: move calib readback value check/save to (*insn_write) X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=332f46e4be24f252fdc719abd52f3ac711c0aab4;p=linux-beck.git staging: comedi: ni_labpc_common: move calib readback value check/save to (*insn_write) Move the check/save of the calib subdevice value to the (*insn_write) function. 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_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c index 685220369c32..4abca1d1db72 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_common.c +++ b/drivers/staging/comedi/drivers/ni_labpc_common.c @@ -1150,10 +1150,6 @@ static void write_caldac(struct comedi_device *dev, unsigned int channel, { struct labpc_private *devpriv = dev->private; - if (value == devpriv->caldac[channel]) - return; - devpriv->caldac[channel] = value; - /* clear caldac load bit and make sure we don't write to eeprom */ devpriv->cmd5 &= ~(CMD5_CALDACLD | CMD5_EEPROMCS | CMD5_WRTPRT); udelay(1); @@ -1178,14 +1174,21 @@ static int labpc_calib_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { + struct labpc_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); /* * Only write the last data value to the caldac. Preceding * data would be overwritten anyway. */ - if (insn->n > 0) - write_caldac(dev, chan, data[insn->n - 1]); + if (insn->n > 0) { + unsigned int val = data[insn->n - 1]; + + if (devpriv->caldac[chan] != val) { + write_caldac(dev, chan, val); + devpriv->caldac[chan] = val; + } + } return insn->n; } @@ -1345,8 +1348,10 @@ int labpc_common_attach(struct comedi_device *dev, s->insn_read = labpc_calib_insn_read; s->insn_write = labpc_calib_insn_write; - for (i = 0; i < s->n_chan; i++) + for (i = 0; i < s->n_chan; i++) { write_caldac(dev, i, s->maxdata / 2); + devpriv->caldac[i] = s->maxdata / 2; + } } else { s->type = COMEDI_SUBD_UNUSED; }