diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-05-14 21:32:17 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-05-16 23:26:01 (GMT) |
commit | e81eaba6c425a5d06623e5ad93cb7b3c096e8d5c (patch) | |
tree | cc35d1674892bb6bd085f0fdc747f529334cccf7 | |
parent | 421b42ab17bdcabedd7549e5887e4c78d64f6c2f (diff) | |
download | linux-fsl-qoriq-e81eaba6c425a5d06623e5ad93cb7b3c096e8d5c.tar.xz |
staging: comedi: dt9812: convert digital in subdevice to (*insn_bits)
Currently the (*insn_read) function for the digital input subdevice
returns the state for a single channel. It's more efficent to use
the (*insn_bits) function and return the state for all the channels.
The comedi core can use the (*insn_bits) to emulate the (*insn_read)
if needed.
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.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c index 1bc89cc..4fd1516 100644 --- a/drivers/staging/comedi/drivers/dt9812.c +++ b/drivers/staging/comedi/drivers/dt9812.c @@ -607,18 +607,21 @@ static int dt9812_analog_out(struct comedi_device *dev, int channel, u16 value) return ret; } -static int dt9812_di_rinsn(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, - unsigned int *data) +static int dt9812_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - unsigned int channel = CR_CHAN(insn->chanspec); - int n; u8 bits = 0; + int ret; - dt9812_digital_in(dev, &bits); - for (n = 0; n < insn->n; n++) - data[n] = ((1 << channel) & bits) != 0; - return n; + ret = dt9812_digital_in(dev, &bits); + if (ret) + return ret; + + data[1] = bits; + + return insn->n; } static int dt9812_do_winsn(struct comedi_device *dev, @@ -837,7 +840,7 @@ static int dt9812_auto_attach(struct comedi_device *dev, s->n_chan = 8; s->maxdata = 1; s->range_table = &range_digital; - s->insn_read = dt9812_di_rinsn; + s->insn_bits = dt9812_di_insn_bits; /* Digital Output subdevice */ s = &dev->subdevices[1]; |