public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev
Subject: Re: [PATCH] soc/tegra: fuse: Fix bitwise vs. logical OR warning
Date: Mon, 25 Oct 2021 07:34:28 -0700	[thread overview]
Message-ID: <YXbAdIc1IEDXa7vg@archlinux-ax161> (raw)
In-Reply-To: <YXHh1lVCzVnyTiZv@qmqm.qmqm.pl>

Hi Michał,

On Thu, Oct 21, 2021 at 11:55:34PM +0200, Michał Mirosław wrote:
> On Thu, Oct 21, 2021 at 02:45:00PM -0700, Nathan Chancellor wrote:
> [...]
> > --- a/drivers/soc/tegra/fuse/speedo-tegra20.c
> > +++ b/drivers/soc/tegra/fuse/speedo-tegra20.c
> > @@ -69,7 +69,7 @@ void __init tegra20_init_speedo_data(struct tegra_sku_info *sku_info)
> >  
> >  	val = 0;
> >  	for (i = CPU_SPEEDO_MSBIT; i >= CPU_SPEEDO_LSBIT; i--) {
> > -		reg = tegra_fuse_read_spare(i) |
> > +		reg = tegra_fuse_read_spare(i) ||
> >  			tegra_fuse_read_spare(i + CPU_SPEEDO_REDUND_OFFS);
> >  		val = (val << 1) | (reg & 0x1);
> >  	}
> > @@ -84,7 +84,7 @@ void __init tegra20_init_speedo_data(struct tegra_sku_info *sku_info)
> >  
> >  	val = 0;
> >  	for (i = SOC_SPEEDO_MSBIT; i >= SOC_SPEEDO_LSBIT; i--) {
> > -		reg = tegra_fuse_read_spare(i) |
> > +		reg = tegra_fuse_read_spare(i) ||
> >  			tegra_fuse_read_spare(i + SOC_SPEEDO_REDUND_OFFS);
> >  		val = (val << 1) | (reg & 0x1);
> >  	}
> 
> It does seem correct, but nevertheless the code looks suspicious. reg is
> already masked with 0x1 as far as I can tell, and there are other places
> which depend on this (like speedo-tegra210.c). Guessing from the use of
> tegra_fuse_read_spare() I would recommend changing its return type as it
> is returing a bit value, not necessarily semantically a boolean.

Yes, I did notice that, as well as the use of tegra_fuse_read_spare()
with boolean operators in tegra-apbmisc.c. I could change it to int if
that is what the maintainers prefer, which would also solve the warning.

Cheers,
Nathan

  reply	other threads:[~2021-10-25 14:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21 21:45 [PATCH] soc/tegra: fuse: Fix bitwise vs. logical OR warning Nathan Chancellor
2021-10-21 21:55 ` Michał Mirosław
2021-10-25 14:34   ` Nathan Chancellor [this message]
2021-11-17 18:21 ` Nick Desaulniers

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=YXbAdIc1IEDXa7vg@archlinux-ax161 \
    --to=nathan@kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=ndesaulniers@google.com \
    --cc=thierry.reding@gmail.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