diff options
author | Randall Spangler <rspangler@chromium.org> | 2013-03-29 16:34:02 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-04-02 14:12:55 -0700 |
commit | 5966f22a8a1928583943b57fc22e72f85d69d079 (patch) | |
tree | e49232c6d5368219faa63cae0ec5e01a4866f837 /common/extpower_gpio.c | |
parent | 97bf36c9d3ad3d96ad6dea7cd6e6f3e164297c43 (diff) | |
download | chrome-ec-5966f22a8a1928583943b57fc22e72f85d69d079.tar.gz |
Add support for calling deferred functions
This is a cleaner way of deferring work from interrupt-time to
task-time without requiring a task for each module which needs this.
Replaces/supersedes delayed hook notification, which didn't scale well
(since every function would have needed to be its own hook type).
BUG=chrome-os-partner:18473
BRANCH=none
TEST=boot system. plug/unplug AC power; notifies the host properly
Change-Id: I50263fe1ce37e74c1ef8db3671379098997102ed
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46953
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common/extpower_gpio.c')
-rw-r--r-- | common/extpower_gpio.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/common/extpower_gpio.c b/common/extpower_gpio.c index 218905f91d..4643b245de 100644 --- a/common/extpower_gpio.c +++ b/common/extpower_gpio.c @@ -17,19 +17,22 @@ int extpower_is_present(void) } /** - * Handle notification of external power change; forward it to host. + * Deferred function to handle external power change */ -static void extpower_changed(void) +static void extpower_deferred(void) { + hook_notify(HOOK_AC_CHANGE); + + /* Forward notification to host */ if (extpower_is_present()) host_set_single_event(EC_HOST_EVENT_AC_CONNECTED); else host_set_single_event(EC_HOST_EVENT_AC_DISCONNECTED); } -DECLARE_HOOK(HOOK_AC_CHANGE, extpower_changed, HOOK_PRIO_DEFAULT); +DECLARE_DEFERRED(extpower_deferred); void extpower_interrupt(enum gpio_signal signal) { /* Trigger deferred notification of external power change */ - hook_notify(HOOK_AC_CHANGE); + hook_call_deferred(extpower_deferred, 0); } |