diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2015-10-06 17:23:43 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-10-12 22:56:26 -0700 |
commit | 8a844a91cab4556b7b7e336951623b394a80c934 (patch) | |
tree | e4bfa77cb6e202fd2fa2cec28543cab189725450 | |
parent | staging: comedi: me_daq: tidy up counter registers (diff) | |
download | linux-dev-8a844a91cab4556b7b7e336951623b394a80c934.tar.xz linux-dev-8a844a91cab4556b7b7e336951623b394a80c934.zip |
staging: comedi: me_daq: allow differential analog inputs
The ai (*insn_read) allows differential analog inputs but the subdevice
initialization is missing the SDF_DIFF subdev_flag to allow the user to
select this mode. Fix the subdevice init.
According to the manual, differential operation only works with the
first 8 channels and bipolar ranges. Add a check to the (*insn_read) to
ensure this.
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>
-rw-r--r-- | drivers/staging/comedi/drivers/me_daq.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index 91104050a203..cfb35662bf23 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -246,6 +246,15 @@ static int me_ai_insn_read(struct comedi_device *dev, unsigned short val; int ret; + /* + * For differential operation, there are only 8 input channels + * and only bipolar ranges are available. + */ + if (aref & AREF_DIFF) { + if (chan > 7 || comedi_range_is_unipolar(s, range)) + return -EINVAL; + } + /* stop any running conversion */ devpriv->ctrl1 &= ~ME_CTRL1_ADC_MODE_MASK; writew(devpriv->ctrl1, dev->mmio + ME_CTRL1_REG); @@ -472,7 +481,7 @@ static int me_auto_attach(struct comedi_device *dev, s = &dev->subdevices[0]; s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE | SDF_COMMON; + s->subdev_flags = SDF_READABLE | SDF_COMMON | SDF_DIFF; s->n_chan = 16; s->maxdata = 0x0fff; s->len_chanlist = 16; |