[PATCH 27/31] staging: comedi: pcl711: no need to calc the timer values twice
H Hartley Sweeten
hsweeten at visionengravers.com
Fri Sep 20 23:44:08 UTC 2013
The comedi core always calls the (*do_cmdtest) function to validate
a command before it calls the (*do_cmd) function.
Since the (*do_cmdtest) has already calculated the timer values in
order to validate the cmd->scan_begin_arg there is no reason to
recalc the values in the (*do_cmd).
This also fixes a bug in the driver. The (*do_cmdtest) was using a
time base value of 100 and but the (*do_cmd) was using a time base
of 500. These result in different timer values. The functions used
to calculate the values are actually the same due to a #define in
the 8253.h header.
Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
Cc: Ian Abbott <abbotti at mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
---
drivers/staging/comedi/drivers/pcl711.c | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c
index 8f068eb..60b7137 100644
--- a/drivers/staging/comedi/drivers/pcl711.c
+++ b/drivers/staging/comedi/drivers/pcl711.c
@@ -331,7 +331,6 @@ static int pcl711_ai_cmdtest(struct comedi_device *dev,
err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
} else {
#define MAX_SPEED 1000
-#define TIMER_BASE 100
err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
MAX_SPEED);
}
@@ -352,11 +351,11 @@ static int pcl711_ai_cmdtest(struct comedi_device *dev,
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
- i8253_cascade_ns_to_timer_2div(TIMER_BASE,
- &devpriv->divisor1,
- &devpriv->divisor2,
- &cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ i8253_cascade_ns_to_timer(500, /* 2 Mhz */
+ &devpriv->divisor1,
+ &devpriv->divisor2,
+ &cmd->scan_begin_arg,
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->scan_begin_arg)
err++;
}
@@ -369,22 +368,16 @@ static int pcl711_ai_cmdtest(struct comedi_device *dev,
static int pcl711_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
- int timer1, timer2;
+ struct pcl711_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
pcl711_set_changain(dev, s, cmd->chanlist[0]);
if (cmd->scan_begin_src == TRIG_TIMER) {
- timer1 = timer2 = 0;
- i8253_cascade_ns_to_timer(500, /* 2 Mhz */
- &timer1, &timer2,
- &cmd->scan_begin_arg,
- TRIG_ROUND_NEAREST);
-
i8254_load(dev->iobase + PCL711_TIMER_BASE, 0,
- 1, timer1, I8254_MODE2 | I8254_BINARY);
+ 1, devpriv->divisor1, I8254_MODE2 | I8254_BINARY);
i8254_load(dev->iobase + PCL711_TIMER_BASE, 0,
- 2, timer2, I8254_MODE2 | I8254_BINARY);
+ 2, devpriv->divisor2, I8254_MODE2 | I8254_BINARY);
/* clear pending interrupts (just in case) */
outb(0, dev->iobase + PCL711_CLRINTR);
--
1.8.3.2
More information about the devel
mailing list