Marcelo Schmitt

MAC0472 - Agile Methods Lab - Patch submission to the Linux kernel

This is a short guide of commands used to send a patch to the Linux kernel.

Warning: This is an old post with potentially outdated information. Read with caution.

Navigate to the repository directory containing the Linux kernel source code you have made changes to:

For example:

cd ~/linux-iio/iio/

In this directory you will find important subdirectories like arch, drivers, scripts, among others.

Use a tool to check the style of your code and make sure your changes respect the kernel coding style.

Make sure your changes compile before submitting your code for community review.

make M=<directory_that_contains_the_files_you_changed> clean
make M=<directory_that_contains_the_files_you_changed>

Example:

make M=drivers/staging/iio/impedance-analyzer clean
make M=drivers/staging/iio/impedance-analyzer

It is also recommended to install the modified kernel in a virtual machine and start it (boot) but that is a subject for another post.

Review the things you did with git diff.

git diff <file_you_changed>

Example:

git diff drivers/staging/iio/impedance-analyzer/ad5933.c

Add the file with the changes made to the files marked for commit.

git add <file_you_changed>

Example:

git add drivers/staging/iio/impedance-analyzer/ad5933.c

Commit.

git commit -s -v

Write the title and commit message describing what changes you made and why. This post explains how to write good commit messages.

Get the list of reviewers you should email your changes to.

Get the hash of the commit before the commit you made

git log

Use git format-patch to create the email that you will send to the mailing list of the subsystem(s) you are working on and responsible for the modified files. Replace the emails after --to with the emails obtained from the maintainers of the file(s) you changed. At the end, put the hash of the commit prior to the commit with your changes.

git format-patch -o <path_where_to_save_the_patch_files> \\
--to="mantainer1@domain.com,mantainer2@domain2.com,mantainerN@domainN.org" \\
--cc="list1@domain.org,list2@domain.org,listN@anotherdomain.org" \\
<hash_of_the_last_commit_before_yours>

Change diretory to where you saved the patch files. You can open your patch with a text editor and double-check your changes and email addresses.

Example:

vim 0001-staging-iio-ad5933-replaced-kfifo-by-triggered_buffer.patch

If everything is ok, you can then send your patch to the maintainers using the an email client like mutt or neomutt.

neomutt -H <patch_file>

Example:

neomutt -H 0001-staging-iio-ad5933-replaced-kfifo-by-triggered_buffer.patch

Okay, the patch with your changes has been sent to the maintainers so they can review your code and maybe incorporate it in the rest of the Linux kernel source code.