staging: comedi: das16m1: don't calc pacer divisors twice
The analog input async command can use the pacer for the convert_src. The (*do_cmdtest) 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. Refactor das16m1_set_pacer() 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. Tidy up das16m1_cmd_exec() a bit. The pacer only needs to be set when the convert_src is TRIG_TIMER. 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>
This commit is contained in:
parent
33eafb7761
commit
863e07c9f8
1 changed files with 14 additions and 27 deletions
|
@ -254,26 +254,16 @@ static int das16m1_cmd_test(struct comedi_device *dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function takes a time in nanoseconds and sets the *
|
static void das16m1_set_pacer(struct comedi_device *dev)
|
||||||
* 2 pacer clocks to the closest frequency possible. It also *
|
|
||||||
* returns the actual sampling period. */
|
|
||||||
static unsigned int das16m1_set_pacer(struct comedi_device *dev,
|
|
||||||
unsigned int ns, int rounding_flags)
|
|
||||||
{
|
{
|
||||||
struct das16m1_private_struct *devpriv = dev->private;
|
struct das16m1_private_struct *devpriv = dev->private;
|
||||||
|
unsigned long timer_base = dev->iobase + DAS16M1_8254_SECOND;
|
||||||
|
|
||||||
i8253_cascade_ns_to_timer_2div(I8254_OSC_BASE_10MHZ,
|
i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
|
||||||
&devpriv->divisor1,
|
i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
|
||||||
&devpriv->divisor2,
|
|
||||||
&ns, rounding_flags);
|
|
||||||
|
|
||||||
/* Write the values of ctr1 and ctr2 into counters 1 and 2 */
|
i8254_write(timer_base, 0, 1, devpriv->divisor1);
|
||||||
i8254_load(dev->iobase + DAS16M1_8254_SECOND, 0, 1, devpriv->divisor1,
|
i8254_write(timer_base, 0, 2, devpriv->divisor2);
|
||||||
2);
|
|
||||||
i8254_load(dev->iobase + DAS16M1_8254_SECOND, 0, 2, devpriv->divisor2,
|
|
||||||
2);
|
|
||||||
|
|
||||||
return ns;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int das16m1_cmd_exec(struct comedi_device *dev,
|
static int das16m1_cmd_exec(struct comedi_device *dev,
|
||||||
|
@ -307,10 +297,14 @@ static int das16m1_cmd_exec(struct comedi_device *dev,
|
||||||
outb(byte, dev->iobase + DAS16M1_QUEUE_DATA);
|
outb(byte, dev->iobase + DAS16M1_QUEUE_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set counter mode and counts */
|
/* enable interrupts and set internal pacer counter mode and counts */
|
||||||
cmd->convert_arg =
|
devpriv->control_state &= ~PACER_MASK;
|
||||||
das16m1_set_pacer(dev, cmd->convert_arg,
|
if (cmd->convert_src == TRIG_TIMER) {
|
||||||
cmd->flags & TRIG_ROUND_MASK);
|
das16m1_set_pacer(dev);
|
||||||
|
devpriv->control_state |= INT_PACER;
|
||||||
|
} else { /* TRIG_EXT */
|
||||||
|
devpriv->control_state |= EXT_PACER;
|
||||||
|
}
|
||||||
|
|
||||||
/* set control & status register */
|
/* set control & status register */
|
||||||
byte = 0;
|
byte = 0;
|
||||||
|
@ -323,13 +317,6 @@ static int das16m1_cmd_exec(struct comedi_device *dev,
|
||||||
/* clear interrupt bit */
|
/* clear interrupt bit */
|
||||||
outb(0, dev->iobase + DAS16M1_CLEAR_INTR);
|
outb(0, dev->iobase + DAS16M1_CLEAR_INTR);
|
||||||
|
|
||||||
/* enable interrupts and internal pacer */
|
|
||||||
devpriv->control_state &= ~PACER_MASK;
|
|
||||||
if (cmd->convert_src == TRIG_TIMER)
|
|
||||||
devpriv->control_state |= INT_PACER;
|
|
||||||
else
|
|
||||||
devpriv->control_state |= EXT_PACER;
|
|
||||||
|
|
||||||
devpriv->control_state |= INTE;
|
devpriv->control_state |= INTE;
|
||||||
outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL);
|
outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue