Help you follow the coding style rules, specially useful for those
new to kernel development or working at the same time in several
projects with different coding styles.

Its configuration file is .clang-format in the root of the kernel tree.
The rules contained there try to approximate the most common kernel
coding style. They also try to follow Documentation/process/coding-style.rst
as much as possible. Since not all the kernel follows the same style,
it is possible that you may want to tweak the defaults for a particular
subsystem or folder. To do so, you can override the defaults by writing
another .clang-format file in a subfolder.

The tool itself has already been included in the repositories of popular
Linux distributions for a long time. Search for clang-format in
your repositories. Otherwise, you can either download pre-built
LLVM/clang binaries or build the source code from:

While it might be tempting to use this to keep a file always in sync with
clang-format, specially if you are writing new files or if you are
a maintainer, please note that people might be running different
clang-format versions or not have it available at all. Therefore,
you should probably refrain yourself from using this in kernel sources;
at least until we see if clang-format becomes commonplace.

By using an integration with your text editor, you can reformat arbitrary
blocks (selections) of code with a single keystroke. This is specially
useful when moving code around, for complex code that is deeply intended,
for multi-line macros (and aligning their backslashes), etc.

Remember that you can always tweak the changes afterwards in those cases
where the tool did not do an optimal job. But as a first approximation,
it can be very useful.

There are integrations for many popular text editors. For some of them,
like vim, emacs, BBEdit and Visual Studio you can find support built-in.
For instructions, read the appropiate section at:

Some features/style options are not enabled by default in the configuration
file in order to minimize the differences between the output and the current
code. In other words, to make the difference as small as possible,
which makes reviewing full-file style, as well diffs and patches as easy
as possible.

In other cases (e.g. particular subsystems/folders/files), the kernel style
might be different and enabling some of these options may approximate
better the style there.

For instance:

Aligning assignments (AlignConsecutiveAssignments).

Aligning declarations (AlignConsecutiveDeclarations).

Reflowing text in comments (ReflowComments).

Sorting #includes (SortIncludes).

They are typically useful for block re-formatting, rather than full-file.
You might want to create another .clang-format file and use that one
from your editor/IDE instead.