Linux-Sparse Archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: "GONG, Ruiqi" <gongruiqi@huaweicloud.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org, gongruiqi1@huawei.com,
	linux-sparse@vger.kernel.org
Subject: Re: [PATCH] pinctrl: renesas: remove checker warnings: x | !y
Date: Tue, 13 Jun 2023 09:38:20 +0200	[thread overview]
Message-ID: <CAMuHMdXGG2xu+nXJt6CSTfV6aM=U=hMW+DiDgP3RhOw8+O8y=A@mail.gmail.com> (raw)
In-Reply-To: <20230613021643.3330661-1-gongruiqi@huaweicloud.com>

Hi Gong,

On Tue, Jun 13, 2023 at 4:13 AM GONG, Ruiqi <gongruiqi@huaweicloud.com> wrote:
> Eliminate the following Sparse reports when building with C=1:
>
> drivers/pinctrl/renesas/pinctrl-rzn1.c:187:52: warning: dubious: x | !y
> drivers/pinctrl/renesas/pinctrl-rzn1.c:193:52: warning: dubious: x | !y
>
> Signed-off-by: GONG, Ruiqi <gongruiqi@huaweicloud.com>

Thanks for your patch!

Looks like sparse needs to be taught the "|" is not used in a boolean
context here?

> --- a/drivers/pinctrl/renesas/pinctrl-rzn1.c
> +++ b/drivers/pinctrl/renesas/pinctrl-rzn1.c
> @@ -184,13 +184,15 @@ static void rzn1_hw_set_lock(struct rzn1_pinctrl *ipctl, u8 lock, u8 value)
>          * address | 1.
>          */
>         if (lock & LOCK_LEVEL1) {
> -               u32 val = ipctl->lev1_protect_phys | !(value & LOCK_LEVEL1);
> +               u32 val = ipctl->lev1_protect_phys |
> +                       (value & LOCK_LEVEL1 ? 0 : 1);
>
>                 writel(val, &ipctl->lev1->status_protect);
>         }
>
>         if (lock & LOCK_LEVEL2) {
> -               u32 val = ipctl->lev2_protect_phys | !(value & LOCK_LEVEL2);
> +               u32 val = ipctl->lev2_protect_phys |
> +                       (value & LOCK_LEVEL2 ? 0 : 1);
>
>                 writel(val, &ipctl->lev2->status_protect);
>         }

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

       reply	other threads:[~2023-06-13  7:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230613021643.3330661-1-gongruiqi@huaweicloud.com>
2023-06-13  7:38 ` Geert Uytterhoeven [this message]
2023-06-13  8:37   ` [PATCH] pinctrl: renesas: remove checker warnings: x | !y Dan Carpenter
2023-06-13  9:45   ` GONG, Ruiqi

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='CAMuHMdXGG2xu+nXJt6CSTfV6aM=U=hMW+DiDgP3RhOw8+O8y=A@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=gongruiqi1@huawei.com \
    --cc=gongruiqi@huaweicloud.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-sparse@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 read-only IMAP folder(s) and NNTP newsgroup(s).