mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 7/9] poller: allow to restrict the poller frequency
Date: Tue, 23 Dec 2014 19:21:56 +0100	[thread overview]
Message-ID: <1419358918-25569-7-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1419358918-25569-1-git-send-email-plagnioj@jcrosoft.com>

so we do not slow down barebox on too much polling
specialy on USB drivers

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 common/poller.c  | 11 ++++++++++-
 include/poller.h |  3 +++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/common/poller.c b/common/poller.c
index 496636d..58b105d 100644
--- a/common/poller.c
+++ b/common/poller.c
@@ -24,6 +24,9 @@ int poller_register(struct poller_struct *poller)
 	list_add_tail(&poller->list, &poller_list);
 	poller->registered = 1;
 
+	if (poller->frequency)
+		poller->poll_next = get_time_ns();
+
 	return 0;
 }
 
@@ -96,8 +99,14 @@ void poller_call(void)
 
 	poller_active = 1;
 
-	list_for_each_entry_safe(poller, tmp, &poller_list, list)
+	list_for_each_entry_safe(poller, tmp, &poller_list, list) {
+
+		if (poller->frequency && get_time_ns() < poller->poll_next)
+			continue;
 		poller->func(poller);
+		if (poller->frequency)
+			poller->poll_next += poller->frequency;
+	}
 
 	poller_active = 0;
 }
diff --git a/include/poller.h b/include/poller.h
index cda5b57..3568a80 100644
--- a/include/poller.h
+++ b/include/poller.h
@@ -14,6 +14,9 @@ struct poller_struct {
 	void (*func)(struct poller_struct *poller);
 	int registered;
 	struct list_head list;
+
+	uint64_t frequency;
+	uint64_t poll_next;
 };
 
 int poller_register(struct poller_struct *poller);
-- 
2.1.3


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

  parent reply	other threads:[~2014-12-23 18:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-23 17:07 [PATCH 0/9] versatilepb, console, graphichs serie Jean-Christophe PLAGNIOL-VILLARD
2014-12-23 18:21 ` [PATCH 1/9] kfifo: allow to pass a null point on kfifo_free Jean-Christophe PLAGNIOL-VILLARD
2014-12-23 18:21   ` [PATCH 2/9] efika-mx-smartbook: enable led hearbeat on mail Jean-Christophe PLAGNIOL-VILLARD
2015-01-05 10:36     ` Sascha Hauer
2014-12-23 18:21   ` [PATCH 3/9] grapric_utils: set_pixel only write 16bit in 16bit mode Jean-Christophe PLAGNIOL-VILLARD
2015-01-05 10:37     ` Sascha Hauer
2014-12-23 18:21   ` [PATCH 4/9] versatilepb: move barebox to 32 MiB and use zImage Jean-Christophe PLAGNIOL-VILLARD
2015-01-05 10:38     ` Sascha Hauer
2014-12-23 18:21   ` [PATCH 5/9] versatilepb: switch to defaultenv-2 Jean-Christophe PLAGNIOL-VILLARD
2015-01-05 10:38     ` Sascha Hauer
2014-12-23 18:21   ` [PATCH 6/9] console: factorize kfifo input support Jean-Christophe PLAGNIOL-VILLARD
2015-01-05 11:18     ` Sascha Hauer
2014-12-23 18:21   ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2015-01-05 10:42     ` [PATCH 7/9] poller: allow to restrict the poller frequency Sascha Hauer
2015-01-06  0:46       ` Jean-Christophe PLAGNIOL-VILLARD
2014-12-23 18:21   ` [PATCH 8/9] console: allow to specify the device id Jean-Christophe PLAGNIOL-VILLARD
2015-01-05 10:46     ` Sascha Hauer
2014-12-23 18:21   ` [PATCH 9/9] defaultenv-2: create a specific defaultenv for splash Jean-Christophe PLAGNIOL-VILLARD
2015-01-05 10:50     ` Sascha Hauer
2015-01-06  0:43       ` Jean-Christophe PLAGNIOL-VILLARD
2015-01-06 12:57         ` Sascha Hauer
2015-01-07  5:49           ` Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1419358918-25569-7-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox