linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Keerthy <j-keerthy@ti.com>, Russell King <linux@armlinux.org.uk>,
	Arnd Bergmann <arnd@arndb.de>, Jonathan Corbet <corbet@lwn.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Davide Ciminaghi <ciminaghi@gnudd.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>,
	linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org,
	linux-doc@vger.kernel.org, x86@kernel.org,
	Andy Shevchenko <andy.shevchenko@gmail.com>
Subject: [PATCH v2 2/9] gpio: aggregator: Stop using ARCH_NR_GPIOS
Date: Fri,  2 Sep 2022 14:42:02 +0200	[thread overview]
Message-ID: <80c5cc7d6e4ece80bc04624d0ffb0baaf4c60fd1.1662116601.git.christophe.leroy@csgroup.eu> (raw)
In-Reply-To: <cover.1662116601.git.christophe.leroy@csgroup.eu>

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@csgroup.eu>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
v2: Moved AGGREGATOR_MAX_GPIOS before code
---
 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 0cb2664085cf..6d17d262ad91 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.37.1


  parent reply	other threads:[~2022-09-02 14:56 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02 12:42 [PATCH v2 0/9] gpio: Get rid of ARCH_NR_GPIOS (v2) Christophe Leroy
2022-09-02 12:42 ` [PATCH v2 1/9] gpio: Remove sta2x11 GPIO driver Christophe Leroy
2022-09-02 12:42 ` Christophe Leroy [this message]
2022-09-02 12:42 ` [PATCH v2 3/9] gpio: davinci: Stop using ARCH_NR_GPIOS Christophe Leroy
2022-09-02 12:42 ` [PATCH v2 4/9] gpiolib: Warn on drivers still using static gpiobase allocation Christophe Leroy
2022-09-02 12:42 ` [PATCH v2 5/9] gpiolib: Get rid of ARCH_NR_GPIOS Christophe Leroy
2022-09-02 14:58   ` Andy Shevchenko
2022-09-02 15:22     ` Christophe Leroy
2022-09-02 12:42 ` [PATCH v2 6/9] Documentation: gpio: Remove text about ARCH_NR_GPIOS Christophe Leroy
2022-09-02 12:42 ` [PATCH v2 7/9] x86: Remove CONFIG_ARCH_NR_GPIO Christophe Leroy
2022-10-17  9:16   ` Thomas Gleixner
2022-09-02 12:42 ` [PATCH v2 8/9] arm: " Christophe Leroy
2022-09-02 12:42 ` [PATCH v2 9/9] arm64: " Christophe Leroy
2022-09-07  9:58 ` [PATCH v2 0/9] gpio: Get rid of ARCH_NR_GPIOS (v2) Bartosz Golaszewski
2022-09-07 10:14   ` Arnd Bergmann
2022-09-14 12:38     ` Linus Walleij
2022-09-14 13:02       ` Andy Shevchenko
2022-09-14 13:03       ` Arnd Bergmann
2022-10-14 14:13         ` Christophe Leroy
2022-10-14 14:22           ` Bartosz Golaszewski
2022-10-17  9:04             ` Bartosz Golaszewski
2022-10-17  9:06               ` Linus Walleij
2022-10-17 12:11                 ` Andy Shevchenko

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=80c5cc7d6e4ece80bc04624d0ffb0baaf4c60fd1.1662116601.git.christophe.leroy@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=andy.shevchenko@gmail.com \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=brgl@bgdev.pl \
    --cc=catalin.marinas@arm.com \
    --cc=ciminaghi@gnudd.com \
    --cc=corbet@lwn.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=geert+renesas@glider.be \
    --cc=hpa@zytor.com \
    --cc=j-keerthy@ti.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).