summaryrefslogtreecommitdiff
path: root/tools/kwboot.c
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2022-03-02 11:49:18 +0100
committerStefan Roese <sr@denx.de>2022-03-04 13:11:42 +0100
commitd8865f8677c6dd43109e22bfbb85a3cd6bf6aca1 (patch)
treebcf2bc4f0a189df19a8ef7d4ca1f1664f96b0174 /tools/kwboot.c
parent0a6f0297c677946907b7ba34d34995fe03055aad (diff)
downloadu-boot-socfpga-d8865f8677c6dd43109e22bfbb85a3cd6bf6aca1.tar.gz
tools: kwboot: Check for return value of kwboot_tty_send() and tcflush()
Failure of kwboot_tty_send() and tcflush() functions is fatal, it does not make sense to continue. So return error back to the caller like in other places where are called these functions. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'tools/kwboot.c')
-rw-r--r--tools/kwboot.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/tools/kwboot.c b/tools/kwboot.c
index 2d2d545d82..5a7c53ce89 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -740,10 +740,8 @@ kwboot_bootmsg(int tty, void *msg)
for (count = 0; count < 128; count++) {
rc = kwboot_tty_send(tty, msg, 8, 0);
- if (rc) {
- usleep(msg_req_delay * 1000);
- continue;
- }
+ if (rc)
+ break;
}
rc = kwboot_tty_recv(tty, &c, 1, msg_rsp_timeo);
@@ -772,11 +770,19 @@ kwboot_bootmsg(int tty, void *msg)
*/
/* flush output queue with remaining boot message patterns */
- tcflush(tty, TCOFLUSH);
+ rc = tcflush(tty, TCOFLUSH);
+ if (rc) {
+ perror("Failed to flush output queue");
+ return rc;
+ }
/* send one xmodem packet with 0xff bytes to force BootROM to re-sync */
memset(&block, 0xff, sizeof(block));
- kwboot_tty_send(tty, &block, sizeof(block), 0);
+ rc = kwboot_tty_send(tty, &block, sizeof(block), 0);
+ if (rc) {
+ perror("Failed to send sync sequence");
+ return rc;
+ }
/*
* Sending 132 bytes via 115200B/8-N-1 takes 11.45 ms, reading 132 bytes
@@ -785,7 +791,11 @@ kwboot_bootmsg(int tty, void *msg)
usleep(30 * 1000);
/* flush remaining NAK replies from input queue */
- tcflush(tty, TCIFLUSH);
+ rc = tcflush(tty, TCIFLUSH);
+ if (rc) {
+ perror("Failed to flush input queue");
+ return rc;
+ }
return 0;
}
@@ -805,10 +815,8 @@ kwboot_debugmsg(int tty, void *msg)
break;
rc = kwboot_tty_send(tty, msg, 8, 0);
- if (rc) {
- usleep(msg_req_delay * 1000);
- continue;
- }
+ if (rc)
+ break;
rc = kwboot_tty_recv(tty, buf, 16, msg_rsp_timeo);