Skip to contentSkip to conversation

gpio: gpio-imx-scu: Use ARRAY_SIZE for array length

PATCH Superseded [email protected] 3 participants 3 messages Aug 9, 2023 – Aug 10, 2023

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: gpio-imx-scu: Use ARRAY_SIZE for array length

From: Rajeshwar R Shinde <[email protected]>

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

---
 drivers/gpio/gpio-imx-scu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-imx-scu.c +1 -1
index e190bde5397d..fb05a53c9712 100644
@@ -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;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 18 lines · On Wed, Aug 9, 2023 at 11:12 PM <[email protected]> wrote:

From: Rajeshwar R Shinde <[email protected]>

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

---
 drivers/gpio/gpio-imx-scu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-imx-scu.c +0 -0
index e190bde5397d..fb05a53c9712 100644

drivers/gpio/gpio-imx-scu.c static int imx_scu_gpio_probe(struct platform_device *pdev) · line 106

Quoted 5 lines
drivers/gpio/gpio-imx-scu.c +1 -1
@@ -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);
...

Quoted 5 lines
drivers/gpio/gpio-imx-scu.c +0 -1
        gc->label = dev_name(dev);
        gc->get = imx_scu_gpio_get;
        gc->set = imx_scu_gpio_set;
--

2.25.1

thanks,
-- Khalid Masum
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

#2 lore raw
In reply to [email protected]
Quoted 7 lines · On Wed, Aug 9, 2023 at 8:12 PM <[email protected]> wrote:

From: Rajeshwar R Shinde <[email protected]>

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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko