mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] add generic polling infrastructure
@ 2010-09-15  7:26 Marc Kleine-Budde
  2010-09-15  7:26 ` [PATCH 1/3] poller: add poller support Marc Kleine-Budde
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2010-09-15  7:26 UTC (permalink / raw)
  To: barebox

This series add a polling infrastructure to barebox. It can be used
to call hardware watchdogs or poll devices to simulate interrupts.

cheers,
Marc


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] poller: add poller support
  2010-09-15  7:26 [PATCH 0/3] add generic polling infrastructure Marc Kleine-Budde
@ 2010-09-15  7:26 ` Marc Kleine-Budde
  2010-09-15  7:47   ` Jean-Christophe PLAGNIOL-VILLARD
  2010-09-15  7:26 ` [PATCH 2/3] clock: add poller call to is_timeout() Marc Kleine-Budde
  2010-09-15  7:26 ` [PATCH 3/3] unlzo: add poller call to unlzo routine Marc Kleine-Budde
  2 siblings, 1 reply; 6+ messages in thread
From: Marc Kleine-Budde @ 2010-09-15  7:26 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 common/Kconfig   |    3 +++
 common/Makefile  |    1 +
 common/poller.c  |   45 +++++++++++++++++++++++++++++++++++++++++++++
 include/poller.h |   32 ++++++++++++++++++++++++++++++++
 4 files changed, 81 insertions(+), 0 deletions(-)
 create mode 100644 common/poller.c
 create mode 100644 include/poller.h

diff --git a/common/Kconfig b/common/Kconfig
index 6556c62..77129bf 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -363,6 +363,9 @@ config DEFAULT_ENVIRONMENT_PATH
 	  Relative pathes will be relative to the barebox Toplevel dir, but absolute
 	  pathes are fine aswell.
 
+config POLLER
+	bool "generic polling infrastructure"
+
 endmenu
 
 menu "Debugging                     "
diff --git a/common/Makefile b/common/Makefile
index 4b8cce0..cd71044 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_OF_FLAT_TREE)	+= ft_build.o
 obj-$(CONFIG_KALLSYMS)		+= kallsyms.o
 obj-$(CONFIG_ENV_HANDLING)	+= environment.o
 obj-$(CONFIG_AUTO_COMPLETE)	+= complete.o
+obj-$(CONFIG_POLLER)		+= poller.o
 
 obj-y += dlmalloc.o
 obj-y += clock.o
diff --git a/common/poller.c b/common/poller.c
new file mode 100644
index 0000000..0583a53
--- /dev/null
+++ b/common/poller.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010 Marc Kleine-Budde <mkl@pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <malloc.h>
+#include <module.h>
+#include <param.h>
+#include <poller.h>
+
+static LIST_HEAD(poller_list);
+static int poller_active;
+
+int poller_register(struct poller_struct *poller)
+{
+	list_add_tail(&poller->list, &poller_list);
+
+	return 0;
+}
+
+int poller_unregister(struct poller_struct *poller)
+{
+	list_del(&poller->list);
+
+	return 0;
+}
+
+void poller_call(void)
+{
+	struct poller_struct *poller, *tmp;
+
+	if (poller_active)
+		return;
+
+	poller_active = 1;
+
+	list_for_each_entry_safe(poller, tmp, &poller_list, list)
+		poller->func(poller);
+
+	poller_active = 0;
+}
diff --git a/include/poller.h b/include/poller.h
new file mode 100644
index 0000000..622ceaa
--- /dev/null
+++ b/include/poller.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010 Marc Kleine-Budde <mkl@pengutronix.de>
+ *
+ * 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);
+
+
+#ifdef CONFIG_POLLER
+void poller_call(void);
+#else
+static inline void poller_call(void)
+{
+	return;
+}
+#endif	/* CMD_POLLER */
+
+#endif	/* !POLLER_H */
-- 
1.7.0.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/3] clock: add poller call to is_timeout()
  2010-09-15  7:26 [PATCH 0/3] add generic polling infrastructure Marc Kleine-Budde
  2010-09-15  7:26 ` [PATCH 1/3] poller: add poller support Marc Kleine-Budde
