<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <HTML ><HEAD ><TITLE >Pardevices and parport_drivers</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="Structure" HREF="c65.html"><LINK REL="PREVIOUS" TITLE="IEEE 1284 transfer modes" HREF="x88.html"><LINK REL="NEXT" TITLE="The IEEE 1284.3 API" HREF="x123.html"></HEAD ><BODY CLASS="SECT1" 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="x88.html" ACCESSKEY="P" ><<< Previous</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Structure</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="x123.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="AEN96" ></A >Pardevices and parport_drivers</H1 ><P > When a parallel port device driver (such as <TT CLASS="LITERAL" >lp</TT >) initialises it tells the sharing layer about itself using <TT CLASS="FUNCTION" >parport_register_driver</TT >. The information is put into a <SPAN CLASS="STRUCTNAME" >struct parport_driver</SPAN >, which is put into a linked list. The information in a <SPAN CLASS="STRUCTNAME" >struct parport_driver</SPAN > really just amounts to some function pointers to callbacks in the parallel port device driver. </P ><P > During its initialisation, a low-level port driver tells the sharing layer about all the ports that it has found (using <TT CLASS="FUNCTION" >parport_register_port</TT >), and the sharing layer creates a <SPAN CLASS="STRUCTNAME" >struct parport</SPAN > for each of them. Each <SPAN CLASS="STRUCTNAME" >struct parport</SPAN > contains (among other things) a pointer to a <SPAN CLASS="STRUCTNAME" >struct parport_operations</SPAN >, which is a list of function pointers for the various operations that can be performed on a port. You can think of a <SPAN CLASS="STRUCTNAME" >struct parport</SPAN > as a parallel port <SPAN CLASS="QUOTE" >"object"</SPAN >, if <SPAN CLASS="QUOTE" >"object-orientated"</SPAN > programming is your thing. The <SPAN CLASS="STRUCTNAME" >parport</SPAN > structures are chained in a linked list, whose head is <TT CLASS="VARNAME" >portlist</TT > (in <TT CLASS="FILENAME" >drivers/parport/share.c</TT >). </P ><P > Once the port has been registered, the low-level port driver announces it. The <TT CLASS="FUNCTION" >parport_announce_port</TT > function walks down the list of parallel port device drivers (<SPAN CLASS="STRUCTNAME" >struct parport_driver</SPAN >s) calling the <TT CLASS="FUNCTION" >attach</TT > function of each (which may block). </P ><P > Similarly, a low-level port driver can undo the effect of registering a port with the <TT CLASS="FUNCTION" >parport_unregister_port</TT > function, and device drivers are notified using the <TT CLASS="FUNCTION" >detach</TT > callback (which may not block). </P ><P > Device drivers can undo the effect of registering themselves with the <TT CLASS="FUNCTION" >parport_unregister_driver</TT > function. </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="x88.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="x123.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >IEEE 1284 transfer modes</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="c65.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >The IEEE 1284.3 API</TD ></TR ></TABLE ></DIV ></BODY ></HTML >