diff options
author | H Hartley Sweeten | 2014-08-26 01:04:45 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2014-08-30 22:22:33 +0200 |
commit | 1d0750cec59b15187e4778d8da8268b00f0db30b (patch) | |
tree | a17d6b5e61f82f0a9cc265e13a5c1a92ed9bd898 /drivers/staging/comedi | |
parent | staging: comedi: ni_670x: cleanup ni_670x_ao_winsn() (diff) | |
download | kernel-qcow2-linux-1d0750cec59b15187e4778d8da8268b00f0db30b.tar.gz kernel-qcow2-linux-1d0750cec59b15187e4778d8da8268b00f0db30b.tar.xz kernel-qcow2-linux-1d0750cec59b15187e4778d8da8268b00f0db30b.zip |
staging: comedi: ni_670x: use comedi_subdevice 'readback'
Use the new comedi_subdevice 'readback' member and the core provided
(*insn_read) for the readback of the analog output subdevice channels.
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>
Diffstat (limited to 'drivers/staging/comedi')
-rw-r--r-- | drivers/staging/comedi/drivers/ni_670x.c | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index 7df8bb50d525..092e2b17a5d3 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -83,7 +83,6 @@ static const struct ni_670x_board ni_670x_boards[] = { struct ni_670x_private { int boardtype; int dio; - unsigned int ao_readback[32]; }; static int ni_670x_ao_insn_write(struct comedi_device *dev, @@ -91,9 +90,8 @@ static int ni_670x_ao_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct ni_670x_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int val = devpriv->ao_readback[chan]; + unsigned int val = s->readback[chan]; int i; /* @@ -114,25 +112,11 @@ static int ni_670x_ao_insn_write(struct comedi_device *dev, /* write channel value */ writel(val, dev->mmio + AO_VALUE_OFFSET); } - devpriv->ao_readback[chan] = val; + s->readback[chan] = val; return insn->n; } -static int ni_670x_ao_rinsn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct ni_670x_private *devpriv = dev->private; - int i; - int chan = CR_CHAN(insn->chanspec); - - for (i = 0; i < insn->n; i++) - data[i] = devpriv->ao_readback[chan]; - - return i; -} - static int ni_670x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -244,7 +228,11 @@ static int ni_670x_auto_attach(struct comedi_device *dev, s->range_table = &range_bipolar10; } s->insn_write = ni_670x_ao_insn_write; - s->insn_read = &ni_670x_ao_rinsn; + s->insn_read = comedi_readback_insn_read; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; s = &dev->subdevices[1]; /* digital i/o subdevice */ |