summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-12-02 11:34:44 -0700
committerCommit Bot <commit-bot@chromium.org>2021-12-04 01:16:34 +0000
commit5b7bc8baba35bc816c7dc94768d9fae05c7b78ec (patch)
tree3186bcee6647e6def78b07551b7b8587b502c306
parentfdbc457cc80443829cb3b3cb9590d151d5ce7a78 (diff)
downloadchrome-ec-5b7bc8baba35bc816c7dc94768d9fae05c7b78ec.tar.gz
zephyr: Use a different way of handling no host commands
When CONFIG_PLATFORM_EC_HOSTCMD is not enabled we want to silently drop the handler routines from the build. The current approach works for gcc but not for clang. Use an exported function instead. BUG=b:208648337 BRANCH=none TEST=CQ and gitlab Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: I63f74e8081556c726472782f60bddbbfbc3e9bf0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3313320 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
-rw-r--r--zephyr/shim/include/zephyr_host_command.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/zephyr/shim/include/zephyr_host_command.h b/zephyr/shim/include/zephyr_host_command.h
index ae8e1f9ee3..138c8636c7 100644
--- a/zephyr/shim/include/zephyr_host_command.h
+++ b/zephyr/shim/include/zephyr_host_command.h
@@ -24,11 +24,17 @@
.version_mask = _version_mask, \
}
#else /* !CONFIG_PLATFORM_EC_HOSTCMD */
-#ifdef __clang__
-#define DECLARE_HOST_COMMAND(command, routine, version_mask)
-#else
-#define DECLARE_HOST_COMMAND(command, routine, version_mask) \
- enum ec_status (routine)(struct host_cmd_handler_args *args) \
- __attribute__((unused))
-#endif /* __clang__ */
+
+/*
+ * Create a fake routine to call the function. The linker should
+ * garbage-collect it since it is behind 'if (0)'
+ */
+#define DECLARE_HOST_COMMAND(command, routine, version_mask) \
+ int __remove_ ## command(void) \
+ { \
+ if (0) \
+ routine(NULL); \
+ return 0; \
+ }
+
#endif /* CONFIG_PLATFORM_EC_HOSTCMD */