summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2014-04-29 12:59:28 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-05-03 20:06:31 -0400
commitf513b63f73e8bebc67a74dd46917788bfdf9c7cd (patch)
tree76df0a7dbd65a763e0fd4c3a8a17f59c58eb81c5
parent8673804de08f047769d33858ad60a252b241bc76 (diff)
downloadlinux-f513b63f73e8bebc67a74dd46917788bfdf9c7cd.tar.gz
linux-f513b63f73e8bebc67a74dd46917788bfdf9c7cd.tar.bz2
linux-f513b63f73e8bebc67a74dd46917788bfdf9c7cd.zip
staging: comedi: cb_pcidas: don't calc ai pacer divisors twice
The analog input async command can use the pacer for the scan_bagin_src or the convert_src. The (*do_cmdtest) validates that only one of these sources has the TRIG_TIMER selected and calculates the divisors when validating the cmd argument. There is no reason to recalc the divisors in the (*do_cmd). Just use the values from the private data. Also, refactor cb_pcidas_load_counters() to use the i8254_set_mode() and i8254_write() helpers instead of i8254_load(). This allows us to use the I8254_* defines when setting the mode to clarify the code. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidas.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c
index 26fc00e552a8..48ac1f43a3d4 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas.c
@@ -943,20 +943,16 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
return 0;
}
-static void cb_pcidas_load_counters(struct comedi_device *dev, unsigned int *ns,
- int rounding_flags)
+static void cb_pcidas_load_counters(struct comedi_device *dev)
{
struct cb_pcidas_private *devpriv = dev->private;
+ unsigned long timer_base = devpriv->pacer_counter_dio + ADC8254;
- i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
- &devpriv->divisor1, &devpriv->divisor2,
- ns, rounding_flags);
+ i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
+ i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
- /* Write the values of ctr1 and ctr2 into counters 1 and 2 */
- i8254_load(devpriv->pacer_counter_dio + ADC8254, 0, 1,
- devpriv->divisor1, 2);
- i8254_load(devpriv->pacer_counter_dio + ADC8254, 0, 2,
- devpriv->divisor2, 2);
+ i8254_write(timer_base, 0, 1, devpriv->divisor1);
+ i8254_write(timer_base, 0, 2, devpriv->divisor2);
}
static int cb_pcidas_ai_cmd(struct comedi_device *dev,
@@ -994,12 +990,8 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev,
outw(bits, devpriv->control_status + ADCMUX_CONT);
/* load counters */
- if (cmd->convert_src == TRIG_TIMER)
- cb_pcidas_load_counters(dev, &cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
- else if (cmd->scan_begin_src == TRIG_TIMER)
- cb_pcidas_load_counters(dev, &cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ if (cmd->scan_begin_src == TRIG_TIMER || cmd->convert_src == TRIG_TIMER)
+ cb_pcidas_load_counters(dev);
/* set number of conversions */
if (cmd->stop_src == TRIG_COUNT)