blob: a2f30a9e28d1c84d19ecf6b4470bde934cfaebbb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001Submitting Drivers For The Linux Kernel
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -03002=======================================
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
4This document is intended to explain how to submit device drivers to the
5various kernel trees. Note that if you are interested in video card drivers
6you should probably talk to XFree86 (http://www.xfree86.org/) and/or X.Org
7(http://x.org/) instead.
8
9Also read the Documentation/SubmittingPatches document.
10
11
12Allocating Device Numbers
13-------------------------
14
15Major and minor numbers for block and character devices are allocated
Randy Dunlap84da7c02005-06-28 20:45:30 -070016by the Linux assigned name and number authority (currently this is
17Torben Mathiasen). The site is http://www.lanana.org/. This
Linus Torvalds1da177e2005-04-16 15:20:36 -070018also deals with allocating numbers for devices that are not going to
19be submitted to the mainstream kernel.
Randy Dunlap84da7c02005-06-28 20:45:30 -070020See Documentation/devices.txt for more information on this.
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Randy Dunlap84da7c02005-06-28 20:45:30 -070022If you don't use assigned numbers then when your device is submitted it will
23be given an assigned number even if that is different from values you may
Linus Torvalds1da177e2005-04-16 15:20:36 -070024have shipped to customers before.
25
26Who To Submit Drivers To
27------------------------
28
29Linux 2.0:
Xose Vazquez Perez5b0ed2c2006-01-08 01:02:49 -080030 No new drivers are accepted for this kernel tree.
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
32Linux 2.2:
Xose Vazquez Perez5b0ed2c2006-01-08 01:02:49 -080033 No new drivers are accepted for this kernel tree.
34
35Linux 2.4:
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 If the code area has a general maintainer then please submit it to
37 the maintainer listed in MAINTAINERS in the kernel file. If the
38 maintainer does not respond or you cannot find the appropriate
Li Yang507a6a82007-10-20 02:02:12 +020039 maintainer then please contact Willy Tarreau <w@1wt.eu>.
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41Linux 2.6:
42 The same rules apply as 2.4 except that you should follow linux-kernel
43 to track changes in API's. The final contact point for Linux 2.6
Francois Camie1f8e872008-10-15 22:01:59 -070044 submissions is Andrew Morton.
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
46What Criteria Determine Acceptance
47----------------------------------
48
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030049Licensing:
50 The code must be released to us under the
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 GNU General Public License. We don't insist on any kind
Randy Dunlap84da7c02005-06-28 20:45:30 -070052 of exclusive GPL licensing, and if you wish the driver
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 to be useful to other communities such as BSD you may well
54 wish to release under multiple licenses.
Xose Vazquez Perez5b0ed2c2006-01-08 01:02:49 -080055 See accepted licenses at include/linux/module.h
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030057Copyright:
58 The copyright owner must agree to use of GPL.
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 It's best if the submitter and copyright owner
60 are the same person/entity. If not, the name of
61 the person/entity authorizing use of GPL should be
62 listed in case it's necessary to verify the will of
Alexey Dobriyan3706baa2006-09-29 02:01:43 -070063 the copyright owner.
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030065Interfaces:
66 If your driver uses existing interfaces and behaves like
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 other drivers in the same class it will be much more likely
Alexey Dobriyan3706baa2006-09-29 02:01:43 -070068 to be accepted than if it invents gratuitous new ones.
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 If you need to implement a common API over Linux and NT
70 drivers do it in userspace.
71
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030072Code:
73 Please use the Linux style of code formatting as documented
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 in Documentation/CodingStyle. If you have sections of code
75 that need to be in other formats, for example because they
76 are shared with a windows driver kit and you want to
77 maintain them just once separate them out nicely and note
78 this fact.
79
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030080Portability:
81 Pointers are not always 32bits, not all computers are little
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 endian, people do not all have floating point and you
83 shouldn't use inline x86 assembler in your driver without
84 careful thought. Pure x86 drivers generally are not popular.
85 If you only have x86 hardware it is hard to test portability
86 but it is easy to make sure the code can easily be made
87 portable.
88
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030089Clarity:
90 It helps if anyone can see how to fix the driver. It helps
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 you because you get patches not bug reports. If you submit a
92 driver that intentionally obfuscates how the hardware works
93 it will go in the bitbucket.
94
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030095PM support:
96 Since Linux is used on many portable and desktop systems, your
Rafael J. Wysocki5b795202007-05-08 00:24:07 -070097 driver is likely to be used on such a system and therefore it
98 should support basic power management by implementing, if
99 necessary, the .suspend and .resume methods used during the
100 system-wide suspend and resume transitions. You should verify
101 that your driver correctly handles the suspend and resume, but
102 if you are unable to ensure that, please at least define the
103 .suspend method returning the -ENOSYS ("Function not
104 implemented") error. You should also try to make sure that your
105 driver uses as little power as possible when it's not doing
106 anything. For the driver testing instructions see
107 Documentation/power/drivers-testing.txt and for a relatively
108 complete overview of the power management issues related to
109 drivers see Documentation/power/devices.txt .
110
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300111Control:
112 In general if there is active maintenance of a driver by
Alexey Dobriyan3706baa2006-09-29 02:01:43 -0700113 the author then patches will be redirected to them unless
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 they are totally obvious and without need of checking.
115 If you want to be the contact and update point for the
116 driver it is a good idea to state this in the comments,
117 and include an entry in MAINTAINERS for your driver.
118
119What Criteria Do Not Determine Acceptance
120-----------------------------------------
121
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300122Vendor:
123 Being the hardware vendor and maintaining the driver is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 often a good thing. If there is a stable working driver from
125 other people already in the tree don't expect 'we are the
Alexey Dobriyan3706baa2006-09-29 02:01:43 -0700126 vendor' to get your driver chosen. Ideally work with the
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 existing driver author to build a single perfect driver.
128
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300129Author:
130 It doesn't matter if a large Linux company wrote the driver,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 or you did. Nobody has any special access to the kernel
132 tree. Anyone who tells you otherwise isn't telling the
133 whole story.
134
135
136Resources
137---------
138
139Linux kernel master tree:
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300140 ftp.\ *country_code*\ .kernel.org:/pub/linux/kernel/...
141
142 where *country_code* == your country code, such as
143 **us**, **uk**, **fr**, etc.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
Ralf Thielow399e1d92011-08-13 12:34:57 -0700145 http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git
Arce, Abraham6d06b812010-05-26 14:42:34 -0700146
Alexey Dobriyan3706baa2006-09-29 02:01:43 -0700147Linux kernel mailing list:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 linux-kernel@vger.kernel.org
149 [mail majordomo@vger.kernel.org to subscribe]
150
151Linux Device Drivers, Third Edition (covers 2.6.10):
152 http://lwn.net/Kernel/LDD3/ (free version)
153
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154LWN.net:
155 Weekly summary of kernel development activity - http://lwn.net/
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300156
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 2.6 API changes:
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 http://lwn.net/Articles/2.6-kernel-api/
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300160
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 Porting drivers from prior kernels to 2.6:
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300162
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 http://lwn.net/Articles/driver-porting/
164
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165KernelNewbies:
166 Documentation and assistance for new kernel programmers
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300167
168 http://kernelnewbies.org/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
170Linux USB project:
Xose Vazquez Pereze1b114e2006-01-14 12:57:41 +0100171 http://www.linux-usb.org/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
Alexey Dobriyan3706baa2006-09-29 02:01:43 -0700173How to NOT write kernel driver by Arjan van de Ven:
174 http://www.fenrus.org/how-to-not-write-a-device-driver-paper.pdf
Xose Vazquez Perez5b0ed2c2006-01-08 01:02:49 -0800175
176Kernel Janitor:
Justin P. Mattock0ea6e612010-07-23 20:51:24 -0700177 http://kernelnewbies.org/KernelJanitors
Arce, Abraham6d06b812010-05-26 14:42:34 -0700178
179GIT, Fast Version Control System:
180 http://git-scm.com/