|
1 | 1 | // SPDX-License-Identifier: GPL-2.0
|
2 | 2 | #include <linux/module.h>
|
3 | 3 | #include <linux/interrupt.h>
|
| 4 | +#include <linux/irqdomain.h> |
4 | 5 | #include <linux/device.h>
|
5 | 6 | #include <linux/gfp.h>
|
6 | 7 | #include <linux/irq.h>
|
@@ -282,3 +283,43 @@ int devm_irq_setup_generic_chip(struct device *dev, struct irq_chip_generic *gc,
|
282 | 283 | }
|
283 | 284 | EXPORT_SYMBOL_GPL(devm_irq_setup_generic_chip);
|
284 | 285 | #endif /* CONFIG_GENERIC_IRQ_CHIP */
|
| 286 | + |
| 287 | +#ifdef CONFIG_IRQ_DOMAIN |
| 288 | +static void devm_irq_domain_remove(struct device *dev, void *res) |
| 289 | +{ |
| 290 | + struct irq_domain **domain = res; |
| 291 | + |
| 292 | + irq_domain_remove(*domain); |
| 293 | +} |
| 294 | + |
| 295 | +/** |
| 296 | + * devm_irq_domain_instantiate() - Instantiate a new irq domain data for a |
| 297 | + * managed device. |
| 298 | + * @dev: Device to instantiate the domain for |
| 299 | + * @info: Domain information pointer pointing to the information for this |
| 300 | + * domain |
| 301 | + * |
| 302 | + * Return: A pointer to the instantiated irq domain or an ERR_PTR value. |
| 303 | + */ |
| 304 | +struct irq_domain *devm_irq_domain_instantiate(struct device *dev, |
| 305 | + const struct irq_domain_info *info) |
| 306 | +{ |
| 307 | + struct irq_domain *domain; |
| 308 | + struct irq_domain **dr; |
| 309 | + |
| 310 | + dr = devres_alloc(devm_irq_domain_remove, sizeof(*dr), GFP_KERNEL); |
| 311 | + if (!dr) |
| 312 | + return ERR_PTR(-ENOMEM); |
| 313 | + |
| 314 | + domain = irq_domain_instantiate(info); |
| 315 | + if (!IS_ERR(domain)) { |
| 316 | + *dr = domain; |
| 317 | + devres_add(dev, dr); |
| 318 | + } else { |
| 319 | + devres_free(dr); |
| 320 | + } |
| 321 | + |
| 322 | + return domain; |
| 323 | +} |
| 324 | +EXPORT_SYMBOL_GPL(devm_irq_domain_instantiate); |
| 325 | +#endif /* CONFIG_IRQ_DOMAIN */ |
0 commit comments