Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'doc/sp-update' into docs-next

Bring in the big SubmittingPatches thrashup.

Conflicts:
Documentation/SubmittingPatches

+220 -224
+220 -224
Documentation/SubmittingPatches
··· 10 10 with "the system." This text is a collection of suggestions which 11 11 can greatly increase the chances of your change being accepted. 12 12 13 - Read Documentation/SubmitChecklist for a list of items to check 14 - before submitting code. If you are submitting a driver, also read 15 - Documentation/SubmittingDrivers. 13 + This document contains a large number of suggestions in a relatively terse 14 + format. For detailed information on how the kernel development process 15 + works, see Documentation/development-process. Also, read 16 + Documentation/SubmitChecklist for a list of items to check before 17 + submitting code. If you are submitting a driver, also read 18 + Documentation/SubmittingDrivers; for device tree binding patches, read 19 + Documentation/devicetree/bindings/submitting-patches.txt. 16 20 17 21 Many of these steps describe the default behavior of the git version 18 22 control system; if you use git to prepare your patches, you'll find much 19 23 of the mechanical work done for you, though you'll still need to prepare 20 - and document a sensible set of patches. 24 + and document a sensible set of patches. In general, use of git will make 25 + your life as a kernel developer easier. 21 26 22 27 -------------------------------------------- 23 28 SECTION 1 - CREATING AND SENDING YOUR CHANGE 24 29 -------------------------------------------- 25 30 26 31 32 + 0) Obtain a current source tree 33 + ------------------------------- 34 + 35 + If you do not have a repository with the current kernel source handy, use 36 + git to obtain one. You'll want to start with the mainline repository, 37 + which can be grabbed with: 38 + 39 + git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 40 + 41 + Note, however, that you may not want to develop against the mainline tree 42 + directly. Most subsystem maintainers run their own trees and want to see 43 + patches prepared against those trees. See the "T:" entry for the subsystem 44 + in the MAINTAINERS file to find that tree, or simply ask the maintainer if 45 + the tree is not listed there. 46 + 47 + It is still possible to download kernel releases via tarballs (as described 48 + in the next section), but that is the hard way to do kernel development. 27 49 28 50 1) "diff -up" 29 51 ------------ 30 52 31 - Use "diff -up" or "diff -uprN" to create patches. git generates patches 32 - in this form by default; if you're using git, you can skip this section 33 - entirely. 53 + If you must generate your patches by hand, use "diff -up" or "diff -uprN" 54 + to create patches. Git generates patches in this form by default; if 55 + you're using git, you can skip this section entirely. 34 56 35 57 All changes to the Linux kernel occur in the form of patches, as 36 58 generated by diff(1). When creating your patch, make sure to create it ··· 64 42 65 43 To create a patch for a single file, it is often sufficient to do: 66 44 67 - SRCTREE= linux-2.6 45 + SRCTREE= linux 68 46 MYFILE= drivers/net/mydriver.c 69 47 70 48 cd $SRCTREE ··· 77 55 or unmodified kernel source tree, and generate a diff against your 78 56 own source tree. For example: 79 57 80 - MYSRC= /devel/linux-2.6 58 + MYSRC= /devel/linux 81 59 82 - tar xvfz linux-2.6.12.tar.gz 83 - mv linux-2.6.12 linux-2.6.12-vanilla 84 - diff -uprN -X linux-2.6.12-vanilla/Documentation/dontdiff \ 85 - linux-2.6.12-vanilla $MYSRC > /tmp/patch 60 + tar xvfz linux-3.19.tar.gz 61 + mv linux-3.19 linux-3.19-vanilla 62 + diff -uprN -X linux-3.19-vanilla/Documentation/dontdiff \ 63 + linux-3.19-vanilla $MYSRC > /tmp/patch 86 64 87 65 "dontdiff" is a list of files which are generated by the kernel during 88 66 the build process, and should be ignored in any diff(1)-generated 89 - patch. The "dontdiff" file is included in the kernel tree in 90 - 2.6.12 and later. 67 + patch. 91 68 92 69 Make sure your patch does not include any extra files which do not 93 70 belong in a patch submission. Make sure to review your patch -after- ··· 104 83 105 84 106 85 2) Describe your changes. 86 + ------------------------- 107 87 108 88 Describe your problem. Whether your patch is a one-line bug fix or 109 89 5000 lines of a new feature, there must be an underlying problem that ··· 146 124 When you submit or resubmit a patch or patch series, include the 147 125 complete patch description and justification for it. Don't just 148 126 say that this is version N of the patch (series). Don't expect the 149 - patch merger to refer back to earlier patch versions or referenced 127 + subsystem maintainer to refer back to earlier patch versions or referenced 150 128 URLs to find the patch description and put that into the patch. 151 129 I.e., the patch (series) and its description should be self-contained. 152 - This benefits both the patch merger(s) and reviewers. Some reviewers 130 + This benefits both the maintainers and reviewers. Some reviewers 153 131 probably didn't even receive earlier versions of the patch. 154 132 155 133 Describe your changes in imperative mood, e.g. "make xyzzy do frotz" ··· 178 156 platform_set_drvdata(), but left the variable "dev" unused, 179 157 delete it. 180 158 159 + You should also be sure to use at least the first twelve characters of the 160 + SHA-1 ID. The kernel repository holds a *lot* of objects, making 161 + collisions with shorter IDs a real possibility. Bear in mind that, even if 162 + there is no collision with your six-character ID now, that condition may 163 + change five years from now. 164 + 181 165 If your patch fixes a bug in a specific commit, e.g. you found an issue using 182 166 git-bisect, please use the 'Fixes:' tag with the first 12 characters of the 183 - SHA-1 ID, and the one line summary. 184 - Example: 167 + SHA-1 ID, and the one line summary. For example: 185 168 186 169 Fixes: e21d2170f366 ("video: remove unnecessary platform_set_drvdata()") 187 170 ··· 199 172 fixes = Fixes: %h (\"%s\") 200 173 201 174 3) Separate your changes. 175 + ------------------------- 202 176 203 - Separate _logical changes_ into a single patch file. 177 + Separate each _logical change_ into a separate patch. 204 178 205 179 For example, if your changes include both bug fixes and performance 206 180 enhancements for a single driver, separate those changes into two ··· 212 184 group those changes into a single patch. Thus a single logical change 213 185 is contained within a single patch. 214 186 187 + The point to remember is that each patch should make an easily understood 188 + change that can be verified by reviewers. Each patch should be justifiable 189 + on its own merits. 190 + 215 191 If one patch depends on another patch in order for a change to be 216 192 complete, that is OK. Simply note "this patch depends on patch X" 217 193 in your patch description. 194 + 195 + When dividing your change into a series of patches, take special care to 196 + ensure that the kernel builds and runs properly after each patch in the 197 + series. Developers using "git bisect" to track down a problem can end up 198 + splitting your patch series at any point; they will not thank you if you 199 + introduce bugs in the middle. 218 200 219 201 If you cannot condense your patch set into a smaller set of patches, 220 202 then only post say 15 or so at a time and wait for review and integration. 221 203 222 204 223 205 224 - 4) Style check your changes. 206 + 4) Style-check your changes. 207 + ---------------------------- 225 208 226 209 Check your patch for basic style violations, details of which can be 227 210 found in Documentation/CodingStyle. Failure to do so simply wastes 228 211 the reviewers time and will get your patch rejected, probably 229 212 without even being read. 230 213 231 - At a minimum you should check your patches with the patch style 232 - checker prior to submission (scripts/checkpatch.pl). You should 233 - be able to justify all violations that remain in your patch. 214 + One significant exception is when moving code from one file to 215 + another -- in this case you should not modify the moved code at all in 216 + the same patch which moves it. This clearly delineates the act of 217 + moving the code and your changes. This greatly aids review of the 218 + actual differences and allows tools to better track the history of 219 + the code itself. 220 + 221 + Check your patches with the patch style checker prior to submission 222 + (scripts/checkpatch.pl). Note, though, that the style checker should be 223 + viewed as a guide, not as a replacement for human judgment. If your code 224 + looks better with a violation then its probably best left alone. 225 + 226 + The checker reports at three levels: 227 + - ERROR: things that are very likely to be wrong 228 + - WARNING: things requiring careful review 229 + - CHECK: things requiring thought 230 + 231 + You should be able to justify all violations that remain in your 232 + patch. 234 233 235 234 235 + 5) Select the recipients for your patch. 236 + ---------------------------------------- 236 237 237 - 5) Select e-mail destination. 238 + You should always copy the appropriate subsystem maintainer(s) on any patch 239 + to code that they maintain; look through the MAINTAINERS file and the 240 + source code revision history to see who those maintainers are. The 241 + script scripts/get_maintainer.pl can be very useful at this step. If you 242 + cannot find a maintainer for the subsystem your are working on, Andrew 243 + Morton (akpm@linux-foundation.org) serves as a maintainer of last resort. 238 244 239 - Look through the MAINTAINERS file and the source code, and determine 240 - if your change applies to a specific subsystem of the kernel, with 241 - an assigned maintainer. If so, e-mail that person. The script 242 - scripts/get_maintainer.pl can be very useful at this step. 245 + You should also normally choose at least one mailing list to receive a copy 246 + of your patch set. linux-kernel@vger.kernel.org functions as a list of 247 + last resort, but the volume on that list has caused a number of developers 248 + to tune it out. Look in the MAINTAINERS file for a subsystem-specific 249 + list; your patch will probably get more attention there. Please do not 250 + spam unrelated lists, though. 243 251 244 - If no maintainer is listed, or the maintainer does not respond, send 245 - your patch to the primary Linux kernel developer's mailing list, 246 - linux-kernel@vger.kernel.org. Most kernel developers monitor this 247 - e-mail list, and can comment on your changes. 248 - 252 + Many kernel-related lists are hosted on vger.kernel.org; you can find a 253 + list of them at http://vger.kernel.org/vger-lists.html. There are 254 + kernel-related lists hosted elsewhere as well, though. 249 255 250 256 Do not send more than 15 patches at once to the vger mailing lists!!! 251 257 252 - 253 258 Linus Torvalds is the final arbiter of all changes accepted into the 254 259 Linux kernel. His e-mail address is <torvalds@linux-foundation.org>. 255 - He gets a lot of e-mail, so typically you should do your best to -avoid- 260 + He gets a lot of e-mail, and, at this point, very few patches go through 261 + Linus directly, so typically you should do your best to -avoid- 256 262 sending him e-mail. 257 263 258 - Patches which are bug fixes, are "obvious" changes, or similarly 259 - require little discussion should be sent or CC'd to Linus. Patches 260 - which require discussion or do not have a clear advantage should 261 - usually be sent first to linux-kernel. Only after the patch is 262 - discussed should the patch then be submitted to Linus. 264 + If you have a patch that fixes an exploitable security bug, send that patch 265 + to security@kernel.org. For severe bugs, a short embargo may be considered 266 + to allow distrbutors to get the patch out to users; in such cases, 267 + obviously, the patch should not be sent to any public lists. 263 268 269 + Patches that fix a severe bug in a released kernel should be directed 270 + toward the stable maintainers by putting a line like this: 264 271 272 + Cc: stable@vger.kernel.org 265 273 266 - 6) Select your CC (e-mail carbon copy) list. 274 + into your patch. 267 275 268 - Unless you have a reason NOT to do so, CC linux-kernel@vger.kernel.org. 276 + Note, however, that some subsystem maintainers want to come to their own 277 + conclusions on which patches should go to the stable trees. The networking 278 + maintainer, in particular, would rather not see individual developers 279 + adding lines like the above to their patches. 269 280 270 - Other kernel developers besides Linus need to be aware of your change, 271 - so that they may comment on it and offer code review and suggestions. 272 - linux-kernel is the primary Linux kernel developer mailing list. 273 - Other mailing lists are available for specific subsystems, such as 274 - USB, framebuffer devices, the VFS, the SCSI subsystem, etc. See the 275 - MAINTAINERS file for a mailing list that relates specifically to 276 - your change. 277 - 278 - Majordomo lists of VGER.KERNEL.ORG at: 279 - <http://vger.kernel.org/vger-lists.html> 280 - 281 - If changes affect userland-kernel interfaces, please send 282 - the MAN-PAGES maintainer (as listed in the MAINTAINERS file) 283 - a man-pages patch, or at least a notification of the change, 284 - so that some information makes its way into the manual pages. 285 - 286 - Even if the maintainer did not respond in step #5, make sure to ALWAYS 287 - copy the maintainer when you change their code. 281 + If changes affect userland-kernel interfaces, please send the MAN-PAGES 282 + maintainer (as listed in the MAINTAINERS file) a man-pages patch, or at 283 + least a notification of the change, so that some information makes its way 284 + into the manual pages. User-space API changes should also be copied to 285 + linux-api@vger.kernel.org. 288 286 289 287 For small patches you may want to CC the Trivial Patch Monkey 290 288 trivial@kernel.org which collects "trivial" patches. Have a look 291 289 into the MAINTAINERS file for its current manager. 292 290 Trivial patches must qualify for one of the following rules: 293 291 Spelling fixes in documentation 294 - Spelling fixes which could break grep(1) 292 + Spelling fixes for errors which could break grep(1) 295 293 Warning fixes (cluttering with useless warnings is bad) 296 294 Compilation fixes (only if they are actually correct) 297 295 Runtime fixes (only if they actually fix things) 298 - Removing use of deprecated functions/macros (eg. check_region) 296 + Removing use of deprecated functions/macros 299 297 Contact detail and documentation fixes 300 298 Non-portable code replaced by portable code (even in arch-specific, 301 299 since people copy, as long as it's trivial) ··· 330 276 331 277 332 278 333 - 7) No MIME, no links, no compression, no attachments. Just plain text. 279 + 6) No MIME, no links, no compression, no attachments. Just plain text. 280 + ----------------------------------------------------------------------- 334 281 335 282 Linus and other kernel developers need to be able to read and comment 336 283 on the changes you are submitting. It is important for a kernel ··· 354 299 See Documentation/email-clients.txt for hints about configuring 355 300 your e-mail client so that it sends your patches untouched. 356 301 357 - 8) E-mail size. 358 - 359 - When sending patches to Linus, always follow step #7. 302 + 7) E-mail size. 303 + --------------- 360 304 361 305 Large changes are not appropriate for mailing lists, and some 362 306 maintainers. If your patch, uncompressed, exceeds 300 kB in size, 363 307 it is preferred that you store your patch on an Internet-accessible 364 - server, and provide instead a URL (link) pointing to your patch. 308 + server, and provide instead a URL (link) pointing to your patch. But note 309 + that if your patch exceeds 300 kB, it almost certainly needs to be broken up 310 + anyway. 311 + 312 + 8) Respond to review comments. 313 + ------------------------------ 314 + 315 + Your patch will almost certainly get comments from reviewers on ways in 316 + which the patch can be improved. You must respond to those comments; 317 + ignoring reviewers is a good way to get ignored in return. Review comments 318 + or questions that do not lead to a code change should almost certainly 319 + bring about a comment or changelog entry so that the next reviewer better 320 + understands what is going on. 321 + 322 + Be sure to tell the reviewers what changes you are making and to thank them 323 + for their time. Code review is a tiring and time-consuming process, and 324 + reviewers sometimes get grumpy. Even in that case, though, respond 325 + politely and address the problems they have pointed out. 365 326 366 327 328 + 9) Don't get discouraged - or impatient. 329 + ---------------------------------------- 367 330 368 - 9) Name your kernel version. 331 + After you have submitted your change, be patient and wait. Reviewers are 332 + busy people and may not get to your patch right away. 369 333 370 - It is important to note, either in the subject line or in the patch 371 - description, the kernel version to which this patch applies. 372 - 373 - If the patch does not apply cleanly to the latest kernel version, 374 - Linus will not apply it. 375 - 376 - 377 - 378 - 10) Don't get discouraged. Re-submit. 379 - 380 - After you have submitted your change, be patient and wait. If Linus 381 - likes your change and applies it, it will appear in the next version 382 - of the kernel that he releases. 383 - 384 - However, if your change doesn't appear in the next version of the 385 - kernel, there could be any number of reasons. It's YOUR job to 386 - narrow down those reasons, correct what was wrong, and submit your 387 - updated change. 388 - 389 - It is quite common for Linus to "drop" your patch without comment. 390 - That's the nature of the system. If he drops your patch, it could be 391 - due to 392 - * Your patch did not apply cleanly to the latest kernel version. 393 - * Your patch was not sufficiently discussed on linux-kernel. 394 - * A style issue (see section 2). 395 - * An e-mail formatting issue (re-read this section). 396 - * A technical problem with your change. 397 - * He gets tons of e-mail, and yours got lost in the shuffle. 398 - * You are being annoying. 399 - 400 - When in doubt, solicit comments on linux-kernel mailing list. 334 + Once upon a time, patches used to disappear into the void without comment, 335 + but the development process works more smoothly than that now. You should 336 + receive comments within a week or so; if that does not happen, make sure 337 + that you have sent your patches to the right place. Wait for a minimum of 338 + one week before resubmitting or pinging reviewers - possibly longer during 339 + busy times like merge windows. 401 340 402 341 403 - 404 - 11) Include PATCH in the subject 342 + 10) Include PATCH in the subject 343 + -------------------------------- 405 344 406 345 Due to high e-mail traffic to Linus, and to linux-kernel, it is common 407 346 convention to prefix your subject line with [PATCH]. This lets Linus ··· 404 355 405 356 406 357 407 - 12) Sign your work 358 + 11) Sign your work 359 + ------------------ 408 360 409 361 To improve tracking of who did what, especially with patches that can 410 362 percolate to their final resting place in the kernel through several ··· 479 429 Special note to back-porters: It seems to be a common and useful practice 480 430 to insert an indication of the origin of a patch at the top of the commit 481 431 message (just after the subject line) to facilitate tracking. For instance, 482 - here's what we see in 2.6-stable : 432 + here's what we see in a 3.x-stable release: 483 433 484 - Date: Tue May 13 19:10:30 2008 +0000 434 + Date: Tue Oct 7 07:26:38 2014 -0400 485 435 486 - SCSI: libiscsi regression in 2.6.25: fix nop timer handling 436 + libata: Un-break ATA blacklist 487 437 488 - commit 4cf1043593db6a337f10e006c23c69e5fc93e722 upstream 438 + commit 1c40279960bcd7d52dbdf1d466b20d24b99176c8 upstream. 489 439 490 - And here's what appears in 2.4 : 440 + And here's what might appear in an older kernel once a patch is backported: 491 441 492 442 Date: Tue May 13 22:12:27 2008 +0200 493 443 ··· 496 446 [backport of 2.6 commit b7acbdfbd1f277c1eb23f344f899cfa4cd0bf36a] 497 447 498 448 Whatever the format, this information provides a valuable help to people 499 - tracking your trees, and to people trying to trouble-shoot bugs in your 449 + tracking your trees, and to people trying to troubleshoot bugs in your 500 450 tree. 501 451 502 452 503 - 13) When to use Acked-by: and Cc: 453 + 12) When to use Acked-by: and Cc: 454 + --------------------------------- 504 455 505 456 The Signed-off-by: tag indicates that the signer was involved in the 506 457 development of the patch, or that he/she was in the patch's delivery path. 507 458 508 459 If a person was not directly involved in the preparation or handling of a 509 460 patch but wishes to signify and record their approval of it then they can 510 - arrange to have an Acked-by: line added to the patch's changelog. 461 + ask to have an Acked-by: line added to the patch's changelog. 511 462 512 463 Acked-by: is often used by the maintainer of the affected code when that 513 464 maintainer neither contributed to nor forwarded the patch. ··· 516 465 Acked-by: is not as formal as Signed-off-by:. It is a record that the acker 517 466 has at least reviewed the patch and has indicated acceptance. Hence patch 518 467 mergers will sometimes manually convert an acker's "yep, looks good to me" 519 - into an Acked-by:. 468 + into an Acked-by: (but note that it is usually better to ask for an 469 + explicit ack). 520 470 521 471 Acked-by: does not necessarily indicate acknowledgement of the entire patch. 522 472 For example, if a patch affects multiple subsystems and has an Acked-by: from ··· 529 477 If a person has had the opportunity to comment on a patch, but has not 530 478 provided such comments, you may optionally add a "Cc:" tag to the patch. 531 479 This is the only tag which might be added without an explicit action by the 532 - person it names. This tag documents that potentially interested parties 533 - have been included in the discussion 480 + person it names - but it should indicate that this person was copied on the 481 + patch. This tag documents that potentially interested parties 482 + have been included in the discussion. 534 483 535 484 536 - 14) Using Reported-by:, Tested-by:, Reviewed-by:, Suggested-by: and Fixes: 485 + 13) Using Reported-by:, Tested-by:, Reviewed-by:, Suggested-by: and Fixes: 486 + -------------------------------------------------------------------------- 537 487 538 488 The Reported-by tag gives credit to people who find bugs and report them and it 539 489 hopefully inspires them to help us again in the future. Please note that if ··· 595 541 method for indicating a bug fixed by the patch. See #2 above for more details. 596 542 597 543 598 - 15) The canonical patch format 544 + 14) The canonical patch format 545 + ------------------------------ 546 + 547 + This section describes how the patch itself should be formatted. Note 548 + that, if you have your patches stored in a git repository, proper patch 549 + formatting can be had with "git format-patch". The tools cannot create 550 + the necessary text, though, so read the instructions below anyway. 599 551 600 552 The canonical patch subject line is: 601 553 ··· 609 549 610 550 The canonical patch message body contains the following: 611 551 612 - - A "from" line specifying the patch author. 552 + - A "from" line specifying the patch author (only needed if the person 553 + sending the patch is not the author). 613 554 614 555 - An empty line. 615 556 ··· 717 656 references. 718 657 719 658 720 - 16) Sending "git pull" requests (from Linus emails) 659 + 15) Sending "git pull" requests 660 + ------------------------------- 721 661 722 - Please write the git repo address and branch name alone on the same line 723 - so that I can't even by mistake pull from the wrong branch, and so 724 - that a triple-click just selects the whole thing. 662 + If you have a series of patches, it may be most convenient to have the 663 + maintainer pull them directly into the subsystem repository with a 664 + "git pull" operation. Note, however, that pulling patches from a developer 665 + requires a higher degree of trust than taking patches from a mailing list. 666 + As a result, many subsystem maintainers are reluctant to take pull 667 + requests, especially from new, unknown developers. If in doubt you can use 668 + the pull request as the cover letter for a normal posting of the patch 669 + series, giving the maintainer the option of using either. 725 670 726 - So the proper format is something along the lines of: 671 + A pull request should have [GIT] or [PULL] in the subject line. The 672 + request itself should include the repository name and the branch of 673 + interest on a single line; it should look something like: 727 674 728 - "Please pull from 675 + Please pull from 729 676 730 - git://jdelvare.pck.nerim.net/jdelvare-2.6 i2c-for-linus 677 + git://jdelvare.pck.nerim.net/jdelvare-2.6 i2c-for-linus 731 678 732 - to get these changes:" 679 + to get these changes:" 733 680 734 - so that I don't have to hunt-and-peck for the address and inevitably 735 - get it wrong (actually, I've only gotten it wrong a few times, and 736 - checking against the diffstat tells me when I get it wrong, but I'm 737 - just a lot more comfortable when I don't have to "look for" the right 738 - thing to pull, and double-check that I have the right branch-name). 681 + A pull request should also include an overall message saying what will be 682 + included in the request, a "git shortlog" listing of the patches 683 + themselves, and a diffstat showing the overall effect of the patch series. 684 + The easiest way to get all this information together is, of course, to let 685 + git do it for you with the "git request-pull" command. 739 686 687 + Some maintainers (including Linus) want to see pull requests from signed 688 + commits; that increases their confidence that the request actually came 689 + from you. Linus, in particular, will not pull from public hosting sites 690 + like GitHub in the absence of a signed tag. 740 691 741 - Please use "git diff -M --stat --summary" to generate the diffstat: 742 - the -M enables rename detection, and the summary enables a summary of 743 - new/deleted or renamed files. 692 + The first step toward creating such tags is to make a GNUPG key and get it 693 + signed by one or more core kernel developers. This step can be hard for 694 + new developers, but there is no way around it. Attending conferences can 695 + be a good way to find developers who can sign your key. 744 696 745 - With rename detection, the statistics are rather different [...] 746 - because git will notice that a fair number of the changes are renames. 697 + Once you have prepared a patch series in git that you wish to have somebody 698 + pull, create a signed tag with "git tag -s". This will create a new tag 699 + identifying the last commit in the series and containing a signature 700 + created with your private key. You will also have the opportunity to add a 701 + changelog-style message to the tag; this is an ideal place to describe the 702 + effects of the pull request as a whole. 747 703 748 - ----------------------------------- 749 - SECTION 2 - HINTS, TIPS, AND TRICKS 750 - ----------------------------------- 704 + If the tree the maintainer will be pulling from is not the repository you 705 + are working from, don't forget to push the signed tag explicitly to the 706 + public tree. 751 707 752 - This section lists many of the common "rules" associated with code 753 - submitted to the kernel. There are always exceptions... but you must 754 - have a really good reason for doing so. You could probably call this 755 - section Linus Computer Science 101. 708 + When generating your pull request, use the signed tag as the target. A 709 + command like this will do the trick: 756 710 757 - 758 - 759 - 1) Read Documentation/CodingStyle 760 - 761 - Nuff said. If your code deviates too much from this, it is likely 762 - to be rejected without further review, and without comment. 763 - 764 - One significant exception is when moving code from one file to 765 - another -- in this case you should not modify the moved code at all in 766 - the same patch which moves it. This clearly delineates the act of 767 - moving the code and your changes. This greatly aids review of the 768 - actual differences and allows tools to better track the history of 769 - the code itself. 770 - 771 - Check your patches with the patch style checker prior to submission 772 - (scripts/checkpatch.pl). The style checker should be viewed as 773 - a guide not as the final word. If your code looks better with 774 - a violation then its probably best left alone. 775 - 776 - The checker reports at three levels: 777 - - ERROR: things that are very likely to be wrong 778 - - WARNING: things requiring careful review 779 - - CHECK: things requiring thought 780 - 781 - You should be able to justify all violations that remain in your 782 - patch. 783 - 784 - 785 - 786 - 2) #ifdefs are ugly 787 - 788 - Code cluttered with ifdefs is difficult to read and maintain. Don't do 789 - it. Instead, put your ifdefs in a header, and conditionally define 790 - 'static inline' functions, or macros, which are used in the code. 791 - Let the compiler optimize away the "no-op" case. 792 - 793 - Simple example, of poor code: 794 - 795 - dev = alloc_etherdev (sizeof(struct funky_private)); 796 - if (!dev) 797 - return -ENODEV; 798 - #ifdef CONFIG_NET_FUNKINESS 799 - init_funky_net(dev); 800 - #endif 801 - 802 - Cleaned-up example: 803 - 804 - (in header) 805 - #ifndef CONFIG_NET_FUNKINESS 806 - static inline void init_funky_net (struct net_device *d) {} 807 - #endif 808 - 809 - (in the code itself) 810 - dev = alloc_etherdev (sizeof(struct funky_private)); 811 - if (!dev) 812 - return -ENODEV; 813 - init_funky_net(dev); 814 - 815 - 816 - 817 - 3) 'static inline' is better than a macro 818 - 819 - Static inline functions are greatly preferred over macros. 820 - They provide type safety, have no length limitations, no formatting 821 - limitations, and under gcc they are as cheap as macros. 822 - 823 - Macros should only be used for cases where a static inline is clearly 824 - suboptimal [there are a few, isolated cases of this in fast paths], 825 - or where it is impossible to use a static inline function [such as 826 - string-izing]. 827 - 828 - 'static inline' is preferred over 'static __inline__', 'extern inline', 829 - and 'extern __inline__'. 830 - 831 - 832 - 833 - 4) Don't over-design. 834 - 835 - Don't try to anticipate nebulous future cases which may or may not 836 - be useful: "Make it as simple as you can, and no simpler." 837 - 711 + git request-pull master git://my.public.tree/linux.git my-signed-tag 838 712 839 713 840 714 ---------------------- 841 - SECTION 3 - REFERENCES 715 + SECTION 2 - REFERENCES 842 716 ---------------------- 843 717 844 718 Andrew Morton, "The perfect patch" (tpp).