How do I build a kernel using patches from LKML?

I would like to compile a kernel for fedora which contains some not yet merged patches which fix a hardware device of mine. The patches are located here.

I have read the guide on compiling a kernel for Fedora.

What I am unsure of is how I get the patches from the mailing list and then apply them to my copy of the Linux source code. Obviously I could copy and paste the changes by hand in to the code but I assume there is a much better way than that. From what I understand you can create a git patch file which you can then apply. What would be the best way to apply this code contained in the emails?

Asked By: Qwertie

||

There’s a dedicated program for patching – patch. It’s widely available across various OSs. Search for it in you repository, it should be there. Then consult your man patch.

Answered By: user147505

This patch series was sent to linux-input, so it’s available on Patchwork. To find it, you’ll need to remove the “Action Required” filter at the top of the screen; you’ll then find v2 of the patch (which matches your link), and also v3 of the patch which is the version that was merged. There’s a handy “Series” link in the top-right-hand corner: click on that, save the resulting file, then in your kernel tree,

git am /path/to/Logitech-G920-fixes.patch

will apply it for you.

On the current kernel tree, you will need to apply this patch first; so download that, and apply

git am /path/to/HID-Fix-assumption-that-devices-have-inputs.patch
git am /path/to/Logitech-G920-fixes.patch

To figure that out, I added the HID tree as a remote, then looked at the log for drivers/hid/hid-logitech-hidpp.c:

git remote add hid https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git
git fetch hid
git log HEAD..hid/for-next drivers/hid/hid-logitech-hidpp.c

If you’re going to work with Patchwork again in the future, it’s worth downloading pwclient and configuring ~/.pwclientrc:

[options]
default = linux-input

[linux-input]
url = https://patchwork.kernel.org/xmlrpc/

Then you can run pwclient git-am 11173117 and pwclient git-am 11197515 to apply the patch series directly.

Answered By: Stephen Kitt
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.