summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2017-08-31 15:56:01 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-09-01 16:41:54 -0700
commit69e10e84aa1554c37c03a97a58058c4ea38de21d (patch)
tree29b31d9a403a8620178b1b0af4293a7c7216a4b7 /chip
parent9663bdca5cae0d2d67d6e9cf422a6b6119a24926 (diff)
downloadchrome-ec-69e10e84aa1554c37c03a97a58058c4ea38de21d.tar.gz
chip/g: Fix usb_console read-only
Currently, the console inhibited output when is_readonly=1, and only inhibited input when is_enabled=0. That's harmless in the current implementation, because common/case_closed_debug() only ever calls it with enabled=0/readonly=1 or enabled=1/readonly=0. But if we ever do decide to use enabled=1/readonly=1, that would have acted like write-only, not read-only. Fix that. BUG=none BRANCH=cr50 TEST=Attach to cr50 USB console, console is read/write. Hack USB console to set is_readonly=1, console is read-only. Change-Id: I04258fe2b040a00f98067d8be48a0632eb16e9c1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/647336 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/g/usb_console.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/chip/g/usb_console.c b/chip/g/usb_console.c
index c3e1e09c01..f77c34a638 100644
--- a/chip/g/usb_console.c
+++ b/chip/g/usb_console.c
@@ -23,8 +23,18 @@
static int last_tx_ok = 1;
static int is_reset;
+
+/*
+ * Start enabled, so we can queue early debug output before the board gets
+ * around to calling usb_console_enable().
+ */
static int is_enabled = 1;
-static int is_readonly;
+
+/*
+ * But start read-only, so we don't accept console input until we explicitly
+ * decide that we're ready for it.
+ */
+static int is_readonly = 1;
/* USB-Serial descriptors */
const struct usb_interface_descriptor USB_IFACE_DESC(USB_IFACE_CONSOLE) =
@@ -287,7 +297,7 @@ int usb_getc(void)
{
int c;
- if (!is_enabled)
+ if (is_readonly || !is_enabled)
return -1;
if (QUEUE_REMOVE_UNITS(&rx_q, &c, 1))
@@ -300,7 +310,7 @@ int usb_puts(const char *outstr)
int ret;
struct queue state;
- if (is_readonly)
+ if (!is_enabled)
return EC_SUCCESS;
ret = usb_wait_console();
@@ -332,7 +342,7 @@ int usb_vprintf(const char *format, va_list args)
int ret;
struct queue state;
- if (is_readonly)
+ if (!is_enabled)
return EC_SUCCESS;
ret = usb_wait_console();