Re: [PATCH 08/12] iio: ad7291: fix channel mapping for event enables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/31/11 11:57, michael.hennerich@xxxxxxxxxx wrote:
> From: Michael Hennerich <michael.hennerich@xxxxxxxxxx>
Pretty closely tied to the previous patch on the channel mapping, but as things
will at least build in between its fine to have it here I guess.
> 
> 
> Signed-off-by: Michael Hennerich <michael.hennerich@xxxxxxxxxx>
merged.
> ---
>  drivers/staging/iio/adc/ad7291.c |   24 ++++++++++++------------
>  1 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c
> index b365a74..1a2fa66 100644
> --- a/drivers/staging/iio/adc/ad7291.c
> +++ b/drivers/staging/iio/adc/ad7291.c
> @@ -100,7 +100,7 @@ struct ad7291_chip_info {
>  	struct regulator	*reg;
>  	u16			int_vref_mv;
>  	u16			command;
> -	u8			c_mask;	/* Active voltage channels for events */
> +	u16			c_mask;	/* Active voltage channels for events */
>  	struct mutex 		state_lock;
>  };
>  
> @@ -380,7 +380,7 @@ static int ad7291_read_event_config(struct iio_dev *indio_dev,
>  	switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) {
>  	case IIO_VOLTAGE:
>  		if (chip->c_mask &
> -		    (1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code)))
> +		    (1 << (15 - IIO_EVENT_CODE_EXTRACT_NUM(event_code))))
>  			return 1;
>  		else
>  			return 0;
> @@ -411,19 +411,19 @@ static int ad7291_write_event_config(struct iio_dev *indio_dev,
>  
>  	switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) {
>  	case IIO_VOLTAGE:
> -		if ((!state) && (chip->c_mask &
> -			       (1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code))))
> -			chip->c_mask &=
> -				~(1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code));
> -		else if (state && (!(chip->c_mask &
> -				(1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code)))))
> -			chip->c_mask |=
> -				(1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code));
> +		if ((!state) && (chip->c_mask & (1 << (15 -
> +				IIO_EVENT_CODE_EXTRACT_NUM(event_code)))))
> +			chip->c_mask &= ~(1 << (15 - IIO_EVENT_CODE_EXTRACT_NUM
> +							(event_code)));
> +		else if (state && (!(chip->c_mask & (1 << (15 -
> +				IIO_EVENT_CODE_EXTRACT_NUM(event_code))))))
> +			chip->c_mask |= (1 << (15 - IIO_EVENT_CODE_EXTRACT_NUM
> +							(event_code)));
>  		else
>  			break;
>  
>  		regval &= ~AD7291_AUTOCYCLE;
> -		regval |= ((u16)chip->c_mask << 8);
> +		regval |= chip->c_mask;
>  		if (chip->c_mask) /* Enable autocycle? */
>  			regval |= AD7291_AUTOCYCLE;
>  
> @@ -460,7 +460,7 @@ static int ad7291_read_raw(struct iio_dev *indio_dev,
>  		case IIO_VOLTAGE:
>  			mutex_lock(&chip->state_lock);
>  			/* If in autocycle mode drop through */
> -			if (chip->command & 0x1) {
> +			if (chip->command & AD7291_AUTOCYCLE) {
>  				mutex_unlock(&chip->state_lock);
>  				return -EBUSY;
>  			}

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux