write and submit your first linux kernel patch

1.        建立自己的branch

         Git branch test

 

2.        切换到branch

         Git checkout test

 

3.        检查编码的风格

cjok@ubuntu:~/git-work/linux$./scripts/checkpatch.pl --file --terse drivers/staging/media/go7007/s2250-board.c

drivers/staging/media/go7007/s2250-board.c:107:ERROR: that open brace { should be on the previous line

total: 1 errors,0 warnings, 698 lines checked

 

4.        修改bug

cjok@ubuntu:~/git-work/linux$ vi drivers/staging/media/go7007/s2250-board.c +107

 

5.        查看修改过的地方

cjok@ubuntu:~/git-work/linux$git diff

diff --gita/drivers/staging/media/go7007/s2250-board.c b/drivers/staging/media/

index e7736a9..385d391 100644

---a/drivers/staging/media/go7007/s2250-board.c

+++ b/drivers/staging/media/go7007/s2250-board.c

@@ -103,8 +103,7 @@ static u16vid_regs_fp[] = {

 };

 

 /* PAL specific values */

-static u16 vid_regs_fp_pal[] =

-{

+static u16 vid_regs_fp_pal[] ={

        0x120, 0x017,

        0x121, 0xd22,

        0x122, 0x122,

 

6.        编译修改过的目录,防止修改时带入新的错误

         Make M=drivers/staging/media/go7007/

 

7.        提交patch

cjok@ubuntu:~/git-work/linux$git commit -a

[test-cjok a041001] staging:media: go7007: fixed  coding style issue

 1 files changed, 1 insertions(+), 2deletions(-)

8.        查看patch信息

cjok@ubuntu:~/git-work/linux$git show --pretty=full

commita04100141fc3708ce19cb4a3228506d675fd3776

Author: CJOK<cjok.liao@gmail.com>

Commit: CJOK<cjok.liao@gmail.com>

 

    staging: media: go7007: fixed  coding style issue

   

    Fixed a coding style issue

 

diff --gita/drivers/staging/media/go7007/s2250-board.c b/drivers/staging/media/

index e7736a9..385d391 100644

---a/drivers/staging/media/go7007/s2250-board.c

+++b/drivers/staging/media/go7007/s2250-board.c

@@ -103,8 +103,7 @@ static u16vid_regs_fp[] = {

 };

 

 /* PAL specific values */

-static u16 vid_regs_fp_pal[] =

-{

+static u16 vid_regs_fp_pal[] ={

        0x120, 0x017,

        0x121, 0xd22,

        0x122, 0x122,

 

9.        格式化patch

cjok@ubuntu:~/git-work/linux$git format-patch master..test-cjok

0001-staging-media-go7007-fixed-coding-style-issue.patch


 

10.    检查patch的编码,防止引入新的错误

cjok@ubuntu:~/git-work/linux$./scripts/checkpatch.pl0001-staging-media-go7007-fixed-coding-style-issue.patch

total: 0 errors, 0 warnings, 9lines checked

 

0001-staging-media-go7007-fixed-coding-style-issue.patchhas no obvious style problems and is ready for submission.

 

11.    获取maintainer和相关人员的email

cjok@ubuntu:~/git-work/linux$./scripts/get_maintainer.pl0001-staging-media-go7007-fixed-coding-style-issue.patch

Mauro Carvalho Chehab<mchehab@infradead.org> (maintainer:MEDIA INPUTINFRA...,commit_signer:1/2=50%)

Greg Kroah-Hartman<gregkh@suse.de> (maintainer:STAGING SUBSYSTEM,commit_signer:1/2=50%)

linux-media@vger.kernel.org(open list:MEDIA INPUT INFRA...)

devel@driverdev.osuosl.org (openlist:STAGING SUBSYSTEM)

linux-kernel@vger.kernel.org(open list)

 

12.    发送email

cjok@ubuntu:~/git-work/linux$git send-email --to linux-media@vger.kernel.org --cc cjok.liao@gmail.com0001-staging-media-go7007-fixed-coding-style-issue.patch

         如果gitsend-email工具没有安装,会出错。apt-get install git-email msmtp下载安装就行了。

 

 

Logo

更多推荐