This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:users:drivers:ath10k:codingstyle [2023/08/01 18:24] Jeff Johnson nits |
en:users:drivers:ath10k:codingstyle [2024/05/05 04:24] (current) Kalle Valo [Tools] Add missing include |
||
---|---|---|---|
Line 5: | Line 5: | ||
- | ===== ath10k Coding Style ===== | + | ===== ath10k/ath11k/ath12k Coding Style ===== |
+ | ==== Introduction ==== | ||
- | ==== Linux coding style ==== | + | This is the coding style document for [[en/users/Drivers/ath10k|ath10k]], [[en/users/Drivers/ath11k|ath11k]] and [[en/users/Drivers/ath12k|ath12k]] drivers. Read this before writing any code. |
+ | |||
+ | ==== Tools ===== | ||
+ | |||
+ | Use latest GCC which you can download from [[https://mirrors.edge.kernel.org/pub/tools/crosstool/|crosstool]]. Setting it up is easy, unpack it to a directory and create a GNUmakefile in Linux sources top-level directory: | ||
+ | |||
+ | <code> | ||
+ | ARCH=x86 | ||
+ | CROSS_COMPILE=/opt/cross/gcc-13.2.0-nolibc/x86_64-linux/bin/x86_64-linux- | ||
+ | |||
+ | export ARCH | ||
+ | export CROSS_COMPILE | ||
+ | include Makefile | ||
+ | </code> | ||
- | ath10k mostly follows [[https://www.kernel.org/doc/html/latest/process/coding-style.html|Linux Coding Style]], so read that first. | + | You will need [[https://docs.kernel.org/dev-tools/sparse.html#getting-sparse|the latest sparse from git]]. Linux distros usually have too old sparse and you will see wrong errors! |
==== Checking code ==== | ==== Checking code ==== | ||
- | For checking the code we have a dedicated script [[https://github.com/qca/qca-swiss-army-knife/blob/master/tools/scripts/ath10k/ath10k-check|ath10k-check]] which runs various tests, including sparse and checkpatch. Run the script with ''--help'' to see the installation and usage instructions. Strongly recommended to run this before submitting patches as it can catch common problems. Example: | + | For checking the code we have dedicated scripts for each driver: |
+ | |||
+ | * [[https://github.com/qca/qca-swiss-army-knife/blob/master/tools/scripts/ath10k/ath10k-check|ath10k-check]] | ||
+ | * [[https://github.com/qca/qca-swiss-army-knife/blob/master/tools/scripts/ath11k/ath11k-check|ath11k-check]] | ||
+ | * [[https://github.com/qca/qca-swiss-army-knife/blob/master/tools/scripts/ath12k/ath12k-check|ath12k-check]] | ||
+ | |||
+ | They run various tests, including sparse and checkpatch. Run the script with ''--help'' to see the installation and usage instructions. ''--version'' shows version information for all dependencies, include that when reporting a problem. | ||
+ | |||
+ | It is required to run the check script before submitting patches as it can catch common problems. There must not be any warnings! | ||
+ | |||
+ | An example how to run the script: | ||
<code> | <code> | ||
Line 46: | Line 70: | ||
~/ath$ | ~/ath$ | ||
</code> | </code> | ||
+ | |||
+ | ==== Linux coding style ==== | ||
+ | |||
+ | ath10k/ath11k/ath12k mostly follows [[https://docs.kernel.org/process/coding-style.html|Linux Coding Style]], so read that first. | ||
==== Status/error variables ==== | ==== Status/error variables ==== | ||
Line 111: | Line 139: | ||
ath10k_warn() is used for errors where it might be possible to recover and ath10k_err() for errors when it's not possible to recover in any way. | ath10k_warn() is used for errors where it might be possible to recover and ath10k_err() for errors when it's not possible to recover in any way. | ||
- | Dan Carpenters g+ post about error paths: [[https://plus.google.com/u/0/106378716002406849458/posts/dnanfhQ4mHQ|https://plus.google.com/u/0/106378716002406849458/posts/dnanfhQ4mHQ]] | + | Dan Carpenter's post about error paths: [[https://staticthinking.wordpress.com/2022/04/28/free-the-last-thing-style/|https://staticthinking.wordpress.com/2022/04/28/free-the-last-thing-style/]] |