Kernel Patch Tutorial

  • Upload
    amit4g

  • View
    228

  • Download
    0

Embed Size (px)

Citation preview

  • 7/30/2019 Kernel Patch Tutorial

    1/28

    Write and Submit

    your first LinuxKernel Patch

    Greg [email protected]

    github.com/gregkh/kernel-tutorial.git

  • 7/30/2019 Kernel Patch Tutorial

    2/28

    Documentation/HOWTO

    Documentation/development_process

  • 7/30/2019 Kernel Patch Tutorial

    3/28

    git remote add linux-next \

    git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.g

    git fetch linux-next

    git fetch --tags linux-next

    .. # later on

    git remote update

    Working with linux-next

  • 7/30/2019 Kernel Patch Tutorial

    4/28

    Linux Kernel Coding Style

    Why Care?

  • 7/30/2019 Kernel Patch Tutorial

    5/28

    It is not merely a matter of aesthetics thatprograms should be written in a particularstyle. Rather there is a psychological basis forwriting programs in a conventional manner:programmers have strong expectations thatother programmers will follow thesediscourse rules. If the rules are violated, thenthe utility afforded by the expectations thatprogrammers have built up over time is

    effectively nullified. Soloway & Ehrlich

  • 7/30/2019 Kernel Patch Tutorial

    6/28

    Documentation/CodingStyl

  • 7/30/2019 Kernel Patch Tutorial

    7/28

    scripts/checkpatch.p

  • 7/30/2019 Kernel Patch Tutorial

    8/28

    SB: otg: Fix bug on remove path without transceiver

    n the case where a gadget driver is removed while noransceiver was found at probe time, a bug intg_put_transceiver() will trigger.

    gned-off-by: Robert Jarzmik cked-by: David Brownell dev);

    if (x)put_device(x->dev);

  • 7/30/2019 Kernel Patch Tutorial

    9/28

    Developer's Certificate of Origin

    (a) I created this change; or

    (b) Based this on a previous work with acompatible license; or

    (c) Provided to me by (a), (b), or (c) and notmodified

    (d) This contribution is public.

  • 7/30/2019 Kernel Patch Tutorial

    10/28

    git diff

    git commit

    git show

    git format-patch

    git send-email

  • 7/30/2019 Kernel Patch Tutorial

    11/28

    scripts/get_maintainer.p

  • 7/30/2019 Kernel Patch Tutorial

    12/28

    Checklist Kernel builds with patch applied

    Correct From: address

    Concise Subject:

    Explain the patch

    Signed-off-by

  • 7/30/2019 Kernel Patch Tutorial

    13/28

    2.6.20 to 2.6.2

    kernelnewbies.org

  • 7/30/2019 Kernel Patch Tutorial

    14/28

  • 7/30/2019 Kernel Patch Tutorial

    15/28

    Write and Submit

    your first LinuxKernel Patch

    Greg Kroah-Hartman

    [email protected]/gregkh/kernel-tutorial.git

  • 7/30/2019 Kernel Patch Tutorial

    16/28

    Documentation/HOWTO

    Documentation/development_process

  • 7/30/2019 Kernel Patch Tutorial

    17/28

    $ git remote add linux-next \git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

    $ git fetch linux-next

    $ git fetch --tags linux-next

    ... # later on

    $ git remote update

    Working with linux-next

  • 7/30/2019 Kernel Patch Tutorial

    18/28

    Linux Kernel Coding Style

    Why Care?

  • 7/30/2019 Kernel Patch Tutorial

    19/28

  • 7/30/2019 Kernel Patch Tutorial

    20/28

    Documentation/CodingStyle

  • 7/30/2019 Kernel Patch Tutorial

    21/28

    scripts/checkpatch.pl

  • 7/30/2019 Kernel Patch Tutorial

    22/28

    USB: otg: Fix bug on remove path without transceiverIn the case where a gadget driver is removed while notransceiver was found at probe time, a bug inotg_put_transceiver() will trigger.

    Signed-off-by: Robert Jarzmik Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman

    --- a/drivers/usb/otg/otg.c+++ b/drivers/usb/otg/otg.c@@ -43,7 +43,8 @@ EXPORT_SYMBOL(otg_get_transceiver);void otg_put_transceiver(struct otg_transceiver *x){- put_device(x->dev);+ if (x)+ put_device(x->dev);

    }

  • 7/30/2019 Kernel Patch Tutorial

    23/28

    Developer's Certificate of Origin

    (a) I created this change; or

    (b) Based this on a previous work with acompatible license; or

    (c) Provided to me by (a), (b), or (c) and notmodified

    (d) This contribution is public.

  • 7/30/2019 Kernel Patch Tutorial

    24/28

    git diff

    git commit

    git show

    git format-patch

    git send-email

  • 7/30/2019 Kernel Patch Tutorial

    25/28

    scripts/get_maintainer.pl

  • 7/30/2019 Kernel Patch Tutorial

    26/28

    Checklist

    Kernel builds with patch applied Correct From: address

    Concise Subject:

    Explain the patch

    Signed-off-by

  • 7/30/2019 Kernel Patch Tutorial

    27/28

    2.6.20 to 2.6.24-rc8

    kernelnewbies.org

  • 7/30/2019 Kernel Patch Tutorial

    28/28