@@ -406,7 +406,131 @@ before it is accepted into the Linux kernel source tree. This ensures
406
406
that every line of code in the Linux kernel, can be tracked back to the
407
407
developer who created it, and the developers who reviewed it.
408
408
409
- Af
409
+
410
+ -- Createing our patch
411
+
412
+ Now that we know how a patch is structured, we can create ours.
413
+
414
+ First, tell git to check in the change that we made:
415
+ $ git commit drivers/staging/comedi/drivers/ni_labpc.c
416
+
417
+ git will fire up your favorite editor and place you in it, with the
418
+ following information already present:
419
+
420
+ # Please enter the commit message for your changes. Lines starting
421
+ # with '#' will be ignored, and an empty message aborts the commit.
422
+ # Explicit paths specified without -i nor -o; assuming --only paths...
423
+ # On branch tutorial
424
+ # Changes to be committed:
425
+ # (use "git reset HEAD <file>..." to unstage)
426
+ #
427
+ # modified: drivers/staging/comedi/drivers/ni_labpc.c
428
+
429
+ Create a summary line for the patch:
430
+ Staging: comedi: fix brace coding style issue in ni_labpc.c
431
+
432
+ And then a more descriptive paragraph:
433
+
434
+ This is a patch to the ni_labpc.c file that fixes up a brace
435
+ warning found by the checkpatch.pl tool
436
+
437
+ Then add your Signed-off-by: line:
438
+
439
+ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
440
+
441
+ Then save the file and git will make the commit, printing out the
442
+ following:
443
+ [tutorial 60de825] Staging: comedi: fix brace coding style issue in ni_labpc.c
444
+ 1 files changed, 2 insertions(+), 4 deletions(-)
445
+
446
+ If you use the command 'git show HEAD' to see the most recent change, it
447
+ will show you the full commit you made:
448
+ $ git show HEAD
449
+
450
+ commit 60de825964d99dee56108ce4c985a7cfc984e402
451
+ Author: Greg Kroah-Hartman <gregkh@suse.de>
452
+ Date: Sat Jan 9 12:07:40 2010 -0800
453
+
454
+ Staging: comedi: fix brace coding style issue in ni_labpc.c
455
+
456
+ This is a patch to the ni_labpc.c file that fixes up a brace
457
+ warning found by the checkpatch.pl tool
458
+
459
+ Signed-off-by: My Name <my_name@my_email_domain>
460
+
461
+ diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
462
+ index dc3f398..a01e35d 100644
463
+ --- a/drivers/staging/comedi/drivers/ni_labpc.c
464
+ +++ b/drivers/staging/comedi/drivers/ni_labpc.c
465
+ @@ -483,12 +483,10 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
466
+
467
+ printk("comedi%d: ni_labpc: %s, io 0x%lx", dev->minor, thisboard->name,
468
+ iobase);
469
+ - if (irq) {
470
+ + if (irq)
471
+ printk(", irq %u", irq);
472
+ - }
473
+ - if (dma_chan) {
474
+ + if (dma_chan)
475
+ printk(", dma %u", dma_chan);
476
+ - }
477
+ printk("\n");
478
+
479
+ if (iobase == 0) {
480
+
481
+
482
+ You are now finished creating your first kernel patch!
483
+
484
+ -- Getting your change into the kernel tree
485
+
486
+ Now that you have created the patch, how do you get it into the kernel
487
+ tree? Linux kernel development primarily still happens through email,
488
+ with patches being sent through email, and review happening that way.
489
+
490
+ First off, let's export our patch in a format that we can use to email
491
+ it to the maintainer who will be responsible for accepting our patch.
492
+
493
+ To do that, once again, git has a command 'format-patch' that you can
494
+ use:
495
+ $ git format-patch master..tutorial
496
+ 0001-Staging-comedi-fix-brace-coding-style-issue-in-ni_la.patch
497
+
498
+ In this command, we are creating all patches that exist in the
499
+ difference from the branch 'master' (which is Linus's branch, remember
500
+ way back at the beginning?) and our private branch, called 'tutorial'.
501
+ This consists of only one change, our patch. It is now in the file
502
+ 0001-Staging-comedi-fix-brace-coding-style-issue-in-ni_la.patch in our
503
+ directory in a format that we can send off.
504
+
505
+ Before we attempt to send the patch off, we should verify that our patch
506
+ is in the correct format, and does not add any errors to the kernel tree
507
+ as far as coding style issues go. To do that, we use the checkpatch.pl
508
+ script again:
509
+ $ ./scripts/checkpatch.pl 0001-Staging-comedi-fix-brace-coding-style-issue-in-ni_la.patch
510
+ total: 0 errors, 0 warnings, 14 lines checked
511
+
512
+ 0001-Staging-comedi-fix-brace-coding-style-issue-in-ni_la.patch has no obvious style problems and is ready for submission.
513
+
514
+ All is good, so it is safe to submit this change.
515
+
516
+ But, who do we send it to? Once again, the kernel developers have made
517
+ this very simple, with a script that will tell you who needs to be
518
+ notified. This script is called, 'get_maintainer.pl', and is also in
519
+ the scripts/ subdirectory in the kernel source tree. This script looks
520
+ at the files you have modified in the patch, and matches it up with the
521
+ information in the MAINTAINTERS file in the kernel source tree that
522
+ describes who is responsible for what portion of the kernel, as well as
523
+ looking at the past history of the files being modified, in order to
524
+ come up with the names and email addresses of the people, and mailing
525
+ lists, that should be notified of this patch.
526
+
527
+ Running this script on our patch, results in the following:
528
+ $ ./scripts/get_maintainer.pl 0001-Staging-comedi-fix-brace-coding-style-issue-in-ni_la.patch
529
+ Greg Kroah-Hartman <gregkh@suse.de>
530
+ Bill Pemberton <wfp5p@virginia.edu>
531
+ devel@driverdev.osuosl.org
532
+ linux-kernel@vger.kernel.org
533
+
410
534
411
535
412
536
0 commit comments