From: Andrea della Porta <andrea.porta@suse.com>
To: Linus Walleij <linusw@kernel.org>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Florian Fainelli <florian.fainelli@broadcom.com>,
Andrea della Porta <andrea.porta@suse.com>,
kernel test robot <lkp@intel.com>
Subject: [PATCH] pinctrl: rp1: Use ARRAY_SIZE() to compute group sizes
Date: Wed, 25 Nov 2026 15:22:30 +0100 [thread overview]
Message-ID: <20261125142230.18076-1-andrea.porta@suse.com> (raw)
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
reply other threads:[~2026-11-25 14:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125142230.18076-1-andrea.porta@suse.com \
--to=andrea.porta@suse.com \
--cc=florian.fainelli@broadcom.com \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®