Skip to content

Commit 1c3e363

Browse files
brglKAGA-KOKO
authored andcommitted
irq/generic-chip: Provide devm_irq_alloc_generic_chip()
Provide a resource managed variant of irq_alloc_generic_chip(). Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Marc Zyngier <marc.zyngier@arm.com> Cc: linux-doc@vger.kernel.org Cc: Jonathan Corbet <corbet@lwn.net> Link: http://lkml.kernel.org/r/1496246820-13250-5-git-send-email-brgl@bgdev.pl
1 parent f160203 commit 1c3e363

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

‎Documentation/driver-model/devres.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ IRQ
311311
devm_irq_alloc_desc_at()
312312
devm_irq_alloc_desc_from()
313313
devm_irq_alloc_descs_from()
314+
devm_irq_alloc_generic_chip()
314315

315316
LED
316317
devm_led_classdev_register()

‎include/linux/irq.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,11 @@ int irq_setup_alt_chip(struct irq_data *d, unsigned int type);
958958
void irq_remove_generic_chip(struct irq_chip_generic *gc, u32 msk,
959959
unsigned int clr, unsigned int set);
960960

961+
struct irq_chip_generic *
962+
devm_irq_alloc_generic_chip(struct device *dev, const char *name, int num_ct,
963+
unsigned int irq_base, void __iomem *reg_base,
964+
irq_flow_handler_t handler);
965+
961966
struct irq_chip_generic *irq_get_domain_generic_chip(struct irq_domain *d, unsigned int hw_irq);
962967

963968
int __irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,

‎kernel/irq/devres.c‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <linux/gfp.h>
55
#include <linux/irq.h>
66

7+
#include "internals.h"
8+
79
/*
810
* Device resource management aware IRQ request/free implementation.
911
*/
@@ -198,3 +200,35 @@ int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from,
198200
return base;
199201
}
200202
EXPORT_SYMBOL_GPL(__devm_irq_alloc_descs);
203+
204+
#ifdef CONFIG_GENERIC_IRQ_CHIP
205+
/**
206+
* devm_irq_alloc_generic_chip - Allocate and initialize a generic chip
207+
* for a managed device
208+
* @dev: Device to allocate the generic chip for
209+
* @name: Name of the irq chip
210+
* @num_ct: Number of irq_chip_type instances associated with this
211+
* @irq_base: Interrupt base nr for this chip
212+
* @reg_base: Register base address (virtual)
213+
* @handler: Default flow handler associated with this chip
214+
*
215+
* Returns an initialized irq_chip_generic structure. The chip defaults
216+
* to the primary (index 0) irq_chip_type and @handler
217+
*/
218+
struct irq_chip_generic *
219+
devm_irq_alloc_generic_chip(struct device *dev, const char *name, int num_ct,
220+
unsigned int irq_base, void __iomem *reg_base,
221+
irq_flow_handler_t handler)
222+
{
223+
struct irq_chip_generic *gc;
224+
unsigned long sz = sizeof(*gc) + num_ct * sizeof(struct irq_chip_type);
225+
226+
gc = devm_kzalloc(dev, sz, GFP_KERNEL);
227+
if (gc)
228+
irq_init_generic_chip(gc, name, num_ct,
229+
irq_base, reg_base, handler);
230+
231+
return gc;
232+
}
233+
EXPORT_SYMBOL_GPL(devm_irq_alloc_generic_chip);
234+
#endif /* CONFIG_GENERIC_IRQ_CHIP */

0 commit comments

Comments
 (0)