Blame view
kernel/irq/devres.c
2.58 KB
5ea817699 [PATCH] sort the ... |
1 2 |
#include <linux/module.h> #include <linux/interrupt.h> |
0af3678f7 rip some includes... |
3 |
#include <linux/device.h> |
1aeb272cf kernel: explicitl... |
4 |
#include <linux/gfp.h> |
5ea817699 [PATCH] sort the ... |
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
/* * Device resource management aware IRQ request/free implementation. */ struct irq_devres { unsigned int irq; void *dev_id; }; static void devm_irq_release(struct device *dev, void *res) { struct irq_devres *this = res; free_irq(this->irq, this->dev_id); } static int devm_irq_match(struct device *dev, void *res, void *data) { struct irq_devres *this = res, *match = data; return this->irq == match->irq && this->dev_id == match->dev_id; } /** |
935bd5b97 genirq: add suppo... |
29 |
* devm_request_threaded_irq - allocate an interrupt line for a managed device |
5ea817699 [PATCH] sort the ... |
30 31 32 |
* @dev: device to request interrupt for * @irq: Interrupt line to allocate * @handler: Function to be called when the IRQ occurs |
935bd5b97 genirq: add suppo... |
33 34 |
* @thread_fn: function to be called in a threaded interrupt context. NULL * for devices which handle everything in @handler |
5ea817699 [PATCH] sort the ... |
35 36 37 38 39 40 41 42 43 44 |
* @irqflags: Interrupt type flags * @devname: An ascii name for the claiming device * @dev_id: A cookie passed back to the handler function * * Except for the extra @dev argument, this function takes the * same arguments and performs the same function as * request_irq(). IRQs requested with this function will be * automatically freed on driver detach. * * If an IRQ allocated with this function needs to be freed |
5c42dc707 devres/irq: Fix d... |
45 |
* separately, devm_free_irq() must be used. |
5ea817699 [PATCH] sort the ... |
46 |
*/ |
935bd5b97 genirq: add suppo... |
47 48 49 50 |
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) |
5ea817699 [PATCH] sort the ... |
51 52 53 54 55 56 57 58 |
{ struct irq_devres *dr; int rc; dr = devres_alloc(devm_irq_release, sizeof(struct irq_devres), GFP_KERNEL); if (!dr) return -ENOMEM; |
935bd5b97 genirq: add suppo... |
59 60 |
rc = request_threaded_irq(irq, handler, thread_fn, irqflags, devname, dev_id); |
5ea817699 [PATCH] sort the ... |
61 |
if (rc) { |
7f30e49ee [PATCH] irq-devre... |
62 |
devres_free(dr); |
5ea817699 [PATCH] sort the ... |
63 64 65 66 67 68 69 70 71 |
return rc; } dr->irq = irq; dr->dev_id = dev_id; devres_add(dev, dr); return 0; } |
935bd5b97 genirq: add suppo... |
72 |
EXPORT_SYMBOL(devm_request_threaded_irq); |
5ea817699 [PATCH] sort the ... |
73 74 75 76 77 78 79 80 81 82 |
/** * devm_free_irq - free an interrupt * @dev: device to free interrupt for * @irq: Interrupt line to free * @dev_id: Device identity to free * * Except for the extra @dev argument, this function takes the * same arguments and performs the same function as free_irq(). * This function instead of free_irq() should be used to manually |
9ce8e498e devres: typo fix ... |
83 |
* free IRQs allocated with devm_request_irq(). |
5ea817699 [PATCH] sort the ... |
84 85 86 87 |
*/ void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id) { struct irq_devres match_data = { irq, dev_id }; |
5ea817699 [PATCH] sort the ... |
88 89 |
WARN_ON(devres_destroy(dev, devm_irq_release, devm_irq_match, &match_data)); |
ae891a1b9 devres: fix possi... |
90 |
free_irq(irq, dev_id); |
5ea817699 [PATCH] sort the ... |
91 92 |
} EXPORT_SYMBOL(devm_free_irq); |