Re: [bug report] gpio: nuvoton: Add Nuvoton NPCM sgpio driver

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

 



On Thu, Jan 11, 2024 at 3:31 PM Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
>
> Hello Jim Liu,
>
> The patch c4f8457d17ce: "gpio: nuvoton: Add Nuvoton NPCM sgpio
> driver" from Dec 29, 2023 (linux-next), leads to the following
> (unpublishable) Smatch static checker warning:
>
>         drivers/gpio/gpio-npcm-sgpio.c:295 npcm_sgpio_setup_clk()
>         warn: why is zero skipped 'i'
>
> drivers/gpio/gpio-npcm-sgpio.c
>     283 static int npcm_sgpio_setup_clk(struct npcm_sgpio *gpio,
>     284                                 const struct npcm_clk_cfg *clk_cfg)
>     285 {
>     286         unsigned long apb_freq;
>     287         u32 val;
>     288         u8 tmp;
>     289         int i;
>     290
>     291         apb_freq = clk_get_rate(gpio->pclk);
>     292         tmp = ioread8(gpio->base + NPCM_IOXCFG1) & ~NPCM_IOXCFG1_SFT_CLK;
>     293
>     294         for (i = clk_cfg->cfg_opt-1; i > 0; i--) {
>                                              ^^^^^
> I believe that this should be >= 0 otherwise it seems like ->sft_clk[0]
> (which is 1024) would never be used anywhere.

The report seems correct to me. JJLIUO could you confirm and possibly
send a fix?

Bartosz

>
> --> 295                 val = apb_freq / clk_cfg->sft_clk[i];
>     296                 if (NPCM_CLK_MHZ > val) {
>     297                         iowrite8(clk_cfg->clk_sel[i] | tmp,
>     298                                  gpio->base + NPCM_IOXCFG1);
>     299                         return 0;
>     300                 }
>     301         }
>     302
>     303         return -EINVAL;
>     304 }
>
> regards,
> dan carpenter
>





[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