kernel/irq/devres.c
Source file repositories/reference/linux-study-clean/kernel/irq/devres.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/irq/devres.c- Extension
.c- Size
- 10815 bytes
- Lines
- 372
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/interrupt.hlinux/irqdomain.hlinux/device.hlinux/gfp.hlinux/irq.hinternals.h
Detected Declarations
struct irq_devresstruct irq_desc_devresstruct irq_generic_chip_devresfunction devm_irq_releasefunction devm_irq_matchfunction devm_request_resultfunction __devm_request_threaded_irqfunction request_threaded_irqfunction __devm_request_any_context_irqfunction request_any_context_irqfunction free_irqfunction devm_irq_desc_releasefunction __devm_irq_alloc_descsfunction primaryfunction devm_irq_remove_generic_chipfunction devm_irq_setup_generic_chipfunction devm_irq_domain_removefunction devm_irq_domain_instantiateexport devm_request_threaded_irqexport devm_request_any_context_irqexport devm_free_irqexport __devm_irq_alloc_descsexport devm_irq_alloc_generic_chipexport devm_irq_setup_generic_chipexport devm_irq_domain_instantiate
Annotated Snippet
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;
}
static int devm_request_result(struct device *dev, int rc, unsigned int irq,
irq_handler_t handler, irq_handler_t thread_fn,
const char *devname)
{
if (rc >= 0)
return rc;
return dev_err_probe(dev, rc, "request_irq(%u) %ps %ps %s\n",
irq, handler, thread_fn, devname ? : "");
}
static 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;
dr = devres_alloc(devm_irq_release, sizeof(struct irq_devres),
GFP_KERNEL);
if (!dr)
return -ENOMEM;
if (!devname)
devname = dev_name(dev);
rc = request_threaded_irq(irq, handler, thread_fn, irqflags, devname,
dev_id);
if (rc) {
devres_free(dr);
return rc;
}
dr->irq = irq;
dr->dev_id = dev_id;
devres_add(dev, dr);
return 0;
}
/**
* devm_request_threaded_irq - allocate an interrupt line for a managed device with error logging
* @dev: Device to request interrupt for
* @irq: Interrupt line to allocate
* @handler: Function to be called when the interrupt 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_name(dev) if NULL
* @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_threaded_irq().
* Interrupts requested with this function will be automatically freed on
* driver detach.
*
* If an interrupt allocated with this function needs to be freed
* separately, devm_free_irq() must be used.
*
* When the request fails, an error message is printed with contextual
* information (device name, interrupt number, handler functions and
* error code). Don't add extra error messages at the call sites.
*
* Return: 0 on success or a negative error number.
*/
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)
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/irqdomain.h`, `linux/device.h`, `linux/gfp.h`, `linux/irq.h`, `internals.h`.
- Detected declarations: `struct irq_devres`, `struct irq_desc_devres`, `struct irq_generic_chip_devres`, `function devm_irq_release`, `function devm_irq_match`, `function devm_request_result`, `function __devm_request_threaded_irq`, `function request_threaded_irq`, `function __devm_request_any_context_irq`, `function request_any_context_irq`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.