path: root/include/poller.h
diff options
authorMarc Kleine-Budde <>2010-12-18 11:25:34 +0100
committerSascha Hauer <>2010-12-20 09:28:21 +0100
commit0277a663bcbebe5be82dc88235fcd0a1465bd5e8 (patch)
tree039e836f2a424149bbffe1c154319be43ef9fe38 /include/poller.h
parentf4b1ebd2fdbfb2fd2382de894e027d014d1505d8 (diff)
Add generic poll infrastructure
Barebox does not have interrupt functionality. Nevertheless it's sometimes useful to periodically call functions, like for example a heartbeat LED or watchdog reset. Instead of cluttering the code with calls to these functions this patch adds a generic polling infrastructure. Code which might run for longer now can call poller_call() periodically which in turn will call all registered pollers. This patch adds a call to poller_call in two generic pathes. First of them is getc() which covers waiting for uart input. Second is ctrlc() which should be called anyway from code which might run for longer. So instead adding poller_call directly to your code, consider checking ctrlc instead which also gives additional convenience to the user. The poller code is safe against reentrancy which means that it's safe to call poller_call inside a poller. Signed-off-by: Marc Kleine-Budde <> Signed-off-by: Sascha Hauer <>
Diffstat (limited to 'include/poller.h')
1 files changed, 31 insertions, 0 deletions
diff --git a/include/poller.h b/include/poller.h
new file mode 100644
index 0000000..dc98155
--- /dev/null
+++ b/include/poller.h
@@ -0,0 +1,31 @@
+ * Copyright (C) 2010 Marc Kleine-Budde <>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+#ifndef POLLER_H
+#define POLLER_H
+#include <linux/list.h>
+struct poller_struct {
+ void (*func)(struct poller_struct *poller);
+ struct list_head list;
+int poller_register(struct poller_struct *poller);
+int poller_unregister(struct poller_struct *poller);
+void poller_call(void);
+static inline void poller_call(void)
+#endif /* CONFIG_POLLER */
+#endif /* !POLLER_H */