[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <DA62SSMI7C52.V2QD509S95QW@bootlin.com>
Date: Mon, 26 May 2025 14:03:12 +0200
From: "Mathieu Dubois-Briand" <mathieu.dubois-briand@...tlin.com>
To: "Bartosz Golaszewski" <brgl@...ev.pl>
Cc: "Lee Jones" <lee@...nel.org>, "Rob Herring" <robh@...nel.org>,
"Krzysztof Kozlowski" <krzk+dt@...nel.org>, "Conor Dooley"
<conor+dt@...nel.org>, "Kamel Bouhara" <kamel.bouhara@...tlin.com>, "Linus
Walleij" <linus.walleij@...aro.org>, "Dmitry Torokhov"
<dmitry.torokhov@...il.com>, Uwe Kleine-König
<ukleinek@...nel.org>, "Michael Walle" <mwalle@...nel.org>, "Mark Brown"
<broonie@...nel.org>, "Greg Kroah-Hartman" <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>, "Danilo Krummrich"
<dakr@...nel.org>, <devicetree@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-gpio@...r.kernel.org>,
<linux-input@...r.kernel.org>, <linux-pwm@...r.kernel.org>,
<andriy.shevchenko@...el.com>, Grégory Clement
<gregory.clement@...tlin.com>, "Thomas Petazzoni"
<thomas.petazzoni@...tlin.com>
Subject: Re: [PATCH v9 06/11] gpio: regmap: Allow to allocate regmap-irq
device
On Thu May 22, 2025 at 3:01 PM CEST, Bartosz Golaszewski wrote:
> On Thu, May 22, 2025 at 2:06 PM Mathieu Dubois-Briand
> <mathieu.dubois-briand@...tlin.com> wrote:
>>
>> GPIO controller often have support for IRQ: allow to easily allocate
>> both gpio-regmap and regmap-irq in one operation.
>>
>> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@...tlin.com>
>> ---
>> drivers/gpio/gpio-regmap.c | 21 +++++++++++++++++++--
>> include/linux/gpio/regmap.h | 11 +++++++++++
>> 2 files changed, 30 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
>> index 87c4225784cf..9cbbbaf82609 100644
>> --- a/drivers/gpio/gpio-regmap.c
>> +++ b/drivers/gpio/gpio-regmap.c
>> @@ -215,6 +215,7 @@ EXPORT_SYMBOL_GPL(gpio_regmap_get_drvdata);
>> */
>> struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config)
>> {
>> + struct irq_domain *irq_domain;
>> struct gpio_regmap *gpio;
>> struct gpio_chip *chip;
>> int ret;
>> @@ -295,8 +296,24 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
>> if (ret < 0)
>> goto err_free_gpio;
>>
>> - if (config->irq_domain) {
>> - ret = gpiochip_irqchip_add_domain(chip, config->irq_domain);
>> +#ifdef CONFIG_REGMAP_IRQ
>> + if (config->regmap_irq_chip) {
>> + struct regmap_irq_chip_data *irq_chip_data;
>> +
>> + ret = devm_regmap_add_irq_chip_fwnode(config->parent, dev_fwnode(config->parent),
>> + config->regmap, config->regmap_irq_line,
>> + config->regmap_irq_flags, 0,
>> + config->regmap_irq_chip, &irq_chip_data);
>
> I don't think using devres here is a good idea. There's no guarantee
> that gpio_regmap_register() will be called on device attach so you
> must not make the release of the resource depend on an associated
> detach which may never happen. Please use the non-managed variant
> here.
Right, I will make sure to use
regmap_add_irq_chip_fwnode()/regmap_del_irq_chip() here.
I should be able to send a new version in the coming days.
>
> Bart
>
Thanks for your review.
Mathieu
--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Powered by blists - more mailing lists