Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: kconfig: Mention IS_REACHABLE as way for optional dependency

Several drivers express optional Kconfig dependency with FOO || !FOO,
but for many choices this is not suitable: lack of stubs for !FOO
like in HWMON. Describe the second, less favorable way of optional
dependency with IS_REACHABLE by moving the code from "imply" chapter to
"Optional dependencies".

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Masahiro Yamada
700bd25b d0beb73d

+18 -11
+18 -11
Documentation/kbuild/kconfig-language.rst
··· 194 194 ability to hook into a secondary subsystem while allowing the user to 195 195 configure that subsystem out without also having to unset these drivers. 196 196 197 - Note: If the combination of FOO=y and BAZ=m causes a link error, 198 - you can guard the function call with IS_REACHABLE():: 199 - 200 - foo_init() 201 - { 202 - if (IS_REACHABLE(CONFIG_BAZ)) 203 - baz_register(&foo); 204 - ... 205 - } 206 - 207 197 Note: If the feature provided by BAZ is highly desirable for FOO, 208 198 FOO should imply not only BAZ, but also its dependency BAR:: 209 199 ··· 578 588 depends on BAR || !BAR 579 589 580 590 This means that there is either a dependency on BAR that disallows 581 - the combination of FOO=y with BAR=m, or BAR is completely disabled. 591 + the combination of FOO=y with BAR=m, or BAR is completely disabled. The BAR 592 + module must provide all the stubs for !BAR case. 593 + 582 594 For a more formalized approach if there are multiple drivers that have 583 595 the same dependency, a helper symbol can be used, like:: 584 596 ··· 590 598 591 599 config BAR_OPTIONAL 592 600 def_tristate BAR || !BAR 601 + 602 + Much less favorable way to express optional dependency is IS_REACHABLE() within 603 + the module code, useful for example when the module BAR does not provide 604 + !BAR stubs:: 605 + 606 + foo_init() 607 + { 608 + if (IS_REACHABLE(CONFIG_BAR)) 609 + bar_register(&foo); 610 + ... 611 + } 612 + 613 + IS_REACHABLE() is generally discouraged, because the code will be silently 614 + discarded, when CONFIG_BAR=m and this code is built-in. This is not what users 615 + usually expect when enabling BAR as module. 593 616 594 617 Kconfig recursive dependency limitations 595 618 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~