Preparing to send a patch to LKML

It took me a couple months to get back to my patch, and in the interim, I forgot everything about formatting a patch series to LKML. Here’s what I have remembered.

There are a handful of tools I need to run to check my code before submitting a patch to the Linux Kernel.

First is the standard format checker included in the kernel itself. I run it this way:

./scripts/checkpatch.pl –max-line-length=80 <file>

It can also be run on a patch, but since my patch is pretty much a file, I used to run it against the file. However, passing in the patch file also works, and will check the commit message.

For Networking code there is an additional requirement, reverse xmas tree order – longest line to shortest – for local variable declarations.

This tool checks that format: https://github.com/ecree-solarflare/xmastree

Checking for endianess issues using a -W=1 build. Typically I will do this via

make -W1 drivers/net/mctp/mctp-pcc.ko

The cover letter goes in the branch description

git branch --edit-description

When preparing the patches, generate them using git format-patch like this:

git format-patch -2 -v6 --cover-letter

This produces:

v6-0000-cover-letter.patch
v6-0001-mctp-pcc-Check-before-sending-MCTP-PCC-response-A.patch
v6-0002-mctp-pcc-Implement-MCTP-over-PCC-Transport.patch

The cover letter needs to be edited,as it has a line like this in it:

Subject: [PATCH v6 0/3] *** SUBJECT HERE ***

There should be a way to get that as part of the workflow, but I do not know what it is. I just put the subject on the next line, and delete the placeholder text each time.

Instead of adding all of the commands to git send-email, I have added them to ~/.gitconfig

[user]
	email = admiyo@os.amperecomputing.com
	name = Adam Young
[core]
	editor = /usr/bin/vi
[init]
	defaultBranch = main
[sendemail]
smtpserver = /usr/bin/msmtp
confirm = auto
confirm = always
smtpserveroption = -v
from = admiyo@os.amperecomputing.com

[sendemail.mctp]
    sender = Adam Young
    #cccmd ="`pwd`/scripts/get_maintainer.pl --nogit --nogit-fallback --norolestats --nol"
    tocmd ="`pwd`/scripts/get_maintainer.pl --nogit --nogit-fallback --norolestats --nol"

I have also added a bunch of people to the cc = section manually that are interested in the patch but not automatically notified. I will have to remove this when I change to working on a different patch.

Before I send the patch:

 git  send-email  --cover-letter *patch --dry-run  --identity=mctp

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.