devm_request_threaded_irq()¶
Purpose¶
Registers an interrupt handler with optional threaded bottom-half handling and device-managed cleanup.
Header¶
Prototype¶
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);
Parameters¶
dev: device used for managed cleanup.irq: IRQ number.handler: top-half handler, orNULL.thread_fn: threaded handler.irqflags: trigger and sharing flags.devname: name shown in interrupt information.dev_id: cookie passed to handlers.
Return Value¶
- Success: returns
0. - Failure: returns a negative errno value.
Minimal Example¶
ret = devm_request_threaded_irq(dev, irq, NULL, my_irq_thread,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
"mydev", priv);
Common Pitfalls¶
- Use
IRQF_ONESHOTwhen using only a threaded handler. - Keep top-half handlers minimal.
- Do not perform slow bus I/O in hard IRQ context.