diff options
author | Anton Staaf <robotboy@chromium.org> | 2016-03-23 12:45:28 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-04-18 17:32:40 -0700 |
commit | 068cd0850684ee28a5a514e5a270edce2edb3979 (patch) | |
tree | e84f2316e37baa72f1c9611e665749d91a3ce8fd /board/plankton | |
parent | 1e7c280491232110e1006d545f9a61ca05d469d5 (diff) | |
download | chrome-ec-068cd0850684ee28a5a514e5a270edce2edb3979.tar.gz |
Deferred: Use deferred_data instead of function pointer
Previously calls to hook_call_deferred were passed the function to call,
which was then looked up in the .rodata.deferred section with a linear
search. This linear search can be replaced with a subtract by passing
the pointer to the deferred_data object created when DECLARE_DEFERRED
was invoked.
Signed-off-by: Anton Staaf <robotboy@chromium.org>
BRANCH=None
BUG=None
CQ-DEPEND=CL:*255812
TEST=make buildall -j
Change-Id: I951dd1541302875b102dd086154cf05591694440
Reviewed-on: https://chromium-review.googlesource.com/334315
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'board/plankton')
-rw-r--r-- | board/plankton/board.c | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/board/plankton/board.c b/board/plankton/board.c index d52f94bca5..a0cd041724 100644 --- a/board/plankton/board.c +++ b/board/plankton/board.c @@ -104,7 +104,8 @@ void hpd_event(enum gpio_signal signal) hpd_prev_ts = now.val; /* All previous hpd level events need to be re-triggered */ - hook_call_deferred(hpd_lvl_deferred, HPD_USTREAM_DEBOUNCE_LVL); + hook_call_deferred(&hpd_lvl_deferred_data, + HPD_USTREAM_DEBOUNCE_LVL); } /* Debounce time for voltage buttons */ @@ -177,13 +178,17 @@ static void set_active_cc(int cc) * is detected. If a type-C connection can be made in both polarities, then we * have a double CC cable, otherwise we have a single CC cable. */ +static void detect_cc_cable(void); +DECLARE_DEFERRED(detect_cc_cable); + static void detect_cc_cable(void) { /* * Delay long enough to guarantee a type-C disconnect will be seen and * a new connection will be made made. */ - hook_call_deferred(detect_cc_cable, PD_T_CC_DEBOUNCE + PD_T_SAFE_0V); + hook_call_deferred(&detect_cc_cable_data, + PD_T_CC_DEBOUNCE + PD_T_SAFE_0V); switch (cable) { case TYPEC_CABLE_NONE: @@ -210,7 +215,6 @@ static void detect_cc_cable(void) break; } } -DECLARE_DEFERRED(detect_cc_cable); static void fake_disconnect_end(void) { @@ -218,14 +222,14 @@ static void fake_disconnect_end(void) board_pd_set_host_mode(fake_pd_host_mode); /* Restart CC cable detection */ - hook_call_deferred(detect_cc_cable, 500*MSEC); + hook_call_deferred(&detect_cc_cable_data, 500*MSEC); } DECLARE_DEFERRED(fake_disconnect_end); static void fake_disconnect_start(void) { /* Cancel detection of CC cable */ - hook_call_deferred(detect_cc_cable, -1); + hook_call_deferred(&detect_cc_cable_data, -1); /* Record the current host mode */ fake_pd_host_mode = !gpio_get_level(GPIO_USBC_CHARGE_EN); @@ -241,7 +245,7 @@ static void fake_disconnect_start(void) fake_pd_disconnected = 1; - hook_call_deferred(fake_disconnect_end, + hook_call_deferred(&fake_disconnect_end_data, fake_pd_disconnect_duration_us); } DECLARE_DEFERRED(fake_disconnect_start); @@ -261,7 +265,7 @@ static void update_usbc_dual_role(int dual_role) * since both CC lines are used and SRC/SNK changes are dictated * by the USB PD protocol state machine. */ - hook_call_deferred(detect_cc_cable, -1); + hook_call_deferred(&detect_cc_cable_data, -1); /* Need to make sure both CC lines are set for SNK or SRC. */ set_active_cc(host_mode); /* Ensure that PD communication is enabled. */ @@ -272,7 +276,7 @@ static void update_usbc_dual_role(int dual_role) * Dualrole mode is not active, resume cable detect function * which controls which CC line is active. */ - hook_call_deferred(detect_cc_cable, 0); + hook_call_deferred(&detect_cc_cable_data, 0); } /* Update dual role setting used in USB PD protocol state machine */ pd_set_dual_role(dual_role); @@ -335,10 +339,10 @@ static void set_usbc_action(enum usbc_action act) * Fake a disconnection for long enough to guarantee * that we disconnect. */ - hook_call_deferred(fake_disconnect_start, -1); - hook_call_deferred(fake_disconnect_end, -1); + hook_call_deferred(&fake_disconnect_start_data, -1); + hook_call_deferred(&fake_disconnect_end_data, -1); fake_pd_disconnect_duration_us = PD_T_SAFE_0V; - hook_call_deferred(fake_disconnect_start, 0); + hook_call_deferred(&fake_disconnect_start_data, 0); set_active_cc(!active_cc); } break; @@ -370,10 +374,13 @@ static void set_usbc_action(enum usbc_action act) /* has Pull-up */ static int prev_dbg20v = 1; + static void button_dbg20v_deferred(void); +DECLARE_DEFERRED(button_dbg20v_deferred); + static void enable_dbg20v_poll(void) { - hook_call_deferred(button_dbg20v_deferred, 10 * MSEC); + hook_call_deferred(&button_dbg20v_deferred_data, 10 * MSEC); } /* Handle debounced button press */ @@ -427,7 +434,7 @@ void button_event(enum gpio_signal signal) { button_pressed = signal; /* reset debounce time */ - hook_call_deferred(button_deferred, BUTTON_DEBOUNCE_US); + hook_call_deferred(&button_deferred_data, BUTTON_DEBOUNCE_US); } static void button_dbg20v_deferred(void) @@ -437,7 +444,6 @@ static void button_dbg20v_deferred(void) else enable_dbg20v_poll(); } -DECLARE_DEFERRED(button_dbg20v_deferred); void vbus_event(enum gpio_signal signal) { @@ -729,10 +735,11 @@ static void board_init(void) /* Initialize USB hub */ if (system_get_reset_flags() & RESET_FLAG_POWER_ON) - hook_call_deferred(board_usb_hub_reset_no_return, 500 * MSEC); + hook_call_deferred(&board_usb_hub_reset_no_return_data, + 500 * MSEC); /* Start detecting CC cable type */ - hook_call_deferred(detect_cc_cable, SECOND); + hook_call_deferred(&detect_cc_cable_data, SECOND); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); @@ -752,11 +759,11 @@ static int cmd_fake_disconnect(int argc, char *argv[]) return EC_ERROR_PARAM2; /* Cancel any pending function calls */ - hook_call_deferred(fake_disconnect_start, -1); - hook_call_deferred(fake_disconnect_end, -1); + hook_call_deferred(&fake_disconnect_start_data, -1); + hook_call_deferred(&fake_disconnect_end_data, -1); fake_pd_disconnect_duration_us = duration_ms * MSEC; - hook_call_deferred(fake_disconnect_start, delay_ms * MSEC); + hook_call_deferred(&fake_disconnect_start_data, delay_ms * MSEC); ccprintf("Fake disconnect for %d ms starting in %d ms.\n", duration_ms, delay_ms); @@ -779,7 +786,7 @@ static int cmd_trigger_dfu(int argc, char *argv[]) ccprintf("Asserting CASE_CLOSE_DFU_L.\n"); ccprintf("If you expect to see DFU debug but it doesn't show up,\n"); ccprintf("try flipping the USB type-C cable.\n"); - hook_call_deferred(trigger_dfu_release, 1500 * MSEC); + hook_call_deferred(&trigger_dfu_release_data, 1500 * MSEC); return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(dfu, cmd_trigger_dfu, NULL, NULL, NULL); |