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 X-Spam-Level: X-Spam-Status: No, score=-19.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A914C4338F for ; Tue, 3 Aug 2021 14:29:56 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id EF57060BD3 for ; Tue, 3 Aug 2021 14:29:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EF57060BD3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4565580394; Tue, 3 Aug 2021 16:29:44 +0200 (CEST) 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="LFGwCk96"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5A45C82DF7; Tue, 3 Aug 2021 16:29:30 +0200 (CEST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (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 8C3E582CDA for ; Tue, 3 Aug 2021 16:29:24 +0200 (CEST) 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: by mail.kernel.org (Postfix) with ESMTPSA id 0954D60F92; Tue, 3 Aug 2021 14:29:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628000963; bh=EhndzDzq+0Bb+FuFtMVhPJkg1S/waFMOKffK+1QWz3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LFGwCk96Uoh2tpvsILBcGuCIOflKmtTzleFP1Oo6X+MciEci2fY1jDWe+w6huVw5M pTalEUGET/gQMzvBjoj4Zfujb77pgMoYBR6Lr0nMwBsEKXDAbvh1+FVMbUzM8/DIOF 5khz5a0vhhweSkVGACZqnomkJ34OTlN6EhwPT9V0aAODaLJNbK+ov56vzUtuN51ERt Xz4OF6pSAD52KW3kLVbx72VII+TpOyBWjSqGVNnOc+CJrV9R7oMNWHeNRVO/RLxAhL 2wKVzPELq6y6/bBg6+7LrmCW7Dq+T59F8gwW8sBa6PuhHwKYxQuILWkYLLYbjGN3Zj OLGsOTsD88biw== Received: by pali.im (Postfix) id BC1C0BFF; Tue, 3 Aug 2021 16:29:22 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Simon Glass , Heinrich Schuchardt , Michal Simek , =?UTF-8?q?Marek=20Beh=C3=BAn?= Cc: u-boot@lists.denx.de Subject: [PATCH 5/7] xyz-modem: Properly abort/terminate transfer on error Date: Tue, 3 Aug 2021 16:28:42 +0200 Message-Id: <20210803142844.19455-6-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210803142844.19455-1-pali@kernel.org> References: <20210803142844.19455-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.34 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.2 at phobos.denx.de X-Virus-Status: Clean Transfer termination tries to instruct sender that transfer was terminated. Print error message and indicates aborted transfer in return value. Signed-off-by: Pali Rohár --- cmd/load.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/load.c b/cmd/load.c index fb8c191fb64f..1ed05a9cd21e 100644 --- a/cmd/load.c +++ b/cmd/load.c @@ -975,6 +975,7 @@ static ulong load_serial_ymodem(ulong offset, int mode) res = xyzModem_stream_open(&info, &err); if (!res) { + err = 0; while ((res = xyzModem_stream_read(ymodemBuf, 1024, &err)) > 0) { store_addr = addr + offset; @@ -987,6 +988,9 @@ static ulong load_serial_ymodem(ulong offset, int mode) rc = flash_write((char *) ymodemBuf, store_addr, res); if (rc != 0) { + xyzModem_stream_terminate(true, &getcxmodem); + xyzModem_stream_close(&err); + printf("\n"); flash_perror(rc); return (~0); } @@ -998,12 +1002,20 @@ static ulong load_serial_ymodem(ulong offset, int mode) } } + if (err) { + xyzModem_stream_terminate((err == xyzModem_cancel) ? false : true, &getcxmodem); + xyzModem_stream_close(&err); + printf("\n%s\n", xyzModem_error(err)); + return (~0); /* Download aborted */ + } + if (IS_ENABLED(CONFIG_CMD_BOOTEFI)) efi_set_bootdev("Uart", "", "", map_sysmem(offset, 0), size); } else { - printf("%s\n", xyzModem_error(err)); + printf("\n%s\n", xyzModem_error(err)); + return (~0); /* Download aborted */ } xyzModem_stream_terminate(false, &getcxmodem); -- 2.20.1