summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2014-11-20 15:07:28 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-26 15:39:16 -0800
commit9c034da124d08237fe973ca0073f5f70297b20fb (patch)
tree6d67e68c08cfd3238f4ce777232d8ac22d5902fe /drivers
parenta1c76758987eac334a7dffcb0b50e597da4ded77 (diff)
staging: comedi: cb_pcidas: tidy up dac08_write_insn()
For consistency with the other calib subdevices, refactor this (*insn_write) function so that it only writes the final data value to the hardware., For aesthetics, rename the function so it has namespace associated with the driver. 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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidas.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c
index 86e3d200bb21..04b6d39d1051 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas.c
@@ -631,34 +631,35 @@ static int cb_pcidas_caldac_insn_write(struct comedi_device *dev,
static void dac08_write(struct comedi_device *dev, unsigned int value)
{
struct cb_pcidas_private *devpriv = dev->private;
- unsigned long cal_reg;
- if (devpriv->dac08_value != value) {
- devpriv->dac08_value = value;
+ value &= 0xff;
+ value |= cal_enable_bits(dev);
- cal_reg = devpriv->control_status + CALIBRATION_REG;
-
- value &= 0xff;
- value |= cal_enable_bits(dev);
-
- /* latch the new value into the caldac */
- outw(value, cal_reg);
- udelay(1);
- outw(value | SELECT_DAC08_BIT, cal_reg);
- udelay(1);
- outw(value, cal_reg);
- udelay(1);
- }
+ /* latch the new value into the caldac */
+ outw(value, devpriv->control_status + CALIBRATION_REG);
+ udelay(1);
+ outw(value | SELECT_DAC08_BIT,
+ devpriv->control_status + CALIBRATION_REG);
+ udelay(1);
+ outw(value, devpriv->control_status + CALIBRATION_REG);
+ udelay(1);
}
-static int dac08_write_insn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int cb_pcidas_dac08_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
{
- int i;
+ struct cb_pcidas_private *devpriv = dev->private;
+
+ if (insn->n) {
+ unsigned int val = data[insn->n - 1];
- for (i = 0; i < insn->n; i++)
- dac08_write(dev, data[i]);
+ if (devpriv->dac08_value != val) {
+ dac08_write(dev, val);
+ devpriv->dac08_value = val;
+ }
+ }
return insn->n;
}
@@ -1531,9 +1532,10 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev,
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
s->n_chan = NUM_CHANNELS_DAC08;
s->insn_read = dac08_read_insn;
- s->insn_write = dac08_write_insn;
+ s->insn_write = cb_pcidas_dac08_insn_write;
s->maxdata = 0xff;
dac08_write(dev, s->maxdata / 2);
+ devpriv->dac08_value = s->maxdata / 2;
} else
s->type = COMEDI_SUBD_UNUSED;