From: Yu-Chun Lin <eleanor.lin@realtek.com>
To: <linusw@kernel.org>, <andriy.shevchenko@intel.com>,
<mwalle@kernel.org>, <brgl@kernel.org>, <tychang@realtek.com>,
<wbg@kernel.org>, <mathieu.dubois-briand@bootlin.com>,
<nuno.sa@analog.com>, <Michael.Hennerich@analog.com>,
<jic23@kernel.org>, <andy@kernel.org>, <o-takashi@sakamocchi.jp>
Cc: <u.kleine-koenig@baylibre.com>, <dakr@kernel.org>,
<bhelgaas@google.com>, <eleanor.lin@realtek.com>,
<dlechner@baylibre.com>, <linux-kernel@vger.kernel.org>,
<linux-gpio@vger.kernel.org>, <linux@analog.com>,
<linux-iio@vger.kernel.org>, <cy.huang@realtek.com>,
<james.tai@realtek.com>, <stanley_chang@realtek.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v8 3/9] gpio: regmap: Apply default resource callbacks for regmap IRQ chip
Date: Sun, 26 Jul 2026 20:51:54 +0800 [thread overview]
Message-ID: <20260726125209.140307-4-eleanor.lin@realtek.com> (raw)
In-Reply-To: <20260726125209.140307-1-eleanor.lin@realtek.com>
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
When GPIO regmap creates an IRQ chip on behalf of the user, it also
takes an ownership of the respective callbacks and driver data.
With that being done, apply default resource callbacks that keep
tracking the IRQ requests and releases.
Reviewed-by: Michael Walle <mwalle@kernel.org>
Reviewed-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Yu-Chun Lin <eleanor.lin@realtek.com>
---
Changes in v8:
- Add Reviewed-by tags from Mathieu and Linus.
---
drivers/gpio/gpio-max7360.c | 7 ++++---
drivers/gpio/gpio-regmap.c | 14 ++++++++++++++
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-max7360.c b/drivers/gpio/gpio-max7360.c
index d12cf1dc8d57..07eda49f375b 100644
--- a/drivers/gpio/gpio-max7360.c
+++ b/drivers/gpio/gpio-max7360.c
@@ -127,7 +127,7 @@ static int max7360_handle_mask_sync(const int index,
const unsigned int mask_buf,
void *const irq_drv_data)
{
- struct regmap *regmap = irq_drv_data;
+ struct regmap *regmap = gpio_regmap_get_drvdata(irq_drv_data);
int ret;
for (unsigned int i = 0; i < MAX7360_MAX_GPIO; i++) {
@@ -170,7 +170,6 @@ static int max7360_gpio_probe(struct platform_device *pdev)
/* Create custom IRQ configuration. */
irq_chip = devm_kzalloc(dev, sizeof(*irq_chip), GFP_KERNEL);
- gpio_config.regmap_irq_chip = irq_chip;
if (!irq_chip)
return -ENOMEM;
@@ -181,7 +180,9 @@ static int max7360_gpio_probe(struct platform_device *pdev)
irq_chip->num_irqs = MAX7360_MAX_GPIO;
irq_chip->irqs = max7360_regmap_irqs;
irq_chip->handle_mask_sync = max7360_handle_mask_sync;
- irq_chip->irq_drv_data = regmap;
+
+ gpio_config.regmap_irq_chip = irq_chip;
+ gpio_config.drvdata = regmap;
for (unsigned int i = 0; i < MAX7360_MAX_GPIO; i++) {
ret = regmap_write_bits(regmap, MAX7360_REG_PWMCFG(i),
diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index 535bd9deaa71..658b892b624c 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -6,6 +6,7 @@
*/
#include <linux/bits.h>
+#include <linux/compiler_attributes.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/io.h>
@@ -288,6 +289,16 @@ void gpio_regmap_relres_irq(struct gpio_regmap *gpio, unsigned int offset)
}
EXPORT_SYMBOL_GPL(gpio_regmap_relres_irq);
+static int __maybe_unused gpio_regmap_irq_reqres(void *irq_drv_data, irq_hw_number_t hwirq)
+{
+ return gpio_regmap_reqres_irq(irq_drv_data, hwirq);
+}
+
+static void __maybe_unused gpio_regmap_irq_relres(void *irq_drv_data, irq_hw_number_t hwirq)
+{
+ gpio_regmap_relres_irq(irq_drv_data, hwirq);
+}
+
void *gpio_regmap_get_drvdata(struct gpio_regmap *gpio)
{
return gpio->driver_data;
@@ -409,6 +420,9 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
#ifdef CONFIG_REGMAP_IRQ
if (config->regmap_irq_chip) {
gpio->regmap_irq_line = config->regmap_irq_line;
+ config->regmap_irq_chip->irq_reqres = gpio_regmap_irq_reqres;
+ config->regmap_irq_chip->irq_relres = gpio_regmap_irq_relres;
+ config->regmap_irq_chip->irq_drv_data = gpio;
ret = regmap_add_irq_chip_fwnode(dev_fwnode(config->parent), config->regmap,
config->regmap_irq_line, config->regmap_irq_flags,
0, config->regmap_irq_chip, &gpio->irq_chip_data);
--
2.43.0
next prev parent reply other threads:[~2026-07-26 12:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-26 12:51 [PATCH v8 0/9] gpio: realtek: Add support for Realtek DHC RTD1625 Yu-Chun Lin
2026-07-26 12:51 ` [PATCH v8 1/9] Revert "gpio: realtek: Add driver for Realtek DHC RTD1625 SoC" Yu-Chun Lin
2026-07-26 12:51 ` [PATCH v8 2/9] gpio: regmap: Provide default IRQ resource request and release callbacks Yu-Chun Lin
2026-07-26 12:51 ` Yu-Chun Lin [this message]
2026-07-26 12:51 ` [PATCH v8 4/9] gpio: regmap: Order kernel-doc descriptions with the actual appearance Yu-Chun Lin
2026-07-26 12:51 ` [PATCH v8 5/9] gpio: regmap: Add gpio_regmap_operation to extend reg_mask_xlate callback Yu-Chun Lin
2026-07-26 12:51 ` [PATCH v8 6/9] gpio: regmap: Add value_xlate callback Yu-Chun Lin
2026-07-26 12:51 ` [PATCH v8 7/9] gpio: regmap: Add set_config callback Yu-Chun Lin
2026-07-26 12:51 ` [PATCH v8 8/9] gpio: regmap: Add IRQ enable/disable helpers Yu-Chun Lin
2026-07-26 12:52 ` [PATCH v8 9/9] gpio: realtek: Add driver for Realtek DHC RTD1625 SoC Yu-Chun Lin
2026-07-27 8:20 ` Mathieu Dubois-Briand
2026-07-27 11:10 ` Bartosz Golaszewski
2026-07-27 11:23 ` Mathieu Dubois-Briand
2026-07-27 13:04 ` Bartosz Golaszewski
2026-07-27 14:07 ` Mathieu Dubois-Briand
2026-08-06 23:44 ` Andy Shevchenko
2026-07-30 9:05 ` [PATCH v8 0/9] gpio: realtek: Add support for Realtek DHC RTD1625 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=20260726125209.140307-4-eleanor.lin@realtek.com \
--to=eleanor.lin@realtek.com \
--cc=Michael.Hennerich@analog.com \
--cc=andriy.shevchenko@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=bhelgaas@google.com \
--cc=brgl@kernel.org \
--cc=cy.huang@realtek.com \
--cc=dakr@kernel.org \
--cc=dlechner@baylibre.com \
--cc=james.tai@realtek.com \
--cc=jic23@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@analog.com \
--cc=mathieu.dubois-briand@bootlin.com \
--cc=mwalle@kernel.org \
--cc=nuno.sa@analog.com \
--cc=o-takashi@sakamocchi.jp \
--cc=stanley_chang@realtek.com \
--cc=tychang@realtek.com \
--cc=u.kleine-koenig@baylibre.com \
--cc=wbg@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
all inboxes | Powered by JetHome®