diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2015-11-13 11:11:24 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-12-18 14:56:30 -0800 |
commit | 5ce4385232255683f3fccca4d6772ae61769f2ad (patch) | |
tree | 746c29ea83d0bfbe19b190a669e99dc7993e160b | |
parent | d0445303f86c6ace7dcaf6d2806445ea0208f151 (diff) |
staging: comedi: adv_pci1710: fix ai (*insn_read)
An (*insn_read) can only happen if the subdevice is in a non-busy state,
i.e. an async command is not running. The board reset and subdevice
(*cancel) will ensure that the control bits (devpriv->ctrl) are already
cleared.
The (*insn_read) only needs to enable the software trigger before reading
samples. It should also disable the software trigger when done. Fix the
(*insn_read) to do this.
For aesthetics, rename the function so it has namespace associated with
the driver.
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/adv_pci1710.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 5f1e86e767c8..93b3e3fedbb6 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -325,7 +325,7 @@ static int pci171x_ai_read_sample(struct comedi_device *dev, return 0; } -static int pci171x_ai_insn_read(struct comedi_device *dev, +static int pci1710_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -334,9 +334,10 @@ static int pci171x_ai_insn_read(struct comedi_device *dev, int ret = 0; int i; - devpriv->ctrl &= PCI171X_CTRL_CNT0; - devpriv->ctrl |= PCI171X_CTRL_SW; /* set software trigger */ + /* enable software trigger */ + devpriv->ctrl |= PCI171X_CTRL_SW; outw(devpriv->ctrl, dev->iobase + PCI171X_CTRL_REG); + outb(0, dev->iobase + PCI171X_CLRFIFO_REG); outb(0, dev->iobase + PCI171X_CLRINT_REG); @@ -359,6 +360,10 @@ static int pci171x_ai_insn_read(struct comedi_device *dev, data[i] = val; } + /* disable software trigger */ + devpriv->ctrl &= ~PCI171X_CTRL_SW; + outw(devpriv->ctrl, dev->iobase + PCI171X_CTRL_REG); + outb(0, dev->iobase + PCI171X_CLRFIFO_REG); outb(0, dev->iobase + PCI171X_CLRINT_REG); @@ -802,7 +807,7 @@ static int pci1710_auto_attach(struct comedi_device *dev, s->n_chan = board->is_pci1713 ? 32 : 16; s->maxdata = 0x0fff; s->range_table = board->ai_range; - s->insn_read = pci171x_ai_insn_read; + s->insn_read = pci1710_ai_insn_read; if (dev->irq) { dev->read_subdev = s; s->subdev_flags |= SDF_CMD_READ; |