[RFT PATCH v2 03/14] gpio: regmap: add callbacks to handle IRQ domains

Andy Shevchenko andriy.shevchenko at linux.intel.com
Fri Nov 27 09:27:47 PST 2026


On Fri, Nov 27, 2026 at 03:52:20PM +0100, Michael Walle wrote:
> At the moment, an IRQ domain is attached via config->irq_domain.
> This means, that it has to be created before the gpio_regmap_register()
> call. The callbacks of the IRQ domain might use the gpio_regmap_*_irq()
> functions. Consumers can already use the domain as soon as it is
> created and this creates a small window where the callbacks dereference
> a NULL pointer.
> 
> To fix this, create a new create_irq_domain() callback, that is called
> after the gpio_chip is added.
> 
> Also add a remove_irq_domain() callback, which is called after the
> gpio_chip is removed and before the gpio_regmap is freed. It is supposed
> to dispose the IRQ mappings and remove the domain.
> 
> Also ordering of the resources matter, so we forbid any device managed
> resource handling. Any resources allocated in the create_irq_domain()
> callback has to be freed manually in the remove_irq_domain() callback.

...

>  	unsigned long *fixed_direction_mask;
>  	unsigned long *fixed_direction_output;

Perhaps a short comment why create_irq_domain is not here?

> +	void (*remove_irq_domain)(struct gpio_regmap *gpio);

...

> +	irq_domain = config->irq_domain;
> +
> +	if (config->create_irq_domain) {
> +		irq_domain = config->create_irq_domain(gpio);

> +		if (IS_ERR(irq_domain)) {
> +			ret = PTR_ERR(irq_domain);
> +			goto err_remove_gpiochip;
> +		}

		ret = PTR_ERR_OR_ZERO(...);
		if (ret)
			goto ...;

> +		gpio->remove_irq_domain = config->remove_irq_domain;
> +	}

-- 
With Best Regards,
Andy Shevchenko





More information about the linux-arm-kernel mailing list