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