SubmittingDrivers 6.3 KB

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