summaryrefslogtreecommitdiff
path: root/chip/stm32/usb_spi.c
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2014-12-02 10:42:22 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-12-08 21:51:59 +0000
commit9e1f4ed7015ac8543169fe41b74f1939a8b86f3b (patch)
tree96e0dbba21fffbb74f8c1b2420c58541501f5b0f /chip/stm32/usb_spi.c
parent731a2e74872159ecfa910c3174e9d3ae50ff2dae (diff)
downloadchrome-ec-9e1f4ed7015ac8543169fe41b74f1939a8b86f3b.tar.gz
USB-SPI: Switch from task to deferred function
The task based approach made sense when it looked like there would be a case closed debugging task to handle multiple bridges (SPI/I2C/USART...). I'm not convinced anymore that that task will be needed, so this simplification seems good. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: Ic431c287c28d10252246fe9f507d9c5fcc64a077 Reviewed-on: https://chromium-review.googlesource.com/232733 Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'chip/stm32/usb_spi.c')
-rw-r--r--chip/stm32/usb_spi.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/chip/stm32/usb_spi.c b/chip/stm32/usb_spi.c
index f0e163cb1b..24b8a530d7 100644
--- a/chip/stm32/usb_spi.c
+++ b/chip/stm32/usb_spi.c
@@ -59,20 +59,12 @@ static void usb_spi_write_packet(struct usb_spi_config const *config,
STM32_TOGGLE_EP(config->endpoint, EP_TX_MASK, EP_TX_VALID, 0);
}
-static int rx_valid(struct usb_spi_config const *config)
-{
- return (STM32_USB_EP(config->endpoint) & EP_RX_MASK) == EP_RX_VALID;
-}
-
-int usb_spi_service_request(struct usb_spi_config const *config)
+void usb_spi_deferred(struct usb_spi_config const *config)
{
uint8_t count;
uint8_t write_count;
uint8_t read_count;
- if (rx_valid(config))
- return 0;
-
count = usb_spi_read_packet(config);
write_count = (config->buffer[0] >> 0) & 0xff;
read_count = (config->buffer[0] >> 8) & 0xff;
@@ -93,8 +85,6 @@ int usb_spi_service_request(struct usb_spi_config const *config)
}
usb_spi_write_packet(config, read_count + 2);
-
- return 1;
}
void usb_spi_tx(struct usb_spi_config const *config)
@@ -105,7 +95,8 @@ void usb_spi_tx(struct usb_spi_config const *config)
void usb_spi_rx(struct usb_spi_config const *config)
{
STM32_TOGGLE_EP(config->endpoint, EP_RX_MASK, EP_RX_NAK, 0);
- config->ready(config);
+
+ hook_call_deferred(config->deferred, 0);
}
void usb_spi_reset(struct usb_spi_config const *config)