summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2015-06-08 10:40:43 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-11 00:08:49 +0000
commitbd7e885ae780493e37a58418a6f0197a4a3b951a (patch)
tree218facf95bb3ccc6510139f00bbabee4858b6166 /driver
parent7fab87e488f58e98dc3669b45eb068be8181ff77 (diff)
downloadchrome-ec-bd7e885ae780493e37a58418a6f0197a4a3b951a.tar.gz
Stream: Remove in_stream/out_stream interface
The in_stream and out_stream interfaces were a first attempt at providing an abstraction for multiple stream like devices (usart, USB, I2C/LPC host interfaces...). But, by baking the queue into the device it proved to be hard to use and required additional resources (task or deferred hook) to handle passing data from one stream to another. Since then the queue policy and producer/consumer interfaces have replaced the stream interfaces. This CL removes the old stream interfaces and updates the only users (deleting the test echo code from the discovery-stm32f072 board and updating the mcdp28x0 driver to use the queue interfaces). Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: Ic0d2abf81eafc4fb2e61172540151f2d0ba45caf Reviewed-on: https://chromium-review.googlesource.com/276163 Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Trybot-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/mcdp28x0.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/driver/mcdp28x0.c b/driver/mcdp28x0.c
index d5d37e1bed..552d2dc474 100644
--- a/driver/mcdp28x0.c
+++ b/driver/mcdp28x0.c
@@ -10,7 +10,8 @@
#include "common.h"
#include "ec_commands.h"
#include "mcdp28x0.h"
-#include "stream_adaptor.h"
+#include "queue.h"
+#include "queue_policies.h"
#include "timer.h"
#include "usart-stm32f0.h"
#include "util.h"
@@ -39,7 +40,14 @@ static inline void print_buffer(uint8_t *buf, int cnt) {}
struct usart_config const usart_mcdp;
-IO_STREAM_CONFIG(usart_mcdp, MCDP_INBUF_MAX, MCDP_OUTBUF_MAX, NULL, NULL);
+struct queue const usart_mcdp_rx_queue = QUEUE_DIRECT(MCDP_INBUF_MAX,
+ uint8_t,
+ usart_mcdp.producer,
+ null_consumer);
+struct queue const usart_mcdp_tx_queue = QUEUE_DIRECT(MCDP_OUTBUF_MAX,
+ uint8_t,
+ null_producer,
+ usart_mcdp.consumer);
USART_CONFIG(usart_mcdp,
CONFIG_MCDP28X0,
@@ -84,15 +92,15 @@ static int tx_serial(const uint8_t *msg, int cnt)
/* 1st byte (not in msg) is always cnt + 2, so seed chksum with that */
uint8_t chksum = compute_checksum(cnt + 2, msg, cnt);
- if (out_stream_write(&usart_mcdp_out.out, &out, 1) != 1)
+ if (queue_add_unit(&usart_mcdp_tx_queue, &out) != 1)
return EC_ERROR_UNKNOWN;
- if (out_stream_write(&usart_mcdp_out.out, msg, cnt) != cnt)
+ if (queue_add_units(&usart_mcdp_tx_queue, msg, cnt) != cnt)
return EC_ERROR_UNKNOWN;
print_buffer((uint8_t *)msg, cnt);
- if (out_stream_write(&usart_mcdp_out.out, &chksum, 1) != 1)
+ if (queue_add_unit(&usart_mcdp_tx_queue, &chksum) != 1)
return EC_ERROR_UNKNOWN;
return EC_SUCCESS;
@@ -119,11 +127,11 @@ static int rx_serial(uint8_t *msg, int cnt)
size_t read;
int retry = 2;
- read = in_stream_read(&usart_mcdp_in.in, msg, cnt);
+ read = queue_remove_units(&usart_mcdp_rx_queue, msg, cnt);
while ((read < cnt) && retry) {
usleep(100*MSEC);
- read += in_stream_read(&usart_mcdp_in.in, msg + read,
- cnt - read);
+ read += queue_remove_units(&usart_mcdp_rx_queue, msg + read,
+ cnt - read);
retry--;
}