File: drivercaveats.html

package info (click to toggle)
comedilib 0.11.0%2B5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, trixie
  • size: 8,540 kB
  • sloc: xml: 19,779; ansic: 14,719; sh: 5,672; cpp: 2,211; ruby: 1,658; perl: 700; makefile: 594; yacc: 439; lex: 86; python: 17
file content (44 lines) | stat: -rw-r--r-- 4,044 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>6.5.  Device driver caveats</title><link rel="stylesheet" type="text/css" href="comedilib.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="index.html" title="Comedi"><link rel="up" href="driverwriting.html" title="6.  Writing a Comedi driver"><link rel="prev" href="drivercallbacks.html" title="6.4.  Callbacks, events and interrupts"><link rel="next" href="integratingdriver.html" title="6.6.  Integrating the driver in the Comedi library"></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">6.5. 
Device driver caveats
</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="drivercallbacks.html">Prev</a> </td><th width="60%" align="center">6. 
Writing a <acronym class="acronym">Comedi</acronym> driver
</th><td width="20%" align="right"> <a accesskey="n" href="integratingdriver.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="drivercaveats"></a>6.5. 
Device driver caveats
</h3></div></div></div><p>
A few things to strive for when writing a new driver:
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
Some DAQ cards consist of different <span class="quote">“<span class="quote">layers</span>”</span> of hardware,
which can each be given their own device driver. Examples are:
some of the National Instruments cards, that all share the same
<span class="emphasis"><em>Mite</em></span> PCI driver chip; the ubiquitous parallel
port, that can be used for simple digital IO acquisitions. If your
new card has such a multi-layer design too, please take the effort to
provide drivers for each layer separately.
</p></li><li class="listitem"><p>
Your hardware driver should be functional appropriate to the resources
allocated.  I.e., if the driver is fully functional when configured
with an IRQ and DMA, it should still function moderately well with
just an IRQ, or still do minor tasks without IRQ or DMA.  Does your
driver really require an IRQ to do digital I/O?  Maybe someone will
want to use your driver <span class="emphasis"><em>just</em></span> to do digital I/O
and has no interrupts available.
</p></li><li class="listitem"><p>
Drivers are to have absolutely <span class="strong"><strong>no</strong></span>
global variables (apart from read-only, constant data, or data structures
shared by all devices), mainly because the existence of global variables
immediately negates any possibility of using the driver for two
devices. The pointer <em class="structfield"><code>dev-&gt;private</code></em> should be used
to point to a structure containing any additional variables needed by
a driver/device combination.
</p></li><li class="listitem"><p>
Drivers should report errors and warnings via the
<code class="function">comedi_error</code> function.
(This is <span class="emphasis"><em>not</em></span> the same function as the user-space
<code class="function"><a class="link" href="func-ref-comedi-perror.html" title="comedi_perror">comedi_perror</a></code> function.)

</p></li></ul></div><p>
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="drivercallbacks.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="driverwriting.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="integratingdriver.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">6.4. 
Callbacks, events and interrupts
 </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 6.6. 
Integrating the driver in the <acronym class="acronym">Comedi</acronym> library
</td></tr></table></div></body></html>