summaryrefslogtreecommitdiff
path: root/common/keyboard_8042.c
diff options
context:
space:
mode:
authorRaul E Rangel <rrangel@chromium.org>2020-02-27 14:09:04 -0700
committerCommit Bot <commit-bot@chromium.org>2020-03-02 06:55:20 +0000
commit3d82db55bb854c2e596d4f52d5b58e32c53ca8b6 (patch)
tree7869fe63face4bb10762b21e454638aedfb6d504 /common/keyboard_8042.c
parent808946d75d23d76dcac0f1e9565b7706e823d156 (diff)
downloadchrome-ec-3d82db55bb854c2e596d4f52d5b58e32c53ca8b6.tar.gz
common/keyboard_8042: Update kblog while holding mutex
i8042_send_to_host can be called from multiple tasks. Make sure we don't mix up or lose any kblog entries. BUG=b:145575366 BRANCH=none TEST=Built and saw kblog is still populated. Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: I5d036f6db4c829c2071850c1ec92f74a24b135b7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2079692 Reviewed-by: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'common/keyboard_8042.c')
-rw-r--r--common/keyboard_8042.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c
index 1e7ea37bc3..3e17e1736f 100644
--- a/common/keyboard_8042.c
+++ b/common/keyboard_8042.c
@@ -252,11 +252,12 @@ static void i8042_send_to_host(int len, const uint8_t *bytes,
int i;
struct data_byte data;
+ /* Enqueue output data if there's space */
+ mutex_lock(&to_host_mutex);
+
for (i = 0; i < len; i++)
kblog_put('s', bytes[i]);
- /* Enqueue output data if there's space */
- mutex_lock(&to_host_mutex);
if (queue_space(&to_host) >= len) {
kblog_put('t', to_host.state->tail);
for (i = 0; i < len; i++) {