staging: comedi: amplc_pci224: use comedi_fc helpers to validate timer args
Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the scan_begin_arg when the scan_begin_src is TRIG_TIMER. For aesthetics reasons, rename the local variable 'tmp' to 'arg'. 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
22a270483d
commit
af50b31b21
|
@ -719,7 +719,7 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
|
|||
{
|
||||
struct pci224_private *devpriv = dev->private;
|
||||
int err = 0;
|
||||
unsigned int tmp;
|
||||
unsigned int arg;
|
||||
|
||||
/* Step 1 : check if triggers are trivially valid */
|
||||
|
||||
|
@ -746,14 +746,14 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
|
|||
* There's only one external trigger signal (which makes these
|
||||
* tests easier). Only one thing can use it.
|
||||
*/
|
||||
tmp = 0;
|
||||
arg = 0;
|
||||
if (cmd->start_src & TRIG_EXT)
|
||||
tmp++;
|
||||
arg++;
|
||||
if (cmd->scan_begin_src & TRIG_EXT)
|
||||
tmp++;
|
||||
arg++;
|
||||
if (cmd->stop_src & TRIG_EXT)
|
||||
tmp++;
|
||||
if (tmp > 1)
|
||||
arg++;
|
||||
if (arg > 1)
|
||||
err |= -EINVAL;
|
||||
|
||||
if (err)
|
||||
|
@ -786,10 +786,10 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
|
|||
err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg,
|
||||
MAX_SCAN_PERIOD);
|
||||
|
||||
tmp = cmd->chanlist_len * CONVERT_PERIOD;
|
||||
if (tmp < MIN_SCAN_PERIOD)
|
||||
tmp = MIN_SCAN_PERIOD;
|
||||
err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, tmp);
|
||||
arg = cmd->chanlist_len * CONVERT_PERIOD;
|
||||
if (arg < MIN_SCAN_PERIOD)
|
||||
arg = MIN_SCAN_PERIOD;
|
||||
err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, arg);
|
||||
break;
|
||||
case TRIG_EXT:
|
||||
/* Force to external trigger 0. */
|
||||
|
@ -840,15 +840,13 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
|
|||
/* Step 4: fix up any arguments. */
|
||||
|
||||
if (cmd->scan_begin_src == TRIG_TIMER) {
|
||||
tmp = cmd->scan_begin_arg;
|
||||
arg = cmd->scan_begin_arg;
|
||||
/* Use two timers. */
|
||||
i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
|
||||
&devpriv->cached_div1,
|
||||
&devpriv->cached_div2,
|
||||
&cmd->scan_begin_arg,
|
||||
cmd->flags);
|
||||
if (tmp != cmd->scan_begin_arg)
|
||||
err++;
|
||||
&arg, cmd->flags);
|
||||
err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
|
||||
}
|
||||
|
||||
if (err)
|
||||
|
|
Loading…
Reference in New Issue