[SRU][J][PATCH 02/12] gpio: aggregator: Stop using ARCH_NR_GPIOS
Koichiro Den
koichiro.den at canonical.com
Fri Apr 11 07:26:53 UTC 2025
From: Christophe Leroy <christophe.leroy at csgroup.eu>
BugLink: https://bugs.launchpad.net/bugs/2103496
ARCH_NR_GPIOS is used locally in aggr_parse() as the maximum number
of GPIOs to be aggregated together by the driver since
commit ec75039d5550 ("gpio: aggregator: Use bitmap_parselist() for
parsing GPIO offsets").
Don't rely on the total possible number of GPIOs in the system but
define a local arbitrary macro for that, set to 512 which should be
large enough as it is also the default value for ARCH_NR_GPIOS.
Signed-off-by: Christophe Leroy <christophe.leroy at csgroup.eu>
Reviewed-by: Geert Uytterhoeven <geert+renesas at glider.be>
Reviewed-by: Andy Shevchenko <andy.shevchenko at gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski at linaro.org>
(cherry picked from commit 95b39792c6646322e0684f1a1aa395ee82b6f3fb)
Signed-off-by: Koichiro Den <koichiro.den at canonical.com>
---
drivers/gpio/gpio-aggregator.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c
index 4cd80d42bcc0..43e7112c35cd 100644
--- a/drivers/gpio/gpio-aggregator.c
+++ b/drivers/gpio/gpio-aggregator.c
@@ -23,6 +23,7 @@
#include <linux/spinlock.h>
#include <linux/string.h>
+#define AGGREGATOR_MAX_GPIOS 512
/*
* GPIO Aggregator sysfs interface
@@ -64,7 +65,7 @@ static int aggr_parse(struct gpio_aggregator *aggr)
unsigned int i, n = 0;
int error = 0;
- bitmap = bitmap_alloc(ARCH_NR_GPIOS, GFP_KERNEL);
+ bitmap = bitmap_alloc(AGGREGATOR_MAX_GPIOS, GFP_KERNEL);
if (!bitmap)
return -ENOMEM;
@@ -84,13 +85,13 @@ static int aggr_parse(struct gpio_aggregator *aggr)
}
/* GPIO chip + offset(s) */
- error = bitmap_parselist(offsets, bitmap, ARCH_NR_GPIOS);
+ error = bitmap_parselist(offsets, bitmap, AGGREGATOR_MAX_GPIOS);
if (error) {
pr_err("Cannot parse %s: %d\n", offsets, error);
goto free_bitmap;
}
- for_each_set_bit(i, bitmap, ARCH_NR_GPIOS) {
+ for_each_set_bit(i, bitmap, AGGREGATOR_MAX_GPIOS) {
error = aggr_add_gpio(aggr, name, i, &n);
if (error)
goto free_bitmap;
--
2.45.2
More information about the kernel-team
mailing list