[PATCH 13/46] staging: comedi: me4000: remove unnecessary ME4000_AI_LIST_INPUT_SINGLE_ENDED

Ian Abbott abbotti at mev.co.uk
Wed Aug 5 11:58:14 UTC 2015


On 04/08/15 18:57, H Hartley Sweeten wrote:
> This define evaluates to 0 and is OR'ed with the 'entry' value that is
> written to the ME4000_AI_CHANNEL_LIST_REG when the channel aref is a
> single-ended type (AREF_GROUND or AREF_COMMON). OR'ing a zero value is
> pretty silly, just remove it.
>
> Simplify me4000_ai_insn_read() a bit. The 'aref' is validated by the core
> and will always be valid.

Actually, the core doesn't validate the 'aref' as it's deemed too much 
bother for the user to set unless they really care about it.

Most drivers don't care if 'aref' has an invalid value either and will 
use some default supported value in that case.  It's okay for me4000 to 
default to single-ended for everything except AREF_DIFF.  So the patch 
is fine, but the 2nd paragraph is a little inaccurate.

>
> Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
> ---
>   drivers/staging/comedi/drivers/me4000.c | 17 +++--------------
>   1 file changed, 3 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c
> index cf7f17f..c3653a35 100644
> --- a/drivers/staging/comedi/drivers/me4000.c
> +++ b/drivers/staging/comedi/drivers/me4000.c
> @@ -110,7 +110,6 @@ broken.
>   #define ME4000_AI_STATUS_BIT_FSM		(1 << 29)
>   #define ME4000_AI_CTRL_BIT_EX_TRIG_BOTH		(1 << 31)
>   #define ME4000_AI_CHANNEL_LIST_REG		0x78
> -#define ME4000_AI_LIST_INPUT_SINGLE_ENDED	(0 << 5)
>   #define ME4000_AI_LIST_INPUT_DIFFERENTIAL	(1 << 5)
>   #define ME4000_AI_LIST_RANGE_BIPOLAR_10		(0 << 6)
>   #define ME4000_AI_LIST_RANGE_BIPOLAR_2_5	(1 << 6)
> @@ -474,13 +473,9 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
>   		return -EINVAL;
>   	}
>
> -	switch (aref) {
> -	case AREF_GROUND:
> -	case AREF_COMMON:
> -		entry |= ME4000_AI_LIST_INPUT_SINGLE_ENDED | chan;
> -		break;
> +	entry |= chan;
>
> -	case AREF_DIFF:
> +	if (aref == AREF_DIFF) {
>   		if (rang == 0 || rang == 1) {
>   			dev_err(dev->class_dev,
>   				"Range must be bipolar when aref = diff\n");
> @@ -492,11 +487,7 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
>   				"Analog input is not available\n");
>   			return -EINVAL;
>   		}
> -		entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL | chan;
> -		break;
> -	default:
> -		dev_err(dev->class_dev, "Invalid aref specified\n");
> -		return -EINVAL;
> +		entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL;
>   	}
>
>   	entry |= ME4000_AI_LIST_LAST_ENTRY;
> @@ -691,8 +682,6 @@ static int ai_write_chanlist(struct comedi_device *dev,
>
>   		if (aref == AREF_DIFF)
>   			entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL;
> -		else
> -			entry |= ME4000_AI_LIST_INPUT_SINGLE_ENDED;
>
>   		outl(entry, dev->iobase + ME4000_AI_CHANNEL_LIST_REG);
>   	}
>


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


More information about the devel mailing list