@ 2010-09-15  7:26 ` Marc Kleine-Budde
  2010-09-15  7:26 ` [PATCH 3/3] unlzo: add poller call to unlzo routine Marc Kleine-Budde
  2 siblings, 0 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2010-09-15  7:26 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 common/clock.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/common/clock.c b/common/clock.c
index 15df0ab..ec63526 100644
--- a/common/clock.c
+++ b/common/clock.c
@@ -27,6 +27,7 @@
 #include <common.h>
 #include <asm-generic/div64.h>
 #include <clock.h>
+#include <poller.h>
 
 static struct clocksource *current_clock;
 static uint64_t time_ns;
@@ -84,6 +85,8 @@ uint32_t clocksource_hz2mult(uint32_t hz, uint32_t shift_constant)
 
 int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
 {
+	poller_call();
+
 	if ((int64_t)(start_ns + time_offset_ns - get_time_ns()) < 0)
 		return 1;
 	else
-- 
1.7.0.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/3] unlzo: add poller call to unlzo routine
  2010-09-15  7:26 [PATCH 0/3] add generic polling infrastructure Marc Kleine-Budde
  2010-09-15  7:26 ` [PATCH 1/3] poller: add poller support Marc Kleine-Budde
  2010-09-15  7:26 ` [PATCH 2/3] clock: add poller call to is_timeout() Marc Kleine-Budde
@ 2010-09-15  7:26 ` Marc Kleine-Budde
  2 siblings, 0 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2010-09-15  7:26 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 lib/decompress_unlzo.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/lib/decompress_unlzo.c b/lib/decompress_unlzo.c
index 8f9cdcf..e9378c4 100644
--- a/lib/decompress_unlzo.c
+++ b/lib/decompress_unlzo.c
@@ -37,6 +37,7 @@
 #include <errno.h>
 #include <fs.h>
 #include <xfuncs.h>
+#include <poller.h>
 
 #include <linux/compiler.h>
 #include <asm/unaligned.h>
@@ -187,6 +188,8 @@ int unlzo(int in_fd, int out_fd, int *dest_len)
 		}
 
 		obytes_processed += dst_len;
+
+		poller_call();
 	}
 
 exit_free:
-- 
1.7.0.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] poller: add poller support
  2010-09-15  7:26 ` [PATCH 1/3] poller: add poller support Marc Kleine-Budde
@ 2010-09-15  7:47   ` Jean-Christophe PLAGNIOL-VILLARD
  2010-09-15  8:30     ` Marc Kleine-Budde
  0 siblings, 1 reply; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-09-15  7:47 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: barebox

Hi,

	a bit more info in the commit will be nice

	but we could name it differently as it could be see as interrupt

Best Regards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] poller: add poller support
  2010-09-15  7:47   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-09-15  8:30     ` Marc Kleine-Budde
  0 siblings, 0 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2010-09-15  8:30 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 1162 bytes --]

On 09/15/2010 09:47 AM, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Hi,
> 
> 	a bit more info in the commit will be nice

I should have put the information from the introduction mail to the
first patch. Here it comes:

This patch adds a generic polling infrastructure to barebox. It defines
a interface to add and remove functions that should be called during a
poll. These functions can be used to reset hardware watchdogs or poll
devices to simulate interrupts.

> 	but we could name it differently as it could be see as interrupt

Do you have a better name? I'm usually bad with good names, but I don't
want to have interrupts or something like this, because it's polling no
real interrupts. E.g. if you don't have the polling call in your
for-loop your code won't be interrupted. (..and it's usually not your
code that's missing the poller call).

cheers, Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-09-15  8:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-15  7:26 [PATCH 0/3] add generic polling infrastructure Marc Kleine-Budde
2010-09-15  7:26 ` [PATCH 1/3] poller: add poller support Marc Kleine-Budde
2010-09-15  7:47   ` Jean-Christophe PLAGNIOL-VILLARD
2010-09-15  8:30     ` Marc Kleine-Budde
2010-09-15  7:26 ` [PATCH 2/3] clock: add poller call to is_timeout() Marc Kleine-Budde
2010-09-15  7:26 ` [PATCH 3/3] unlzo: add poller call to unlzo routine Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox