public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: "Stefan Roese" <sr@denx.de>, "Marek Behún" <marek.behun@nic.cz>,
	"Tony Dinh" <mibodhi@gmail.com>
Cc: u-boot@lists.denx.de
Subject: [PATCH u-boot-marvell 01/10] tools: kwboot: Check for return value of kwboot_tty_send() and tcflush()
Date: Wed,  2 Mar 2022 11:49:18 +0100	[thread overview]
Message-ID: <20220302104927.18607-2-pali@kernel.org> (raw)
In-Reply-To: <20220302104927.18607-1-pali@kernel.org>

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>
---
 tools/kwboot.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/tools/kwboot.c b/tools/kwboot.c
index 2d2d545d8258..5a7c53ce8929 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);
 
-- 
2.20.1


  reply	other threads:[~2022-03-02 10:52 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-02 10:49 [PATCH u-boot-marvell 00/10] tools: kwboot: Fix boot and terminal mode Pali Rohár
2022-03-02 10:49 ` Pali Rohár [this message]
2022-03-04  7:48   ` [PATCH u-boot-marvell 01/10] tools: kwboot: Check for return value of kwboot_tty_send() and tcflush() Stefan Roese
2022-03-02 10:49 ` [PATCH u-boot-marvell 02/10] tools: kwboot: Remove msg_req_delay Pali Rohár
2022-03-04  7:48   ` Stefan Roese
2022-03-02 10:49 ` [PATCH u-boot-marvell 03/10] tools: kwboot: Cleanup bootmsg and debugmsg variables Pali Rohár
2022-03-04  7:48   ` Stefan Roese
2022-03-02 10:49 ` [PATCH u-boot-marvell 04/10] tools: kwboot: Use separate thread for sending boot message pattern Pali Rohár
2022-03-04  7:49   ` Stefan Roese
2022-03-02 10:49 ` [PATCH u-boot-marvell 05/10] tools: kwboot: Fix sending and processing debug message pattern (-d option) Pali Rohár
2022-03-04  7:49   ` Stefan Roese
2022-03-02 10:49 ` [PATCH u-boot-marvell 06/10] tools: kwboot: Add support for backspace key in mini terminal Pali Rohár
2022-03-04  7:49   ` Stefan Roese
2022-03-02 10:49 ` [PATCH u-boot-marvell 07/10] tools: kwboot: Update usage Pali Rohár
2022-03-04  7:49   ` Stefan Roese
2022-03-02 10:49 ` [PATCH u-boot-marvell 08/10] tools: kwboot: Update manpage Pali Rohár
2022-03-04  7:50   ` Stefan Roese
2022-03-02 10:49 ` [PATCH u-boot-marvell 09/10] tools: kwboot: Update doc about Avanta Pali Rohár
2022-03-04  7:50   ` Stefan Roese
2022-03-02 10:49 ` [PATCH u-boot-marvell 10/10] tools: kwboot: Update references with public links Pali Rohár
2022-03-04  7:50   ` Stefan Roese
2022-03-02 20:51 ` [PATCH u-boot-marvell 00/10] tools: kwboot: Fix boot and terminal mode Tony Dinh
2022-03-02 21:03   ` Pali Rohár
2022-03-02 21:18     ` Tony Dinh
2022-03-03 23:58       ` Tony Dinh
2022-03-04  0:05         ` Pali Rohár
2022-03-04  4:52           ` Tony Dinh
2022-03-04  7:47 ` Stefan Roese
2022-03-04 12:24 ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220302104927.18607-2-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=marek.behun@nic.cz \
    --cc=mibodhi@gmail.com \
    --cc=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox