summaryrefslogtreecommitdiff
path: root/common/hooks.c
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2016-03-29 11:27:53 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-04-19 12:23:52 -0700
commit95858f385c35fbe6a95f0bad72ade9290b2a2d41 (patch)
tree1b856056c3eca8180839383c863f6ea6b55f7b4c /common/hooks.c
parent69668a04436700071bc2a26400f5f52f0e499020 (diff)
downloadchrome-ec-95858f385c35fbe6a95f0bad72ade9290b2a2d41.tar.gz
Deferred: Remove hard coded number of deferreds
Previously the maximum number of deferred routines was specified by the the default maximum number of deferred routines you had to override this, and if you wanted fewer, you still payed the price of having the defer_until array statically allocated to be the maximum size. This change removes that define and instead creates the RAM state of the deferred routine (the time to wait until to call the deferred) when the deferred is declared. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j manually test on discovery-stm32f072 Change-Id: Id3db84ee1795226b7818c57f68c1f637567831dc Reviewed-on: https://chromium-review.googlesource.com/335597 Commit-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/hooks.c')
-rw-r--r--common/hooks.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/common/hooks.c b/common/hooks.c
index 1a1a1aa819..b6eb019b7c 100644
--- a/common/hooks.c
+++ b/common/hooks.c
@@ -52,7 +52,6 @@ static const struct hook_ptrs hook_list[] = {
};
/* Times for deferrable functions */
-static uint64_t defer_until[DEFERRABLE_MAX_COUNT];
static int defer_new_call;
static int hook_task_started;
@@ -141,10 +140,10 @@ int hook_call_deferred(const struct deferred_data *data, int us)
if (us == -1) {
/* Cancel */
- defer_until[i] = 0;
+ __deferred_until[i] = 0;
} else {
/* Set alarm */
- defer_until[i] = get_time().val + us;
+ __deferred_until[i] = get_time().val + us;
/*
* Flag that hook_call_deferred() has been called. If the hook
* task is already active, this will allow it to go through the
@@ -181,14 +180,14 @@ void hook_task(void)
/* Handle deferred routines */
for (i = 0; i < DEFERRED_FUNCS_COUNT; i++) {
- if (defer_until[i] && defer_until[i] < t) {
+ if (__deferred_until[i] && __deferred_until[i] < t) {
CPRINTS("hook call deferred 0x%p",
__deferred_funcs[i].routine);
/*
* Call deferred function. Clear timer first,
* so it can request itself be called later.
*/
- defer_until[i] = 0;
+ __deferred_until[i] = 0;
__deferred_funcs[i].routine();
}
}
@@ -220,14 +219,15 @@ void hook_task(void)
/* Wake earlier if needed by a deferred routine */
defer_new_call = 0;
+
for (i = 0; i < DEFERRED_FUNCS_COUNT && next > 0; i++) {
- if (!defer_until[i])
+ if (!__deferred_until[i])
continue;
- if (defer_until[i] < t)
+ if (__deferred_until[i] < t)
next = 0;
- else if (defer_until[i] - t < next)
- next = defer_until[i] - t;
+ else if (__deferred_until[i] - t < next)
+ next = __deferred_until[i] - t;
}
/*