summaryrefslogtreecommitdiff
path: root/chip/stm32/usb_spi.h
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2016-03-23 12:45:28 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-04-18 17:32:40 -0700
commit068cd0850684ee28a5a514e5a270edce2edb3979 (patch)
treee84f2316e37baa72f1c9611e665749d91a3ce8fd /chip/stm32/usb_spi.h
parent1e7c280491232110e1006d545f9a61ca05d469d5 (diff)
downloadchrome-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/stm32/usb_spi.h')
-rw-r--r--chip/stm32/usb_spi.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/chip/stm32/usb_spi.h b/chip/stm32/usb_spi.h
index 5395e9530f..9a061af0c3 100644
--- a/chip/stm32/usb_spi.h
+++ b/chip/stm32/usb_spi.h
@@ -111,7 +111,7 @@ struct usb_spi_config {
/*
* Deferred function to call to handle SPI request.
*/
- void (*deferred)(void);
+ const struct deferred_data *deferred;
/*
* Pointers to USB packet RAM and bounce buffer.
@@ -140,6 +140,7 @@ struct usb_spi_config {
static usb_uint CONCAT2(NAME, _ep_rx_buffer_)[USB_MAX_PACKET_SIZE / 2] __usb_ram; \
static usb_uint CONCAT2(NAME, _ep_tx_buffer_)[USB_MAX_PACKET_SIZE / 2] __usb_ram; \
static void CONCAT2(NAME, _deferred_)(void); \
+ DECLARE_DEFERRED(CONCAT2(NAME, _deferred_)); \
struct usb_spi_state CONCAT2(NAME, _state_) = { \
.enabled_host = 0, \
.enabled_device = 0, \
@@ -149,7 +150,7 @@ struct usb_spi_config {
.state = &CONCAT2(NAME, _state_), \
.interface = INTERFACE, \
.endpoint = ENDPOINT, \
- .deferred = CONCAT2(NAME, _deferred_), \
+ .deferred = &CONCAT2(NAME, _deferred__data), \
.buffer = CONCAT2(NAME, _buffer_), \
.rx_ram = CONCAT2(NAME, _ep_rx_buffer_), \
.tx_ram = CONCAT2(NAME, _ep_tx_buffer_), \
@@ -197,8 +198,7 @@ struct usb_spi_config {
USB_DECLARE_IFACE(INTERFACE, \
CONCAT2(NAME, _interface_)); \
static void CONCAT2(NAME, _deferred_)(void) \
- { usb_spi_deferred(&NAME); } \
- DECLARE_DEFERRED(CONCAT2(NAME, _deferred_));
+ { usb_spi_deferred(&NAME); }
/*
* Handle SPI request in a deferred callback.