Skip to content

Commit 933fca1

Browse files
bigguinessgregkh
authored andcommitted
staging: comedi: dmm32at: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'ai_scans_left' and use the comedi_async 'scans_done' to detect the end-of-acquisition. This also removes the artifical max limit on the cmd->stop_arg. Signed-off-by: H Hartley Sweeten <[email protected]> Reviewed-by: Ian Abbott <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4d9b071 commit 933fca1

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

drivers/staging/comedi/drivers/dmm32at.c

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ static const struct comedi_lrange dmm32at_aoranges = {
153153
struct dmm32at_private {
154154
int data;
155155
int ai_inuse;
156-
unsigned int ai_scans_left;
157156
unsigned char dio_config;
158157
};
159158

@@ -330,13 +329,10 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev,
330329

331330
err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
332331

333-
if (cmd->stop_src == TRIG_COUNT) {
334-
err |= cfc_check_trigger_arg_max(&cmd->stop_arg, 0xfffffff0);
332+
if (cmd->stop_src == TRIG_COUNT)
335333
err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
336-
} else {
337-
/* TRIG_NONE */
334+
else /* TRIG_NONE */
338335
err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
339-
}
340336

341337
if (err)
342338
return 3;
@@ -405,7 +401,6 @@ static void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec)
405401

406402
static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
407403
{
408-
struct dmm32at_private *devpriv = dev->private;
409404
struct comedi_cmd *cmd = &s->async->cmd;
410405
int range;
411406
unsigned char chanlo, chanhi;
@@ -437,13 +432,6 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
437432
/* reset the interrupt just in case */
438433
outb(DMM32AT_INTRESET, dev->iobase + DMM32AT_CNTRL);
439434

440-
if (cmd->stop_src == TRIG_COUNT)
441-
devpriv->ai_scans_left = cmd->stop_arg;
442-
else { /* TRIG_NONE */
443-
devpriv->ai_scans_left = 0xffffffff; /* indicates TRIG_NONE to
444-
* isr */
445-
}
446-
447435
/*
448436
* wait for circuit to settle
449437
* we don't have the 'insn' here but it's not needed
@@ -452,7 +440,7 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
452440
if (ret)
453441
return ret;
454442

455-
if (devpriv->ai_scans_left > 1) {
443+
if (cmd->stop_src == TRIG_NONE || cmd->stop_arg > 1) {
456444
/* start the clock and enable the interrupts */
457445
dmm32at_setaitimer(dev, cmd->scan_begin_arg);
458446
} else {
@@ -476,7 +464,6 @@ static int dmm32at_ai_cancel(struct comedi_device *dev,
476464
static irqreturn_t dmm32at_isr(int irq, void *d)
477465
{
478466
struct comedi_device *dev = d;
479-
struct dmm32at_private *devpriv = dev->private;
480467
unsigned char intstat;
481468
unsigned int samp;
482469
unsigned short msb, lsb;
@@ -503,14 +490,10 @@ static irqreturn_t dmm32at_isr(int irq, void *d)
503490
comedi_buf_write_samples(s, &samp, 1);
504491
}
505492

506-
if (devpriv->ai_scans_left != 0xffffffff) { /* TRIG_COUNT */
507-
devpriv->ai_scans_left--;
508-
if (devpriv->ai_scans_left == 0) {
509-
/* set the buffer to be flushed with an EOF */
510-
s->async->events |= COMEDI_CB_EOA;
511-
}
493+
if (cmd->stop_src == TRIG_COUNT &&
494+
s->async->scans_done >= cmd->stop_arg)
495+
s->async->events |= COMEDI_CB_EOA;
512496

513-
}
514497
comedi_handle_events(dev, s);
515498
}
516499

0 commit comments

Comments
 (0)