summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNamyoon Woo <namyoon@chromium.org>2019-06-18 19:00:32 -0700
committerCommit Bot <commit-bot@chromium.org>2019-06-19 06:35:33 +0000
commit932f9ca08307623f5ca3e2831f0809fa18f31460 (patch)
tree8dea76355f59078e9de6302068194a59c390314d
parent407f92ee30ceb2bdca0d633653fcbaaebc58e128 (diff)
downloadchrome-ec-932f9ca08307623f5ca3e2831f0809fa18f31460.tar.gz
Revert "g: minor fix in putting a character into usb_console tx queue"
The patch cases slow-down in CR50 uart when RDD is not connected. BUG=None BRANCH=None TEST=manually ran on bob This reverts commit 2d62dee3a8f32499bab8f4b95b84a9eaeea919dc. Change-Id: I92c4b8e7d065a01dc2c398778351db207ab28ca5 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1666318 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r--chip/g/usb_console.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/chip/g/usb_console.c b/chip/g/usb_console.c
index 6dd7286dde..68cdea8a6e 100644
--- a/chip/g/usb_console.c
+++ b/chip/g/usb_console.c
@@ -251,6 +251,9 @@ static int usb_wait_console(void)
timestamp_t deadline = get_time();
int wait_time_us = 1;
+ if (!is_enabled || !tx_fifo_is_ready())
+ return EC_SUCCESS;
+
deadline.val += USB_CONSOLE_TIMEOUT_US;
/*
@@ -308,12 +311,10 @@ static int __tx_char(void *context, int c)
while (QUEUE_ADD_UNITS(state, &c, 1) != 1)
usleep(500);
-
- return EC_SUCCESS;
#else
- return QUEUE_ADD_UNITS(state, &c, 1) ? EC_SUCCESS :
- EC_ERROR_OVERFLOW;
+ QUEUE_ADD_UNITS(state, &c, 1);
#endif
+ return 0;
}
/*
@@ -334,25 +335,24 @@ int usb_getc(void)
int usb_puts(const char *outstr)
{
int ret;
+ struct queue state;
if (!is_enabled)
return EC_SUCCESS;
ret = usb_wait_console();
- if (ret == EC_SUCCESS) {
- struct queue state = tx_q;
-
- while (*outstr) {
- ret = __tx_char(&state, *outstr);
- if (ret != EC_SUCCESS)
- break;
- outstr++;
- }
+ if (ret)
+ return ret;
+ state = tx_q;
+ while (*outstr)
+ if (__tx_char(&state, *outstr++))
+ break;
+
+ if (queue_count(&state))
handle_output();
- }
- return ret;
+ return *outstr ? EC_ERROR_OVERFLOW : EC_SUCCESS;
}
int usb_putc(int c)
@@ -367,18 +367,20 @@ int usb_putc(int c)
int usb_vprintf(const char *format, va_list args)
{
int ret;
+ struct queue state;
if (!is_enabled)
return EC_SUCCESS;
ret = usb_wait_console();
- if (ret == EC_SUCCESS) {
- struct queue state = tx_q;
+ if (ret)
+ return ret;
- ret = vfnprintf(__tx_char, &state, format, args);
+ state = tx_q;
+ ret = vfnprintf(__tx_char, &state, format, args);
+ if (queue_count(&state))
handle_output();
- }
return ret;
}