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 03/13] gpio: rtd1625: create the IRQ domain from the gpio-regmap callback
Date: Thu, 26 Nov 2026 16:35:14 +0100 [thread overview]
Message-ID: <20261126153600.299724-4-mwalle@kernel.org> (raw)
In-Reply-To: <20261126153600.299724-1-mwalle@kernel.org>
Use the new .create_irq_domain() to actually create the domain. This
way, there is no window where a NULL pointer could be dereferenced.
Switch the irq host_data to the gpio_regmap pointer because it will
already be needed in the irq domain callbacks. Otherwise the
.create_irq_domain() callback would have to set the data->gpio_reg
pointer which looks odd.
Signed-off-by: Michael Walle <mwalle@kernel.org>
---
drivers/gpio/gpio-rtd1625.c | 74 ++++++++++++++++++++-----------------
1 file changed, 41 insertions(+), 33 deletions(-)
diff --git a/drivers/gpio/gpio-rtd1625.c b/drivers/gpio/gpio-rtd1625.c
index cf4f61603dfb..0713692804e2 100644
--- a/drivers/gpio/gpio-rtd1625.c
+++ b/drivers/gpio/gpio-rtd1625.c
@@ -79,7 +79,6 @@ struct rtd1625_gpio_info {
};
struct rtd1625_gpio {
- struct gpio_regmap *gpio_reg;
const struct rtd1625_gpio_info *info;
struct regmap *regmap;
unsigned int irqs[RTD1625_MAX_IRQS];
@@ -290,7 +289,7 @@ static void rtd1625_gpio_irq_handle(struct irq_desc *desc)
static void rtd1625_gpio_ack_irq(struct irq_data *d)
{
- struct rtd1625_gpio *data = irq_data_get_irq_chip_data(d);
+ struct rtd1625_gpio *data = gpio_regmap_get_drvdata(irq_data_get_irq_chip_data(d));
irq_hw_number_t hwirq = irqd_to_hwirq(d);
u32 irq_type = irqd_get_trigger_type(d);
u32 bit_mask = BIT(hwirq % 32);
@@ -352,11 +351,12 @@ static void rtd1625_gpio_disable_level_irq(struct rtd1625_gpio *data, irq_hw_num
static void rtd1625_gpio_enable_irq(struct irq_data *d)
{
- struct rtd1625_gpio *data = irq_data_get_irq_chip_data(d);
+ struct gpio_regmap *gpio_reg = irq_data_get_irq_chip_data(d);
+ struct rtd1625_gpio *data = gpio_regmap_get_drvdata(gpio_reg);
irq_hw_number_t hwirq = irqd_to_hwirq(d);
u32 irq_type = irqd_get_trigger_type(d);
- gpio_regmap_enable_irq(data->gpio_reg, hwirq);
+ gpio_regmap_enable_irq(gpio_reg, hwirq);
if (irq_type & IRQ_TYPE_EDGE_BOTH)
rtd1625_gpio_enable_edge_irq(data, hwirq);
@@ -366,7 +366,8 @@ static void rtd1625_gpio_enable_irq(struct irq_data *d)
static void rtd1625_gpio_disable_irq(struct irq_data *d)
{
- struct rtd1625_gpio *data = irq_data_get_irq_chip_data(d);
+ struct gpio_regmap *gpio_reg = irq_data_get_irq_chip_data(d);
+ struct rtd1625_gpio *data = gpio_regmap_get_drvdata(gpio_reg);
irq_hw_number_t hwirq = irqd_to_hwirq(d);
u32 irq_type = irqd_get_trigger_type(d);
@@ -375,7 +376,7 @@ static void rtd1625_gpio_disable_irq(struct irq_data *d)
else if (irq_type & IRQ_TYPE_LEVEL_MASK)
rtd1625_gpio_disable_level_irq(data, hwirq);
- gpio_regmap_disable_irq(data->gpio_reg, hwirq);
+ gpio_regmap_disable_irq(gpio_reg, hwirq);
}
static int rtd1625_gpio_irq_set_level_type(struct irq_data *d, bool level)
@@ -385,7 +386,7 @@ static int rtd1625_gpio_irq_set_level_type(struct irq_data *d, bool level)
struct rtd1625_gpio *data;
int ret;
- data = irq_data_get_irq_chip_data(d);
+ data = gpio_regmap_get_drvdata(irq_data_get_irq_chip_data(d));
if (!(data->info->irq_type_support & IRQ_TYPE_LEVEL_MASK))
return -EINVAL;
@@ -406,7 +407,7 @@ static int rtd1625_gpio_irq_set_level_type(struct irq_data *d, bool level)
static int rtd1625_gpio_irq_set_edge_type(struct irq_data *d, bool polarity)
{
- struct rtd1625_gpio *data = irq_data_get_irq_chip_data(d);
+ struct rtd1625_gpio *data = gpio_regmap_get_drvdata(irq_data_get_irq_chip_data(d));
u32 val = RTD1625_GPIO_WREN(RTD1625_GPIO_EDGE_INT_DP);
irq_hw_number_t hwirq = irqd_to_hwirq(d);
int ret;
@@ -454,16 +455,16 @@ static int rtd1625_gpio_irq_set_type(struct irq_data *d, unsigned int type)
static int rtd1625_gpio_irq_request_resources(struct irq_data *d)
{
- struct rtd1625_gpio *data = irq_data_get_irq_chip_data(d);
+ struct gpio_regmap *gpio_reg = irq_data_get_irq_chip_data(d);
- return gpio_regmap_reqres_irq(data->gpio_reg, d->hwirq);
+ return gpio_regmap_reqres_irq(gpio_reg, d->hwirq);
}
static void rtd1625_gpio_irq_release_resources(struct irq_data *d)
{
- struct rtd1625_gpio *data = irq_data_get_irq_chip_data(d);
+ struct gpio_regmap *gpio_reg = irq_data_get_irq_chip_data(d);
- gpio_regmap_relres_irq(data->gpio_reg, d->hwirq);
+ gpio_regmap_relres_irq(gpio_reg, d->hwirq);
}
static struct irq_chip rtd1625_iso_gpio_irq_chip = {
@@ -505,9 +506,9 @@ static int rtd1625_gpio_setup_irq(struct platform_device *pdev, struct rtd1625_g
static int rtd1625_gpio_irq_map(struct irq_domain *domain, unsigned int irq,
irq_hw_number_t hwirq)
{
- struct rtd1625_gpio *data = domain->host_data;
+ struct gpio_regmap *gpio_reg = domain->host_data;
- irq_set_chip_data(irq, data);
+ irq_set_chip_data(irq, gpio_reg);
irq_set_chip_and_handler(irq, &rtd1625_iso_gpio_irq_chip, handle_bad_irq);
@@ -524,6 +525,31 @@ static const struct irq_domain_ops rtd1625_gpio_irq_domain_ops = {
.xlate = irq_domain_xlate_twocell,
};
+static struct irq_domain *rtd1625_gpio_create_irq_domain(struct gpio_regmap *gpio_reg)
+{
+ struct rtd1625_gpio *data = gpio_regmap_get_drvdata(gpio_reg);
+ struct device *dev = regmap_get_device(data->regmap);
+ struct platform_device *pdev = to_platform_device(dev);
+ struct irq_domain_info d_info = {};
+ int ret;
+
+ d_info.fwnode = dev_fwnode(&pdev->dev);
+ d_info.size = data->info->num_gpios;
+ d_info.hwirq_max = data->info->num_gpios;
+ d_info.ops = &rtd1625_gpio_irq_domain_ops;
+ d_info.host_data = gpio_reg;
+
+ data->domain = devm_irq_domain_instantiate(dev, &d_info);
+ if (IS_ERR(data->domain))
+ return data->domain;
+
+ ret = rtd1625_gpio_setup_irq(pdev, data);
+ if (ret)
+ return ERR_PTR(ret);
+
+ return data->domain;
+}
+
static const struct regmap_config rtd1625_gpio_regmap_config = {
.reg_bits = 32,
.reg_stride = 4,
@@ -536,12 +562,10 @@ static const struct regmap_config rtd1625_gpio_regmap_config = {
static int rtd1625_gpio_probe(struct platform_device *pdev)
{
struct gpio_regmap_config config = {};
- struct irq_domain_info d_info = {};
struct device *dev = &pdev->dev;
struct gpio_regmap *gpio_reg;
struct rtd1625_gpio *data;
void __iomem *irq_base;
- int ret;
data = devm_kzalloc_obj(dev, *data);
if (!data)
@@ -578,29 +602,13 @@ static int rtd1625_gpio_probe(struct platform_device *pdev)
config.set_config = rtd1625_gpio_set_config;
config.value_xlate = rtd1625_value_xlate;
- d_info.fwnode = dev_fwnode(&pdev->dev);
- d_info.size = data->info->num_gpios;
- d_info.hwirq_max = data->info->num_gpios;
- d_info.ops = &rtd1625_gpio_irq_domain_ops;
- d_info.host_data = data;
-
- data->domain = devm_irq_domain_instantiate(dev, &d_info);
- if (IS_ERR(data->domain))
- return PTR_ERR(data->domain);
-
- ret = rtd1625_gpio_setup_irq(pdev, data);
- if (ret)
- return ret;
-
- config.irq_domain = data->domain;
config.drvdata = data;
+ config.create_irq_domain = rtd1625_gpio_create_irq_domain;
gpio_reg = devm_gpio_regmap_register(dev, &config);
if (IS_ERR(gpio_reg))
return PTR_ERR(gpio_reg);
- data->gpio_reg = gpio_reg;
-
return 0;
}
--
2.47.3
next prev parent reply other threads:[~2026-11-26 15:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 15:35 [RFT PATCH 00/13] gpio: regmap: IRQ domain cleanups Michael Walle
2026-11-26 15:35 ` [RFT PATCH 01/13] gpio: regmap: remove gpiochip before tearing down irqchip Michael Walle
2026-11-26 15:35 ` [RFT PATCH 02/13] gpio: regmap: add a callback to create the IRQ domain Michael Walle
2026-11-26 15:47 ` sashiko-bot
2026-11-26 21:52 ` Joseph Telaak
2026-11-26 15:35 ` Michael Walle [this message]
2026-11-26 15:54 ` [RFT PATCH 03/13] gpio: rtd1625: create the IRQ domain from the gpio-regmap callback sashiko-bot
2026-11-26 15:35 ` [RFT PATCH 04/13] gpio: axiado-sgpio: " Michael Walle
2026-11-30 9:39 ` Petar Stepanovic
2026-11-30 10:11 ` Michael Walle
2026-11-26 15:35 ` [RFT PATCH 05/13] gpio: regmap: add a helper to add a regmap-irq chip Michael Walle
2026-11-26 15:35 ` [RFT PATCH 06/13] gpio: max7360: create the regmap-irq chip from the gpio-regmap callback Michael Walle
2026-11-26 20:43 ` Andy Shevchenko
2026-11-27 8:59 ` Michael Walle
2026-11-26 15:35 ` [RFT PATCH 07/13] gpio: sl28cpld: " Michael Walle
2026-11-26 15:35 ` [RFT PATCH 08/13] gpio: idio-16: " Michael Walle
2026-11-26 15:35 ` [RFT PATCH 09/13] gpio: pcie-idio-24: " Michael Walle
2026-11-26 15:48 ` sashiko-bot
2026-11-27 9:03 ` Michael Walle
2026-11-26 15:35 ` [RFT PATCH 10/13] gpio: ws16c48: " Michael Walle
2026-11-26 15:35 ` [RFT PATCH 11/13] gpio: 104-idi-48: " Michael Walle
2026-11-26 15:48 ` sashiko-bot
2026-11-26 15:35 ` [RFT PATCH 12/13] gpio: i8255: " Michael Walle
2026-11-26 15:35 ` [RFT PATCH 13/13] gpio: regmap: remove irq_domain and the regmap-irq configuration Michael Walle
2026-11-26 21:52 ` Joseph Telaak
2026-11-26 20:48 ` [RFT PATCH 00/13] gpio: regmap: IRQ domain cleanups 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=20261126153600.299724-4-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.