devm_request..._context_irq(9)
π devm_request_any_context_irq β the managed-device interrupt grabber, but make it β¨loggedβ¨
okay so bestie, welcome to the Kernel API Manual section of your life π«Ά. This page is about devm_request_any_context_irq(9) β yes, the title is literally written as devm_request..._context_irq(9) because kernel devs love a dramatic ellipsis, and honestly? iconic. This one is like request_any_context_irq but managed, meaning the kernel cleans up your mess for you when the driver dips. π
πΈ NAME πΈ
devm_request_any_context_irq β allocate an interrupt line for a managed device with error logging. like, it grabs the IRQ, it does devres magic so you don't leak it, and it yells at you in the logs if something goes wrong. all three vibes in one function β¨
π SYNOPSIS π
int devm_request_any_context_irq (struct device *dev , unsigned int irq
, irq_handler_t handler , unsigned long irqflags , const char *devname ,
void *dev_id );
copy it exactly, don't get creative, this is C not a vibe-based language π
π ARGUMENTS π
devβ the device you're requesting this interrupt for. main character energy is the device. πirqβ the interrupt line you wanna allocate. this is the number you're claiming, no cap.handlerβ the function that gets called when the interrupt fires. your callback. the moment it all happens. π₯irqflagsβ interrupt type flags. the personality settings for how this IRQ behaves.devnameβ an ascii name for the claiming device. and hey, if you passNULL, it just usesdev_name(dev). convenient fr fr. β¨dev_idβ a cookie that gets passed back to your handler function. a little treat you send out into the world and get returned. π
π¦ DESCRIPTION π¦
so, except for that extra dev argument, this function takes the same arguments and performs the same function as request_any_context_irq. same energy, one extra parameter. π
the glow-up is this: interrupts requested with this function are automatically freed on driver detach. no manual cleanup arc, no leak drama, the devres machinery just handles it. we love a self-cleaning situation. π§
but listen β if an interrupt allocated with this function needs to be freed separately (like, while the driver is still alive), you must use devm_free_irq. that's not optional, that's just the rules, bestie. π
and when the request fails, an error message gets printed with contextual info β device name, interrupt number, handler functions and error code. it literally tells you what broke. so don't add extra error messages at the call sites, okay? it's already doing the most. adding your own is giving clutter. π
β RETURN β
IRQC_IS_HARDIRQ or IRQC_IS_NESTED on success β those are your good-ending outcomes, slay π β or a negative error number if it went sideways. check it, always. π
π SEE ALSO π
- Kernel file
./kernel/irq/devres.c devm_request_threaded_irq(9)devm_free_irq(9)__devm_irq_alloc_descs(9)devm_irq_alloc_generic_chip(9)devm_irq_setup_generic_chip(9)devm_irq_domain_instantiate(9)
go read them, that's your homework, iykyk πβ¨
okay that's the whole page, bye bestie π
this iconic little doc lives at ./kernel/irq, and it's dated October 2026 β so yes, it's from the future and it's still correct. periodt. π
πΈπ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms