@@ -43,4 +43,14 @@
*/
#define IS_MODULE(option) config_enabled(option##_MODULE)
+
+/*
+ * IS_DEPENDENCY_SATISFIED(CONFIG_SELF, CONFIG_FOO) evaluates to 1 if
+ * CONFIG_FOO is set to 'y' or 'm', and set the same as CONFIG_SELF.
+ * Useful for specifying build-time config dependencies.
+ */
+#define IS_DEPENDENCY_SATISFIED(self, dependency) \
+ ((config_enabled(self) && config_enabled(dependency)) || \
+ (config_enabled(self##_MODULE) && config_enabled(dependency##_MODULE)))
+
#endif /* __LINUX_KCONFIG_H */
Most of the time, when we use IS_ENABLED() it's to specify a dependency on a config option that might be enabled. But if this option is enabled as a module, and we are built-in, then we'll have missing symbols. This new macro is therefore useful to specify a dependency on another config. But it also needs to know our own config option in order to check if the dependency is properly satisfied. IS_DEPENDENCY_SATISFIED(CONFIG_SELF, CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm', and set the same as CONFIG_SELF. It evaluates to 0 otherwise. Signed-off-by: Anisse Astier <anisse@astier.eu> --- include/linux/kconfig.h | 10 ++++++++++ 1 file changed, 10 insertions(+)