Commit 9c034da1 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

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: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a1c76758
Loading
Loading
Loading
Loading
+25 −23
Original line number Diff line number Diff line
@@ -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;

		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);
	outw(value, devpriv->control_status + CALIBRATION_REG);
	udelay(1);
		outw(value | SELECT_DAC08_BIT, cal_reg);
	outw(value | SELECT_DAC08_BIT,
	     devpriv->control_status + CALIBRATION_REG);
	udelay(1);
		outw(value, cal_reg);
	outw(value, devpriv->control_status + CALIBRATION_REG);
	udelay(1);
}
}

static int dac08_write_insn(struct comedi_device *dev,
static int cb_pcidas_dac08_insn_write(struct comedi_device *dev,
				      struct comedi_subdevice *s,
			    struct comedi_insn *insn, unsigned int *data)
				      struct comedi_insn *insn,
				      unsigned int *data)
{
	int i;
	struct cb_pcidas_private *devpriv = dev->private;

	for (i = 0; i < insn->n; i++)
		dac08_write(dev, data[i]);
	if (insn->n) {
		unsigned int val = data[insn->n - 1];

		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;