linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: gpio-imx-scu: Use ARRAY_SIZE for array length
@ 2023-08-09 17:12 coolrrsh
  2023-08-10  6:46 ` Khalid Masum
  2023-08-10  9:54 ` Andy Shevchenko
  0 siblings, 2 replies; 3+ messages in thread
From: coolrrsh @ 2023-08-09 17:12 UTC (permalink / raw)
  To: linus.walleij, brgl, andy, linux-gpio, linux-kernel
  Cc: linux-kernel-mentees, Rajeshwar R Shinde

From: Rajeshwar R Shinde <coolrrsh@gmail.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@gmail.com>
---
 drivers/gpio/gpio-imx-scu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-imx-scu.c b/drivers/gpio/gpio-imx-scu.c
index e190bde5397d..fb05a53c9712 100644
--- a/drivers/gpio/gpio-imx-scu.c
+++ b/drivers/gpio/gpio-imx-scu.c
@@ -103,7 +103,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)/sizeof(unsigned int);
 	gc->label = dev_name(dev);
 	gc->get = imx_scu_gpio_get;
 	gc->set = imx_scu_gpio_set;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: gpio-imx-scu: Use ARRAY_SIZE for array length
  2023-08-09 17:12 [PATCH] gpio: gpio-imx-scu: Use ARRAY_SIZE for array length coolrrsh
@ 2023-08-10  6:46 ` Khalid Masum
  2023-08-10  9:54 ` Andy Shevchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Khalid Masum @ 2023-08-10  6:46 UTC (permalink / raw)
  To: coolrrsh
  Cc: linus.walleij, brgl, andy, linux-gpio, linux-kernel,
	linux-kernel-mentees

On Wed, Aug 9, 2023 at 11:12 PM <coolrrsh@gmail.com> wrote:
>
> From: Rajeshwar R Shinde <coolrrsh@gmail.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@gmail.com>
> ---
>  drivers/gpio/gpio-imx-scu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-imx-scu.c b/drivers/gpio/gpio-imx-scu.c
> index e190bde5397d..fb05a53c9712 100644
> --- a/drivers/gpio/gpio-imx-scu.c
> +++ b/drivers/gpio/gpio-imx-scu.c
> @@ -103,7 +103,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)/sizeof(unsigned int);
Since ARRAY_SIZE is being used, no need to divide it with sizeof unsigned int
again.
...
 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

thanks,
  -- Khalid Masum

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: gpio-imx-scu: Use ARRAY_SIZE for array length
  2023-08-09 17:12 [PATCH] gpio: gpio-imx-scu: Use ARRAY_SIZE for array length coolrrsh
  2023-08-10  6:46 ` Khalid Masum
@ 2023-08-10  9:54 ` Andy Shevchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2023-08-10  9:54 UTC (permalink / raw)
  To: coolrrsh
  Cc: linus.walleij, brgl, andy, linux-gpio, linux-kernel,
	linux-kernel-mentees

On Wed, Aug 9, 2023 at 8:12 PM <coolrrsh@gmail.com> wrote:
>
> From: Rajeshwar R Shinde <coolrrsh@gmail.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

Can you test your changes, please?
We don't want just mechanical (scripted) conversion with obviously
wrong results.

NAK.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-10  9:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-09 17:12 [PATCH] gpio: gpio-imx-scu: Use ARRAY_SIZE for array length coolrrsh
2023-08-10  6:46 ` Khalid Masum
2023-08-10  9:54 ` Andy Shevchenko

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 NNTP newsgroup(s).