blob: 58bc047e7b95e332fdebbc6e379b09e720f9c499 [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
Jonathan Corbet31b24be2016-10-26 16:45:29 -060011.. note::
12
13 This document is old and has seen little maintenance in recent years; it
14 should probably be updated or, perhaps better, just deleted. Most of
15 what is here can be found in the other development documents anyway.
16
17 Oh, and we don't really recommend submitting changes to XFree86 :)
18
Federico Vagaf77af632018-11-21 01:35:19 +010019Also read the :ref:`Documentation/process/submitting-patches.rst <submittingpatches>`
20document.
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
22
23Allocating Device Numbers
24-------------------------
25
26Major and minor numbers for block and character devices are allocated
Randy Dunlap84da7c02005-06-28 20:45:30 -070027by the Linux assigned name and number authority (currently this is
28Torben Mathiasen). The site is http://www.lanana.org/. This
Linus Torvalds1da177e2005-04-16 15:20:36 -070029also deals with allocating numbers for devices that are not going to
30be submitted to the mainstream kernel.
Federico Vagaf77af632018-11-21 01:35:19 +010031See :ref:`Documentation/admin-guide/devices.rst <admin_devices>`
32for more information on this.
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Randy Dunlap84da7c02005-06-28 20:45:30 -070034If you don't use assigned numbers then when your device is submitted it will
35be given an assigned number even if that is different from values you may
Linus Torvalds1da177e2005-04-16 15:20:36 -070036have shipped to customers before.
37
38Who To Submit Drivers To
39------------------------
40
41Linux 2.0:
Xose Vazquez Perez5b0ed2c2006-01-08 01:02:49 -080042 No new drivers are accepted for this kernel tree.
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
44Linux 2.2:
Xose Vazquez Perez5b0ed2c2006-01-08 01:02:49 -080045 No new drivers are accepted for this kernel tree.
46
47Linux 2.4:
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 If the code area has a general maintainer then please submit it to
49 the maintainer listed in MAINTAINERS in the kernel file. If the
50 maintainer does not respond or you cannot find the appropriate
Li Yang507a6a82007-10-20 02:02:12 +020051 maintainer then please contact Willy Tarreau <w@1wt.eu>.
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Mauro Carvalho Chehabdca22a62016-09-21 08:51:05 -030053Linux 2.6 and upper:
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 The same rules apply as 2.4 except that you should follow linux-kernel
Mauro Carvalho Chehabdca22a62016-09-21 08:51:05 -030055 to track changes in API's. The final contact point for Linux 2.6+
Francois Camie1f8e872008-10-15 22:01:59 -070056 submissions is Andrew Morton.
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58What Criteria Determine Acceptance
59----------------------------------
60
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030061Licensing:
62 The code must be released to us under the
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 GNU General Public License. We don't insist on any kind
Randy Dunlap84da7c02005-06-28 20:45:30 -070064 of exclusive GPL licensing, and if you wish the driver
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 to be useful to other communities such as BSD you may well
66 wish to release under multiple licenses.
Xose Vazquez Perez5b0ed2c2006-01-08 01:02:49 -080067 See accepted licenses at include/linux/module.h
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030069Copyright:
70 The copyright owner must agree to use of GPL.
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 It's best if the submitter and copyright owner
72 are the same person/entity. If not, the name of
73 the person/entity authorizing use of GPL should be
74 listed in case it's necessary to verify the will of
Alexey Dobriyan3706baa2006-09-29 02:01:43 -070075 the copyright owner.
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030077Interfaces:
78 If your driver uses existing interfaces and behaves like
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 other drivers in the same class it will be much more likely
Alexey Dobriyan3706baa2006-09-29 02:01:43 -070080 to be accepted than if it invents gratuitous new ones.
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 If you need to implement a common API over Linux and NT
82 drivers do it in userspace.
83
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030084Code:
85 Please use the Linux style of code formatting as documented
Mauro Carvalho Chehab8c27ceff32016-10-18 10:12:27 -020086 in :ref:`Documentation/process/coding-style.rst <codingStyle>`.
Mauro Carvalho Chehabdca22a62016-09-21 08:51:05 -030087 If you have sections of code
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 that need to be in other formats, for example because they
89 are shared with a windows driver kit and you want to
90 maintain them just once separate them out nicely and note
91 this fact.
92
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -030093Portability:
94 Pointers are not always 32bits, not all computers are little
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 endian, people do not all have floating point and you
96 shouldn't use inline x86 assembler in your driver without
97 careful thought. Pure x86 drivers generally are not popular.
98 If you only have x86 hardware it is hard to test portability
99 but it is easy to make sure the code can easily be made
100 portable.
101
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300102Clarity:
103 It helps if anyone can see how to fix the driver. It helps
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 you because you get patches not bug reports. If you submit a
105 driver that intentionally obfuscates how the hardware works
106 it will go in the bitbucket.
107
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300108PM support:
109 Since Linux is used on many portable and desktop systems, your
Rafael J. Wysocki5b795202007-05-08 00:24:07 -0700110 driver is likely to be used on such a system and therefore it
111 should support basic power management by implementing, if
112 necessary, the .suspend and .resume methods used during the
113 system-wide suspend and resume transitions. You should verify
114 that your driver correctly handles the suspend and resume, but
115 if you are unable to ensure that, please at least define the
116 .suspend method returning the -ENOSYS ("Function not
117 implemented") error. You should also try to make sure that your
118 driver uses as little power as possible when it's not doing
119 anything. For the driver testing instructions see
120 Documentation/power/drivers-testing.txt and for a relatively
121 complete overview of the power management issues related to
Federico Vagaf77af632018-11-21 01:35:19 +0100122 drivers see :ref:`Documentation/driver-api/pm/devices.rst <driverapi_pm_devices>`.
Rafael J. Wysocki5b795202007-05-08 00:24:07 -0700123
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300124Control:
125 In general if there is active maintenance of a driver by
Alexey Dobriyan3706baa2006-09-29 02:01:43 -0700126 the author then patches will be redirected to them unless
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 they are totally obvious and without need of checking.
128 If you want to be the contact and update point for the
129 driver it is a good idea to state this in the comments,
130 and include an entry in MAINTAINERS for your driver.
131
132What Criteria Do Not Determine Acceptance
133-----------------------------------------
134
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300135Vendor:
136 Being the hardware vendor and maintaining the driver is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 often a good thing. If there is a stable working driver from
138 other people already in the tree don't expect 'we are the
Alexey Dobriyan3706baa2006-09-29 02:01:43 -0700139 vendor' to get your driver chosen. Ideally work with the
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 existing driver author to build a single perfect driver.
141
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300142Author:
143 It doesn't matter if a large Linux company wrote the driver,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 or you did. Nobody has any special access to the kernel
145 tree. Anyone who tells you otherwise isn't telling the
146 whole story.
147
148
149Resources
150---------
151
152Linux kernel master tree:
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300153 ftp.\ *country_code*\ .kernel.org:/pub/linux/kernel/...
154
155 where *country_code* == your country code, such as
156 **us**, **uk**, **fr**, etc.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157
Ralf Thielow399e1d92011-08-13 12:34:57 -0700158 http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git
Arce, Abraham6d06b812010-05-26 14:42:34 -0700159
Alexey Dobriyan3706baa2006-09-29 02:01:43 -0700160Linux kernel mailing list:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 linux-kernel@vger.kernel.org
162 [mail majordomo@vger.kernel.org to subscribe]
163
164Linux Device Drivers, Third Edition (covers 2.6.10):
165 http://lwn.net/Kernel/LDD3/ (free version)
166
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167LWN.net:
168 Weekly summary of kernel development activity - http://lwn.net/
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300169
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 2.6 API changes:
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300171
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 http://lwn.net/Articles/2.6-kernel-api/
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300173
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 Porting drivers from prior kernels to 2.6:
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300175
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 http://lwn.net/Articles/driver-porting/
177
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178KernelNewbies:
179 Documentation and assistance for new kernel programmers
Mauro Carvalho Chehabceeb1a52016-09-19 08:07:52 -0300180
181 http://kernelnewbies.org/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
183Linux USB project:
Xose Vazquez Pereze1b114e2006-01-14 12:57:41 +0100184 http://www.linux-usb.org/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
Alexey Dobriyan3706baa2006-09-29 02:01:43 -0700186How to NOT write kernel driver by Arjan van de Ven:
187 http://www.fenrus.org/how-to-not-write-a-device-driver-paper.pdf
Xose Vazquez Perez5b0ed2c2006-01-08 01:02:49 -0800188
189Kernel Janitor:
Justin P. Mattock0ea6e612010-07-23 20:51:24 -0700190 http://kernelnewbies.org/KernelJanitors
Arce, Abraham6d06b812010-05-26 14:42:34 -0700191
192GIT, Fast Version Control System:
193 http://git-scm.com/