From: Michael Walle <mwalle@kernel.org>
To: William Breathitt Gray <wbg@kernel.org>,
Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
Petar Stepanovic <pstepanovic@axiado.com>,
SriNavmani A <srinavmani@axiado.com>,
Prasad Bolisetty <pbolisetty@axiado.com>,
Tzu-Hao Wei <twei@axiado.com>,
Karthikeyan Mitran <kmitran@axiado.com>,
Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>,
Michael Walle <mwalle@kernel.org>, Lee Jones <lee@kernel.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Long Zhao <longzhao@ambarella.com>,
Joseph Telaak <joseph@telaak.dev>
Cc: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [RFT PATCH v2 11/14] gpio: ws16c48: create the regmap-irq chip from the gpio-regmap callback
Date: Fri, 27 Nov 2026 15:52:28 +0100 [thread overview]
Message-ID: <20261127145232.814492-12-mwalle@kernel.org> (raw)
In-Reply-To: <20261127145232.814492-1-mwalle@kernel.org>
Use the new gpio_regmap_add_irq_chip() helper to create the regmap-irq
domain.
Signed-off-by: Michael Walle <mwalle@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-ws16c48.c | 36 +++++++++++++++++++++++++-----------
1 file changed, 25 insertions(+), 11 deletions(-)
diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
index cd0c35c057cb..6a5e74fc3395 100644
--- a/drivers/gpio/gpio-ws16c48.c
+++ b/drivers/gpio/gpio-ws16c48.c
@@ -104,16 +104,20 @@ static const struct regmap_irq ws16c48_regmap_irqs[WS16C48_NUM_IRQS] = {
* @map: regmap for the device
* @lock: synchronization lock to prevent I/O race conditions
* @irq_mask: I/O bits affected by interrupts
+ * @chip: regmap_irq_chip for the device
+ * @irq: parent IRQ
*/
struct ws16c48_gpio {
struct regmap *map;
raw_spinlock_t lock;
u8 irq_mask[WS16C48_NUM_IRQS / WS16C48_NGPIO_PER_REG];
+ struct regmap_irq_chip *chip;
+ unsigned int irq;
};
static int ws16c48_handle_pre_irq(void *const irq_drv_data) __acquires(&ws16c48gpio->lock)
{
- struct ws16c48_gpio *const ws16c48gpio = irq_drv_data;
+ struct ws16c48_gpio *const ws16c48gpio = gpio_regmap_get_drvdata(irq_drv_data);
/* Lock to prevent Page/Lock register change while we handle IRQ */
raw_spin_lock(&ws16c48gpio->lock);
@@ -123,7 +127,7 @@ static int ws16c48_handle_pre_irq(void *const irq_drv_data) __acquires(&ws16c48g
static int ws16c48_handle_post_irq(void *const irq_drv_data) __releases(&ws16c48gpio->lock)
{
- struct ws16c48_gpio *const ws16c48gpio = irq_drv_data;
+ struct ws16c48_gpio *const ws16c48gpio = gpio_regmap_get_drvdata(irq_drv_data);
raw_spin_unlock(&ws16c48gpio->lock);
@@ -133,7 +137,7 @@ static int ws16c48_handle_post_irq(void *const irq_drv_data) __releases(&ws16c48
static int ws16c48_handle_mask_sync(const int index, const unsigned int mask_buf_def,
const unsigned int mask_buf, void *const irq_drv_data)
{
- struct ws16c48_gpio *const ws16c48gpio = irq_drv_data;
+ struct ws16c48_gpio *const ws16c48gpio = gpio_regmap_get_drvdata(irq_drv_data);
unsigned long flags;
int ret = 0;
@@ -167,7 +171,7 @@ static int ws16c48_set_type_config(unsigned int **const buf, const unsigned int
const struct regmap_irq *const irq_data, const int idx,
void *const irq_drv_data)
{
- struct ws16c48_gpio *const ws16c48gpio = irq_drv_data;
+ struct ws16c48_gpio *const ws16c48gpio = gpio_regmap_get_drvdata(irq_drv_data);
unsigned int polarity;
unsigned long flags;
int ret;
@@ -242,6 +246,19 @@ static int ws16c48_irq_init_hw(struct regmap *const map)
return regmap_write(map, WS16C48_PAGE_LOCK, INT_ID_PAGE);
}
+static struct irq_domain *ws16c48_create_irq_domain(struct gpio_regmap *gpio)
+{
+ struct ws16c48_gpio *const ws16c48gpio = gpio_regmap_get_drvdata(gpio);
+ struct irq_domain *domain;
+
+ domain = gpio_regmap_add_irq_chip(gpio, ws16c48gpio->irq, 0, ws16c48gpio->chip);
+ if (IS_ERR(domain))
+ return dev_err_cast_probe(regmap_get_device(ws16c48gpio->map), domain,
+ "IRQ registration failed\n");
+
+ return domain;
+}
+
static int ws16c48_probe(struct device *dev, unsigned int id)
{
struct ws16c48_gpio *ws16c48gpio;
@@ -250,7 +267,6 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
struct gpio_regmap_config gpio_config = {};
void __iomem *regs;
struct regmap_irq_chip *chip;
- struct regmap_irq_chip_data *chip_data;
ws16c48gpio = devm_kzalloc_obj(dev, *ws16c48gpio);
if (!ws16c48gpio)
@@ -286,7 +302,8 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
chip->handle_post_irq = ws16c48_handle_post_irq;
chip->handle_mask_sync = ws16c48_handle_mask_sync;
chip->set_type_config = ws16c48_set_type_config;
- chip->irq_drv_data = ws16c48gpio;
+ ws16c48gpio->chip = chip;
+ ws16c48gpio->irq = irq[id];
raw_spin_lock_init(&ws16c48gpio->lock);
@@ -295,10 +312,6 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
if (err)
return err;
- err = devm_regmap_add_irq_chip(dev, ws16c48gpio->map, irq[id], 0, 0, chip, &chip_data);
- if (err)
- return dev_err_probe(dev, err, "IRQ registration failed\n");
-
gpio_config.parent = dev;
gpio_config.regmap = ws16c48gpio->map;
gpio_config.ngpio = WS16C48_NGPIO;
@@ -308,7 +321,8 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
/* Setting a GPIO to 0 allows it to be used as an input */
gpio_config.reg_dir_out_base = GPIO_REGMAP_ADDR(WS16C48_DAT_BASE);
gpio_config.ngpio_per_reg = WS16C48_NGPIO_PER_REG;
- gpio_config.irq_domain = regmap_irq_get_domain(chip_data);
+ gpio_config.drvdata = ws16c48gpio;
+ gpio_config.create_irq_domain = ws16c48_create_irq_domain;
return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &gpio_config));
}
--
2.47.3
next prev parent reply other threads:[~2026-11-27 14:53 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 14:52 [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 01/14] gpio: regmap: use the correct number for .ngpio_per_reg Michael Walle
2026-11-27 17:19 ` Andy Shevchenko
2026-11-30 10:21 ` Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 02/14] gpio: regmap: remove gpiochip before tearing down irqchip Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 03/14] gpio: regmap: add callbacks to handle IRQ domains Michael Walle
2026-11-27 17:27 ` Andy Shevchenko
2026-11-27 14:52 ` [RFT PATCH v2 04/14] gpio: rtd1625: create the IRQ domain from the gpio-regmap callback Michael Walle
2026-11-27 18:30 ` Andy Shevchenko
2026-11-30 14:37 ` Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 05/14] gpio: axiado-sgpio: " Michael Walle
2026-11-27 18:35 ` Andy Shevchenko
2026-11-30 14:51 ` Petar Stepanovic
2026-11-27 14:52 ` [RFT PATCH v2 06/14] gpio: regmap: add helpers to add a regmap-irq chip Michael Walle
2026-11-27 18:43 ` Andy Shevchenko
2026-11-30 10:35 ` Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 07/14] gpio: max7360: create the regmap-irq chip from the gpio-regmap callback Michael Walle
2026-11-27 18:48 ` Andy Shevchenko
2026-11-30 12:58 ` Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 08/14] gpio: sl28cpld: " Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 09/14] gpio: idio-16: " Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 10/14] gpio: pcie-idio-24: " Michael Walle
2026-11-27 14:52 ` Michael Walle [this message]
2026-11-27 14:52 ` [RFT PATCH v2 12/14] gpio: 104-idi-48: " Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 13/14] gpio: i8255: " Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 14/14] gpio: regmap: remove irq_domain and the regmap-irq configuration Michael Walle
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=20261127145232.814492-12-mwalle@kernel.org \
--to=mwalle@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=brgl@kernel.org \
--cc=joseph@telaak.dev \
--cc=kmitran@axiado.com \
--cc=lee@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=longzhao@ambarella.com \
--cc=mathieu.dubois-briand@bootlin.com \
--cc=pbolisetty@axiado.com \
--cc=pstepanovic@axiado.com \
--cc=srinavmani@axiado.com \
--cc=twei@axiado.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.