[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMRc=Md4K1KwXiC69QqK_Kk02+4vEiu2Leir9OT4hy=jSzaXpA@mail.gmail.com>
Date: Fri, 11 Aug 2023 16:20:52 +0200
From: Bartosz Golaszewski <brgl@...ev.pl>
To: coolrrsh@...il.com
Cc: linus.walleij@...aro.org, andy@...nel.org,
linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-kernel-mentees@...ts.linuxfoundation.org
Subject: Re: [PATCH v3] gpio: gpio-imx-scu: Use ARRAY_SIZE for array length
On Thu, Aug 10, 2023 at 3:06 PM <coolrrsh@...il.com> wrote:
>
> From: Rajeshwar R Shinde <coolrrsh@...il.com>
>
> Use of macro ARRAY_SIZE to calculate array size minimizes
> the redundant code and improves code reusability.
> This fixes warnings reported by Coccinelle:
> drivers/gpio/gpio-imx-scu.c:106:32-33: WARNING: Use ARRAY_SIZE
>
> Signed-off-by: Rajeshwar R Shinde <coolrrsh@...il.com>
> ---
> v1->v2
> ARRAY_SIZE calculates array length, so changed
> gc->ngpio = ARRAY_SIZE(scu_rsrc_arr)/sizeof(unsigned int) to
> gc->ngpio = ARRAY_SIZE(scu_rsrc_arr)
>
> v2->v3
> added linux/kernel.h containing ARRAY_SIZE definition
>
> ---
> drivers/gpio/gpio-imx-scu.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-imx-scu.c b/drivers/gpio/gpio-imx-scu.c
> index e190bde5397d..13baf465aedf 100644
> --- a/drivers/gpio/gpio-imx-scu.c
> +++ b/drivers/gpio/gpio-imx-scu.c
> @@ -6,6 +6,7 @@
> * to control the PIN resources on SCU domain.
> */
>
> +#include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/gpio/driver.h>
> #include <linux/platform_device.h>
> @@ -103,7 +104,7 @@ static int imx_scu_gpio_probe(struct platform_device *pdev)
> gc = &priv->chip;
> gc->base = -1;
> gc->parent = dev;
> - gc->ngpio = sizeof(scu_rsrc_arr)/sizeof(unsigned int);
> + gc->ngpio = ARRAY_SIZE(scu_rsrc_arr);
> gc->label = dev_name(dev);
> gc->get = imx_scu_gpio_get;
> gc->set = imx_scu_gpio_set;
> --
> 2.25.1
>
The commit title should be "gpio: imx-scu: ..."
I fixed it and applied.
Bart
Powered by blists - more mailing lists