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: linux-iio@vger.kernel.org
Subject: Re: iio: mlx90614: Implement filter configuration
Date: Fri, 2 Oct 2015 11:32:24 +0300	[thread overview]
Message-ID: <20151002083224.GJ7289@mwanda> (raw)
In-Reply-To: <CAKv63uuxuKJ5QY_jpxVe895+AMhyxWWrCWim6BgeB8kLsoNB-A@mail.gmail.com>

On Fri, Oct 02, 2015 at 10:12:01AM +0200, Crt Mori wrote:
> > It looks a little more readable without any casts and it works exactly
> > the same since the casts were just for decoration.
> >
> 
> Like I said they are on most processors, but might not be on others.

And monkeys *might* fly out of my butt.

> I rather have it defined than let compiler decide

Focus on writing simple code and not making it portable for time
travellers to 1980.

> 
> >         ret = mlx90614_write_word(client, MLX90614_CONFIG,
> >                                   (i << MLX90614_CONFIG_IIR_SHIFT) |
> >                                   ((0x7 << MLX90614_CONFIG_FIR_SHIFT) |
> >                                    (ret & ~MLX90614_CONFIG_FIR_MASK) &
> >                                    (~MLX90614_CONFIG_IIR_MASK)));
> >
> > The 0x7 is a magic number.  I would think it would be a named _MASK
> > macro.  Ah, we do have a macro for that.
> 
> That macro is for mask and it is just coincidence that they are the
> same. I would like to keep the
> way it is in case someone wants to change FIR values as well.

Did you read the rest of the email?  This code make no sense.  We know
that it has never been tested since the earlier ret test was inverted so
it was unreachable.  Why are you defending something that is so clearly
wrong?  Anyway get rid of the magic number at least.

regards,
dan carpenter


  reply	other threads:[~2015-10-02  8:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-01 22:16 iio: mlx90614: Implement filter configuration Dan Carpenter
2015-10-01 23:09 ` Crt Mori
2015-10-02  7:00   ` Dan Carpenter
2015-10-02  8:12     ` Crt Mori
2015-10-02  8:32       ` Dan Carpenter [this message]
2015-10-02  8:48         ` Crt Mori
2015-10-02  8:56           ` Dan Carpenter
2015-10-02  9:04             ` Crt Mori

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=20151002083224.GJ7289@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=cmo@melexis.com \
    --cc=linux-iio@vger.kernel.org \
    /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).