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 /chip/g | |
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 'chip/g')
-rw-r--r-- | chip/g/usb-stream.h | 12 | ||||
-rw-r--r-- | chip/g/usb_console.c | 10 |
2 files changed, 11 insertions, 11 deletions
diff --git a/chip/g/usb-stream.h b/chip/g/usb-stream.h index a79d530035..b789c65925 100644 --- a/chip/g/usb-stream.h +++ b/chip/g/usb-stream.h @@ -31,8 +31,8 @@ struct usb_stream_config { /* * Deferred function to call to handle USB and Queue request. */ - void (*deferred_tx)(void); - void (*deferred_rx)(void); + const struct deferred_data *deferred_tx; + const struct deferred_data *deferred_rx; int tx_size; int rx_size; @@ -109,14 +109,16 @@ extern struct producer_ops const usb_stream_producer_ops; static uint8_t CONCAT2(NAME, _buf_tx_)[TX_SIZE]; \ static int CONCAT2(NAME, _is_reset_); \ static void CONCAT2(NAME, _deferred_tx_)(void); \ + DECLARE_DEFERRED(CONCAT2(NAME, _deferred_tx_)); \ static void CONCAT2(NAME, _deferred_rx_)(void); \ + DECLARE_DEFERRED(CONCAT2(NAME, _deferred_rx_)); \ struct usb_stream_config const NAME = { \ .endpoint = ENDPOINT, \ .is_reset = &CONCAT2(NAME, _is_reset_), \ .in_desc = &CONCAT2(NAME, _in_desc_), \ .out_desc = &CONCAT2(NAME, _out_desc_), \ - .deferred_tx = CONCAT2(NAME, _deferred_tx_), \ - .deferred_rx = CONCAT2(NAME, _deferred_rx_), \ + .deferred_tx = &CONCAT2(NAME, _deferred_tx__data), \ + .deferred_rx = &CONCAT2(NAME, _deferred_rx__data), \ .tx_size = TX_SIZE, \ .rx_size = RX_SIZE, \ .tx_ram = CONCAT2(NAME, _buf_tx_), \ @@ -162,10 +164,8 @@ extern struct producer_ops const usb_stream_producer_ops; }; \ static void CONCAT2(NAME, _deferred_tx_)(void) \ { tx_stream_handler(&NAME); } \ - DECLARE_DEFERRED(CONCAT2(NAME, _deferred_tx_)); \ static void CONCAT2(NAME, _deferred_rx_)(void) \ { rx_stream_handler(&NAME); } \ - DECLARE_DEFERRED(CONCAT2(NAME, _deferred_rx_)); \ static void CONCAT2(NAME, _ep_tx)(void) \ { \ usb_stream_tx(&NAME); \ diff --git a/chip/g/usb_console.c b/chip/g/usb_console.c index 27a8d15b95..41f98251fa 100644 --- a/chip/g/usb_console.c +++ b/chip/g/usb_console.c @@ -156,7 +156,7 @@ DECLARE_DEFERRED(rx_fifo_handler); static void con_ep_rx(void) { /* Wake up the Rx FIFO handler */ - hook_call_deferred(rx_fifo_handler, 0); + hook_call_deferred(&rx_fifo_handler_data, 0); /* clear the RX/OUT interrupts */ GR_USB_DOEPINT(USB_EP_CONSOLE) = 0xffffffff; @@ -189,14 +189,14 @@ DECLARE_DEFERRED(tx_fifo_handler); static void handle_output(void) { /* Wake up the Tx FIFO handler */ - hook_call_deferred(tx_fifo_handler, 0); + hook_call_deferred(&tx_fifo_handler_data, 0); } /* Tx/IN interrupt handler */ static void con_ep_tx(void) { /* Wake up the Tx FIFO handler */ - hook_call_deferred(tx_fifo_handler, 0); + hook_call_deferred(&tx_fifo_handler_data, 0); /* clear the Tx/IN interrupts */ GR_USB_DIEPINT(USB_EP_CONSOLE) = 0xffffffff; @@ -223,8 +223,8 @@ static void ep_reset(void) is_reset = 1; /* Flush any queued data */ - hook_call_deferred(tx_fifo_handler, 0); - hook_call_deferred(rx_fifo_handler, 0); + hook_call_deferred(&tx_fifo_handler_data, 0); + hook_call_deferred(&rx_fifo_handler_data, 0); } |