xref: /OK3568_Linux_fs/kernel/Documentation/process/submitting-drivers.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. _submittingdrivers:
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunSubmitting Drivers For The Linux Kernel
4*4882a593Smuzhiyun=======================================
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunThis document is intended to explain how to submit device drivers to the
7*4882a593Smuzhiyunvarious kernel trees. Note that if you are interested in video card drivers
8*4882a593Smuzhiyunyou should probably talk to XFree86 (https://www.xfree86.org/) and/or X.Org
9*4882a593Smuzhiyun(https://x.org/) instead.
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun.. note::
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun   This document is old and has seen little maintenance in recent years; it
14*4882a593Smuzhiyun   should probably be updated or, perhaps better, just deleted.  Most of
15*4882a593Smuzhiyun   what is here can be found in the other development documents anyway.
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun   Oh, and we don't really recommend submitting changes to XFree86 :)
18*4882a593Smuzhiyun
19*4882a593SmuzhiyunAlso read the :ref:`Documentation/process/submitting-patches.rst <submittingpatches>`
20*4882a593Smuzhiyundocument.
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun
23*4882a593SmuzhiyunAllocating Device Numbers
24*4882a593Smuzhiyun-------------------------
25*4882a593Smuzhiyun
26*4882a593SmuzhiyunMajor and minor numbers for block and character devices are allocated
27*4882a593Smuzhiyunby the Linux assigned name and number authority (currently this is
28*4882a593SmuzhiyunTorben Mathiasen). The site is https://www.lanana.org/. This
29*4882a593Smuzhiyunalso deals with allocating numbers for devices that are not going to
30*4882a593Smuzhiyunbe submitted to the mainstream kernel.
31*4882a593SmuzhiyunSee :ref:`Documentation/admin-guide/devices.rst <admin_devices>`
32*4882a593Smuzhiyunfor more information on this.
33*4882a593Smuzhiyun
34*4882a593SmuzhiyunIf you don't use assigned numbers then when your device is submitted it will
35*4882a593Smuzhiyunbe given an assigned number even if that is different from values you may
36*4882a593Smuzhiyunhave shipped to customers before.
37*4882a593Smuzhiyun
38*4882a593SmuzhiyunWho To Submit Drivers To
39*4882a593Smuzhiyun------------------------
40*4882a593Smuzhiyun
41*4882a593SmuzhiyunLinux 2.0:
42*4882a593Smuzhiyun	No new drivers are accepted for this kernel tree.
43*4882a593Smuzhiyun
44*4882a593SmuzhiyunLinux 2.2:
45*4882a593Smuzhiyun	No new drivers are accepted for this kernel tree.
46*4882a593Smuzhiyun
47*4882a593SmuzhiyunLinux 2.4:
48*4882a593Smuzhiyun	If the code area has a general maintainer then please submit it to
49*4882a593Smuzhiyun	the maintainer listed in MAINTAINERS in the kernel file. If the
50*4882a593Smuzhiyun	maintainer does not respond or you cannot find the appropriate
51*4882a593Smuzhiyun	maintainer then please contact Willy Tarreau <w@1wt.eu>.
52*4882a593Smuzhiyun
53*4882a593SmuzhiyunLinux 2.6 and upper:
54*4882a593Smuzhiyun	The same rules apply as 2.4 except that you should follow linux-kernel
55*4882a593Smuzhiyun	to track changes in API's. The final contact point for Linux 2.6+
56*4882a593Smuzhiyun	submissions is Andrew Morton.
57*4882a593Smuzhiyun
58*4882a593SmuzhiyunWhat Criteria Determine Acceptance
59*4882a593Smuzhiyun----------------------------------
60*4882a593Smuzhiyun
61*4882a593SmuzhiyunLicensing:
62*4882a593Smuzhiyun		The code must be released to us under the
63*4882a593Smuzhiyun		GNU General Public License. If you wish the driver to be
64*4882a593Smuzhiyun		useful to other communities such as BSD you may release
65*4882a593Smuzhiyun		under multiple licenses. If you choose to release under
66*4882a593Smuzhiyun		licenses other than the GPL, you should include your
67*4882a593Smuzhiyun		rationale for your license choices in your cover letter.
68*4882a593Smuzhiyun		See accepted licenses at include/linux/module.h
69*4882a593Smuzhiyun
70*4882a593SmuzhiyunCopyright:
71*4882a593Smuzhiyun		The copyright owner must agree to use of GPL.
72*4882a593Smuzhiyun		It's best if the submitter and copyright owner
73*4882a593Smuzhiyun		are the same person/entity. If not, the name of
74*4882a593Smuzhiyun		the person/entity authorizing use of GPL should be
75*4882a593Smuzhiyun		listed in case it's necessary to verify the will of
76*4882a593Smuzhiyun		the copyright owner.
77*4882a593Smuzhiyun
78*4882a593SmuzhiyunInterfaces:
79*4882a593Smuzhiyun		If your driver uses existing interfaces and behaves like
80*4882a593Smuzhiyun		other drivers in the same class it will be much more likely
81*4882a593Smuzhiyun		to be accepted than if it invents gratuitous new ones.
82*4882a593Smuzhiyun		If you need to implement a common API over Linux and NT
83*4882a593Smuzhiyun		drivers do it in userspace.
84*4882a593Smuzhiyun
85*4882a593SmuzhiyunCode:
86*4882a593Smuzhiyun		Please use the Linux style of code formatting as documented
87*4882a593Smuzhiyun		in :ref:`Documentation/process/coding-style.rst <codingStyle>`.
88*4882a593Smuzhiyun		If you have sections of code
89*4882a593Smuzhiyun		that need to be in other formats, for example because they
90*4882a593Smuzhiyun		are shared with a windows driver kit and you want to
91*4882a593Smuzhiyun		maintain them just once separate them out nicely and note
92*4882a593Smuzhiyun		this fact.
93*4882a593Smuzhiyun
94*4882a593SmuzhiyunPortability:
95*4882a593Smuzhiyun		Pointers are not always 32bits, not all computers are little
96*4882a593Smuzhiyun		endian, people do not all have floating point and you
97*4882a593Smuzhiyun		shouldn't use inline x86 assembler in your driver without
98*4882a593Smuzhiyun		careful thought. Pure x86 drivers generally are not popular.
99*4882a593Smuzhiyun		If you only have x86 hardware it is hard to test portability
100*4882a593Smuzhiyun		but it is easy to make sure the code can easily be made
101*4882a593Smuzhiyun		portable.
102*4882a593Smuzhiyun
103*4882a593SmuzhiyunClarity:
104*4882a593Smuzhiyun		It helps if anyone can see how to fix the driver. It helps
105*4882a593Smuzhiyun		you because you get patches not bug reports. If you submit a
106*4882a593Smuzhiyun		driver that intentionally obfuscates how the hardware works
107*4882a593Smuzhiyun		it will go in the bitbucket.
108*4882a593Smuzhiyun
109*4882a593SmuzhiyunPM support:
110*4882a593Smuzhiyun		Since Linux is used on many portable and desktop systems, your
111*4882a593Smuzhiyun		driver is likely to be used on such a system and therefore it
112*4882a593Smuzhiyun		should support basic power management by implementing, if
113*4882a593Smuzhiyun		necessary, the .suspend and .resume methods used during the
114*4882a593Smuzhiyun		system-wide suspend and resume transitions.  You should verify
115*4882a593Smuzhiyun		that your driver correctly handles the suspend and resume, but
116*4882a593Smuzhiyun		if you are unable to ensure that, please at least define the
117*4882a593Smuzhiyun		.suspend method returning the -ENOSYS ("Function not
118*4882a593Smuzhiyun		implemented") error.  You should also try to make sure that your
119*4882a593Smuzhiyun		driver uses as little power as possible when it's not doing
120*4882a593Smuzhiyun		anything.  For the driver testing instructions see
121*4882a593Smuzhiyun		Documentation/power/drivers-testing.rst and for a relatively
122*4882a593Smuzhiyun		complete overview of the power management issues related to
123*4882a593Smuzhiyun		drivers see :ref:`Documentation/driver-api/pm/devices.rst <driverapi_pm_devices>`.
124*4882a593Smuzhiyun
125*4882a593SmuzhiyunControl:
126*4882a593Smuzhiyun		In general if there is active maintenance of a driver by
127*4882a593Smuzhiyun		the author then patches will be redirected to them unless
128*4882a593Smuzhiyun		they are totally obvious and without need of checking.
129*4882a593Smuzhiyun		If you want to be the contact and update point for the
130*4882a593Smuzhiyun		driver it is a good idea to state this in the comments,
131*4882a593Smuzhiyun		and include an entry in MAINTAINERS for your driver.
132*4882a593Smuzhiyun
133*4882a593SmuzhiyunWhat Criteria Do Not Determine Acceptance
134*4882a593Smuzhiyun-----------------------------------------
135*4882a593Smuzhiyun
136*4882a593SmuzhiyunVendor:
137*4882a593Smuzhiyun		Being the hardware vendor and maintaining the driver is
138*4882a593Smuzhiyun		often a good thing. If there is a stable working driver from
139*4882a593Smuzhiyun		other people already in the tree don't expect 'we are the
140*4882a593Smuzhiyun		vendor' to get your driver chosen. Ideally work with the
141*4882a593Smuzhiyun		existing driver author to build a single perfect driver.
142*4882a593Smuzhiyun
143*4882a593SmuzhiyunAuthor:
144*4882a593Smuzhiyun		It doesn't matter if a large Linux company wrote the driver,
145*4882a593Smuzhiyun		or you did. Nobody has any special access to the kernel
146*4882a593Smuzhiyun		tree. Anyone who tells you otherwise isn't telling the
147*4882a593Smuzhiyun		whole story.
148*4882a593Smuzhiyun
149*4882a593Smuzhiyun
150*4882a593SmuzhiyunResources
151*4882a593Smuzhiyun---------
152*4882a593Smuzhiyun
153*4882a593SmuzhiyunLinux kernel master tree:
154*4882a593Smuzhiyun	ftp.\ *country_code*\ .kernel.org:/pub/linux/kernel/...
155*4882a593Smuzhiyun
156*4882a593Smuzhiyun	where *country_code* == your country code, such as
157*4882a593Smuzhiyun	**us**, **uk**, **fr**, etc.
158*4882a593Smuzhiyun
159*4882a593Smuzhiyun	https://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git
160*4882a593Smuzhiyun
161*4882a593SmuzhiyunLinux kernel mailing list:
162*4882a593Smuzhiyun	linux-kernel@vger.kernel.org
163*4882a593Smuzhiyun	[mail majordomo@vger.kernel.org to subscribe]
164*4882a593Smuzhiyun
165*4882a593SmuzhiyunLinux Device Drivers, Third Edition (covers 2.6.10):
166*4882a593Smuzhiyun	https://lwn.net/Kernel/LDD3/  (free version)
167*4882a593Smuzhiyun
168*4882a593SmuzhiyunLWN.net:
169*4882a593Smuzhiyun	Weekly summary of kernel development activity - https://lwn.net/
170*4882a593Smuzhiyun
171*4882a593Smuzhiyun	2.6 API changes:
172*4882a593Smuzhiyun
173*4882a593Smuzhiyun		https://lwn.net/Articles/2.6-kernel-api/
174*4882a593Smuzhiyun
175*4882a593Smuzhiyun	Porting drivers from prior kernels to 2.6:
176*4882a593Smuzhiyun
177*4882a593Smuzhiyun		https://lwn.net/Articles/driver-porting/
178*4882a593Smuzhiyun
179*4882a593SmuzhiyunKernelNewbies:
180*4882a593Smuzhiyun	Documentation and assistance for new kernel programmers
181*4882a593Smuzhiyun
182*4882a593Smuzhiyun		https://kernelnewbies.org/
183*4882a593Smuzhiyun
184*4882a593SmuzhiyunLinux USB project:
185*4882a593Smuzhiyun	http://www.linux-usb.org/
186*4882a593Smuzhiyun
187*4882a593SmuzhiyunHow to NOT write kernel driver by Arjan van de Ven:
188*4882a593Smuzhiyun	http://www.fenrus.org/how-to-not-write-a-device-driver-paper.pdf
189*4882a593Smuzhiyun
190*4882a593SmuzhiyunKernel Janitor:
191*4882a593Smuzhiyun	https://kernelnewbies.org/KernelJanitors
192*4882a593Smuzhiyun
193*4882a593SmuzhiyunGIT, Fast Version Control System:
194*4882a593Smuzhiyun	https://git-scm.com/
195