Mauro Carvalho Chehab | 609d99a | 2016-09-19 08:07:56 -0300 | [diff] [blame] | 1 | .. _submittingdrivers: |
| 2 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | Submitting Drivers For The Linux Kernel |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 4 | ======================================= |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | |
| 6 | This document is intended to explain how to submit device drivers to the |
| 7 | various kernel trees. Note that if you are interested in video card drivers |
Alexander A. Klimov | e7b4311 | 2020-06-21 15:36:30 +0200 | [diff] [blame] | 8 | you should probably talk to XFree86 (https://www.xfree86.org/) and/or X.Org |
| 9 | (https://x.org/) instead. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
Jonathan Corbet | 31b24be | 2016-10-26 16:45:29 -0600 | [diff] [blame] | 11 | .. 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 Vaga | f77af63 | 2018-11-21 01:35:19 +0100 | [diff] [blame] | 19 | Also read the :ref:`Documentation/process/submitting-patches.rst <submittingpatches>` |
| 20 | document. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
| 22 | |
| 23 | Allocating Device Numbers |
| 24 | ------------------------- |
| 25 | |
| 26 | Major and minor numbers for block and character devices are allocated |
Randy Dunlap | 84da7c0 | 2005-06-28 20:45:30 -0700 | [diff] [blame] | 27 | by the Linux assigned name and number authority (currently this is |
Alexander A. Klimov | e7b4311 | 2020-06-21 15:36:30 +0200 | [diff] [blame] | 28 | Torben Mathiasen). The site is https://www.lanana.org/. This |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | also deals with allocating numbers for devices that are not going to |
| 30 | be submitted to the mainstream kernel. |
Federico Vaga | f77af63 | 2018-11-21 01:35:19 +0100 | [diff] [blame] | 31 | See :ref:`Documentation/admin-guide/devices.rst <admin_devices>` |
| 32 | for more information on this. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
Randy Dunlap | 84da7c0 | 2005-06-28 20:45:30 -0700 | [diff] [blame] | 34 | If you don't use assigned numbers then when your device is submitted it will |
| 35 | be given an assigned number even if that is different from values you may |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | have shipped to customers before. |
| 37 | |
| 38 | Who To Submit Drivers To |
| 39 | ------------------------ |
| 40 | |
| 41 | Linux 2.0: |
Xose Vazquez Perez | 5b0ed2c | 2006-01-08 01:02:49 -0800 | [diff] [blame] | 42 | No new drivers are accepted for this kernel tree. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
| 44 | Linux 2.2: |
Xose Vazquez Perez | 5b0ed2c | 2006-01-08 01:02:49 -0800 | [diff] [blame] | 45 | No new drivers are accepted for this kernel tree. |
| 46 | |
| 47 | Linux 2.4: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | 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 Yang | 507a6a8 | 2007-10-20 02:02:12 +0200 | [diff] [blame] | 51 | maintainer then please contact Willy Tarreau <w@1wt.eu>. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Mauro Carvalho Chehab | dca22a6 | 2016-09-21 08:51:05 -0300 | [diff] [blame] | 53 | Linux 2.6 and upper: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | The same rules apply as 2.4 except that you should follow linux-kernel |
Mauro Carvalho Chehab | dca22a6 | 2016-09-21 08:51:05 -0300 | [diff] [blame] | 55 | to track changes in API's. The final contact point for Linux 2.6+ |
Francois Cami | e1f8e87 | 2008-10-15 22:01:59 -0700 | [diff] [blame] | 56 | submissions is Andrew Morton. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
| 58 | What Criteria Determine Acceptance |
| 59 | ---------------------------------- |
| 60 | |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 61 | Licensing: |
| 62 | The code must be released to us under the |
Dave Hansen | 755a2f1 | 2020-08-14 07:56:25 -0700 | [diff] [blame] | 63 | GNU General Public License. If you wish the driver to be |
| 64 | useful to other communities such as BSD you may release |
| 65 | under multiple licenses. If you choose to release under |
| 66 | licenses other than the GPL, you should include your |
| 67 | rationale for your license choices in your cover letter. |
Xose Vazquez Perez | 5b0ed2c | 2006-01-08 01:02:49 -0800 | [diff] [blame] | 68 | See accepted licenses at include/linux/module.h |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 70 | Copyright: |
| 71 | The copyright owner must agree to use of GPL. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | It's best if the submitter and copyright owner |
| 73 | are the same person/entity. If not, the name of |
| 74 | the person/entity authorizing use of GPL should be |
| 75 | listed in case it's necessary to verify the will of |
Alexey Dobriyan | 3706baa | 2006-09-29 02:01:43 -0700 | [diff] [blame] | 76 | the copyright owner. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 78 | Interfaces: |
| 79 | If your driver uses existing interfaces and behaves like |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | other drivers in the same class it will be much more likely |
Alexey Dobriyan | 3706baa | 2006-09-29 02:01:43 -0700 | [diff] [blame] | 81 | to be accepted than if it invents gratuitous new ones. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | If you need to implement a common API over Linux and NT |
| 83 | drivers do it in userspace. |
| 84 | |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 85 | Code: |
| 86 | Please use the Linux style of code formatting as documented |
Mauro Carvalho Chehab | 8c27ceff3 | 2016-10-18 10:12:27 -0200 | [diff] [blame] | 87 | in :ref:`Documentation/process/coding-style.rst <codingStyle>`. |
Mauro Carvalho Chehab | dca22a6 | 2016-09-21 08:51:05 -0300 | [diff] [blame] | 88 | If you have sections of code |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | that need to be in other formats, for example because they |
| 90 | are shared with a windows driver kit and you want to |
| 91 | maintain them just once separate them out nicely and note |
| 92 | this fact. |
| 93 | |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 94 | Portability: |
| 95 | Pointers are not always 32bits, not all computers are little |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | endian, people do not all have floating point and you |
| 97 | shouldn't use inline x86 assembler in your driver without |
| 98 | careful thought. Pure x86 drivers generally are not popular. |
| 99 | If you only have x86 hardware it is hard to test portability |
| 100 | but it is easy to make sure the code can easily be made |
| 101 | portable. |
| 102 | |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 103 | Clarity: |
| 104 | It helps if anyone can see how to fix the driver. It helps |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | you because you get patches not bug reports. If you submit a |
| 106 | driver that intentionally obfuscates how the hardware works |
| 107 | it will go in the bitbucket. |
| 108 | |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 109 | PM support: |
| 110 | Since Linux is used on many portable and desktop systems, your |
Rafael J. Wysocki | 5b79520 | 2007-05-08 00:24:07 -0700 | [diff] [blame] | 111 | driver is likely to be used on such a system and therefore it |
| 112 | should support basic power management by implementing, if |
| 113 | necessary, the .suspend and .resume methods used during the |
| 114 | system-wide suspend and resume transitions. You should verify |
| 115 | that your driver correctly handles the suspend and resume, but |
| 116 | if you are unable to ensure that, please at least define the |
| 117 | .suspend method returning the -ENOSYS ("Function not |
| 118 | implemented") error. You should also try to make sure that your |
| 119 | driver uses as little power as possible when it's not doing |
| 120 | anything. For the driver testing instructions see |
Mauro Carvalho Chehab | 151f4e2 | 2019-06-13 07:10:36 -0300 | [diff] [blame] | 121 | Documentation/power/drivers-testing.rst and for a relatively |
Rafael J. Wysocki | 5b79520 | 2007-05-08 00:24:07 -0700 | [diff] [blame] | 122 | complete overview of the power management issues related to |
Federico Vaga | f77af63 | 2018-11-21 01:35:19 +0100 | [diff] [blame] | 123 | drivers see :ref:`Documentation/driver-api/pm/devices.rst <driverapi_pm_devices>`. |
Rafael J. Wysocki | 5b79520 | 2007-05-08 00:24:07 -0700 | [diff] [blame] | 124 | |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 125 | Control: |
| 126 | In general if there is active maintenance of a driver by |
Alexey Dobriyan | 3706baa | 2006-09-29 02:01:43 -0700 | [diff] [blame] | 127 | the author then patches will be redirected to them unless |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | they are totally obvious and without need of checking. |
| 129 | If you want to be the contact and update point for the |
| 130 | driver it is a good idea to state this in the comments, |
| 131 | and include an entry in MAINTAINERS for your driver. |
| 132 | |
| 133 | What Criteria Do Not Determine Acceptance |
| 134 | ----------------------------------------- |
| 135 | |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 136 | Vendor: |
| 137 | Being the hardware vendor and maintaining the driver is |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | often a good thing. If there is a stable working driver from |
| 139 | other people already in the tree don't expect 'we are the |
Alexey Dobriyan | 3706baa | 2006-09-29 02:01:43 -0700 | [diff] [blame] | 140 | vendor' to get your driver chosen. Ideally work with the |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | existing driver author to build a single perfect driver. |
| 142 | |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 143 | Author: |
| 144 | It doesn't matter if a large Linux company wrote the driver, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | or you did. Nobody has any special access to the kernel |
| 146 | tree. Anyone who tells you otherwise isn't telling the |
| 147 | whole story. |
| 148 | |
| 149 | |
| 150 | Resources |
| 151 | --------- |
| 152 | |
| 153 | Linux kernel master tree: |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 154 | ftp.\ *country_code*\ .kernel.org:/pub/linux/kernel/... |
| 155 | |
| 156 | where *country_code* == your country code, such as |
| 157 | **us**, **uk**, **fr**, etc. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
Alexander A. Klimov | e7b4311 | 2020-06-21 15:36:30 +0200 | [diff] [blame] | 159 | https://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git |
Arce, Abraham | 6d06b81 | 2010-05-26 14:42:34 -0700 | [diff] [blame] | 160 | |
Alexey Dobriyan | 3706baa | 2006-09-29 02:01:43 -0700 | [diff] [blame] | 161 | Linux kernel mailing list: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | linux-kernel@vger.kernel.org |
| 163 | [mail majordomo@vger.kernel.org to subscribe] |
| 164 | |
| 165 | Linux Device Drivers, Third Edition (covers 2.6.10): |
Alexander A. Klimov | e7b4311 | 2020-06-21 15:36:30 +0200 | [diff] [blame] | 166 | https://lwn.net/Kernel/LDD3/ (free version) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | LWN.net: |
Alexander A. Klimov | e7b4311 | 2020-06-21 15:36:30 +0200 | [diff] [blame] | 169 | Weekly summary of kernel development activity - https://lwn.net/ |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 170 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | 2.6 API changes: |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 172 | |
Alexander A. Klimov | e7b4311 | 2020-06-21 15:36:30 +0200 | [diff] [blame] | 173 | https://lwn.net/Articles/2.6-kernel-api/ |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 174 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | Porting drivers from prior kernels to 2.6: |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 176 | |
Alexander A. Klimov | e7b4311 | 2020-06-21 15:36:30 +0200 | [diff] [blame] | 177 | https://lwn.net/Articles/driver-porting/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | KernelNewbies: |
| 180 | Documentation and assistance for new kernel programmers |
Mauro Carvalho Chehab | ceeb1a5 | 2016-09-19 08:07:52 -0300 | [diff] [blame] | 181 | |
Alexander A. Klimov | e7b4311 | 2020-06-21 15:36:30 +0200 | [diff] [blame] | 182 | https://kernelnewbies.org/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | |
| 184 | Linux USB project: |
Xose Vazquez Perez | e1b114e | 2006-01-14 12:57:41 +0100 | [diff] [blame] | 185 | http://www.linux-usb.org/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | |
Alexey Dobriyan | 3706baa | 2006-09-29 02:01:43 -0700 | [diff] [blame] | 187 | How to NOT write kernel driver by Arjan van de Ven: |
| 188 | http://www.fenrus.org/how-to-not-write-a-device-driver-paper.pdf |
Xose Vazquez Perez | 5b0ed2c | 2006-01-08 01:02:49 -0800 | [diff] [blame] | 189 | |
| 190 | Kernel Janitor: |
Alexander A. Klimov | e7b4311 | 2020-06-21 15:36:30 +0200 | [diff] [blame] | 191 | https://kernelnewbies.org/KernelJanitors |
Arce, Abraham | 6d06b81 | 2010-05-26 14:42:34 -0700 | [diff] [blame] | 192 | |
| 193 | GIT, Fast Version Control System: |
Alexander A. Klimov | e7b4311 | 2020-06-21 15:36:30 +0200 | [diff] [blame] | 194 | https://git-scm.com/ |