<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <HTML ><HEAD ><TITLE >parport_register_device</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="The Linux 2.4 Parallel Port Subsystem" HREF="book1.html"><LINK REL="UP" TITLE=" Linux parallel port driver API reference " HREF="a950.html"><LINK REL="PREVIOUS" TITLE="parport_find_base" HREF="r1300.html"><LINK REL="NEXT" TITLE="parport_unregister_device" HREF="r1428.html"></HEAD ><BODY CLASS="REFENTRY" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >The Linux 2.4 Parallel Port Subsystem</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="r1300.html" ACCESSKEY="P" ><<< Previous</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="r1428.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="AEN1331" ></A ><SPAN CLASS="phrase" ><SPAN CLASS="PHRASE" >parport_register_device</SPAN ></SPAN ></H1 ><DIV CLASS="REFNAMEDIV" ><A NAME="AEN1335" ></A ><H2 >Name</H2 >parport_register_device -- register a device on a parallel port </DIV ><DIV CLASS="REFSYNOPSISDIV" ><A NAME="AEN1338" ></A ><H2 >Synopsis</H2 ><DIV CLASS="FUNCSYNOPSIS" ><A NAME="AEN1340" ></A ><P ></P ><P ><CODE ><CODE CLASS="FUNCDEF" >struct pardevice * <TT CLASS="FUNCTION" >parport_register_device </TT ></CODE >(struct parport * <TT CLASS="PARAMETER" ><I >port</I ></TT >, const char * <TT CLASS="PARAMETER" ><I >name</I ></TT >, int (*<TT CLASS="PARAMETER" ><I >pf</I ></TT >) (void *), void (*<TT CLASS="PARAMETER" ><I >kf</I ></TT >) (void *), void (*<TT CLASS="PARAMETER" ><I >irq_func</I ></TT >) (int, void *, struct pt_regs *), int <TT CLASS="PARAMETER" ><I >flags</I ></TT >, void * <TT CLASS="PARAMETER" ><I >handle</I ></TT >);</CODE ></P ><P ></P ></DIV ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN1361" ></A ><H2 >Arguments</H2 ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="PARAMETER" ><I >port</I ></TT ></DT ><DD ><P > port to which the device is attached </P ></DD ><DT ><TT CLASS="PARAMETER" ><I >name</I ></TT ></DT ><DD ><P > a name to refer to the device </P ></DD ><DT ><TT CLASS="PARAMETER" ><I >pf</I ></TT ></DT ><DD ><P > preemption callback </P ></DD ><DT ><TT CLASS="PARAMETER" ><I >kf</I ></TT ></DT ><DD ><P > kick callback (wake-up) </P ></DD ><DT ><TT CLASS="PARAMETER" ><I >irq_func</I ></TT ></DT ><DD ><P > interrupt handler </P ></DD ><DT ><TT CLASS="PARAMETER" ><I >flags</I ></TT ></DT ><DD ><P > registration flags </P ></DD ><DT ><TT CLASS="PARAMETER" ><I >handle</I ></TT ></DT ><DD ><P > data for callback functions </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN1399" ></A ><H2 >Description</H2 ><P > This function, called by parallel port device drivers, declares that a device is connected to a port, and tells the system all it needs to know. </P ><P > The <TT CLASS="PARAMETER" ><I >name</I ></TT > is allocated by the caller and must not be deallocated until the caller calls <TT CLASS="PARAMETER" ><I >parport_unregister_device</I ></TT > for that device. </P ><P > The preemption callback function, <TT CLASS="PARAMETER" ><I >pf</I ></TT >, is called when this device driver has claimed access to the port but another device driver wants to use it. It is given <TT CLASS="PARAMETER" ><I >handle</I ></TT > as its parameter, and should return zero if it is willing for the system to release the port to another driver on its behalf. If it wants to keep control of the port it should return non-zero, and no action will be taken. It is good manners for the driver to try to release the port at the earliest opportunity after its preemption callback rejects a preemption attempt. Note that if a preemption callback is happy for preemption to go ahead, there is no need to release the port; it is done automatically. This function may not block, as it may be called from interrupt context. If the device driver does not support preemption, <TT CLASS="PARAMETER" ><I >pf</I ></TT > can be <TT CLASS="CONSTANT" >NULL</TT >. </P ><P > The wake-up (<SPAN CLASS="QUOTE" >"kick"</SPAN >) callback function, <TT CLASS="PARAMETER" ><I >kf</I ></TT >, is called when the port is available to be claimed for exclusive access; that is, <TT CLASS="FUNCTION" >parport_claim</TT > is guaranteed to succeed when called from inside the wake-up callback function. If the driver wants to claim the port it should do so; otherwise, it need not take any action. This function may not block, as it may be called from interrupt context. If the device driver does not want to be explicitly invited to claim the port in this way, <TT CLASS="PARAMETER" ><I >kf</I ></TT > can be <TT CLASS="CONSTANT" >NULL</TT >. </P ><P > The interrupt handler, <TT CLASS="PARAMETER" ><I >irq_func</I ></TT >, is called when an interrupt arrives from the parallel port. Note that if a device driver wants to use interrupts it should use <TT CLASS="FUNCTION" >parport_enable_irq</TT >, and can also check the irq member of the parport structure representing the port. </P ><P > The parallel port (lowlevel) driver is the one that has called <TT CLASS="FUNCTION" >request_irq</TT > and whose interrupt handler is called first. This handler does whatever needs to be done to the hardware to acknowledge the interrupt (for PC-style ports there is nothing special to be done). It then tells the IEEE 1284 code about the interrupt, which may involve reacting to an IEEE 1284 event depending on the current IEEE 1284 phase. After this, it calls <TT CLASS="PARAMETER" ><I >irq_func</I ></TT >. Needless to say, <TT CLASS="PARAMETER" ><I >irq_func</I ></TT > will be called from interrupt context, and may not block. </P ><P > The <TT CLASS="CONSTANT" >PARPORT_DEV_EXCL</TT > flag is for preventing port sharing, and so should only be used when sharing the port with other device drivers is impossible and would lead to incorrect behaviour. Use it sparingly! Normally, <TT CLASS="PARAMETER" ><I >flags</I ></TT > will be zero. </P ><P > This function returns a pointer to a structure that represents the device on the port, or <TT CLASS="CONSTANT" >NULL</TT > if there is not enough memory to allocate space for that structure. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="r1300.html" ACCESSKEY="P" ><<< Previous</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="book1.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="r1428.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><SPAN CLASS="phrase" ><SPAN CLASS="PHRASE" >parport_find_base</SPAN ></SPAN ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="a950.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><SPAN CLASS="phrase" ><SPAN CLASS="PHRASE" >parport_unregister_device</SPAN ></SPAN ></TD ></TR ></TABLE ></DIV ></BODY ></HTML >