[PATCH 20/28] staging: comedi: rti800: tidy up analog input 'muxgain'

Ian Abbott abbotti at mev.co.uk
Tue Apr 9 10:10:29 UTC 2013


On 2013-04-09 02:20, H Hartley Sweeten wrote:
> -/* settling delay times in usec for different gains */
> -static const int gaindelay[] = { 10, 20, 40, 80 };

>   		if (insn->n > 0) {
> -			BUG_ON(gain >= ARRAY_SIZE(gaindelay));
> -			udelay(gaindelay[gain]);
> +			int delay = (gain == 0) ? 10 :
> +				    (gain == 1) ? 20 :
> +				    (gain == 2) ? 40 : 80;
> +
> +			udelay(delay);
>   		}

You could use:

	int delay = 10 << gain;

although that would be harder to tweak later.

-- 
-=( 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