Skip to content

Commit

Permalink
genirq: add support for threaded interrupts to devres
Browse files Browse the repository at this point in the history
Some devices use devres_request_irq() for to install their interrupt
handler. Add support for threaded interrupts to devres as well.

[tglx - simplified and adapted to latest threadirq version]

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Arjan van de Ven authored and Thomas Gleixner committed Mar 24, 2009
1 parent 3aa551c commit 935bd5b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
17 changes: 14 additions & 3 deletions include/linux/interrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,20 @@ extern void free_irq(unsigned int, void *);

struct device;

extern int __must_check devm_request_irq(struct device *dev, unsigned int irq,
irq_handler_t handler, unsigned long irqflags,
const char *devname, void *dev_id);
extern int __must_check
devm_request_threaded_irq(struct device *dev, unsigned int irq,
irq_handler_t handler, irq_handler_t thread_fn,
unsigned long irqflags, const char *devname,
void *dev_id);

static inline int __must_check
devm_request_irq(struct device *dev, unsigned int irq, irq_handler_t handler,
unsigned long irqflags, const char *devname, void *dev_id)
{
return devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
devname, dev_id);
}

extern void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id);

/*
Expand Down
16 changes: 10 additions & 6 deletions kernel/irq/devres.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ static int devm_irq_match(struct device *dev, void *res, void *data)
}

/**
* devm_request_irq - allocate an interrupt line for a managed device
* devm_request_threaded_irq - allocate an interrupt line for a managed device
* @dev: device to request interrupt for
* @irq: Interrupt line to allocate
* @handler: Function to be called when the IRQ occurs
* @thread_fn: function to be called in a threaded interrupt context. NULL
* for devices which handle everything in @handler
* @irqflags: Interrupt type flags
* @devname: An ascii name for the claiming device
* @dev_id: A cookie passed back to the handler function
Expand All @@ -42,9 +44,10 @@ static int devm_irq_match(struct device *dev, void *res, void *data)
* If an IRQ allocated with this function needs to be freed
* separately, dev_free_irq() must be used.
*/
int devm_request_irq(struct device *dev, unsigned int irq,
irq_handler_t handler, unsigned long irqflags,
const char *devname, void *dev_id)
int devm_request_threaded_irq(struct device *dev, unsigned int irq,
irq_handler_t handler, irq_handler_t thread_fn,
unsigned long irqflags, const char *devname,
void *dev_id)
{
struct irq_devres *dr;
int rc;
Expand All @@ -54,7 +57,8 @@ int devm_request_irq(struct device *dev, unsigned int irq,
if (!dr)
return -ENOMEM;

rc = request_irq(irq, handler, irqflags, devname, dev_id);
rc = request_threaded_irq(irq, handler, thread_fn, irqflags, devname,
dev_id);
if (rc) {
devres_free(dr);
return rc;
Expand All @@ -66,7 +70,7 @@ int devm_request_irq(struct device *dev, unsigned int irq,

return 0;
}
EXPORT_SYMBOL(devm_request_irq);
EXPORT_SYMBOL(devm_request_threaded_irq);

/**
* devm_free_irq - free an interrupt
Expand Down

0 comments on commit 935bd5b

Please sign in to comment.