Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 353953
b: refs/heads/master
c: ea4f72b
h: refs/heads/master
i:
  353951: cfd76ce
v: v3
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Jan 7, 2013
1 parent e7c5c75 commit 662c1f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 594dc67c239afd2f33b40c826bba887b38adf270
refs/heads/master: ea4f72b27985e21c846ffbff1a27871db4f8708e
24 changes: 14 additions & 10 deletions trunk/drivers/staging/comedi/drivers/comedi_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ struct waveform_private {
unsigned long ai_count; /* number of conversions remaining */
unsigned int scan_period; /* scan period in usec */
unsigned int convert_period; /* conversion period in usec */
unsigned timer_running:1;
unsigned int ao_loopbacks[N_CHANS];
};

Expand Down Expand Up @@ -176,6 +175,7 @@ static void waveform_ai_interrupt(unsigned long arg)
unsigned long elapsed_time;
unsigned int num_scans;
struct timeval now;
bool stopping = false;

do_gettimeofday(&now);

Expand All @@ -189,6 +189,15 @@ static void waveform_ai_interrupt(unsigned long arg)
(devpriv->usec_remainder + elapsed_time) % devpriv->scan_period;
async->events = 0;

if (cmd->stop_src == TRIG_COUNT) {
unsigned int remaining = cmd->stop_arg - devpriv->ai_count;
if (num_scans >= remaining) {
/* about to finish */
num_scans = remaining;
stopping = true;
}
}

for (i = 0; i < num_scans; i++) {
for (j = 0; j < cmd->chanlist_len; j++) {
cfc_write_to_buffer(dev->read_subdev,
Expand All @@ -205,18 +214,15 @@ static void waveform_ai_interrupt(unsigned long arg)
devpriv->
convert_period));
}
devpriv->ai_count++;
if (cmd->stop_src == TRIG_COUNT
&& devpriv->ai_count >= cmd->stop_arg) {
async->events |= COMEDI_CB_EOA;
break;
}
}

devpriv->ai_count += i;
devpriv->usec_current += elapsed_time;
devpriv->usec_current %= devpriv->usec_period;

if ((async->events & COMEDI_CB_EOA) == 0 && devpriv->timer_running)
if (stopping)
async->events |= COMEDI_CB_EOA;
else
mod_timer(&devpriv->timer, jiffies + 1);

comedi_event(dev, dev->read_subdev);
Expand Down Expand Up @@ -315,7 +321,6 @@ static int waveform_ai_cmd(struct comedi_device *dev,
return -1;
}

devpriv->timer_running = 1;
devpriv->ai_count = 0;
devpriv->scan_period = cmd->scan_begin_arg / nano_per_micro;

Expand All @@ -342,7 +347,6 @@ static int waveform_ai_cancel(struct comedi_device *dev,
{
struct waveform_private *devpriv = dev->private;

devpriv->timer_running = 0;
del_timer_sync(&devpriv->timer);
return 0;
}
Expand Down

0 comments on commit 662c1f6

Please sign in to comment.