Re: [PATCH] pinctrl: renesas: remove checker warnings: x | !y

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Gong,

On Tue, Jun 13, 2023 at 4:13 AM GONG, Ruiqi <gongruiqi@xxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxx>

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@xxxxxxxxxxxxxx

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



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux