Kernel submission

De Mathux
Révision datée du 20 avril 2023 à 00:07 par Admin (discussion | contributions) (→‎Commands and advice before sending to LKML)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)

Commands and advice before sending to LKML

Having a patch ready for the kernel need some attention. To have the best chances for your patch to be accepted, you have to read

Documentation/SubmittingPatches or


kernel_patch_tutorial by GregKh




Sending patch process

More recent way with the b4 tool

Here is a resume of the commands you may have to use

Setup Sources

Patch should be build against linux-next branch Detailed informations

Get Sources

   $ git clone
         # or: git://
   Cloning into 'linux'...
   $ cd linux
   $ git remote add linux-next
                         # or: git://
   $ git fetch linux-next
   $ git fetch --tags linux-next

Update Sources

   $ git checkout master      # to be safe
   $ git remote update

Start branch

   $ git tag -l "next-*" | tail
   $ git checkout -b my_local_branch next-20140625
   Switched to a new branch 'my_local_branch'

Sources indentation and style

First follow coding style rules describe in


You can correct your indentation using

scripts/Lindent MyFile.c

Make sure that the compilation do not produce unjustified warning


And check that you follow the recommended rules

scripts/ --strict -f MyFile.c

Or a given commit

scripts/ -g HASH

Commit message

Current code does (A), this has a problem whith (B). We can improve this doing (C°, because (D).

Rebase your work

git fetch --all --tags
git rebase [origin/master]

Create the patch

Once checkpatch is ok with your file, you can create the patch to send using git.

  1. Commit your modification ( cf. Documentation/SubmittingPatches for the commit message) on a dev branch
  2. Create the patch
git format-patch -o patches --subject-prefix="PATCH" -s COMMIT-ID

or for second patch version

git format-patch -o patches --subject-prefix="PATCHv2" -s COMMIT-ID
-s is for sign-off
-n will generate numbered patches in [PATCH n/m] format, even with a single patch.
–cover-letter will generate a cover letter file so that you can fill in the description for your entire set of patches. If you only have one patch, you should skip this.

The files generated in patches directory could be check using

scripts/ --strict my_patch.patch

Send the patch

Then you can send the patch to the lkml.

Destinataires are describe in Documentation/SubmittingPatches. In short, do not forget to CC and the dest could be find using

scripts/ path_to_file_i_modify

To send it, you can use a mail client. Mail should be in plain text and patched included in the mail corp (once again cf. Documentation/SubmittingPatches).

You can also use the git send-email tool (As this module is optional on the distribution, it may require additional installation). You need to configure git and add in ~/.gitconfig

                  smtpencryption = tls
                  smtpserver =
                  smtpuser =
                  smtpserverport = 587

then you can send the mail, with all the patches in the "patches" directory created by git format-patch

git send-email --annotate patches

Other Links