<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>request_threaded_irq</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="The Linux Kernel API" /><link rel="up" href="ch09.html#id2664173" title="Interrupt Handling" /><link rel="prev" href="re306.html" title="free_irq" /><link rel="next" href="ch09s02.html" title="DMA Channels" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span>request_threaded_irq</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="re306.html">Prev</a> </td><th width="60%" align="center">Interrupt Handling</th><td width="20%" align="right"> <a accesskey="n" href="ch09s02.html">Next</a></td></tr></table><hr /></div><div class="refentry" title="request_threaded_irq"><a id="API-request-threaded-irq"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>request_threaded_irq — allocate an interrupt line </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">request_threaded_irq </b>(</code></td><td>unsigned int <var class="pdparam">irq</var>, </td></tr><tr><td> </td><td>irq_handler_t <var class="pdparam">handler</var>, </td></tr><tr><td> </td><td>irq_handler_t <var class="pdparam">thread_fn</var>, </td></tr><tr><td> </td><td>unsigned long <var class="pdparam">irqflags</var>, </td></tr><tr><td> </td><td>const char * <var class="pdparam">devname</var>, </td></tr><tr><td> </td><td>void * <var class="pdparam">dev_id</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1" title="Arguments"><a id="id2665378"></a><h2>Arguments</h2><div class="variablelist"><dl><dt><span class="term"><em class="parameter"><code>irq</code></em></span></dt><dd><p> Interrupt line to allocate </p></dd><dt><span class="term"><em class="parameter"><code>handler</code></em></span></dt><dd><p> Function to be called when the IRQ occurs. Primary handler for threaded interrupts If NULL and thread_fn != NULL the default primary handler is installed </p></dd><dt><span class="term"><em class="parameter"><code>thread_fn</code></em></span></dt><dd><p> Function called from the irq handler thread If NULL, no irq thread is created </p></dd><dt><span class="term"><em class="parameter"><code>irqflags</code></em></span></dt><dd><p> Interrupt type flags </p></dd><dt><span class="term"><em class="parameter"><code>devname</code></em></span></dt><dd><p> An ascii name for the claiming device </p></dd><dt><span class="term"><em class="parameter"><code>dev_id</code></em></span></dt><dd><p> A cookie passed back to the handler function </p></dd></dl></div></div><div class="refsect1" title="Description"><a id="id2665494"></a><h2>Description</h2><p> This call allocates interrupt resources and enables the interrupt line and IRQ handling. From the point this call is made your handler function may be invoked. Since your handler function must clear any interrupt the board raises, you must take care both to initialise your hardware and to set up the interrupt handler in the right order. </p><p> If you want to set up a threaded irq handler for your device then you need to supply <em class="parameter"><code>handler</code></em> and <em class="parameter"><code>thread_fn</code></em>. <em class="parameter"><code>handler</code></em> ist still called in hard interrupt context and has to check whether the interrupt originates from the device. If yes it needs to disable the interrupt on the device and return IRQ_WAKE_THREAD which will wake up the handler thread and run <em class="parameter"><code>thread_fn</code></em>. This split handler design is necessary to support shared interrupts. </p><p> Dev_id must be globally unique. Normally the address of the device data structure is used as the cookie. Since the handler receives this value it makes sense to use it. </p><p> If your interrupt is shared you must pass a non NULL dev_id as this is required when freeing the interrupt. </p></div><div class="refsect1" title="Flags"><a id="id2665553"></a><h2>Flags</h2><p> </p><p> IRQF_SHARED Interrupt is shared IRQF_DISABLED Disable local interrupts while processing IRQF_SAMPLE_RANDOM The interrupt can be used for entropy IRQF_TRIGGER_* Specify active edge(s) or level </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="re306.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch09.html#id2664173">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch09s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span>free_irq</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> DMA Channels</td></tr></table></div></body></html>