root/lm-sensors/trunk/doc/developers/new_drivers

Revision 4170, 7.2 kB (checked in by ruik, 2 years ago)

Fix the links to status/supported pages.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 These are the steps you should follow to write a new driver and
2 submit it to us so that it will be applied cleanly to our package.
3 See at the bottom for adding new chip support to an existing driver.
4
5 Don't be intimidated by the list, it's just here so we don't
6 forget anything.
7 We are more than happy to help you with any part of the process.
8
9 There are two types of drivers, chip and bus.
10 Steps which apply to only one type of driver are noted.
11
12 These instructions are for 2.4-kernel-compatible drivers.
13 If you wish to write a driver for 2.6 only, not all of the following
14 steps apply.
15
16 ---------------------------------------------------------------------
17
18 * Check our "New Drivers" page for status!!
19
20 * Contact us.
21   You are of course free to write your own drivers, but it is smart to
22   check first nobody else is already working on it, in case the
23   New Drivers page is out of date.
24   Tell us it's OK to put your name on the "New Drivers" page.
25
26 * Consider subscribing to the mailing list.
27
28 * Check out our latest code from SVN.
29   You should use this as a base for your development.
30   See instructions on our download page.
31
32 * Write the new driver.
33   If you write a driver for a device that is similar to one we already
34   support, use the other device driver as a template. If you don't know
35   which one to use, either ask us or use the following defaults.
36   For a chip driver, use lm78.c as template. For an SMBus-only adapter,
37   use i2c-piix4.c. Use i2c-via.c for an I2C-level adapter ('bit banger').
38   Usually, we make all prefixes start with the driver name. This is not
39   really necessary, as these symbols will not be exported anyway. But by
40   doing this, you are sure you do not shadow any global kernel names.
41
42 * A quick note about conversions. The conversions which are specified
43   in the sensor chip datasheet and which *cannot* vary from one board to
44   the next are performed by the driver. If other conversions are
45   necessary, they are performed in user-space.
46
47 * Meet Kernel coding standards.
48   See Documentation/CodingStyle in the kernel source.
49   Be sure and use 8 column tabs.
50   Also, please do not use // comments.
51   Also, please do not go past column 80.
52   Also, please use C99 struct initializers {.foo = blat}
53   Please do this _before_ you check in your driver.
54
55 * Meet /proc naming standards in the ctl_table (for chip drivers only).
56   See doc/developers/proc for information. Please do not deviate from
57   this without discussion.
58
59 * Add the driver to the Module.mk (the makefile).
60   Usually, you can just add it to KERNEL{CHIPS,DRIVERS}TARGETS in the
61   Module.mk file in the directory itself. Put it at the beginning,
62   where the comment says to put drivers NOT included in mkpatch.
63
64 * Make sure it compiles cleanly.
65   Check compilation with 'make DEBUG=1' if you use debugging
66   information. Remember, things put between #ifdef DEBUG #endif may never
67   stop the driver from functioning; they should just output additional
68   information.
69
70 * Check for external symbols.
71   'nm --extern --defined' should only output symbols starting with __module,
72   cleanup_module, init_module and some kernel versioning symbols. Mark all
73   other symbols as static in your source file.
74
75 * Test the module.
76   Test with a recent 2.4 kernel.
77   For bus drivers, use i2cdetect and i2cdump. For i2cdump, test all supported
78   bus access modes (see i2cdump man page).
79   For chip drivers, cat all files in applicable /proc or /sys directory
80   and check for problems. Write all supported settings.
81   Check ALARM indications.
82
83 * Add detection information to prog/detect/sensors-detect.
84   This is a perl script that automatically detects what chips and adapters
85   are present. Contact us if you need help.
86
87 * Add chip information to lib/chips.{c,h} (for chip drivers only).
88   Until you have done this, the chip will be invisible for user-level
89   programs which use libsensors. Use standard names in lib/chips.c;
90   see also the comments in etc/sensors.conf.eg for help.
91   Contact us if you need more assistance.
92
93 * Be sure that SYSCTL and ALARM definitions in the driver are bracketed
94   by the special comments so that the kernel/include/sensors.h
95   file, which is generated automatically, contains your definitions.
96   (for chip drivers only)
97
98 * Add a procedure to prog/sensors/chips.[ch] (for chip drivers only).
99   This is a function specific for your driver that
100   makes the included 'sensors' program pretty-print your chip information.
101
102 * Add an line for the procedure in the matches[] table in
103   prog/sensors/main.c (for chip drivers only).
104   This tells sensors to call your new procedure when the chip name matches.
105
106 * Add entries to etc/sensors.conf.eg (for chip drivers only).
107   If needed, you can set defaults here.
108
109 * Test the userspace apps (sensors-detect and sensors).
110   Test setting limits with sensors -s.
111
112 * Add the name of the device to the README file.
113
114 * Add your name to the CONTRIBUTORS file.
115
116 * Add entries to the CHANGES file. Please keep in alphabetical order.
117
118 * Write a doc/chips/xxx or doc/busses/xxx file.
119
120 * Add entry to doc/chips/SUMMARY (for chip drivers only).
121
122 * Clearly specify licensing and copyright.
123   Make sure the GPL boilerplate and your name
124   (or if applicable your company's name) is at the top of the
125   new driver so we know you are giving it to us under the GPL.
126
127 * Submit the changes to us.
128   Do a 'svn update' to get in sync (things will have changed since
129   you started), then submit the changes to us as a patch against SVN.
130
131 * If you want to have your driver integrated to Linux 2.6, you have to
132   port your driver to the new sysfs interface. Once done and preferably
133   after testing, submit a patch to our mailing list: see
134   http://www.lm-sensors.org/wiki/AuthorsAndContributors
135   Make sure to check the current status for your driver first:
136   http://www.lm-sensors.org/wiki/Kernel2.6
137   http://www.lm-sensors.org/wiki/Devices
138
139 ---------------------------------------------------------------------
140 Checklist for us to do on the webpage:
141
142 * Add entry to 'supported drivers' page
143
144 * Update entry on 'new drivers' page
145
146 ---------------------------------------------------------------------
147 Checklist for mkpatch support, after the driver is tested and stable:
148
149 * Add .c file to mkpatch/FILES.
150
151 * Add makefile entry in mkpatch/mkpatch.pl (2 places - old and new formats).
152   (don't bother with old format, obsolete)
153
154 * Add config help to mkpatch/mkpatch.pl.
155
156 * Add config entry to mkpatch/Config.in (chip drivers only)
157
158 * Add config entry in mkpatch/mkpatch.pl (bus drivers only)
159
160 * Move .o reference in kernel/[chips,busses]/Module.mk
161   from first to second section.
162
163
164 ---------------------------------------------------------------------
165 Checklist for _adding_ support for a chip to an _existing_ driver:
166
167 * Make the changes to the driver itself.
168
169 * Add detection information to prog/detect/sensors-detect.
170
171 * Add a strncmp() call for the new prefix in prog/sensors/main.c
172   (chip drivers only).
173
174 * Add entries for the new prefix to etc/sensors.conf.eg (chip drivers only).
175
176 * Update config help in mkpatch/mkpatch.pl.
177
178 * Update config entry in mkpatch/Config.in (chip drivers only)
179
180 * Update config entry in mkpatch/mkpatch.pl (bus drivers only)
181
182 * Update doc/[chips,busses]/xxx file
183
184 * Update doc/chips/SUMMARY file (chip drivers only)
185
186 * Update list in README
187
188 * Submit the changes as a patch or check them in
189
190 * Update entry on 'new drivers' page
191
Note: See TracBrowser for help on using the browser.