u-boot/include/linux
Simon Glass 097ff01fb9 kconfig: Add support for conditional values
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>
2022-02-08 23:07:59 -05:00
..
byteorder include/linux/byteorder: Fix compilation of __constant_cpu_to_be32() 2021-12-19 09:50:47 +01:00
clk clk: at91: add pre-requisite headers for AT91 clock architecture 2020-09-22 11:27:18 +03:00
mtd mtd: Remove mtd_erase_callback() entirely 2021-10-23 15:47:33 +05:30
soc/ti firmware: ti_sci: Include linux/err.h in ti_sci_protocol.h 2021-09-17 14:47:03 -04:00
unaligned
usb WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
apm_bios.h WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
arm-smccc.h smccc: fix sign bit expansion 2021-01-27 16:58:57 -05:00
asn1_ber_bytecode.h cmd: add asn1_compiler 2019-12-06 16:44:20 -05:00
asn1_decoder.h cmd: add asn1_compiler 2019-12-06 16:44:20 -05:00
asn1.h cmd: add asn1_compiler 2019-12-06 16:44:20 -05:00
bch.h
bitfield.h linux/bitfield.h: Add primitives for manipulating bitfields both in host- and fixed-endian 2020-07-10 11:47:12 +02:00
bitmap.h linux: bitmap.h: Add find_next_zero_area function 2022-02-08 11:00:03 -05:00
bitops.h log: convert pr_*() to logging 2021-03-01 09:54:11 -05:00
bitrev.h
bug.h
build_bug.h build_bug.h: add wrapper for _Static_assert 2021-07-01 16:34:32 -04:00
clk-provider.h doc: replace @return by Return: 2022-01-19 18:11:34 +01:00
compat.h linux/compat.h: Remove debug() from spin_lock_irqsave() 2020-12-02 16:21:58 -05:00
compiler_attributes.h treewide: Convert macro and uses of __section(foo) to __section("foo") 2021-05-24 14:21:30 -04:00
compiler_types.h compilers: Introduce options for forcing inlining on SPL/TPL 2020-07-01 11:48:05 -04:00
compiler-clang.h compiler*.h: sync include/linux/compiler*.h with Linux 5.7-rc5 2020-07-01 11:48:05 -04:00
compiler-gcc.h compiler*.h: sync include/linux/compiler*.h with Linux 5.7-rc5 2020-07-01 11:48:05 -04:00
compiler-intel.h compiler*.h: sync include/linux/compiler*.h with Linux 5.7-rc5 2020-07-01 11:48:05 -04:00
compiler.h WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
completion.h compat linux: import completion from linux 4.18 2019-04-22 11:55:58 -04:00
const.h
crc7.h
crc32.h
ctype.h
delay.h
dma-direction.h
dma-mapping.h dma-mapping: Add header file for ARCH_DMA_MINALIGN 2020-06-02 13:06:11 -04:00
drm_dp_helper.h
edd.h
err.h linux err: make ERR_PTR/PTR_ERR architecture specific 2019-11-07 18:01:13 -05:00
errno.h
ethtool.h net: ethtool: Add ethernet speed macros for higher speeds 2021-07-26 09:18:45 +02:00
fb.h
if_ether.h
if_vlan.h include: import if_vlan.h from Linux 2021-11-23 09:57:55 +02:00
immap_qe.h mpc83xx: Introduce ARCH_MPC836* 2019-05-20 13:50:34 +02:00
input.h
intel-smc.h arm: socfpga: smc: Add function to get usercode 2021-04-08 17:29:13 +08:00
io.h include: linux: io: define devm_ioremap on board with ioremap 2019-04-22 11:55:58 -04:00
ioctl.h
iopoll.h iopoll: Add readl_poll_sleep_timeout 2020-05-11 01:30:49 +05:30
ioport.h WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
kbuild.h
kconfig.h kconfig: Add support for conditional values 2022-02-08 23:07:59 -05:00
kernel.h include: kernel.h: define SSIZE_MAX 2020-08-24 16:37:53 +02:00
libfdt_env.h fdt: Add INT32_MAX to kernel.h for libfdt 2019-11-04 18:15:32 -07:00
libfdt.h libfdt: split fdt_region declarations out to <fdt_region.h> 2020-04-26 14:24:08 -06:00
linkage.h
linux_string.h
list_sort.h
list.h WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
log2.h
lzo.h
math64.h
mbus.h
mc146818rtc.h
mdio.h
mii.h common: Move mii_init() function out of common.h 2019-12-02 18:23:13 -05:00
netdevice.h
oid_registry.h lib: add oid registry utility 2019-12-06 16:44:20 -05:00
poison.h
posix_types.h
printk.h log: convert pr_*() to logging 2021-03-01 09:54:11 -05:00
pruss_driver.h soc: ti: pruss: Add a platform driver for PRUSS in TI SoCs 2021-07-15 17:56:04 +05:30
psci.h psci: add features/reset2 support 2021-04-20 07:31:12 -04:00
rational.h lib: rational: copy the rational fraction lib routines from Linux 2021-06-11 16:34:52 +05:30
rbtree_augmented.h
rbtree.h
screen_info.h WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
serial_reg.h WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
sizes.h
stat.h
stddef.h stddef: Avoid warning with clang with offsetof() 2022-01-13 09:13:41 -07:00
string.h doc: replace @return by Return: 2022-01-19 18:11:34 +01:00
stringify.h
time.h linux/time.h: include vsprintf.h 2019-12-06 16:44:19 -05:00
typecheck.h
types.h common: Move type declarations to linux/types.h 2020-01-17 13:27:25 -05:00
utf.h usb: gadget: move utf8_to_utf16le to header file 2021-01-31 14:08:56 +01:00
xxhash.h lib: Add xxhash support 2019-05-05 08:48:50 -04:00
zstd.h doc: replace @return by Return: 2022-01-19 18:11:34 +01:00