[RFT PATCH v2 04/14] gpio: rtd1625: create the IRQ domain from the gpio-regmap callback
Michael Walle
mwalle at kernel.org
Mon Nov 30 06:37:17 PST 2026
Hi,
>> +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 irq_domain_info d_info = {};
>> +
>> + d_info.fwnode = dev_fwnode(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 = irq_domain_instantiate(&d_info);
>> + if (IS_ERR(data->domain))
>> + return data->domain;
>
> This is open coded irq_domain_create_linear(). The only difference is that we
> propagate the underneath error code instead of decoding NULL as ENOMEM or
> EINVAL or something like that. If this is the case, add a comment explaining
> why, otherwise somebody will change that in the future w/o much thinking.
Yes! I'm going to use irq_domain_create_linear().
>
> Note, it was open coded since there is no devm_*() helper for that.
>
>> + for (unsigned int i = 0; i < RTD1625_MAX_IRQS; i++) {
>> + if (data->irqs[i])
>> + irq_set_chained_handler_and_data(data->irqs[i],
>> + rtd1625_gpio_irq_handle,
>> + data);
>> + }
>> +
>> + return data->domain;
>> +}
>
> ...
>
>> +static void rtd1625_gpio_remove_irq_domain(struct gpio_regmap *gpio_reg)
>> +{
>> + struct rtd1625_gpio *data = gpio_regmap_get_drvdata(gpio_reg);
>> +
>> + for (unsigned int i = 0; i < RTD1625_MAX_IRQS; i++) {
>
>> + if (data->irqs[i])
>
> Do you need this? It seems to me that irq_to_desc() returns NULL
> and scoped_irqdesc_get_and_buslock() does nothing. Yes, I know
> it's a tricky code.
Maybe, but I couldn't find any code already relying on that. So do
we really want to do that here?
Alternatively, we could add num_irqs to struct rtd1625_gpio and just
end the for loop at that boundary. But I'm not sure that's worth it.
I don't care too much. I'm fine either way, but I haven't looked too
closely if passing 0 as irq is fine.
-michael
>
>> + irq_set_chained_handler_and_data(data->irqs[i], NULL, NULL);
>> + }
>> +
>> + for (irq_hw_number_t hwirq = 0; hwirq < data->info->num_gpios; hwirq++)
>> + irq_dispose_mapping(irq_find_mapping(data->domain, hwirq));
>> +
>> + irq_domain_remove(data->domain);
>> +}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 297 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20261130/5c9ef75f/attachment.sig>
More information about the linux-arm-kernel
mailing list