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

staging: comedi: amplc_pci230: use comedi_async 'scans_done' to detect AO EOA

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

Use the helper function comedi_nscans_left() to get the number of scans in the
async buffer of 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 f5345d45
...@@ -491,7 +491,6 @@ struct pci230_private { ...@@ -491,7 +491,6 @@ struct pci230_private {
spinlock_t ao_stop_spinlock; /* Spin lock for stopping AO command */ spinlock_t ao_stop_spinlock; /* Spin lock for stopping AO command */
unsigned long daqio; /* PCI230's DAQ I/O space */ unsigned long daqio; /* PCI230's DAQ I/O space */
unsigned int ai_scan_count; /* Number of AI scans remaining */ unsigned int ai_scan_count; /* Number of AI scans remaining */
unsigned int ao_scan_count; /* Number of AO scans remaining. */
int intr_cpuid; /* ID of CPU running ISR */ int intr_cpuid; /* ID of CPU running ISR */
unsigned short hwver; /* Hardware version (for '+' models) */ unsigned short hwver; /* Hardware version (for '+' models) */
unsigned short adccon; /* ADCCON register value */ unsigned short adccon; /* ADCCON register value */
...@@ -1073,13 +1072,12 @@ static void pci230_ao_stop(struct comedi_device *dev, ...@@ -1073,13 +1072,12 @@ static void pci230_ao_stop(struct comedi_device *dev,
static void pci230_handle_ao_nofifo(struct comedi_device *dev, static void pci230_handle_ao_nofifo(struct comedi_device *dev,
struct comedi_subdevice *s) struct comedi_subdevice *s)
{ {
struct pci230_private *devpriv = dev->private;
struct comedi_async *async = s->async; struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd; struct comedi_cmd *cmd = &async->cmd;
unsigned short data; unsigned short data;
int i; int i;
if (cmd->stop_src == TRIG_COUNT && devpriv->ao_scan_count == 0) if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg)
return; return;
for (i = 0; i < cmd->chanlist_len; i++) { for (i = 0; i < cmd->chanlist_len; i++) {
...@@ -1093,13 +1091,8 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev, ...@@ -1093,13 +1091,8 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev,
s->readback[chan] = data; s->readback[chan] = data;
} }
if (cmd->stop_src == TRIG_COUNT) { if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg)
devpriv->ao_scan_count--;
if (devpriv->ao_scan_count == 0) {
/* End of acquisition. */
async->events |= COMEDI_CB_EOA; async->events |= COMEDI_CB_EOA;
}
}
} }
/* /*
...@@ -1112,7 +1105,7 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev, ...@@ -1112,7 +1105,7 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev,
struct pci230_private *devpriv = dev->private; struct pci230_private *devpriv = dev->private;
struct comedi_async *async = s->async; struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd; struct comedi_cmd *cmd = &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;
...@@ -1120,17 +1113,10 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev, ...@@ -1120,17 +1113,10 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev,
/* Get DAC FIFO status. */ /* Get DAC FIFO status. */
dacstat = inw(devpriv->daqio + PCI230_DACCON); dacstat = inw(devpriv->daqio + PCI230_DACCON);
/* 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 && num_scans == 0)
if (cmd->stop_src == TRIG_COUNT) {
/* Fixed number of scans. */
if (num_scans > devpriv->ao_scan_count)
num_scans = devpriv->ao_scan_count;
if (devpriv->ao_scan_count == 0) {
/* End of acquisition. */
events |= COMEDI_CB_EOA; events |= COMEDI_CB_EOA;
}
}
if (events == 0) { if (events == 0) {
/* Check for FIFO underrun. */ /* Check for FIFO underrun. */
if (dacstat & PCI230P2_DAC_FIFO_UNDERRUN_LATCHED) { if (dacstat & PCI230P2_DAC_FIFO_UNDERRUN_LATCHED) {
...@@ -1175,21 +1161,16 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev, ...@@ -1175,21 +1161,16 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev,
} }
} }
if (cmd->stop_src == TRIG_COUNT) { if (cmd->stop_src == TRIG_COUNT &&
devpriv->ao_scan_count -= num_scans; async->scans_done >= cmd->stop_arg) {
if (devpriv->ao_scan_count == 0) {
/* /*
* All data for the command has been written * All data for the command has been written
* to FIFO. Set FIFO interrupt trigger level * to FIFO. Set FIFO interrupt trigger level
* to 'empty'. * to 'empty'.
*/ */
devpriv->daccon = devpriv->daccon &= ~PCI230P2_DAC_INT_FIFO_MASK;
(devpriv->daccon & devpriv->daccon |= PCI230P2_DAC_INT_FIFO_EMPTY;
~PCI230P2_DAC_INT_FIFO_MASK) | outw(devpriv->daccon, devpriv->daqio + PCI230_DACCON);
PCI230P2_DAC_INT_FIFO_EMPTY;
outw(devpriv->daccon,
devpriv->daqio + PCI230_DACCON);
}
} }
/* Check if FIFO underrun occurred while writing to FIFO. */ /* Check if FIFO underrun occurred while writing to FIFO. */
dacstat = inw(devpriv->daqio + PCI230_DACCON); dacstat = inw(devpriv->daqio + PCI230_DACCON);
...@@ -1341,8 +1322,6 @@ static int pci230_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -1341,8 +1322,6 @@ static int pci230_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
return -EBUSY; return -EBUSY;
} }
devpriv->ao_scan_count = cmd->stop_arg;
/* /*
* Set range - see analogue output range table; 0 => unipolar 10V, * Set range - see analogue output range table; 0 => unipolar 10V,
* 1 => bipolar +/-10V range scale * 1 => bipolar +/-10V range scale
......
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