[PATCH v3 12/16] common: poller: replace explicit calls to poller_call() with resched()

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Mar 10 08:47:56 GMT 2021


From: Ahmad Fatoum <ahmad at a3f.at>

We won't replace pollers with bthreads completely over night. To make
migration easier, replace explicit calls to poller_call with a new
resched() function. This can be made to call bthread_reschedule() in
future and eventually replaced with bthread_reschedule() once pollers
are removed.

Signed-off-by: Ahmad Fatoum <ahmad at a3f.at>
---
 common/clock.c   |  4 ++--
 common/console.c |  4 ++--
 include/sched.h  | 12 ++++++++++++
 lib/readline.c   |  4 ++--
 4 files changed, 18 insertions(+), 6 deletions(-)
 create mode 100644 include/sched.h

diff --git a/common/clock.c b/common/clock.c
index 7eeba88317ac..fa90d1a4576f 100644
--- a/common/clock.c
+++ b/common/clock.c
@@ -13,7 +13,7 @@
 #include <init.h>
 #include <linux/math64.h>
 #include <clock.h>
-#include <poller.h>
+#include <sched.h>
 
 static uint64_t time_ns;
 
@@ -172,7 +172,7 @@ int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
 	int ret = is_timeout_non_interruptible(start_ns, time_offset_ns);
 
 	if (time_offset_ns >= 100 * USECOND)
-		poller_call();
+		resched();
 
 	return ret;
 }
diff --git a/common/console.c b/common/console.c
index 306149c99ea1..a436c37aa3e8 100644
--- a/common/console.c
+++ b/common/console.c
@@ -17,7 +17,7 @@
 #include <clock.h>
 #include <kfifo.h>
 #include <module.h>
-#include <poller.h>
+#include <sched.h>
 #include <ratp_bb.h>
 #include <magicvar.h>
 #include <globalvar.h>
@@ -585,7 +585,7 @@ int ctrlc(void)
 	if (ctrlc_abort)
 		return 1;
 
-	poller_call();
+	resched();
 
 #ifdef ARCH_HAS_CTRLC
 	ret = arch_ctrlc();
diff --git a/include/sched.h b/include/sched.h
new file mode 100644
index 000000000000..43d239c3ef63
--- /dev/null
+++ b/include/sched.h
@@ -0,0 +1,12 @@
+/* SPDX License Identifier: GPL-2.0 */
+#ifndef __BAREBOX_SCHED_H_
+#define __BAREBOX_SCHED_H_
+
+#include <poller.h>
+
+static inline void resched(void)
+{
+	poller_call();
+}
+
+#endif
diff --git a/lib/readline.c b/lib/readline.c
index e5370f9c7b6e..25aa99b95e46 100644
--- a/lib/readline.c
+++ b/lib/readline.c
@@ -2,7 +2,7 @@
 #include <readkey.h>
 #include <init.h>
 #include <libbb.h>
-#include <poller.h>
+#include <sched.h>
 #include <xfuncs.h>
 #include <complete.h>
 #include <linux/ctype.h>
@@ -200,7 +200,7 @@ int readline(const char *prompt, char *buf, int len)
 
 	while (1) {
 		while (!tstc())
-			poller_call();
+			resched();
 
 		ichar = read_key();
 
-- 
2.29.2




More information about the barebox mailing list