Linux Tegra architecture development
 help / color / mirror / Atom feed
From: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
To: Nathan Chancellor <nathan@kernel.org>
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: Thu, 21 Oct 2021 23:55:34 +0200	[thread overview]
Message-ID: <YXHh1lVCzVnyTiZv@qmqm.qmqm.pl> (raw)
In-Reply-To: <20211021214500.2388146-1-nathan@kernel.org>

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.

Best Regards
Michał Mirosław

  reply	other threads:[~2021-10-21 21:55 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 [this message]
2021-10-25 14:34   ` Nathan Chancellor
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=YXHh1lVCzVnyTiZv@qmqm.qmqm.pl \
    --to=mirq-linux@rere.qmqm.pl \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --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