summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2016-12-01 18:56:29 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2016-12-25 15:21:09 +0000
commit43b7137b35c48041626788472aa9e8a623636ea5 (patch)
tree883e4b50f85102e465504d9cdbc36021180cacfd
parent29c3e71249be16965d733c2dfb274c3866e4c3a9 (diff)
downloadchrome-ec-43b7137b35c48041626788472aa9e8a623636ea5.tar.gz
usb_updater: close connection when no data is transferred
When usb_updater is invoked with the '-f' option and without specifying the binary file to transmit, the cr50 still enters the data transfer mode, even though the host is not transferring anything. As a result cr50 stays in the 'rx_outside_block' state until timeout expires. Another usb_updater invocation fails if attempted before timeout expiration. The UPGRADE_DONE PDU sent by the host causes the state machine to switch to the idle state immediately. BRANCH=none BUG=none TEST=ran the following commands: usb_updater -f && usb_updater -f the second invocation used to fail before this change, now it succeeds. Change-Id: Iceafeb30de6011975fbf47dabc7c6c494177c0f7 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/415554 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/422757 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org>
-rw-r--r--extra/usb_updater/usb_updater.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/extra/usb_updater/usb_updater.c b/extra/usb_updater/usb_updater.c
index 71ca80a822..a6371b2cf4 100644
--- a/extra/usb_updater/usb_updater.c
+++ b/extra/usb_updater/usb_updater.c
@@ -1280,7 +1280,10 @@ int main(int argc, char *argv[])
transferred_sections = transfer_and_reboot(&td, data, data_len);
free(data);
}
+
if (td.ep_type == usb_xfer) {
+ if (!data)
+ send_done(&td.uep);
libusb_close(td.uep.devh);
libusb_exit(NULL);
}