diff options
author | Wei-Han Chen <stimim@google.com> | 2018-06-05 14:23:39 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-06-06 05:00:58 -0700 |
commit | f939638a0eabe92ae7381d6e020c6858403f92c6 (patch) | |
tree | a9114ef2a6aa6abb997cb5126bfb2881546032b5 /driver/touchpad_st.c | |
parent | 65d87bf9f0ef9b084d91ed44eda58b7463c82b48 (diff) | |
download | chrome-ec-f939638a0eabe92ae7381d6e020c6858403f92c6.tar.gz |
driver/touchpad_st.c: fix a bug in st_tp_reset
In st_tp_reset, we should exit the function when we received a
controller ready event. The "break" statement only breaks inner for
loop, not while loop. Fix this bug.
BRANCH=whiskers
BUG=b:70482333
TEST=sudo ./extra/usb_updater/usb_updater2 -d 18d1:5030 --tp_update <fw>
TEST=sudo extra/usb_updater/usb_updater2 -d 18d1:5030 --tp_debug=01
TEST=(EC console) touchpad_st calibrate
Signed-off-by: Wei-Han Chen <stimim@chromium.org>
Change-Id: I92f94cce33c32ab26924fb91b50cd192d179ba90
Reviewed-on: https://chromium-review.googlesource.com/1086894
Commit-Ready: Wei-Han Chen <stimim@chromium.org>
Tested-by: Wei-Han Chen <stimim@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'driver/touchpad_st.c')
-rw-r--r-- | driver/touchpad_st.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/driver/touchpad_st.c b/driver/touchpad_st.c index e20a2810f3..4193e9da86 100644 --- a/driver/touchpad_st.c +++ b/driver/touchpad_st.c @@ -421,11 +421,11 @@ static int st_tp_read_all_events(void) */ static int st_tp_reset(void) { - int i, num_events; + int i, num_events, retry = 100; board_touchpad_reset(); - while (1) { + while (retry--) { num_events = st_tp_read_all_events(); if (num_events < 0) return -num_events; @@ -433,20 +433,23 @@ static int st_tp_reset(void) for (i = 0; i < num_events; i++) { struct st_tp_event_t *e = &rx_buf.events[i]; - if (e->evt_id == ST_TP_EVENT_ID_CONTROLLER_READY) - break; + if (e->evt_id == ST_TP_EVENT_ID_CONTROLLER_READY) { + CPRINTS("Touchpad ready"); + return 0; + } } msleep(10); } - CPRINTS("Touchpad ready"); - return 0; + CPRINTS("Timeout waiting for controller ready."); + return EC_ERROR_TIMEOUT; } /* Initialize the controller ICs after reset */ static void st_tp_init(void) { - st_tp_reset(); + if (st_tp_reset()) + return; /* * On boot, ST firmware will load system info to host data memory, * So we don't need to reload it. @@ -700,7 +703,8 @@ static void st_tp_full_initialize(void) uint8_t tx_buf[] = { ST_TP_CMD_WRITE_SYSTEM_COMMAND, 0x00, 0x03 }; st_tp_stop_scan(); - st_tp_reset(); + if (st_tp_reset()) + return; CPRINTS("Start full initialization"); spi_transaction(SPI, tx_buf, sizeof(tx_buf), NULL, 0); |