2016-09-19 19:07:56 +08:00
|
|
|
.. _submittingdrivers:
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
Submitting Drivers For The Linux Kernel
|
2016-09-19 19:07:52 +08:00
|
|
|
=======================================
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
This document is intended to explain how to submit device drivers to the
|
|
|
|
various kernel trees. Note that if you are interested in video card drivers
|
2020-06-21 21:36:30 +08:00
|
|
|
you should probably talk to XFree86 (https://www.xfree86.org/) and/or X.Org
|
|
|
|
(https://x.org/) instead.
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-10-27 06:45:29 +08:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
This document is old and has seen little maintenance in recent years; it
|
|
|
|
should probably be updated or, perhaps better, just deleted. Most of
|
|
|
|
what is here can be found in the other development documents anyway.
|
|
|
|
|
|
|
|
Oh, and we don't really recommend submitting changes to XFree86 :)
|
|
|
|
|
2018-11-21 08:35:19 +08:00
|
|
|
Also read the :ref:`Documentation/process/submitting-patches.rst <submittingpatches>`
|
|
|
|
document.
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
Allocating Device Numbers
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
Major and minor numbers for block and character devices are allocated
|
2005-06-29 11:45:30 +08:00
|
|
|
by the Linux assigned name and number authority (currently this is
|
2020-06-21 21:36:30 +08:00
|
|
|
Torben Mathiasen). The site is https://www.lanana.org/. This
|
2005-04-17 06:20:36 +08:00
|
|
|
also deals with allocating numbers for devices that are not going to
|
|
|
|
be submitted to the mainstream kernel.
|
2018-11-21 08:35:19 +08:00
|
|
|
See :ref:`Documentation/admin-guide/devices.rst <admin_devices>`
|
|
|
|
for more information on this.
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-06-29 11:45:30 +08:00
|
|
|
If you don't use assigned numbers then when your device is submitted it will
|
|
|
|
be given an assigned number even if that is different from values you may
|
2005-04-17 06:20:36 +08:00
|
|
|
have shipped to customers before.
|
|
|
|
|
|
|
|
Who To Submit Drivers To
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
Linux 2.0:
|
2006-01-08 17:02:49 +08:00
|
|
|
No new drivers are accepted for this kernel tree.
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
Linux 2.2:
|
2006-01-08 17:02:49 +08:00
|
|
|
No new drivers are accepted for this kernel tree.
|
|
|
|
|
|
|
|
Linux 2.4:
|
2005-04-17 06:20:36 +08:00
|
|
|
If the code area has a general maintainer then please submit it to
|
|
|
|
the maintainer listed in MAINTAINERS in the kernel file. If the
|
|
|
|
maintainer does not respond or you cannot find the appropriate
|
2007-10-20 08:02:12 +08:00
|
|
|
maintainer then please contact Willy Tarreau <w@1wt.eu>.
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-09-21 19:51:05 +08:00
|
|
|
Linux 2.6 and upper:
|
2005-04-17 06:20:36 +08:00
|
|
|
The same rules apply as 2.4 except that you should follow linux-kernel
|
2016-09-21 19:51:05 +08:00
|
|
|
to track changes in API's. The final contact point for Linux 2.6+
|
2008-10-16 13:01:59 +08:00
|
|
|
submissions is Andrew Morton.
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
What Criteria Determine Acceptance
|
|
|
|
----------------------------------
|
|
|
|
|
2016-09-19 19:07:52 +08:00
|
|
|
Licensing:
|
|
|
|
The code must be released to us under the
|
2020-08-14 22:56:25 +08:00
|
|
|
GNU General Public License. If you wish the driver to be
|
|
|
|
useful to other communities such as BSD you may release
|
|
|
|
under multiple licenses. If you choose to release under
|
|
|
|
licenses other than the GPL, you should include your
|
|
|
|
rationale for your license choices in your cover letter.
|
2006-01-08 17:02:49 +08:00
|
|
|
See accepted licenses at include/linux/module.h
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-09-19 19:07:52 +08:00
|
|
|
Copyright:
|
|
|
|
The copyright owner must agree to use of GPL.
|
2005-04-17 06:20:36 +08:00
|
|
|
It's best if the submitter and copyright owner
|
|
|
|
are the same person/entity. If not, the name of
|
|
|
|
the person/entity authorizing use of GPL should be
|
|
|
|
listed in case it's necessary to verify the will of
|
2006-09-29 17:01:43 +08:00
|
|
|
the copyright owner.
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-09-19 19:07:52 +08:00
|
|
|
Interfaces:
|
|
|
|
If your driver uses existing interfaces and behaves like
|
2005-04-17 06:20:36 +08:00
|
|
|
other drivers in the same class it will be much more likely
|
2006-09-29 17:01:43 +08:00
|
|
|
to be accepted than if it invents gratuitous new ones.
|
2005-04-17 06:20:36 +08:00
|
|
|
If you need to implement a common API over Linux and NT
|
|
|
|
drivers do it in userspace.
|
|
|
|
|
2016-09-19 19:07:52 +08:00
|
|
|
Code:
|
|
|
|
Please use the Linux style of code formatting as documented
|
2016-10-18 20:12:27 +08:00
|
|
|
in :ref:`Documentation/process/coding-style.rst <codingStyle>`.
|
2016-09-21 19:51:05 +08:00
|
|
|
If you have sections of code
|
2005-04-17 06:20:36 +08:00
|
|
|
that need to be in other formats, for example because they
|
|
|
|
are shared with a windows driver kit and you want to
|
|
|
|
maintain them just once separate them out nicely and note
|
|
|
|
this fact.
|
|
|
|
|
2016-09-19 19:07:52 +08:00
|
|
|
Portability:
|
|
|
|
Pointers are not always 32bits, not all computers are little
|
2005-04-17 06:20:36 +08:00
|
|
|
endian, people do not all have floating point and you
|
|
|
|
shouldn't use inline x86 assembler in your driver without
|
|
|
|
careful thought. Pure x86 drivers generally are not popular.
|
|
|
|
If you only have x86 hardware it is hard to test portability
|
|
|
|
but it is easy to make sure the code can easily be made
|
|
|
|
portable.
|
|
|
|
|
2016-09-19 19:07:52 +08:00
|
|
|
Clarity:
|
|
|
|
It helps if anyone can see how to fix the driver. It helps
|
2005-04-17 06:20:36 +08:00
|
|
|
you because you get patches not bug reports. If you submit a
|
|
|
|
driver that intentionally obfuscates how the hardware works
|
|
|
|
it will go in the bitbucket.
|
|
|
|
|
2016-09-19 19:07:52 +08:00
|
|
|
PM support:
|
|
|
|
Since Linux is used on many portable and desktop systems, your
|
2007-05-08 15:24:07 +08:00
|
|
|
driver is likely to be used on such a system and therefore it
|
|
|
|
should support basic power management by implementing, if
|
|
|
|
necessary, the .suspend and .resume methods used during the
|
|
|
|
system-wide suspend and resume transitions. You should verify
|
|
|
|
that your driver correctly handles the suspend and resume, but
|
|
|
|
if you are unable to ensure that, please at least define the
|
|
|
|
.suspend method returning the -ENOSYS ("Function not
|
|
|
|
implemented") error. You should also try to make sure that your
|
|
|
|
driver uses as little power as possible when it's not doing
|
|
|
|
anything. For the driver testing instructions see
|
2019-06-13 18:10:36 +08:00
|
|
|
Documentation/power/drivers-testing.rst and for a relatively
|
2007-05-08 15:24:07 +08:00
|
|
|
complete overview of the power management issues related to
|
2018-11-21 08:35:19 +08:00
|
|
|
drivers see :ref:`Documentation/driver-api/pm/devices.rst <driverapi_pm_devices>`.
|
2007-05-08 15:24:07 +08:00
|
|
|
|
2016-09-19 19:07:52 +08:00
|
|
|
Control:
|
|
|
|
In general if there is active maintenance of a driver by
|
2006-09-29 17:01:43 +08:00
|
|
|
the author then patches will be redirected to them unless
|
2005-04-17 06:20:36 +08:00
|
|
|
they are totally obvious and without need of checking.
|
|
|
|
If you want to be the contact and update point for the
|
|
|
|
driver it is a good idea to state this in the comments,
|
|
|
|
and include an entry in MAINTAINERS for your driver.
|
|
|
|
|
|
|
|
What Criteria Do Not Determine Acceptance
|
|
|
|
-----------------------------------------
|
|
|
|
|
2016-09-19 19:07:52 +08:00
|
|
|
Vendor:
|
|
|
|
Being the hardware vendor and maintaining the driver is
|
2005-04-17 06:20:36 +08:00
|
|
|
often a good thing. If there is a stable working driver from
|
|
|
|
other people already in the tree don't expect 'we are the
|
2006-09-29 17:01:43 +08:00
|
|
|
vendor' to get your driver chosen. Ideally work with the
|
2005-04-17 06:20:36 +08:00
|
|
|
existing driver author to build a single perfect driver.
|
|
|
|
|
2016-09-19 19:07:52 +08:00
|
|
|
Author:
|
|
|
|
It doesn't matter if a large Linux company wrote the driver,
|
2005-04-17 06:20:36 +08:00
|
|
|
or you did. Nobody has any special access to the kernel
|
|
|
|
tree. Anyone who tells you otherwise isn't telling the
|
|
|
|
whole story.
|
|
|
|
|
|
|
|
|
|
|
|
Resources
|
|
|
|
---------
|
|
|
|
|
|
|
|
Linux kernel master tree:
|
2016-09-19 19:07:52 +08:00
|
|
|
ftp.\ *country_code*\ .kernel.org:/pub/linux/kernel/...
|
|
|
|
|
|
|
|
where *country_code* == your country code, such as
|
|
|
|
**us**, **uk**, **fr**, etc.
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2020-06-21 21:36:30 +08:00
|
|
|
https://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git
|
2010-05-27 05:42:34 +08:00
|
|
|
|
2006-09-29 17:01:43 +08:00
|
|
|
Linux kernel mailing list:
|
2005-04-17 06:20:36 +08:00
|
|
|
linux-kernel@vger.kernel.org
|
|
|
|
[mail majordomo@vger.kernel.org to subscribe]
|
|
|
|
|
|
|
|
Linux Device Drivers, Third Edition (covers 2.6.10):
|
2020-06-21 21:36:30 +08:00
|
|
|
https://lwn.net/Kernel/LDD3/ (free version)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
LWN.net:
|
2020-06-21 21:36:30 +08:00
|
|
|
Weekly summary of kernel development activity - https://lwn.net/
|
2016-09-19 19:07:52 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
2.6 API changes:
|
2016-09-19 19:07:52 +08:00
|
|
|
|
2020-06-21 21:36:30 +08:00
|
|
|
https://lwn.net/Articles/2.6-kernel-api/
|
2016-09-19 19:07:52 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
Porting drivers from prior kernels to 2.6:
|
2016-09-19 19:07:52 +08:00
|
|
|
|
2020-06-21 21:36:30 +08:00
|
|
|
https://lwn.net/Articles/driver-porting/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
KernelNewbies:
|
|
|
|
Documentation and assistance for new kernel programmers
|
2016-09-19 19:07:52 +08:00
|
|
|
|
2020-06-21 21:36:30 +08:00
|
|
|
https://kernelnewbies.org/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
Linux USB project:
|
2006-01-14 19:57:41 +08:00
|
|
|
http://www.linux-usb.org/
|
2006-01-08 17:02:49 +08:00
|
|
|
|
2006-09-29 17:01:43 +08:00
|
|
|
How to NOT write kernel driver by Arjan van de Ven:
|
|
|
|
http://www.fenrus.org/how-to-not-write-a-device-driver-paper.pdf
|
2006-01-08 17:02:49 +08:00
|
|
|
|
|
|
|
Kernel Janitor:
|
2020-06-21 21:36:30 +08:00
|
|
|
https://kernelnewbies.org/KernelJanitors
|
2010-05-27 05:42:34 +08:00
|
|
|
|
|
|
|
GIT, Fast Version Control System:
|
2020-06-21 21:36:30 +08:00
|
|
|
https://git-scm.com/
|