From 4457e5c61d825a2673547e4cd60570a77fbcc3cd Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:27:51 +0200 Subject: cyclic: introduce u-boot/schedule.h I noticed an "unnecessary" include of in global_data.h, in the sense that nothing in cyclic.h is needed in order to define 'struct global_data'. Well, it's not unnecessary, as it implicitly ensures that everybody gets a declaration of schedule(), and schedule() is (obviously) called all over the tree. Almost none of those places directly include , but for historical reasons, many do include (most schedule() instances are replacements of WATCHDOG_RESET()). However, very few TUs actually need the declarations of the cyclic_register() and struct cyclic_info, and they also don't really need anything from the watchdog.h header. So introduce a new header which just contains a declaration of schedule(), which can then be included from all the places that do call schedule(). I removed the direct reference to cyclic_run(), because we shouldn't have two public functions for doing roughly the same without being very explicit about when one should call one or the other. Testing of later patches that explicitly include when schedule() is used revealed a problem with host tool build on win32, which apparently picked up a host . To avoid that problem, put the new header in include/u-boot/ and hence make the include statements say . Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- include/cyclic.h | 12 +----------- include/u-boot/schedule.h | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 include/u-boot/schedule.h (limited to 'include') diff --git a/include/cyclic.h b/include/cyclic.h index cd95b691d48..e8de616dcd5 100644 --- a/include/cyclic.h +++ b/include/cyclic.h @@ -13,6 +13,7 @@ #include #include +#include // to be removed later /** * struct cyclic_info - Information about cyclic execution function @@ -94,13 +95,6 @@ struct hlist_head *cyclic_get_list(void); */ void cyclic_run(void); -/** - * schedule() - Schedule all potentially waiting tasks - * - * Basically a wrapper for cyclic_run(), pontentially enhanced by some - * other parts, that need to get handled periodically. - */ -void schedule(void); #else static inline void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func, @@ -116,10 +110,6 @@ static inline void cyclic_run(void) { } -static inline void schedule(void) -{ -} - static inline int cyclic_unregister_all(void) { return 0; diff --git a/include/u-boot/schedule.h b/include/u-boot/schedule.h new file mode 100644 index 00000000000..4fd34c41229 --- /dev/null +++ b/include/u-boot/schedule.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _U_BOOT_SCHEDULE_H +#define _U_BOOT_SCHEDULE_H + +#if CONFIG_IS_ENABLED(CYCLIC) +/** + * schedule() - Schedule all potentially waiting tasks + * + * Run all pending tasks registered via the cyclic framework, and + * potentially perform other actions that need to be done + * periodically. + */ +void schedule(void); + +#else + +static inline void schedule(void) +{ +} + +#endif + +#endif -- cgit v1.2.3 From 307449de9058657eef544043013e8655468b3032 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:27:56 +0200 Subject: cyclic: make cyclic_run static The only caller left is schedule(); everybody outside cyclic.c now calls or references schedule(). Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- include/cyclic.h | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'include') diff --git a/include/cyclic.h b/include/cyclic.h index e8de616dcd5..c6c463d68e9 100644 --- a/include/cyclic.h +++ b/include/cyclic.h @@ -87,14 +87,6 @@ int cyclic_unregister_all(void); */ struct hlist_head *cyclic_get_list(void); -/** - * cyclic_run() - Interate over all registered cyclic functions - * - * Interate over all registered cyclic functions and if the it's function - * needs to be executed, then call into these registered functions. - */ -void cyclic_run(void); - #else static inline void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func, @@ -106,10 +98,6 @@ static inline void cyclic_unregister(struct cyclic_info *cyclic) { } -static inline void cyclic_run(void) -{ -} - static inline int cyclic_unregister_all(void) { return 0; -- cgit v1.2.3 From bd665754894ffe4ea01e43f4fc5d3ef4cba1689d Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:27:57 +0200 Subject: watchdog.h: change include of cyclic.h to u-boot/schedule.h Nobody relies on getting the cyclic API declared by including the watchdog.h header, but for historical reasons, many TUs include watchdog.h to get a declaration of schedule(). Now that we have a dedicated header for just that, include that header instead of cyclic.h. Eventually, all TUs that call schedule() should themselves include u-boot/schedule.h, but this is a step towards getting rid of unnecessary include statements in cyclic.h and global_data.h. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- include/watchdog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/watchdog.h b/include/watchdog.h index d1956fafca1..0149b44d077 100644 --- a/include/watchdog.h +++ b/include/watchdog.h @@ -10,7 +10,7 @@ #ifndef _WATCHDOG_H_ #define _WATCHDOG_H_ -#include +#include // to be removed later /* * Reset the watchdog timer, always returns 0 -- cgit v1.2.3 From 6459964d738fe74f2cec7bca7caa1de444bc9d54 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:28:02 +0200 Subject: global_data.h: remove unnecesary include of cyclic.h Nothing in cyclic.h is needed to define struct global_data, so do not include that header. If any .c file relies on getting cyclic.h through asm/global_data.h, it needs to include it itself. Signed-off-by: Rasmus Villemoes Reviewed-by: Tom Rini Reviewed-by: Stefan Roese --- include/asm-generic/global_data.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 644a0d77873..b84cc5bbecd 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -21,7 +21,6 @@ #ifndef __ASSEMBLY__ #include -#include #include #include #include -- cgit v1.2.3