From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Andy Whitcroft <apw@canonical.com>,
Joe Perches <joe@perches.com>,
Dwaipayan Ray <dwaipayanray1@gmail.com>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>,
Fabio Estevam <festevam@gmail.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Haibo Chen <haibo.chen@nxp.com>,
Catalin Popescu <catalin.popescu@leica-geosystems.com>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/4] gpiolib: add opt-out for existing drivers with static GPIO base
Date: Mon, 13 Jan 2025 23:19:09 +0100 [thread overview]
Message-ID: <20250113-b4-imx-gpio-base-warning-v1-1-0a28731a5cf6@pengutronix.de> (raw)
In-Reply-To: <20250113-b4-imx-gpio-base-warning-v1-0-0a28731a5cf6@pengutronix.de>
Some drivers have had deterministic GPIO numbering for most of
their existence, e.g. the i.MX GPIO since commit 7e6086d9e54a
("gpio/mxc: specify gpio base for device tree probe"), more than
12 years ago.
Reverting this to dynamically numbered will break existing setups in
the worst manner possible: The build will succeed, the kernel will not
print warnings, but users will find their devices essentially toggling
GPIOs at random with the potential of permanent damage.
As these concerns won't go away until the sysfs interface is removed,
let's add a new struct gpio_chip::legacy_static_base member that can be
used by existing drivers that have been grandfathered in to suppress
the warning currently being printed:
gpio gpiochip0: Static allocation of GPIO base is deprecated,
use dynamic allocation.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/gpio/gpiolib.c | 2 +-
include/linux/gpio/driver.h | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 679ed764cb143c4b3357106de1570e8d38441372..bedeb8f28badfb7287c4929f9ad0825e050a79c9 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1011,7 +1011,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
* drop this and assign a poison instead.
*/
gc->base = base;
- } else {
+ } else if (!gc->legacy_static_base) {
dev_warn(&gdev->dev,
"Static allocation of GPIO base is deprecated, use dynamic allocation.\n");
}
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 2dd7cb9cc270a68ddedbcdd5d44e0d0f88dfa785..6e820d79d03e61123f89aaf884d35d4a1a5918a7 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -382,6 +382,10 @@ struct gpio_irq_chip {
* implies that if the chip supports IRQs, these IRQs need to be threaded
* as the chip access may sleep when e.g. reading out the IRQ status
* registers.
+ * @legacy_static_base: set for some existing drivers, where @base is non-negative
+ * and changing that would induce so much breakage that they were
+ * grandfathered in until GPIO sysfs support is removed altogether.
+ * Do not set this for any new drivers.
* @read_reg: reader function for generic GPIO
* @write_reg: writer function for generic GPIO
* @be_bits: if the generic GPIO has big endian bit order (bit 31 is representing
@@ -467,6 +471,7 @@ struct gpio_chip {
u16 offset;
const char *const *names;
bool can_sleep;
+ bool legacy_static_base;
#if IS_ENABLED(CONFIG_GPIO_GENERIC)
unsigned long (*read_reg)(void __iomem *reg);
--
2.39.5
next prev parent reply other threads:[~2025-01-13 22:19 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 22:19 [PATCH 0/4] gpio: mxc: silence warning about GPIO base being statically allocated Ahmad Fatoum
2025-01-13 22:19 ` Ahmad Fatoum [this message]
2025-01-14 9:49 ` [PATCH 1/4] gpiolib: add opt-out for existing drivers with static GPIO base Andy Shevchenko
2025-01-14 10:06 ` Ahmad Fatoum
2025-01-14 19:38 ` Andy Shevchenko
2025-01-15 7:07 ` Ahmad Fatoum
2025-01-15 13:04 ` Kent Gibson
2025-01-21 10:26 ` Ahmad Fatoum
2025-01-15 12:00 ` Linus Walleij
2025-01-21 11:34 ` Ahmad Fatoum
2025-01-13 22:19 ` [PATCH 2/4] checkpatch: warn about use of legacy_static_base Ahmad Fatoum
2025-01-14 14:37 ` Linus Walleij
2025-01-13 22:19 ` [PATCH 3/4] gpio: mxc: remove dead code after switch to DT-only Ahmad Fatoum
2025-01-14 9:51 ` Andy Shevchenko
2025-01-15 16:55 ` Bartosz Golaszewski
2025-01-21 10:16 ` Ahmad Fatoum
2025-01-13 22:19 ` [PATCH 4/4] gpio: mxc: silence warning about GPIO base being statically allocated Ahmad Fatoum
2025-01-14 9:46 ` [PATCH 0/4] " Andy Shevchenko
2025-01-14 9:55 ` Ahmad Fatoum
2025-01-14 19:43 ` Andy Shevchenko
2025-01-15 7:03 ` Ahmad Fatoum
2025-01-15 15:16 ` Andy Shevchenko
2025-01-21 11:16 ` Ahmad Fatoum
2025-01-15 16:52 ` Bartosz Golaszewski
2025-01-21 10:37 ` Ahmad Fatoum
2025-01-23 9:19 ` Bartosz Golaszewski
2025-01-23 8:06 ` (subset) " Bartosz Golaszewski
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=20250113-b4-imx-gpio-base-warning-v1-1-0a28731a5cf6@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=andy.shevchenko@gmail.com \
--cc=apw@canonical.com \
--cc=brgl@bgdev.pl \
--cc=catalin.popescu@leica-geosystems.com \
--cc=dario.binacchi@amarulasolutions.com \
--cc=dwaipayanray1@gmail.com \
--cc=festevam@gmail.com \
--cc=haibo.chen@nxp.com \
--cc=imx@lists.linux.dev \
--cc=joe@perches.com \
--cc=kernel@pengutronix.de \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@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).