Coding style guidelines for kernel developers
Many large projects specify their own set of coding guidelines; so does the Linux kernel community. Adhering to the Linux kernel coding style guidelines is a really good idea when writing kernel and/or kernel module code. You can see the style guidelines officially documented here: https://www.kernel.org/doc/html/latest/process/coding-style.html (please do read them!).
Furthermore, as part of the (quite exhaustive) code-submission checklist(s) for developers like you wanting to upstream your code, you are expected to run your patch through a Perl script that checks your code for congruence with the Linux kernel coding style: scripts/checkpatch.pl
.
By default, this script only runs on a well-formatted git
patch. It’s possible to run it against standalone C code (as in your out-of-tree kernel module code), as follows (as our “better” Makefile indeed does):
<kernel-src>/scripts/checkpatch.pl --no-tree...