We are using linux3.12 and its led driver has a bug which got fixed in later version of Linux. We see that driver change in Linux 3.15 see Linux Cross Reference

Now my question is how can I find a patch which induced this change ?

Another question is how can I get access to development kernel source tree e.g. kernel-3.14.18 tree ?


how can I find a patch which induced this change

Use cgit, go here and click on tree. Navigate to the file you're looking for and then click log. You can then see the changes to the file.


To download the Linux kernel sources, go to kernel.org and choose your version.

The unstable development tree is here: https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/

  • i couldn't see kernel version's source tree which is not stable. – AnkurTank Sep 19 '14 at 10:44

getting the kernel source

Clone the stable kernel tree:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

Change into it:

cd linux-stable

Checkout a tag where the bug is fixed:

git checkout v3.15

You know the file you're after drivers/leds/led-core.c and where the bug is fixed (3.15) and broken (3.12) so there are a few ways you can proceed from here.


You could use git blame drivers/leds/led-core.c but i find this view messy.

I prefer tig, a curses-based interface to git, so just:

tig blame drivers/leds/led-core.c

and view each line of the file and those commits interactively. You can go up and down with the arrow keys, and go into a commit with Enter. Exit with q.

You can see the patch you linked to in LXR on Lines 42-46:

2014-02-04 00:11 Stefan Sørensen 8d82fef         /* never on - just set to off */
2014-02-04 00:11 Stefan Sørensen 8d82fef         if (!delay_on) {
2014-02-04 00:11 Stefan Sørensen 8d82fef                 __led_set_brightness(led_cdev, LED_OFF);
2012-03-23 15:02 Bryan Wu        a403d93                 return;
2014-02-04 00:11 Stefan Sørensen 8d82fef         }

So you're looking for 8d82fef. Press Enter over any of those lines and you'll open the patch.

This is much more useful for bigger files with lots of recent patches.


You need a date range, so looking in git log of the "good" and "bad" tags, the 3.15 and 3.12 merges were:

commit 1860e379875dfe7271c649058aeddffe5afd9d0d
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Jun 8 11:19:54 2014 -0700

    Linux 3.15


commit 5e01dc7b26d9f24f39abace5da98ccbd6a5ceb52
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Nov 3 15:41:51 2013 -0800

    Linux 3.12

So anything between Nov 2 2013 and Jun 8 2014 is your patch.

Look in the log of the file in question:

git log drivers/leds/led-core.c

The only patch which matches this date range is the latest one:

commit 8d82fef8bbee588d071372eb02439d2053b4bfe4
Author: Stefan Sørensen <stefan.sorensen@spectralink.com>
Date:   Tue Feb 4 00:11:42 2014 -0800

    leds: Turn off led if blinking is disabled

the patch

Now you've used either of those methods to find the commit which fixes your problem, get the patch of the commit, compared to its ancestor, with:

git diff 8d82fef8^ 8d82fef8 drivers/leds/led-core.c

You can pipe this to a file if you want:

git diff 8d82fef8^ 8d82fef8 drivers/leds/led-core.c > led-blinking-fix.patch

Now you have a patch to apply to your in-house kernel tree.

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.