summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-05-14 14:33:09 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-05-16 16:26:02 -0700
commit83a69f5adb81b3432fb1e58485639c391cc65f17 (patch)
tree27cf5530ecf387704d8aa4824ce4707213836e42
parent36c973d0896a5319cf3089c20e8d9881bc60297e (diff)
staging: comedi: dt9812: cleanup analog in subdevice (*insn_read)
For aesthetic reasons, rename the function to help with grepping and rename some of the local vars. dt9812_analog_in() can fail. Make sure to check for any failure and return the errno. The comedi core expects the (*insn_read) functions to return either an errno or the number of samples read. Change the final return to insn->n to make this clearer. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/drivers/dt9812.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c
index 7f6d43a33de3..c83dc7f7e9f4 100644
--- a/drivers/staging/comedi/drivers/dt9812.c
+++ b/drivers/staging/comedi/drivers/dt9812.c
@@ -631,20 +631,24 @@ static int dt9812_do_insn_bits(struct comedi_device *dev,
return insn->n;
}
-static int dt9812_ai_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data)
+static int dt9812_ai_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
{
- unsigned int channel = CR_CHAN(insn->chanspec);
- int n;
-
- for (n = 0; n < insn->n; n++) {
- u16 value = 0;
+ unsigned int chan = CR_CHAN(insn->chanspec);
+ u16 val = 0;
+ int ret;
+ int i;
- dt9812_analog_in(dev, channel, &value, DT9812_GAIN_1);
- data[n] = value;
+ for (i = 0; i < insn->n; i++) {
+ ret = dt9812_analog_in(dev, chan, &val, DT9812_GAIN_1);
+ if (ret)
+ return ret;
+ data[i] = val;
}
- return n;
+
+ return insn->n;
}
static int dt9812_ao_rinsn(struct comedi_device *dev,
@@ -845,7 +849,7 @@ static int dt9812_auto_attach(struct comedi_device *dev,
s->n_chan = 8;
s->maxdata = 0x0fff;
s->range_table = is_unipolar ? &range_unipolar2_5 : &range_bipolar10;
- s->insn_read = dt9812_ai_rinsn;
+ s->insn_read = dt9812_ai_insn_read;
/* Analog Output subdevice */
s = &dev->subdevices[3];