« Kernel submission » : différence entre les versions

De Mathux
 
(Une version intermédiaire par le même utilisateur non affichée)
Ligne 3 : Ligne 3 :
Having a patch ready for the kernel need some attention.
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  
To have the best chances for your patch to be accepted, you have to read  
  Documentation/SubmittingPatches
  Documentation/SubmittingPatches or https://www.kernel.org/doc/html/latest/process/submitting-patches.html


=== Links ===
=== Links ===
Ligne 16 : Ligne 16 :
[https://yaapb.wordpress.com/2012/12/14/10-things-you-need-to-do-before-sending-your-patch-to-lkml/ Sending patch process]
[https://yaapb.wordpress.com/2012/12/14/10-things-you-need-to-do-before-sending-your-patch-to-lkml/ Sending patch process]


Here is a resume of the commands you may have to us
[https://people.kernel.org/monsieuricon/sending-a-kernel-patch-with-b4-part-1 More recent way with the b4 tool]
 
Here is a resume of the commands you may have to use


=== Setup Sources ===
=== Setup Sources ===

Dernière version du 19 avril 2023 à 23:07

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 https://www.kernel.org/doc/html/latest/process/submitting-patches.html

Links

kernel_patch_tutorial by GregKh

PatchTipsAndTricks

CheckpatchTips

FirstKernelPatch

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 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
         # or: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
   Cloning into 'linux'...
   $ cd linux
   $ git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
                         # or: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.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
   next-20140612
   next-20140613
   ...
   $ 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

Documentation/CodingStyle

You can correct your indentation using

scripts/Lindent MyFile.c

Make sure that the compilation do not produce unjustified warning

make

And check that you follow the recommended rules

scripts/checkpatch.pl --strict -f MyFile.c

Or a given commit

scripts/checkpatch.pl -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/checkpatch.pl --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 linux-kernel@vger.kernel.org and the dest could be find using

scripts/get_maintainer.pl 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

           [sendemail]
                  smtpencryption = tls
                  smtpserver = smtp.gmail.com
                  smtpuser = yourname@gmail.com
                  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