summaryrefslogtreecommitdiff
path: root/doc/develop/codingstyle.rst
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2025-04-01 16:55:25 -0600
committerTom Rini <trini@konsulko.com>2025-04-11 12:16:44 -0600
commitfa72470a4ec5522fe92986bb53b22167d35d0913 (patch)
tree8fb582e2b8406dbda0bd019ad50bc3b8616a6568 /doc/develop/codingstyle.rst
parent0471f8d0012ff9794014d222151acb65ce387550 (diff)
doc/develop/codingstyle.rst: Expand to include CONFIG_IS_ENABLED and PHASE_
Expand the conditional compilation section to explain when to use CONFIG_IS_ENABLED rather than IS_ENABLED and provide an example. Next, note what the PHASE_ macro is supposed to be used for as well. Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'doc/develop/codingstyle.rst')
-rw-r--r--doc/develop/codingstyle.rst19
1 files changed, 19 insertions, 0 deletions
diff --git a/doc/develop/codingstyle.rst b/doc/develop/codingstyle.rst
index 7211e4e4eed..bc18b2ebb7b 100644
--- a/doc/develop/codingstyle.rst
+++ b/doc/develop/codingstyle.rst
@@ -192,6 +192,25 @@ inside the block, and check it for correctness (syntax, types, symbol
references, etc). Thus, you still have to use an #ifdef if the code inside the
block references symbols that will not exist if the condition is not met.
+When working with xPL (see :doc:`spl` for more information) we need to take
+further care to use the right macro. In the case where a symbol may be
+referenced with an xPL-specific Kconfig symbol, use the CONFIG_IS_ENABLED macro
+instead, in a similar manner:
+
+.. code-block:: c
+
+ if (CONIG_IS_ENABLED(SOMETHING)) {
+ ...
+ }
+
+When dealing with a Kconfig symbol that has both a normal name and one or more
+xPL-prefixed names, the Makefile needs special consideration as well. The
+PHASE\_ macro helps us in this situation thusly:
+
+.. code-block:: make
+
+ obj-$(CONFIG_$(PHASE_)SOMETHING) += something.o
+
At the end of any non-trivial #if or #ifdef block (more than a few lines),
place a comment after the #endif on the same line, noting the conditional
expression used. For instance: