linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Crt Mori <cmo@melexis.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	linux-iio@vger.kernel.org,
	Vianney le Clement de Saint-Marcq
	<vianney.leclement@essensium.com>,
	Peter Meerwald <pmeerw@pmeerw.net>
Subject: Re: [PATCH] [BUGFIX] iio: mlx96014: Error checking from positive to negative
Date: Fri, 2 Oct 2015 12:53:43 +0300	[thread overview]
Message-ID: <20151002095343.GL7289@mwanda> (raw)
In-Reply-To: <1443777243-5095-1-git-send-email-cmo@melexis.com>

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

      reply	other threads:[~2015-10-02  9:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-02  9:14 [PATCH] [BUGFIX] iio: mlx96014: Error checking from positive to negative Crt Mori
2015-10-02  9:53 ` Dan Carpenter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151002095343.GL7289@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=cmo@melexis.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --cc=vianney.leclement@essensium.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).