Re: [PATCH] [BUGFIX] iio: mlx96014: Error checking from positive to negative

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

 



On Fri, Oct 02, 2015 at 02:14:03AM -0700, Crt Mori wrote:
>  	/* Write changed values */
>  	ret = mlx90614_write_word(client, MLX90614_CONFIG,
>  			(i << MLX90614_CONFIG_IIR_SHIFT) |
> -			(((u16) ((0x7 << MLX90614_CONFIG_FIR_SHIFT) |
> -			((u16) ret & (~((u16) MLX90614_CONFIG_FIR_MASK))))) &
> -			(~(u16) MLX90614_CONFIG_IIR_MASK)));
> +			(((u16) ((MLX90614_CONST_FIR << MLX90614_CONFIG_FIR_SHIFT) |
> +			((u16) ret & ((u16) ~MLX90614_CONFIG_FIR_MASK)))) &
> +			((u16) ~MLX90614_CONFIG_IIR_MASK)));

Yeah.  Ok.  This works.  When I was looking at it, I got some of the
parenthesis mixed up so I simplified it in the wrong way.  It really is
an unparsable wall of gobbledigook.  Also the casts are still not needed
even for time travellers I mentioned earlier.

This could be written more simply as:

	ret &= ~MLX90614_CONFIG_FIR_MASK;
	ret &= ~MLX90614_CONFIG_IIR_MASK;
	ret |= MLX90614_CONST_FIR << MLX90614_CONFIG_FIR_SHIFT;

	ret = mlx90614_write_word(client, MLX90614_CONFIG,
				  i << MLX90614_CONFIG_IIR_SHIFT | ret);

regards,
dan carpenter
--
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