提交 99928e65 编写于 作者: H H Hartley Sweeten 提交者: Greg Kroah-Hartman

staging: comedi: dt9812: cleanup analog out subdevice (*insn_write)

For aesthetic reasons, rename the function to help with grepping and
rename some of the local vars.

The dt9812_analog_out() function can fail. Make sure to check for any
failure and return the errno.

The comedi core expects the (*insn_write) functions to return either
an errno or the number of samples written. Change the final return to
insn->n to make this clearer.
Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 e79f18e6
...@@ -656,16 +656,22 @@ static int dt9812_ao_insn_read(struct comedi_device *dev, ...@@ -656,16 +656,22 @@ static int dt9812_ao_insn_read(struct comedi_device *dev,
return insn->n; return insn->n;
} }
static int dt9812_ao_winsn(struct comedi_device *dev, static int dt9812_ao_insn_write(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn, struct comedi_subdevice *s,
unsigned int *data) struct comedi_insn *insn,
unsigned int *data)
{ {
unsigned int channel = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
int n; int ret;
int i;
for (n = 0; n < insn->n; n++) for (i = 0; i < insn->n; i++) {
dt9812_analog_out(dev, channel, data[n]); ret = dt9812_analog_out(dev, chan, data[i]);
return n; if (ret)
return ret;
}
return insn->n;
} }
static int dt9812_find_endpoints(struct comedi_device *dev) static int dt9812_find_endpoints(struct comedi_device *dev)
...@@ -847,7 +853,7 @@ static int dt9812_auto_attach(struct comedi_device *dev, ...@@ -847,7 +853,7 @@ static int dt9812_auto_attach(struct comedi_device *dev,
s->n_chan = 2; s->n_chan = 2;
s->maxdata = 0x0fff; s->maxdata = 0x0fff;
s->range_table = is_unipolar ? &range_unipolar2_5 : &range_bipolar10; s->range_table = is_unipolar ? &range_unipolar2_5 : &range_bipolar10;
s->insn_write = dt9812_ao_winsn; s->insn_write = dt9812_ao_insn_write;
s->insn_read = dt9812_ao_insn_read; s->insn_read = dt9812_ao_insn_read;
devpriv->ao_shadow[0] = is_unipolar ? 0x0000 : 0x0800; devpriv->ao_shadow[0] = is_unipolar ? 0x0000 : 0x0800;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册