From 6ed59a76a0d1250059b8cdd61e0c3cf0f25b5a69 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Tue, 22 Jun 2021 10:26:12 +0200 Subject: common: move workqueue handling from poller_call() to sched() Workqueues are run out of poller_call, not because of a dependency, but because when they were added, poller_call was directly called from is_timeout. With the addition of bthreads, there is now a general resched() function that runs pollers and switches between bthreads. It makes sense to move workqueue handling there as well to keep scheduling matter contained in a single function. Do so. Signed-off-by: Ahmad Fatoum Link: https://lore.barebox.org/20210622082617.18011-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer --- common/poller.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'common/poller.c') diff --git a/common/poller.c b/common/poller.c index 61da5698d2..0409d3cf81 100644 --- a/common/poller.c +++ b/common/poller.c @@ -10,11 +10,14 @@ #include #include #include -#include -#include static LIST_HEAD(poller_list); -int poller_active; +static int __poller_active; + +bool poller_active(void) +{ + return __poller_active; +} int poller_register(struct poller_struct *poller, const char *name) { @@ -110,23 +113,13 @@ int poller_async_unregister(struct poller_async *pa) void poller_call(void) { struct poller_struct *poller, *tmp; - bool run_workqueues = !slice_acquired(&command_slice); - - if (poller_active) - return; - - command_slice_acquire(); - - if (run_workqueues) - wq_do_all_works(); - poller_active = 1; + __poller_active = 1; list_for_each_entry_safe(poller, tmp, &poller_list, list) poller->func(poller); - command_slice_release(); - poller_active = 0; + __poller_active = 0; } #if defined CONFIG_CMD_POLLER -- cgit v1.2.3