1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>parport_register_device</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux Device Drivers"><link rel="up" href="parportdev.html" title="Chapter&#160;3.&#160;Parallel Port Devices"><link rel="prev" href="API-parport-remove-port.html" title="parport_remove_port"><link rel="next" href="API-parport-unregister-device.html" title="parport_unregister_device"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">parport_register_device</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-parport-remove-port.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;3.&#160;Parallel Port Devices</th><td width="20%" align="right">&#160;<a accesskey="n" href="API-parport-unregister-device.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-parport-register-device"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>parport_register_device &#8212; 
2     register a device on a parallel port
3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">struct pardevice * <b class="fsfunc">parport_register_device </b>(</code></td><td>struct parport * <var class="pdparam">port</var>, </td></tr><tr><td>&#160;</td><td>const char * <var class="pdparam">name</var>, </td></tr><tr><td>&#160;</td><td>int (*<var class="pdparam">pf</var>)
4     <code>(</code>void *<code>)</code>, </td></tr><tr><td>&#160;</td><td>void (*<var class="pdparam">kf</var>)
5     <code>(</code>void *<code>)</code>, </td></tr><tr><td>&#160;</td><td>void (*<var class="pdparam">irq_func</var>)
6     <code>(</code>void *<code>)</code>, </td></tr><tr><td>&#160;</td><td>int <var class="pdparam">flags</var>, </td></tr><tr><td>&#160;</td><td>void * <var class="pdparam">handle</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a name="idp1111045812"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>port</code></em></span></dt><dd><p>
7     port to which the device is attached
8    </p></dd><dt><span class="term"><em class="parameter"><code>name</code></em></span></dt><dd><p>
9     a name to refer to the device
10    </p></dd><dt><span class="term"><em class="parameter"><code>pf</code></em></span></dt><dd><p>
11     preemption callback
12    </p></dd><dt><span class="term"><em class="parameter"><code>kf</code></em></span></dt><dd><p>
13     kick callback (wake-up)
14    </p></dd><dt><span class="term"><em class="parameter"><code>irq_func</code></em></span></dt><dd><p>
15     interrupt handler
16    </p></dd><dt><span class="term"><em class="parameter"><code>flags</code></em></span></dt><dd><p>
17     registration flags
18    </p></dd><dt><span class="term"><em class="parameter"><code>handle</code></em></span></dt><dd><p>
19     data for callback functions
20    </p></dd></dl></div></div><div class="refsect1"><a name="idp1111053572"></a><h2>Description</h2><p>
21   This function, called by parallel port device drivers,
22   declares that a device is connected to a port, and tells the
23   system all it needs to know.
24   </p><p>
25
26   The <em class="parameter"><code>name</code></em> is allocated by the caller and must not be
27   deallocated until the caller calls <em class="parameter"><code>parport_unregister_device</code></em>
28   for that device.
29   </p><p>
30
31   The preemption callback function, <em class="parameter"><code>pf</code></em>, is called when this
32   device driver has claimed access to the port but another
33   device driver wants to use it.  It is given <em class="parameter"><code>handle</code></em> as its
34   parameter, and should return zero if it is willing for the
35   system to release the port to another driver on its behalf.
36   If it wants to keep control of the port it should return
37   non-zero, and no action will be taken.  It is good manners for
38   the driver to try to release the port at the earliest
39   opportunity after its preemption callback rejects a preemption
40   attempt.  Note that if a preemption callback is happy for
41   preemption to go ahead, there is no need to release the port;
42   it is done automatically.  This function may not block, as it
43   may be called from interrupt context.  If the device driver
44   does not support preemption, <em class="parameter"><code>pf</code></em> can be <code class="constant">NULL</code>.
45   </p><p>
46
47   The wake-up (<span class="quote">&#8220;<span class="quote">kick</span>&#8221;</span>) callback function, <em class="parameter"><code>kf</code></em>, is called when
48   the port is available to be claimed for exclusive access; that
49   is, <code class="function">parport_claim</code> is guaranteed to succeed when called from
50   inside the wake-up callback function.  If the driver wants to
51   claim the port it should do so; otherwise, it need not take
52   any action.  This function may not block, as it may be called
53   from interrupt context.  If the device driver does not want to
54   be explicitly invited to claim the port in this way, <em class="parameter"><code>kf</code></em> can
55   be <code class="constant">NULL</code>.
56   </p><p>
57
58   The interrupt handler, <em class="parameter"><code>irq_func</code></em>, is called when an interrupt
59   arrives from the parallel port.  Note that if a device driver
60   wants to use interrupts it should use <code class="function">parport_enable_irq</code>,
61   and can also check the irq member of the parport structure
62   representing the port.
63   </p><p>
64
65   The parallel port (lowlevel) driver is the one that has called
66   <code class="function">request_irq</code> and whose interrupt handler is called first.
67   This handler does whatever needs to be done to the hardware to
68   acknowledge the interrupt (for PC-style ports there is nothing
69   special to be done).  It then tells the IEEE 1284 code about
70   the interrupt, which may involve reacting to an IEEE 1284
71   event depending on the current IEEE 1284 phase.  After this,
72   it calls <em class="parameter"><code>irq_func</code></em>.  Needless to say, <em class="parameter"><code>irq_func</code></em> will be called
73   from interrupt context, and may not block.
74   </p><p>
75
76   The <code class="constant">PARPORT_DEV_EXCL</code> flag is for preventing port sharing, and
77   so should only be used when sharing the port with other device
78   drivers is impossible and would lead to incorrect behaviour.
79   Use it sparingly!  Normally, <em class="parameter"><code>flags</code></em> will be zero.
80   </p><p>
81
82   This function returns a pointer to a structure that represents
83   the device on the port, or <code class="constant">NULL</code> if there is not enough memory
84   to allocate space for that structure.
85</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-parport-remove-port.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="parportdev.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="API-parport-unregister-device.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">parport_remove_port</span>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span class="phrase">parport_unregister_device</span></td></tr></table></div></body></html>
86