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?

2 Answers 2


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:

default = 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.

  • When I run this I get Applying: HID: logitech-hidpp: split g920_get_config() error: patch failed: drivers/hid/hid-logitech-hidpp.c:2081 error: drivers/hid/hid-logitech-hidpp.c: patch does not apply Patch failed at 0001 HID: logitech-hidpp: split g920_get_config()
    – Qwertie
    Oct 22, 2019 at 10:07
  • 1
    What git hash are you applying the patch on? Put another way, how did you get the kernel tree you’re using? Oct 22, 2019 at 10:08
  • I just ran git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
    – Qwertie
    Oct 23, 2019 at 10:23
  • Ah, you need another patch on Linus’ tree, see my updated answer for details. Oct 23, 2019 at 10:50

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.

  • patch is designed to ignore parts of the file it's given that don't look like a patch; the idea being one can pipe the entire email/post straight to patch and things will just work.
    – studog
    Oct 22, 2019 at 13:07
  • 1
    If your linux source tree is a git clone, then git am is better because it will actually register the patch in git. Moreover, it'll let you resolve conflicts in a similar way git merge does, unlike patch, which will just put rejected hunks into a *.rej file.
    – Ruslan
    Oct 22, 2019 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.