097ff01fb9
At present if an optional Kconfig value needs to be used it must be bracketed by #ifdef. For example, with this Kconfig setup: config WIBBLE bool "Support wibbles, the world needs more wibbles" config WIBBLE_ADDR hex "Address of the wibble" depends on WIBBLE then the following code must be used: #ifdef CONFIG_WIBBLE static void handle_wibble(void) { int val = CONFIG_WIBBLE_ADDR; ... } #endif static void init_machine() { ... #ifdef CONFIG_WIBBLE handle_wibble(); #endif } Add a new IF_ENABLED_INT() to help with this. So now it is possible to write, without #ifdefs: static void handle_wibble(void) { int val = IF_ENABLED_INT(CONFIG_WIBBLE, CONFIG_WIBBLE_ADDR); ... } static void init_machine() { ... if (IS_ENABLED(CONFIG_WIBBLE)) handle_wibble(); } The value will be CONFIG_WIBBLE_ADDR if CONFIG_WIBBLE is defined and will produce a build error if not.. This allows us to reduce the use of #ifdef in the code, ensuring that the compiler still checks the code even if it is not ultimately used for a particular build. Add a CONFIG_IF_ENABLED_INT() version as well. If an attempt is made to use a value that does not exist (i.e. when the conditional is not enabled), an error about a non-existing function is generated, e.g.: common/bloblist.c:447: undefined reference to `invalid_use_of_IF_ENABLED_INT' Signed-off-by: Simon Glass <sjg@chromium.org> |
||
---|---|---|
.. | ||
byteorder | ||
clk | ||
mtd | ||
soc/ti | ||
unaligned | ||
usb | ||
apm_bios.h | ||
arm-smccc.h | ||
asn1_ber_bytecode.h | ||
asn1_decoder.h | ||
asn1.h | ||
bch.h | ||
bitfield.h | ||
bitmap.h | ||
bitops.h | ||
bitrev.h | ||
bug.h | ||
build_bug.h | ||
clk-provider.h | ||
compat.h | ||
compiler_attributes.h | ||
compiler_types.h | ||
compiler-clang.h | ||
compiler-gcc.h | ||
compiler-intel.h | ||
compiler.h | ||
completion.h | ||
const.h | ||
crc7.h | ||
crc32.h | ||
ctype.h | ||
delay.h | ||
dma-direction.h | ||
dma-mapping.h | ||
drm_dp_helper.h | ||
edd.h | ||
err.h | ||
errno.h | ||
ethtool.h | ||
fb.h | ||
if_ether.h | ||
if_vlan.h | ||
immap_qe.h | ||
input.h | ||
intel-smc.h | ||
io.h | ||
ioctl.h | ||
iopoll.h | ||
ioport.h | ||
kbuild.h | ||
kconfig.h | ||
kernel.h | ||
libfdt_env.h | ||
libfdt.h | ||
linkage.h | ||
linux_string.h | ||
list_sort.h | ||
list.h | ||
log2.h | ||
lzo.h | ||
math64.h | ||
mbus.h | ||
mc146818rtc.h | ||
mdio.h | ||
mii.h | ||
netdevice.h | ||
oid_registry.h | ||
poison.h | ||
posix_types.h | ||
printk.h | ||
pruss_driver.h | ||
psci.h | ||
rational.h | ||
rbtree_augmented.h | ||
rbtree.h | ||
screen_info.h | ||
serial_reg.h | ||
sizes.h | ||
stat.h | ||
stddef.h | ||
string.h | ||
stringify.h | ||
time.h | ||
typecheck.h | ||
types.h | ||
utf.h | ||
xxhash.h | ||
zstd.h |