[PATCH 02/23] staging: comedi: cb_pcidas: don't calc ao pacer divisors twice

Ian Abbott abbotti at mev.co.uk
Tue Apr 29 14:54:11 UTC 2014


On 2014-04-28 19:53, H Hartley Sweeten wrote:
> The analog output async command can use the pacer for the scan_begin_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.
>
> For aesthetics, factor out the code that loads the counters to match the
> analog input.
>
> 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/cb_pcidas.c | 28 +++++++++++++++-------------
>   1 file changed, 15 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c
> index ec51186..fc50048 100644
> --- a/drivers/staging/comedi/drivers/cb_pcidas.c
> +++ b/drivers/staging/comedi/drivers/cb_pcidas.c
> @@ -943,7 +943,7 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
>   	return 0;
>   }
>
> -static void cb_pcidas_load_counters(struct comedi_device *dev)
> +static void cb_pcidas_ai_load_counters(struct comedi_device *dev)
>   {
>   	struct cb_pcidas_private *devpriv = dev->private;
>   	unsigned long timer_base = devpriv->pacer_counter_dio + ADC8254;
> @@ -990,7 +990,7 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev,
>
>   	/*  load counters */
>   	if (cmd->scan_begin_src == TRIG_TIMER || cmd->convert_src == TRIG_TIMER)
> -		cb_pcidas_load_counters(dev);
> +		cb_pcidas_ai_load_counters(dev);
>
>   	/*  set number of conversions */
>   	if (cmd->stop_src == TRIG_COUNT)
> @@ -1195,6 +1195,17 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
>   	return 0;
>   }
>
> +static void cb_pcidas_ao_load_counters(struct comedi_device *dev)
> +{
> +	struct cb_pcidas_private *devpriv = dev->private;
> +	unsigned long timer_base = devpriv->pacer_counter_dio + DAC8254;
> +
> +	i8254_load(timer_base, 0,
> +		   1, devpriv->ao_divisor1, I8254_MODE2 | I8254_BINARY);
> +	i8254_load(timer_base, 0,
> +		   2, devpriv->ao_divisor2, I8254_MODE2 | I8254_BINARY);
> +}
> +

The mode value should be 2 (cf. my remark on patch 01).

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti at mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-


More information about the devel mailing list