staging: comedi: cb_pcidas: absorb caldac/trimpot write functions

These functions are all just wrappers for cb_pcidas_calib_write().
Remove them and absorb the code into the callers.

Remove the unnecessary masking of the 'chan'. It will always be in
range due to the subdevice initialization.

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>
This commit is contained in:
H Hartley Sweeten 2015-10-13 17:47:50 -07:00 committed by Greg Kroah-Hartman
parent eddd2a4c67
commit 2d71464fd1
1 changed files with 12 additions and 26 deletions

View File

@ -571,13 +571,6 @@ static void cb_pcidas_calib_write(struct comedi_device *dev,
outw(calib_bits, devpriv->pcibar1 + PCIDAS_CALIB_REG); outw(calib_bits, devpriv->pcibar1 + PCIDAS_CALIB_REG);
} }
static void cb_pcidas_caldac_8800_write(struct comedi_device *dev,
unsigned int chan, unsigned int val)
{
/* write 11-bit value to caldac */
cb_pcidas_calib_write(dev, ((chan & 0x7) << 8) | val, 11, false);
}
static int cb_pcidas_caldac_insn_write(struct comedi_device *dev, static int cb_pcidas_caldac_insn_write(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, struct comedi_insn *insn,
@ -589,7 +582,9 @@ static int cb_pcidas_caldac_insn_write(struct comedi_device *dev,
unsigned int val = data[insn->n - 1]; unsigned int val = data[insn->n - 1];
if (s->readback[chan] != val) { if (s->readback[chan] != val) {
cb_pcidas_caldac_8800_write(dev, chan, val); /* write 11-bit channel/value to caldac */
cb_pcidas_calib_write(dev, (chan << 8) | val, 11,
false);
s->readback[chan] = val; s->readback[chan] = val;
} }
} }
@ -634,20 +629,6 @@ static int cb_pcidas_dac08_insn_write(struct comedi_device *dev,
return insn->n; return insn->n;
} }
static void cb_pcidas_trimpot_7376_write(struct comedi_device *dev,
unsigned int val)
{
/* write 7-bit value to trimpot */
cb_pcidas_calib_write(dev, val, 7, true);
}
static void cb_pcidas_trimpot_8402_write(struct comedi_device *dev,
unsigned int chan, unsigned int val)
{
/* write 10-bit value to trimpot */
cb_pcidas_calib_write(dev, ((chan & 0x3) << 8) | val, 10, true);
}
static void cb_pcidas_trimpot_write(struct comedi_device *dev, static void cb_pcidas_trimpot_write(struct comedi_device *dev,
unsigned int chan, unsigned int val) unsigned int chan, unsigned int val)
{ {
@ -655,10 +636,12 @@ static void cb_pcidas_trimpot_write(struct comedi_device *dev,
switch (board->trimpot) { switch (board->trimpot) {
case AD7376: case AD7376:
cb_pcidas_trimpot_7376_write(dev, val); /* write 7-bit value to trimpot */
cb_pcidas_calib_write(dev, val, 7, true);
break; break;
case AD8402: case AD8402:
cb_pcidas_trimpot_8402_write(dev, chan, val); /* write 10-bit channel/value to trimpot */
cb_pcidas_calib_write(dev, (chan << 8) | val, 10, true);
break; break;
default: default:
dev_err(dev->class_dev, "driver bug?\n"); dev_err(dev->class_dev, "driver bug?\n");
@ -1414,8 +1397,11 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev,
return ret; return ret;
for (i = 0; i < s->n_chan; i++) { for (i = 0; i < s->n_chan; i++) {
cb_pcidas_caldac_8800_write(dev, i, s->maxdata / 2); unsigned int val = s->maxdata / 2;
s->readback[i] = s->maxdata / 2;
/* write 11-bit channel/value to caldac */
cb_pcidas_calib_write(dev, (i << 8) | val, 11, false);
s->readback[i] = val;
} }
/* Calibration subdevice - trim potentiometer */ /* Calibration subdevice - trim potentiometer */