submitting-drivers.rst 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. .. _submittingdrivers:
  2. Submitting Drivers For The Linux Kernel
  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. .. note::
  9. This document is old and has seen little maintenance in recent years; it
  10. should probably be updated or, perhaps better, just deleted. Most of
  11. what is here can be found in the other development documents anyway.
  12. Oh, and we don't really recommend submitting changes to XFree86 :)
  13. Also read the Documentation/process/submitting-patches.rst document.
  14. Allocating Device Numbers
  15. -------------------------
  16. Major and minor numbers for block and character devices are allocated
  17. by the Linux assigned name and number authority (currently this is
  18. Torben Mathiasen). The site is http://www.lanana.org/. This
  19. also deals with allocating numbers for devices that are not going to
  20. be submitted to the mainstream kernel.
  21. See Documentation/admin-guide/devices.rst for more information on this.
  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
  24. have shipped to customers before.
  25. Who To Submit Drivers To
  26. ------------------------
  27. Linux 2.0:
  28. No new drivers are accepted for this kernel tree.
  29. Linux 2.2:
  30. No new drivers are accepted for this kernel tree.
  31. Linux 2.4:
  32. If the code area has a general maintainer then please submit it to
  33. the maintainer listed in MAINTAINERS in the kernel file. If the
  34. maintainer does not respond or you cannot find the appropriate
  35. maintainer then please contact Willy Tarreau <w@1wt.eu>.
  36. Linux 2.6 and upper:
  37. The same rules apply as 2.4 except that you should follow linux-kernel
  38. to track changes in API's. The final contact point for Linux 2.6+
  39. submissions is Andrew Morton.
  40. What Criteria Determine Acceptance
  41. ----------------------------------
  42. Licensing:
  43. The code must be released to us under the
  44. GNU General Public License. We don't insist on any kind
  45. of exclusive GPL licensing, and if you wish the driver
  46. to be useful to other communities such as BSD you may well
  47. wish to release under multiple licenses.
  48. See accepted licenses at include/linux/module.h
  49. Copyright:
  50. The copyright owner must agree to use of GPL.
  51. It's best if the submitter and copyright owner
  52. are the same person/entity. If not, the name of
  53. the person/entity authorizing use of GPL should be
  54. listed in case it's necessary to verify the will of
  55. the copyright owner.
  56. Interfaces:
  57. If your driver uses existing interfaces and behaves like
  58. other drivers in the same class it will be much more likely
  59. to be accepted than if it invents gratuitous new ones.
  60. If you need to implement a common API over Linux and NT
  61. drivers do it in userspace.
  62. Code:
  63. Please use the Linux style of code formatting as documented
  64. in :ref:`Documentation/process/coding-style.rst <codingStyle>`.
  65. If you have sections of code
  66. that need to be in other formats, for example because they
  67. are shared with a windows driver kit and you want to
  68. maintain them just once separate them out nicely and note
  69. this fact.
  70. Portability:
  71. Pointers are not always 32bits, not all computers are little
  72. endian, people do not all have floating point and you
  73. shouldn't use inline x86 assembler in your driver without
  74. careful thought. Pure x86 drivers generally are not popular.
  75. If you only have x86 hardware it is hard to test portability
  76. but it is easy to make sure the code can easily be made
  77. portable.
  78. Clarity:
  79. It helps if anyone can see how to fix the driver. It helps
  80. you because you get patches not bug reports. If you submit a
  81. driver that intentionally obfuscates how the hardware works
  82. it will go in the bitbucket.
  83. PM support:
  84. Since Linux is used on many portable and desktop systems, your
  85. driver is likely to be used on such a system and therefore it
  86. should support basic power management by implementing, if
  87. necessary, the .suspend and .resume methods used during the
  88. system-wide suspend and resume transitions. You should verify
  89. that your driver correctly handles the suspend and resume, but
  90. if you are unable to ensure that, please at least define the
  91. .suspend method returning the -ENOSYS ("Function not
  92. implemented") error. You should also try to make sure that your
  93. driver uses as little power as possible when it's not doing
  94. anything. For the driver testing instructions see
  95. Documentation/power/drivers-testing.txt and for a relatively
  96. complete overview of the power management issues related to
  97. drivers see Documentation/driver-api/pm/devices.rst.
  98. Control:
  99. In general if there is active maintenance of a driver by
  100. the author then patches will be redirected to them unless
  101. they are totally obvious and without need of checking.
  102. If you want to be the contact and update point for the
  103. driver it is a good idea to state this in the comments,
  104. and include an entry in MAINTAINERS for your driver.
  105. What Criteria Do Not Determine Acceptance
  106. -----------------------------------------
  107. Vendor:
  108. Being the hardware vendor and maintaining the driver is
  109. often a good thing. If there is a stable working driver from
  110. other people already in the tree don't expect 'we are the
  111. vendor' to get your driver chosen. Ideally work with the
  112. existing driver author to build a single perfect driver.
  113. Author:
  114. It doesn't matter if a large Linux company wrote the driver,
  115. or you did. Nobody has any special access to the kernel
  116. tree. Anyone who tells you otherwise isn't telling the
  117. whole story.
  118. Resources
  119. ---------
  120. Linux kernel master tree:
  121. ftp.\ *country_code*\ .kernel.org:/pub/linux/kernel/...
  122. where *country_code* == your country code, such as
  123. **us**, **uk**, **fr**, etc.
  124. http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git
  125. Linux kernel mailing list:
  126. linux-kernel@vger.kernel.org
  127. [mail majordomo@vger.kernel.org to subscribe]
  128. Linux Device Drivers, Third Edition (covers 2.6.10):
  129. http://lwn.net/Kernel/LDD3/ (free version)
  130. LWN.net:
  131. Weekly summary of kernel development activity - http://lwn.net/
  132. 2.6 API changes:
  133. http://lwn.net/Articles/2.6-kernel-api/
  134. Porting drivers from prior kernels to 2.6:
  135. http://lwn.net/Articles/driver-porting/
  136. KernelNewbies:
  137. Documentation and assistance for new kernel programmers
  138. http://kernelnewbies.org/
  139. Linux USB project:
  140. http://www.linux-usb.org/
  141. How to NOT write kernel driver by Arjan van de Ven:
  142. http://www.fenrus.org/how-to-not-write-a-device-driver-paper.pdf
  143. Kernel Janitor:
  144. http://kernelnewbies.org/KernelJanitors
  145. GIT, Fast Version Control System:
  146. http://git-scm.com/