From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94FD9C433EF for ; Wed, 2 Mar 2022 10:52:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1313483CA9; Wed, 2 Mar 2022 11:52:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="uGSuitUr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5D3B08391E; Wed, 2 Mar 2022 11:52:53 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A699383108 for ; Wed, 2 Mar 2022 11:52:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 02B2761743; Wed, 2 Mar 2022 10:52:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7D82C004E1; Wed, 2 Mar 2022 10:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646218364; bh=WkEvOUsJF4IM+S6MHyDHxOK+6LDIw82ElUR7pTRZetU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uGSuitUrBeyeK4YFminPmoDl0oay9RMZu9LLyeg55xsIEYew9XRrawYCe6CLvt3Oy pj6hxbGKGVwnngs9WWOMB6jbYbmrbaaqie2gVGHVagN4A6b2SmxRsr0amUh40yIHF9 oYg+vIU1cFg8ghDKynSRtSxZZ5+rAmVwQ1LVBGrybU1cW5R6vlgrd36c2YB+aTNRpb 1ZN6IRS4n4V14QildHd3EYFZSzeH4mxVjpwoi/12JCka5Ut0LtgH2D3nscp/NmOFdS lS9OZ5k+UOEUFs3t72ypjkY/zQXvQbu8x8Y8Nc7wiISTmO7r8fs9uWzPQ/JXeh7Inb 5/InfPRInaq/Q== Received: by pali.im (Postfix) id 1056D95D; Wed, 2 Mar 2022 11:52:42 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Stefan Roese , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Tony Dinh 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 Message-Id: <20220302104927.18607-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220302104927.18607-1-pali@kernel.org> References: <20220302104927.18607-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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 --- 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