aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2015-10-27 12:59:20 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-28 19:58:36 -0400
commit4e5ffbf29c2042464c64998d2798431c358df251 (patch)
treefe1cb489adf60dc7b63e84934016b9fd67f35cdf
parentf3f24dff89748215f7f3054487731bec3b618669 (diff)
staging: comedi: comedi_test: make timer rate similar to scan rate
The asynchronous command handling for the analog input subdevice uses a kernel timer which expires approximately `HZ` times a second. However, it only needs to do anything after each scan period. Set the timer to expire just after the next scan period. Although the timer expiry function `waveform_ai_interrupt()` uses precise time values to generate the fake waveforms used to generate the data, those time values are constructed in a precise sequence, and do not depend on the time the timer expiry function is actually called. So the timer expiry rate does not have to be very precise. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/drivers/comedi_test.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c
index 1b3ad7fb3720..9655dc333e34 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -52,6 +52,7 @@
52 52
53#include <linux/timer.h> 53#include <linux/timer.h>
54#include <linux/ktime.h> 54#include <linux/ktime.h>
55#include <linux/jiffies.h>
55 56
56#define N_CHANS 8 57#define N_CHANS 8
57 58
@@ -215,10 +216,12 @@ static void waveform_ai_interrupt(unsigned long arg)
215 if (devpriv->wf_current >= devpriv->wf_period) 216 if (devpriv->wf_current >= devpriv->wf_period)
216 devpriv->wf_current %= devpriv->wf_period; 217 devpriv->wf_current %= devpriv->wf_period;
217 218
218 if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg) 219 if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg) {
219 async->events |= COMEDI_CB_EOA; 220 async->events |= COMEDI_CB_EOA;
220 else 221 } else {
221 mod_timer(&devpriv->ai_timer, jiffies + 1); 222 mod_timer(&devpriv->ai_timer,
223 jiffies + usecs_to_jiffies(devpriv->ai_scan_period));
224 }
222 225
223 comedi_handle_events(dev, s); 226 comedi_handle_events(dev, s);
224} 227}
@@ -354,7 +357,9 @@ static int waveform_ai_cmd(struct comedi_device *dev,
354 wf_current = devpriv->ai_last_scan_time; 357 wf_current = devpriv->ai_last_scan_time;
355 devpriv->wf_current = do_div(wf_current, devpriv->wf_period); 358 devpriv->wf_current = do_div(wf_current, devpriv->wf_period);
356 359
357 devpriv->ai_timer.expires = jiffies + 1; 360 devpriv->ai_timer.expires =
361 jiffies + usecs_to_jiffies(devpriv->ai_scan_period);
362
358 /* mark command as active */ 363 /* mark command as active */
359 smp_mb__before_atomic(); 364 smp_mb__before_atomic();
360 set_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits); 365 set_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits);