Commit d682141e authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: amplc_pci224: use comedi_async 'scans_done' to detect EOA

Remove the private data member 'ao_stop_count' and use the comedi_async
'scans_done' member to detect the end-of-acquisition.

Use the helper function comedi_nscans_left() to determine the number of scans
available in the async buffer or left in the command.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2ee37750
...@@ -381,7 +381,6 @@ struct pci224_private { ...@@ -381,7 +381,6 @@ struct pci224_private {
unsigned short daccon; unsigned short daccon;
unsigned int cached_div1; unsigned int cached_div1;
unsigned int cached_div2; unsigned int cached_div2;
unsigned int ao_stop_count;
unsigned short ao_enab; /* max 16 channels so 'short' will do */ unsigned short ao_enab; /* max 16 channels so 'short' will do */
unsigned char intsce; unsigned char intsce;
}; };
...@@ -514,26 +513,18 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, ...@@ -514,26 +513,18 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev,
{ {
struct pci224_private *devpriv = dev->private; struct pci224_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd; struct comedi_cmd *cmd = &s->async->cmd;
unsigned int num_scans; unsigned int num_scans = comedi_nscans_left(s, 0);
unsigned int room; unsigned int room;
unsigned short dacstat; unsigned short dacstat;
unsigned int i, n; unsigned int i, n;
/* Determine number of scans available in buffer. */
num_scans = comedi_buf_read_n_available(s) / comedi_bytes_per_scan(s);
if (cmd->stop_src == TRIG_COUNT) {
/* Fixed number of scans. */
if (num_scans > devpriv->ao_stop_count)
num_scans = devpriv->ao_stop_count;
}
/* Determine how much room is in the FIFO (in samples). */ /* Determine how much room is in the FIFO (in samples). */
dacstat = inw(dev->iobase + PCI224_DACCON); dacstat = inw(dev->iobase + PCI224_DACCON);
switch (dacstat & PCI224_DACCON_FIFOFL_MASK) { switch (dacstat & PCI224_DACCON_FIFOFL_MASK) {
case PCI224_DACCON_FIFOFL_EMPTY: case PCI224_DACCON_FIFOFL_EMPTY:
room = PCI224_FIFO_ROOM_EMPTY; room = PCI224_FIFO_ROOM_EMPTY;
if (cmd->stop_src == TRIG_COUNT && if (cmd->stop_src == TRIG_COUNT &&
devpriv->ao_stop_count == 0) { s->async->scans_done >= cmd->stop_arg) {
/* FIFO empty at end of counted acquisition. */ /* FIFO empty at end of counted acquisition. */
s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_EOA;
comedi_handle_events(dev, s); comedi_handle_events(dev, s);
...@@ -574,18 +565,16 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, ...@@ -574,18 +565,16 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev,
dev->iobase + PCI224_DACDATA); dev->iobase + PCI224_DACDATA);
} }
} }
if (cmd->stop_src == TRIG_COUNT) { if (cmd->stop_src == TRIG_COUNT &&
devpriv->ao_stop_count -= num_scans; s->async->scans_done >= cmd->stop_arg) {
if (devpriv->ao_stop_count == 0) { /*
/* * Change FIFO interrupt trigger level to wait
* Change FIFO interrupt trigger level to wait * until FIFO is empty.
* until FIFO is empty. */
*/ devpriv->daccon = COMBINE(devpriv->daccon,
devpriv->daccon = COMBINE(devpriv->daccon, PCI224_DACCON_FIFOINTR_EMPTY,
PCI224_DACCON_FIFOINTR_EMPTY, PCI224_DACCON_FIFOINTR_MASK);
PCI224_DACCON_FIFOINTR_MASK); outw(devpriv->daccon, dev->iobase + PCI224_DACCON);
outw(devpriv->daccon, dev->iobase + PCI224_DACCON);
}
} }
if ((devpriv->daccon & PCI224_DACCON_TRIG_MASK) == if ((devpriv->daccon & PCI224_DACCON_TRIG_MASK) ==
PCI224_DACCON_TRIG_NONE) { PCI224_DACCON_TRIG_NONE) {
...@@ -907,14 +896,6 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -907,14 +896,6 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (cmd->scan_begin_src == TRIG_TIMER) if (cmd->scan_begin_src == TRIG_TIMER)
pci224_ao_start_pacer(dev, s); pci224_ao_start_pacer(dev, s);
/*
* Sort out end of acquisition.
*/
if (cmd->stop_src == TRIG_COUNT)
devpriv->ao_stop_count = cmd->stop_arg;
else /* TRIG_EXT | TRIG_NONE */
devpriv->ao_stop_count = 0;
spin_lock_irqsave(&devpriv->ao_spinlock, flags); spin_lock_irqsave(&devpriv->ao_spinlock, flags);
if (cmd->start_src == TRIG_INT) { if (cmd->start_src == TRIG_INT) {
s->async->inttrig = pci224_ao_inttrig_start; s->async->inttrig = pci224_ao_inttrig_start;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment