<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//en">
<!–Converted with LaTeX2HTML 2022 (Released January 1, 2022) –>
<HTML lang="en">
<HEAD>
<TITLE>Contents of How to update your driver</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<META NAME="viewport" CONTENT="width=device-width, initial-scale=1.0">
<META NAME="Generator" CONTENT="LaTeX2HTML v2022">
<LINK REL="STYLESHEET" HREF="cdrom-st.css">
<LINK REL="previous" HREF="node29_mn.html">
<LINK REL="up" HREF="node23_mn.html">
<LINK REL="next" HREF="node35_mn.html">
</HEAD>
<BODY bgcolor="#ffffff" text="#000000" link="#9944EE" vlink="#0000ff" alink="#00ff00">
<H2><A ID="SECTION00047000000000000000">
How to update your driver</A>
</H2>
<P>
<OL>
<LI>Make a backup of your current driver.
</LI>
<LI>Get hold of the files <TT>cdrom.c</TT> and <TT>ucdrom.h</TT>, they should be in
the directory tree that came with this documentation.
</LI>
<LI>Include <TT><linux/ucdrom.h></TT> just after <TT>cdrom.h</TT>.
</LI>
<LI>change the 3rd argument of <!– MATH
registerblkdev
–>
<I>register</I><SUB>b</SUB><I>lkdev</I> from
<!– MATH
SPMamp; < your - drive > fops
–>
<I>&</I>; < <I>your</I> - <I>drive</I> > <SUB>f</SUB><I>ops</I> to <!– MATH
&cdromfops
–>
&<I>cdrom</I><SUB>f</SUB><I>ops</I>.
</LI>
<LI>Just after that line, add a line to register to the CD<SMALL>ROM</SMALL> routines:
<P><!– MATH
registercdrom(major, < name > , < your - drive > dops);
–>
</P>
<DIV ALIGN="CENTER">
<I>register</I><SUB>c</SUB><I>drom</I>(<I>major</I>, < <I>name</I> > , < <I>your</I> - <I>drive</I> > <SUB>d</SUB><I>ops</I>);
</DIV><P></P>
Similarly, add a call to <!– MATH
unregistercdrom()
–>
<I>unregister</I><SUB>c</SUB><I>drom</I>().
</LI>
<LI>Copy an example of the device-operations <I>struct</I> to your source,
e.g., from <TT>cm206.c</TT> <!– MATH
cm206dops
–>
<I>cm</I>206<SUB>d</SUB><I>ops</I>, and change all entries to names
corresponding to your driver, or names you just happen to like. If
your driver doesn't support a certain function, make the entry
<I>NULL</I>. At the entry <!– MATH
capability
–>
<I>capability</I> you should list all capabilities
your drive could support, in principle. If your drive has a capability
that is not listed, please send me a message.
</LI>
<LI>Implement all functions in your <!– MATH
< device > dops
–>
< <I>device</I> > <SUB>d</SUB><I>ops</I> structure,
according to prototypes listed in <TT>ucdrom.h</TT>, and specifications given in
section <A HREF="node2_ct.html#cdrom.c"><IMG ALT="[*]" SRC="crossref.png"></A>. Most likely you have already implemented
the code in a large part, and you may just have to adapt the prototype
and return values.
</LI>
<LI>Rename your <!– MATH
< device > ioctl ()
–>
< <I>device</I> > <SUB>i</SUB><I>octl</I> () function to <!– MATH
audioioctl
–>
<I>audio</I><SUB>i</SUB><I>octl</I> and
change the prototype a little. Remove entries listed in the first part
in section <A HREF="node29_ct.html#cdrom-ioctl"><IMG ALT="[*]" SRC="crossref.png"></A>, if your code was OK, these are just calls
to the routines you adapted in the previous step.
</LI>
<LI>You may remove all remaining memory checking code in the
<!– MATH
audioioctl ()
–>
<I>audio</I><SUB>i</SUB><I>octl</I> () function that deals with audio commands (these are
listed in the second part of section <A HREF="node29_ct.html#cdrom-ioctl"><IMG ALT="[*]" SRC="crossref.png"></A>). There is no
need for memory allocation either, so most <I>case</I>s in the <I>switch</I>
statement look similar to:
<P><!– MATH
case CDROMREADTOCENTRY :
gettocentry
(
struct cdromtocentry*)
arg
;
–>
</P>
<DIV ALIGN="CENTER">
<I>case</I> <I>CDROMREADTOCENTRY</I> : <I>get</I><SUB>t</SUB><I>oc</I><SUB>e</SUB><I>ntry</I><IMG
STYLE="" SRC="img9.png"
ALT="
">(<I>struct</I> <I>cdrom</I><SUB>t</SUB><I>ocentry</I>*) <I>arg</I><IMG
STYLE="" SRC="img10.png"
ALT="
">;
</DIV><P></P>
</LI>
<LI>All remaining <I>ioctl</I> cases must be moved to a separate
function, <!– MATH
< device > ioctl
–>
< <I>device</I> > <SUB>i</SUB><I>octl</I>, the device-dependent <I>ioctl</I>s. Note that
memory checking and allocation must be kept in this code!
</LI>
<LI>Change the prototypes of <!– MATH
< device > open()
–>
< <I>device</I> > <SUB>o</SUB><I>pen</I>() and
<!– MATH
< device > release()
–>
< <I>device</I> > <SUB>r</SUB><I>elease</I>(), and remove any strategic code (i.e., tray
movement, door locking, etc.).
</LI>
<LI>Try to recompile the drivers. We advice you to use modules, both
for <TT>cdrom.o</TT> and your driver, as debugging is much easier this
way.
</LI>
</OL>
<P>
<HR>
</BODY>
</HTML>