[PATCH 5/5] staging: comedi: das16: only program pacer when convert_src is TRIG_TIMER

Ian Abbott abbotti at mev.co.uk
Mon Jan 26 10:45:00 UTC 2015


On 23/01/15 23:12, H Hartley Sweeten wrote:
> The (*do_cmdtest) validates the cmd->convert_src as (TRIG_TIMER | TRIG_EXT |
> TRIG_NOW). Only the TRIG_TIMER source validates the cmd->convert_arg using
> the i8253_cascade_ns_to_timer() helper. The (*do_cmd) operation should only
> program the pacer when the convert_src indicates that the pacer is used. It
> should also not be modifying the cmd paramters.
>
> Check the convert_src in das16_cmd_exec() before programming the pacer. Remove
> the unnecessary i8253_cascade_ns_to_timer() in das16_set_pacer() and change
> the return type to void.
>
> 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/das16.c | 12 +++---------
>   1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
> index 626eb21..7d891b9 100644
> --- a/drivers/staging/comedi/drivers/das16.c
> +++ b/drivers/staging/comedi/drivers/das16.c
> @@ -628,22 +628,15 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
>   	return 0;
>   }
>
> -static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
> -				    unsigned int flags)
> +static void das16_set_pacer(struct comedi_device *dev)
>   {
>   	struct das16_private_struct *devpriv = dev->private;
>   	unsigned long timer_base = dev->iobase + DAS16_TIMER_BASE_REG;
>
> -	i8253_cascade_ns_to_timer(devpriv->clockbase,
> -				  &devpriv->divisor1, &devpriv->divisor2,
> -				  &ns, flags);
> -
>   	i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
>   	i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
>   	i8254_write(timer_base, 0, 1, devpriv->divisor1);
>   	i8254_write(timer_base, 0, 2, devpriv->divisor2);
> -
> -	return ns;
>   }
>
>   static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
> @@ -684,7 +677,8 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
>   	}
>
>   	/* set counter mode and counts */
> -	cmd->convert_arg = das16_set_pacer(dev, cmd->convert_arg, cmd->flags);
> +	if (cmd->convert_src == TRIG_TIMER)
> +		das16_set_pacer(dev);

The original code is wrong as it only works when cmd->convert_src == 
TRIG_TIMER.  Referring to my reply to patch 1, it should also set the 
pacer if cmd->scan_begin_src == TRIG_TIMER. (At most one of 
scan_begin_src and convert_src can be set to TRIG_TIMER.)

>
>   	/* enable counters */
>   	byte = 0;
>


-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti at mev.co.uk> )=-
-=(                          Web: http://www.mev.co.uk/  )=-


More information about the devel mailing list