submitting-drivers.rst 6.65 KB
Newer Older
1 2
.. _submittingdrivers:

Linus Torvalds's avatar
Linus Torvalds committed
3
Submitting Drivers For The Linux Kernel
4
=======================================
Linus Torvalds's avatar
Linus Torvalds committed
5 6 7 8 9 10

This document is intended to explain how to submit device drivers to the
various kernel trees. Note that if you are interested in video card drivers
you should probably talk to XFree86 (http://www.xfree86.org/) and/or X.Org
(http://x.org/) instead.

11 12 13 14 15 16 17 18
.. note::

   This document is old and has seen little maintenance in recent years; it
   should probably be updated or, perhaps better, just deleted.  Most of
   what is here can be found in the other development documents anyway.

   Oh, and we don't really recommend submitting changes to XFree86 :)

19
Also read the Documentation/process/submitting-patches.rst document.
Linus Torvalds's avatar
Linus Torvalds committed
20 21 22 23 24 25


Allocating Device Numbers
-------------------------

Major and minor numbers for block and character devices are allocated
26 27
by the Linux assigned name and number authority (currently this is
Torben Mathiasen). The site is http://www.lanana.org/. This
Linus Torvalds's avatar
Linus Torvalds committed
28 29
also deals with allocating numbers for devices that are not going to
be submitted to the mainstream kernel.
30
See Documentation/admin-guide/devices.rst for more information on this.
Linus Torvalds's avatar
Linus Torvalds committed
31

32 33
If you don't use assigned numbers then when your device is submitted it will
be given an assigned number even if that is different from values you may
Linus Torvalds's avatar
Linus Torvalds committed
34 35 36 37 38 39
have shipped to customers before.

Who To Submit Drivers To
------------------------

Linux 2.0:
40
	No new drivers are accepted for this kernel tree.
Linus Torvalds's avatar
Linus Torvalds committed
41 42

Linux 2.2:
43 44 45
	No new drivers are accepted for this kernel tree.

Linux 2.4:
Linus Torvalds's avatar
Linus Torvalds committed
46 47 48
	If the code area has a general maintainer then please submit it to
	the maintainer listed in MAINTAINERS in the kernel file. If the
	maintainer does not respond or you cannot find the appropriate
Li Yang's avatar
Li Yang committed
49
	maintainer then please contact Willy Tarreau <w@1wt.eu>.
Linus Torvalds's avatar
Linus Torvalds committed
50

51
Linux 2.6 and upper:
Linus Torvalds's avatar
Linus Torvalds committed
52
	The same rules apply as 2.4 except that you should follow linux-kernel
53
	to track changes in API's. The final contact point for Linux 2.6+
54
	submissions is Andrew Morton.
Linus Torvalds's avatar
Linus Torvalds committed
55 56 57 58

What Criteria Determine Acceptance
----------------------------------

59 60
Licensing:
		The code must be released to us under the
Linus Torvalds's avatar
Linus Torvalds committed
61
		GNU General Public License. We don't insist on any kind
62
		of exclusive GPL licensing, and if you wish the driver
Linus Torvalds's avatar
Linus Torvalds committed
63 64
		to be useful to other communities such as BSD you may well
		wish to release under multiple licenses.
65
		See accepted licenses at include/linux/module.h
Linus Torvalds's avatar
Linus Torvalds committed
66

67 68
Copyright:
		The copyright owner must agree to use of GPL.
Linus Torvalds's avatar
Linus Torvalds committed
69 70 71 72
		It's best if the submitter and copyright owner
		are the same person/entity. If not, the name of
		the person/entity authorizing use of GPL should be
		listed in case it's necessary to verify the will of
73
		the copyright owner.
Linus Torvalds's avatar
Linus Torvalds committed
74

75 76
Interfaces:
		If your driver uses existing interfaces and behaves like
Linus Torvalds's avatar
Linus Torvalds committed
77
		other drivers in the same class it will be much more likely
78
		to be accepted than if it invents gratuitous new ones.
Linus Torvalds's avatar
Linus Torvalds committed
79 80 81
		If you need to implement a common API over Linux and NT
		drivers do it in userspace.

82 83
Code:
		Please use the Linux style of code formatting as documented
84
		in :ref:`Documentation/process/coding-style.rst <codingStyle>`.
85
		If you have sections of code
Linus Torvalds's avatar
Linus Torvalds committed
86 87 88 89 90
		that need to be in other formats, for example because they
		are shared with a windows driver kit and you want to
		maintain them just once separate them out nicely and note
		this fact.

91 92
Portability:
		Pointers are not always 32bits, not all computers are little
Linus Torvalds's avatar
Linus Torvalds committed
93 94 95 96 97 98 99
		endian, people do not all have floating point and you
		shouldn't use inline x86 assembler in your driver without
		careful thought. Pure x86 drivers generally are not popular.
		If you only have x86 hardware it is hard to test portability
		but it is easy to make sure the code can easily be made
		portable.

100 101
Clarity:
		It helps if anyone can see how to fix the driver. It helps
Linus Torvalds's avatar
Linus Torvalds committed
102 103 104 105
		you because you get patches not bug reports. If you submit a
		driver that intentionally obfuscates how the hardware works
		it will go in the bitbucket.

106 107
PM support:
		Since Linux is used on many portable and desktop systems, your
108 109 110 111 112 113 114 115 116 117 118 119
		driver is likely to be used on such a system and therefore it
		should support basic power management by implementing, if
		necessary, the .suspend and .resume methods used during the
		system-wide suspend and resume transitions.  You should verify
		that your driver correctly handles the suspend and resume, but
		if you are unable to ensure that, please at least define the
		.suspend method returning the -ENOSYS ("Function not
		implemented") error.  You should also try to make sure that your
		driver uses as little power as possible when it's not doing
		anything.  For the driver testing instructions see
		Documentation/power/drivers-testing.txt and for a relatively
		complete overview of the power management issues related to
120
		drivers see Documentation/power/admin-guide/devices.rst .
121

122 123
Control:
		In general if there is active maintenance of a driver by
124
		the author then patches will be redirected to them unless
Linus Torvalds's avatar
Linus Torvalds committed
125 126 127 128 129 130 131 132
		they are totally obvious and without need of checking.
		If you want to be the contact and update point for the
		driver it is a good idea to state this in the comments,
		and include an entry in MAINTAINERS for your driver.

What Criteria Do Not Determine Acceptance
-----------------------------------------

133 134
Vendor:
		Being the hardware vendor and maintaining the driver is
Linus Torvalds's avatar
Linus Torvalds committed
135 136
		often a good thing. If there is a stable working driver from
		other people already in the tree don't expect 'we are the
137
		vendor' to get your driver chosen. Ideally work with the
Linus Torvalds's avatar
Linus Torvalds committed
138 139
		existing driver author to build a single perfect driver.

140 141
Author:
		It doesn't matter if a large Linux company wrote the driver,
Linus Torvalds's avatar
Linus Torvalds committed
142 143 144 145 146 147 148 149 150
		or you did. Nobody has any special access to the kernel
		tree. Anyone who tells you otherwise isn't telling the
		whole story.


Resources
---------

Linux kernel master tree:
151 152 153 154
	ftp.\ *country_code*\ .kernel.org:/pub/linux/kernel/...

	where *country_code* == your country code, such as
	**us**, **uk**, **fr**, etc.
Linus Torvalds's avatar
Linus Torvalds committed
155

156
	http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git
157

158
Linux kernel mailing list:
Linus Torvalds's avatar
Linus Torvalds committed
159 160 161 162 163 164 165 166
	linux-kernel@vger.kernel.org
	[mail majordomo@vger.kernel.org to subscribe]

Linux Device Drivers, Third Edition (covers 2.6.10):
	http://lwn.net/Kernel/LDD3/  (free version)

LWN.net:
	Weekly summary of kernel development activity - http://lwn.net/
167

Linus Torvalds's avatar
Linus Torvalds committed
168
	2.6 API changes:
169

Linus Torvalds's avatar
Linus Torvalds committed
170
		http://lwn.net/Articles/2.6-kernel-api/
171

Linus Torvalds's avatar
Linus Torvalds committed
172
	Porting drivers from prior kernels to 2.6:
173

Linus Torvalds's avatar
Linus Torvalds committed
174 175 176 177
		http://lwn.net/Articles/driver-porting/

KernelNewbies:
	Documentation and assistance for new kernel programmers
178 179

		http://kernelnewbies.org/
Linus Torvalds's avatar
Linus Torvalds committed
180 181

Linux USB project:
182
	http://www.linux-usb.org/
183

184 185
How to NOT write kernel driver by Arjan van de Ven:
	http://www.fenrus.org/how-to-not-write-a-device-driver-paper.pdf
186 187

Kernel Janitor:
188
	http://kernelnewbies.org/KernelJanitors
189 190 191

GIT, Fast Version Control System:
	http://git-scm.com/