U-Boot Coding Style
The following Coding Style requirements shall be mandatory for all code contributed to
the U-Boot project.
Exceptions are only allowed if code from other projects is integrated with no
or only minimal changes.
The following rules apply:
- All contributions to U-Boot should conform to the Linux kernel
coding style; see the file
and the script
in your Linux kernel source
- Make sure to run the checkpatch.pl
script from the Linux source tree to check your patches. See also Patches for more comments on this tool.
Note that this should be done before posting on the mailing list!
- Source files originating from different projects (for example
the MTD subsystem or the hush shell code from the BusyBox
project) may, after careful consideration, be exempted from
these rules. For such files, the original coding style may be
kept to ease subsequent migration to newer versions of those
- Please note that U-Boot is implemented in C (and to some small
parts in Assembler); no C++ is used, so please do not use C++
style comments (//) in your code.
- Please also stick to the following formatting rules:
- Remove any trailing white space
- Use TAB characters for indentation
and vertical alignment, not spaces
- Make sure NOT to use DOS '\r\n' line feeds
- Do not add more than 2 consecutive empty lines to source files
- Do not add trailing empty lines to source files
- Using the option
git config --global color.diff auto will help
to visually see whitespace problems in
diff output from
- In Emacs one can use
M-x whitespace-global-mode to get visual
feedback on the nasty details.
M-x whitespace-cleanup does The Right Thing
Submissions of new code or patches that do not conform to these
requirements shall be rejected with a request to reformat the