blob: 2ac931645e5386bd0e2e5ce3deb073befecf32af [file] [log] [blame]
Mauro Carvalho Chehab609d99a2016-09-19 08:07:56 -03001.. _submittingdrivers:
2
Linus Torvalds1da177e2005-04-16 15:20:36 -07003Submitting Drivers For The Linux Kernel
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -03004=======================================
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
6This document is intended to explain how to submit device drivers to the
7various kernel trees. Note that if you are interested in video card drivers
8you should probably talk to XFree86 (http://www.xfree86.org/) and/or X.Org
9(http://x.org/) instead.
10
11Also read the Documentation/SubmittingPatches document.
12
13
14Allocating Device Numbers
15-------------------------
16
17Major and minor numbers for block and character devices are allocated
Randy Dunlap84da7c02005-06-28 20:45:30 -070018by the Linux assigned name and number authority (currently this is
19Torben Mathiasen). The site is http://www.lanana.org/. This
Linus Torvalds1da177e2005-04-16 15:20:36 -070020also deals with allocating numbers for devices that are not going to
21be submitted to the mainstream kernel.
Randy Dunlap84da7c02005-06-28 20:45:30 -070022See Documentation/devices.txt for more information on this.
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Randy Dunlap84da7c02005-06-28 20:45:30 -070024If you don't use assigned numbers then when your device is submitted it will
25be given an assigned number even if that is different from values you may
Linus Torvalds1da177e2005-04-16 15:20:36 -070026have shipped to customers before.
27
28Who To Submit Drivers To
29------------------------
30
31Linux 2.0:
Xose Vazquez Perez5b0ed2c2006-01-08 01:02:49 -080032 No new drivers are accepted for this kernel tree.
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
34Linux 2.2:
Xose Vazquez Perez5b0ed2c2006-01-08 01:02:49 -080035 No new drivers are accepted for this kernel tree.
36
37Linux 2.4:
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 If the code area has a general maintainer then please submit it to
39 the maintainer listed in MAINTAINERS in the kernel file. If the
40 maintainer does not respond or you cannot find the appropriate
Li Yang507a6a82007-10-20 02:02:12 +020041 maintainer then please contact Willy Tarreau <w@1wt.eu>.
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43Linux 2.6:
44 The same rules apply as 2.4 except that you should follow linux-kernel
45 to track changes in API's. The final contact point for Linux 2.6
Francois Camie1f8e872008-10-15 22:01:59 -070046 submissions is Andrew Morton.
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
48What Criteria Determine Acceptance
49----------------------------------
50
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030051Licensing:
52 The code must be released to us under the
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 GNU General Public License. We don't insist on any kind
Randy Dunlap84da7c02005-06-28 20:45:30 -070054 of exclusive GPL licensing, and if you wish the driver
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 to be useful to other communities such as BSD you may well
56 wish to release under multiple licenses.
Xose Vazquez Perez5b0ed2c2006-01-08 01:02:49 -080057 See accepted licenses at include/linux/module.h
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030059Copyright:
60 The copyright owner must agree to use of GPL.
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 It's best if the submitter and copyright owner
62 are the same person/entity. If not, the name of
63 the person/entity authorizing use of GPL should be
64 listed in case it's necessary to verify the will of
Alexey Dobriyan3706baa2006-09-29 02:01:43 -070065 the copyright owner.
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030067Interfaces:
68 If your driver uses existing interfaces and behaves like
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 other drivers in the same class it will be much more likely
Alexey Dobriyan3706baa2006-09-29 02:01:43 -070070 to be accepted than if it invents gratuitous new ones.
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 If you need to implement a common API over Linux and NT
72 drivers do it in userspace.
73
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030074Code:
75 Please use the Linux style of code formatting as documented
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 in Documentation/CodingStyle. If you have sections of code
77 that need to be in other formats, for example because they
78 are shared with a windows driver kit and you want to
79 maintain them just once separate them out nicely and note
80 this fact.
81
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030082Portability:
83 Pointers are not always 32bits, not all computers are little
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 endian, people do not all have floating point and you
85 shouldn't use inline x86 assembler in your driver without
86 careful thought. Pure x86 drivers generally are not popular.
87 If you only have x86 hardware it is hard to test portability
88 but it is easy to make sure the code can easily be made
89 portable.
90
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030091Clarity:
92 It helps if anyone can see how to fix the driver. It helps
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 you because you get patches not bug reports. If you submit a
94 driver that intentionally obfuscates how the hardware works
95 it will go in the bitbucket.
96
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030097PM support:
98 Since Linux is used on many portable and desktop systems, your
Rafael J. Wysocki5b795202007-05-08 00:24:07 -070099 driver is likely to be used on such a system and therefore it
100 should support basic power management by implementing, if
101 necessary, the .suspend and .resume methods used during the
102 system-wide suspend and resume transitions. You should verify
103 that your driver correctly handles the suspend and resume, but
104 if you are unable to ensure that, please at least define the
105 .suspend method returning the -ENOSYS ("Function not
106 implemented") error. You should also try to make sure that your
107 driver uses as little power as possible when it's not doing
108 anything. For the driver testing instructions see
109 Documentation/power/drivers-testing.txt and for a relatively
110 complete overview of the power management issues related to
111 drivers see Documentation/power/devices.txt .
112
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300113Control:
114 In general if there is active maintenance of a driver by
Alexey Dobriyan3706baa2006-09-29 02:01:43 -0700115 the author then patches will be redirected to them unless
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 they are totally obvious and without need of checking.
117 If you want to be the contact and update point for the
118 driver it is a good idea to state this in the comments,
119 and include an entry in MAINTAINERS for your driver.
120
121What Criteria Do Not Determine Acceptance
122-----------------------------------------
123
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300124Vendor:
125 Being the hardware vendor and maintaining the driver is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 often a good thing. If there is a stable working driver from
127 other people already in the tree don't expect 'we are the
Alexey Dobriyan3706baa2006-09-29 02:01:43 -0700128 vendor' to get your driver chosen. Ideally work with the
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 existing driver author to build a single perfect driver.
130
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300131Author:
132 It doesn't matter if a large Linux company wrote the driver,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 or you did. Nobody has any special access to the kernel
134 tree. Anyone who tells you otherwise isn't telling the
135 whole story.
136
137
138Resources
139---------
140
141Linux kernel master tree:
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300142 ftp.\ *country_code*\ .kernel.org:/pub/linux/kernel/...
143
144 where *country_code* == your country code, such as
145 **us**, **uk**, **fr**, etc.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Ralf Thielow399e1d92011-08-13 12:34:57 -0700147 http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git
Arce, Abraham6d06b812010-05-26 14:42:34 -0700148
Alexey Dobriyan3706baa2006-09-29 02:01:43 -0700149Linux kernel mailing list:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 linux-kernel@vger.kernel.org
151 [mail majordomo@vger.kernel.org to subscribe]
152
153Linux Device Drivers, Third Edition (covers 2.6.10):
154 http://lwn.net/Kernel/LDD3/ (free version)
155
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156LWN.net:
157 Weekly summary of kernel development activity - http://lwn.net/
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 2.6 API changes:
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300160
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 http://lwn.net/Articles/2.6-kernel-api/
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300162
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 Porting drivers from prior kernels to 2.6:
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300164
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 http://lwn.net/Articles/driver-porting/
166
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167KernelNewbies:
168 Documentation and assistance for new kernel programmers
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300169
170 http://kernelnewbies.org/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
172Linux USB project:
Xose Vazquez Pereze1b114e2006-01-14 12:57:41 +0100173 http://www.linux-usb.org/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
Alexey Dobriyan3706baa2006-09-29 02:01:43 -0700175How to NOT write kernel driver by Arjan van de Ven:
176 http://www.fenrus.org/how-to-not-write-a-device-driver-paper.pdf
Xose Vazquez Perez5b0ed2c2006-01-08 01:02:49 -0800177
178Kernel Janitor:
Justin P. Mattock0ea6e612010-07-23 20:51:24 -0700179 http://kernelnewbies.org/KernelJanitors
Arce, Abraham6d06b812010-05-26 14:42:34 -0700180
181GIT, Fast Version Control System:
182 http://git-scm.com/