devm_request_threaded_irq(9)
π devm_request_threaded_irq(9) β from the Kernel API Manual π
okay bestie, buckle up, because this is the page you'll be pulling up every single time you wire an interrupt into a driver. this is devm_request_threaded_irq(9) (yes, the (9) means kernel API manual section, iykyk β¨) and it's the managed-device glow-up of the classic interrupt request β it allocates an interrupt line for a managed device and logs errors for you. main character energy fr fr π«Ά
β¨ SYNOPSIS β¨
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 );
that's the whole vibe. seven arguments, one int back, no cap π
πΈ ARGUMENTS πΈ
devβ the device you're requesting the interrupt for. this is the extra one that makes it managed π§irqβ the interrupt line you wanna allocate.handlerβ the function that gets called when the interrupt occurs. your first responder πthread_fnβ the function called in a threaded interrupt context. passNULLfor devices that handle absolutely everything insidehandler(some devices just don't need the thread, and that's valid π).irqflagsβ the interrupt type flags.devnameβ an ascii name for the claiming device. if you passNULL, it falls back todev_name(dev)πdev_idβ a cookie that gets passed back to the handler function. yes, literally a cookie π
π DESCRIPTION π
so here's the tea: except for that extra dev argument, this function takes the same arguments and performs the same function as request_threaded_irq. (love a consistent API, honestly.) πΈ
the big deal, the reason you're here:
Interrupts requested with this function will be automatically freed on driver detach.
no manual cleanup, no forgetting, no 3am bug hunt. it's giving responsible adult energy π
but β and hear me out β if an interrupt allocated with this function ever needs to be freed separately, you must use devm_free_irq. don't get creative, bestie π
and the part everyone skips: when the request fails, an error message is already printed with all the contextual info β device name, interrupt number, handler functions, and the error code. so don't add extra error messages at the call sites. it's already handled. it ate. let it cook π
β RETURN β
0 on success, or a negative error number. that's it, that's the whole personality.
π¦ SEE ALSO π¦
kernel file ./kernel/irq/devres.c β that's where the magic lives, go read it π
devm_request_any_context_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)
and that's the page!! π«Ά sign-off time: this cutie lives in ./kernel/irq, dated October 2026, and its whole name in the manual is devm_request_threaded_irq(9) β remember it, cite it, love it πβ¨π
π¦ 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