diff options
author | Jett Rink <jettrink@chromium.org> | 2020-02-19 09:06:07 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-25 02:28:17 +0000 |
commit | ab70d6a8b5b0f64bd3b826122da2a3b3ffd5c990 (patch) | |
tree | 224e77b4c7d56cd1881bc88ee2d9a666a33306e7 /util/iteflash.c | |
parent | 89af0a45c4600225d0752efe3804c679d2886181 (diff) | |
download | chrome-ec-ab70d6a8b5b0f64bd3b826122da2a3b3ffd5c990.tar.gz |
iteflash: honor Ctrl+C signal
Ensure all configuration (e.g. CCD, FTDI, linux) abort
when Ctrl+c is pressed.
BRANCH=none
BUG=none
TEST=Verify the Ctrl+c quits when using linux driver
with C2D2
Change-Id: Idc0555ae9689a118d9375f2b31f24cc7d1e61a4b
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2064591
Reviewed-by: Matthew Blecker <matthewb@chromium.org>
Diffstat (limited to 'util/iteflash.c')
-rw-r--r-- | util/iteflash.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/util/iteflash.c b/util/iteflash.c index fd83980c77..4ba8b62bac 100644 --- a/util/iteflash.c +++ b/util/iteflash.c @@ -172,6 +172,10 @@ static void config_release(struct iteflash_config *conf) static inline int i2c_byte_transfer(struct common_hnd *chnd, uint8_t addr, uint8_t *data, int write, int numbytes) { + /* If we got a termination signal, stop sending data */ + if (exit_requested) + return -1; + return chnd->conf.i2c_if->byte_transfer(chnd, addr, data, write, numbytes); } @@ -220,10 +224,6 @@ static int i2c_add_send_byte(struct ftdi_context *ftdi, uint8_t *buf, uint8_t failed_ack = 0; for (i = 0; i < tcnt; i++) { - /* If we got a termination signal, stop sending data */ - if (exit_requested) - return -1; - /* WORKAROUND: force SDA before sending the next byte */ *b++ = SET_BITS_LOW; *b++ = SDA_BIT; *b++ = SCL_BIT | SDA_BIT; /* write byte */ @@ -318,10 +318,6 @@ static int i2c_add_recv_bytes(struct ftdi_context *ftdi, uint8_t *buf, rbuf_idx = 0; do { - /* If we got a termination signal, stop sending data */ - if (exit_requested) - return -1; - ret = ftdi_read_data(ftdi, &rbuf[rbuf_idx], rcnt); if (ret < 0) { fprintf(stderr, "read byte failed\n"); @@ -343,10 +339,6 @@ static int ccd_i2c_byte_transfer(struct common_hnd *chnd, uint8_t addr, size_t response_size; size_t extra = 0; - /* Do nothing if user wants to quit. */ - if (exit_requested) - return -1; - /* * Build a message following format described in ./include/usb_i2c.h. * |