mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pinctrl: rp1: Use ARRAY_SIZE() to compute group sizes
@ 2026-11-25 14:22 Andrea della Porta
  0 siblings, 0 replies; only message in thread
From: Andrea della Porta @ 2026-11-25 14:22 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-gpio, linux-kernel, Florian Fainelli, Andrea della Porta,
	kernel test robot

Coccinelle reports:

  drivers/pinctrl/pinctrl-rp1.c:343:39-40: WARNING: Use ARRAY_SIZE
  drivers/pinctrl/pinctrl-rp1.c:444:33-34: WARNING: Use ARRAY_SIZE

PIN_ARRAY_SIZE() and GRP_ARRAY_SIZE() open-code the element count of a
compound literal as sizeof(array) / sizeof(element), duplicating the
element type from the corresponding PIN_ARRAY() and GRP_ARRAY() macros.

Use ARRAY_SIZE() on the PIN_ARRAY()/GRP_ARRAY() compound literals
instead, so the element type is no longer repeated and the array check
in ARRAY_SIZE() applies. Wrap the compound literals in parentheses so
they can be safely passed as macro arguments, and include
<linux/array_size.h> explicitly.

No functional change is expected.

Fixes: e3ce7b897388 ("pinctrl: rp1: Implement RaspberryPi RP1 pinmux/pinconf support")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/20261117140555.KfUW4BDK-lkp@intel.com/
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
 drivers/pinctrl/pinctrl-rp1.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-rp1.c b/drivers/pinctrl/pinctrl-rp1.c
index dd0e85c2ca33..da86bbc40f41 100644
--- a/drivers/pinctrl/pinctrl-rp1.c
+++ b/drivers/pinctrl/pinctrl-rp1.c
@@ -8,6 +8,7 @@
  * pinctrl-bcm2835.c, please see original file for copyright information
  */
 
+#include <linux/array_size.h>
 #include <linux/gpio/driver.h>
 #include <linux/of_irq.h>
 #include <linux/pinctrl/pinconf.h>
@@ -338,9 +339,9 @@ static struct pinctrl_pin_desc rp1_gpio_pins[] = {
 };
 
 #define PIN_ARRAY(...) \
-	(const unsigned int []) {__VA_ARGS__}
+	((const unsigned int []) {__VA_ARGS__})
 #define PIN_ARRAY_SIZE(...) \
-	(sizeof((unsigned int[]) {__VA_ARGS__}) / sizeof(unsigned int))
+	ARRAY_SIZE(PIN_ARRAY(__VA_ARGS__))
 #define RP1_GROUP(name, ...) \
 	PINCTRL_PINGROUP(#name, PIN_ARRAY(__VA_ARGS__), \
 			 PIN_ARRAY_SIZE(__VA_ARGS__))
@@ -439,9 +440,9 @@ static const struct pingroup rp1_gpio_groups[] = {
 };
 
 #define GRP_ARRAY(...) \
-	(const char * []) {__VA_ARGS__}
+	((const char * []) {__VA_ARGS__})
 #define GRP_ARRAY_SIZE(...) \
-	(sizeof((char *[]) {__VA_ARGS__}) / sizeof(char *))
+	ARRAY_SIZE(GRP_ARRAY(__VA_ARGS__))
 #define RP1_FNC(f, ...) \
 	[func_##f] = PINCTRL_PINFUNCTION(#f, GRP_ARRAY(__VA_ARGS__), \
 					 GRP_ARRAY_SIZE(__VA_ARGS__))
-- 
2.51.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-25 14:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 14:22 [PATCH] pinctrl: rp1: Use ARRAY_SIZE() to compute group sizes Andrea della Porta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®