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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 AAF65C4338F for ; Wed, 25 Aug 2021 13:50:53 +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 2364E610D2 for ; Wed, 25 Aug 2021 13:50:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2364E610D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nic.cz 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 5AE02831D4; Wed, 25 Aug 2021 15:49:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="X8XUKVg2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 555B882F4D; Wed, 25 Aug 2021 15:47:40 +0200 (CEST) Received: from mail.nic.cz (lists.nic.cz [217.31.204.67]) (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 D7D198312A for ; Wed, 25 Aug 2021 15:46:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 6A68D140A6D; Wed, 25 Aug 2021 15:46:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1629899197; bh=D+kc9GBUcGJraWeEDp7PfsyHT8SAYkD/ZNMw86nbkCc=; h=From:To:Date; b=X8XUKVg2A5r5W68OE5O6YGMVc620its+zPV+onepNVYLmsAsgR6gyeOPKuqNkRgeJ VBHP6pDOJs0KLySA8yerg6yND+9fMIf7Jd+JzbxhHw0JYU1lSIeiPTJYdtPEK8ppzW vAy5OJKUcJOFxraQjH+WsjYHOxFRXAOtJsc7EztM= From: =?UTF-8?q?Marek=20Beh=C3=BAn?= To: Stefan Roese Cc: u-boot@lists.denx.de, pali@kernel.org, Chris Packham , Baruch Siach , Dennis Gilmore , Mario Six , Jon Nettleton , =?UTF-8?q?Marek=20Beh=C3=BAn?= Subject: [PATCH u-boot-marvell 17/29] tools: kwboot: Always call kwboot_img_patch_hdr() Date: Wed, 25 Aug 2021 15:46:22 +0200 Message-Id: <20210825134634.3959-18-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210825134634.3959-1-marek.behun@nic.cz> References: <20210825134634.3959-1-marek.behun@nic.cz> 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 From: Pali Rohár The kwboot_img_patch_hdr() function already decides if header patching is needed. Always call this function and deprecate the unneeded command line option `-p`. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- tools/kwboot.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/tools/kwboot.c b/tools/kwboot.c index 6674a253ff..031cea7550 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -692,9 +692,9 @@ out: } static void * -kwboot_mmap_image(const char *path, size_t *size, int prot) +kwboot_mmap_image(const char *path, size_t *size) { - int rc, fd, flags; + int rc, fd; struct stat st; void *img; @@ -709,9 +709,7 @@ kwboot_mmap_image(const char *path, size_t *size, int prot) if (rc) goto out; - flags = (prot & PROT_WRITE) ? MAP_PRIVATE : MAP_SHARED; - - img = mmap(NULL, st.st_size, prot, flags, fd, 0); + img = mmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); if (img == MAP_FAILED) { img = NULL; goto out; @@ -816,7 +814,6 @@ kwboot_usage(FILE *stream, char *progname) fprintf(stream, "\n"); fprintf(stream, " -b : boot with preamble (Kirkwood, Armada 370/XP)\n"); - fprintf(stream, " -p: patch to type 0x69 (uart boot)\n"); fprintf(stream, " -D : boot without preamble (Dove)\n"); fprintf(stream, " -d: enter debug mode\n"); @@ -836,7 +833,7 @@ int main(int argc, char **argv) { const char *ttypath, *imgpath; - int rv, rc, tty, term, prot, patch; + int rv, rc, tty, term; void *bootmsg; void *debugmsg; void *img; @@ -850,7 +847,6 @@ main(int argc, char **argv) imgpath = NULL; img = NULL; term = 0; - patch = 0; size = 0; speed = B115200; @@ -877,7 +873,7 @@ main(int argc, char **argv) break; case 'p': - patch = 1; + /* nop, for backward compatibility */ break; case 't': @@ -917,9 +913,6 @@ main(int argc, char **argv) if (!bootmsg && !term && !debugmsg) goto usage; - if (patch && !imgpath) - goto usage; - if (argc - optind < 1) goto usage; @@ -932,16 +925,12 @@ main(int argc, char **argv) } if (imgpath) { - prot = PROT_READ | (patch ? PROT_WRITE : 0); - - img = kwboot_mmap_image(imgpath, &size, prot); + img = kwboot_mmap_image(imgpath, &size); if (!img) { perror(imgpath); goto out; } - } - if (patch) { rc = kwboot_img_patch_hdr(img, size); if (rc) { fprintf(stderr, "%s: Invalid image.\n", imgpath); -- 2.31.1