From f6b1cc27cd267919218dc7727bd87dbc874d5d2e Mon Sep 17 00:00:00 2001 From: "Jes B. Klinke" Date: Fri, 20 Jan 2023 23:15:25 -0800 Subject: common/hooks.h: Tolerate same function registered as multiple hooks The file clock-stm32l4.c registers the function clock_chipset_startup as both HOOK_CHIPSET_STARTUP and HOOK_CHIPSET_RESUME. Before this change, compiling with hooks disabled would lead to a linker error as a function unused_hook_clock_chipset_startup() would be declared twice. This change makes it such that the hook, as well as the name of the registered function is concatenated into the synthetic function name. BUG=b:192262089 TEST=make BOARD=hyperdebug Change-Id: Ic7ead88e2fd86d509769a1c0a88a788b72576238 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4183953 Tested-by: Jes Klinke Commit-Queue: Jes Klinke Reviewed-by: Brian Nemec --- include/hooks.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/hooks.h b/include/hooks.h index aebf7a3c7e..a1bb97e55d 100644 --- a/include/hooks.h +++ b/include/hooks.h @@ -396,10 +396,10 @@ int hook_call_deferred(const struct deferred_data *data, int us); * CONFIG_COMMON_RUNTIME nor CONFIG_PLATFORM_EC_HOOKS is defined) */ #define hook_call_deferred(unused1, unused2) -1 -#define DECLARE_HOOK(t, func, p) \ - void CONCAT2(unused_hook_, func)(void) \ - { \ - func(); \ +#define DECLARE_HOOK(t, func, p) \ + void CONCAT4(unused_hook_, t, _, func)(void) \ + { \ + func(); \ } #define DECLARE_DEFERRED(func) \ void CONCAT2(unused_deferred_, func)(void) \ -- cgit v1.2.1