Re: [bug report] pinctrl: renesas: rzg2l: Drop struct rzg2l_variable_pin_cfg

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

 



Hi Prabhakar,

On Mon, Jun 17, 2024 at 2:47 PM Lad, Prabhakar
<prabhakar.csengg@xxxxxxxxx> wrote:
> On Mon, Jun 17, 2024 at 10:35 AM Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
> > Commit 13a8cae6e561 ("pinctrl: renesas: rzg2l: Drop struct
> > rzg2l_variable_pin_cfg") from May 30, 2024 (linux-next), leads to the
> > following Smatch static checker warning:
> >
> >         drivers/pinctrl/renesas/pinctrl-rzg2l.c:374 rzg2l_pinctrl_get_variable_pin_cfg()
> >         warn: was expecting a 64 bit value instead of '~((((1))) << (16))'
> >
> Is there any way I can replicate the same on my setup? I tried the
> kcehker utility but it didn't print the above warning.
>
> > drivers/pinctrl/renesas/pinctrl-rzg2l.c
> >     362 static u64 rzg2l_pinctrl_get_variable_pin_cfg(struct rzg2l_pinctrl *pctrl,
> >     363                                               u64 pincfg,
> >     364                                               unsigned int port,
> >     365                                               u8 pin)
> >     366 {
> >     367         unsigned int i;
> >     368
> >     369         for (i = 0; i < pctrl->data->n_variable_pin_cfg; i++) {
> >     370                 u64 cfg = pctrl->data->variable_pin_cfg[i];
> >     371
> >     372                 if (FIELD_GET(VARIABLE_PIN_CFG_PORT_MASK, cfg) == port &&
> >     373                     FIELD_GET(VARIABLE_PIN_CFG_PIN_MASK, cfg) == pin)
> > --> 374                         return (pincfg & ~PIN_CFG_VARIABLE) | FIELD_GET(PIN_CFG_MASK, cfg);
> >
> > pincfg is a u64 and we're returning a u64.  The code here is trying to
> > mask out PIN_CFG_VARIABLE which is BIT(16).  But because it's BIT()
> > instead of BIT_ULL(16) then it ends up masking the high 32 bits as well.

Note that there is no issue on 64-bit platforms (i.e. all affected
platforms), as BIT() does produce a 64-bit value if unsigned long
is 64-bit.

> Thanks, I'll update the macro to use BIT_ULL().
>
> @Geert, shal I update the PIN_CFG_* macros to use BIT_ULL to avoid
> such issues further in the same patch?

Yes, please do so.
Thanks!

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