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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF037C433EF for ; Fri, 24 Sep 2021 21:11:57 +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 3D6EF61090 for ; Fri, 24 Sep 2021 21:11:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3D6EF61090 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 DD5E08349E; Fri, 24 Sep 2021 23:10:53 +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="qjZYHvhD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8A3A5834F8; Fri, 24 Sep 2021 23:08:37 +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 A1CA383514 for ; Fri, 24 Sep 2021 23:07:57 +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=kabel@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 8F40F61361; Fri, 24 Sep 2021 21:07:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632517676; bh=T7z3Qbn30iP4ckiXNnfhCGFnwYSJF7CkgjaWhn5LFYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qjZYHvhDkXU5TC4IpNml06fI39sKhvYO28SiptkNCZsN9IzzvpPl6bdeFguv2ZEvL vKe0v5qSVG0WNSmLPEcvmdkeofJzgBdlMdVoegerPjgrR50IohapvCRATSmV7iBFue jdatMLm0NM1+OfLtuJhYX+dEPAJ+4YMq+o83oISyx/VGy4lVMLiB9sA0/+u7q0qt0g 5YZCvyEBslH1wA1kodBXi17jzv/3Rlvxzd27weVN25vBku9yKPPYpTHG15PlkV3Z2e 7zPi2umxKvZ38kHGx7Ghk0Lw4KZKJbqKsYSb0qHyn6csbZjwlJ6D8r1flGgKzcXVh4 +JeEfi4T6F0nA== 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 v3 18/39] tools: kwboot: Always call kwboot_img_patch_hdr() Date: Fri, 24 Sep 2021 23:06:55 +0200 Message-Id: <20210924210716.29752-19-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210924210716.29752-1-kabel@kernel.org> References: <20210924210716.29752-1-kabel@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 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 ad91afd075..9394a51380 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -709,9 +709,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; @@ -726,9 +726,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; @@ -833,7 +831,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"); @@ -853,7 +850,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; @@ -867,7 +864,6 @@ main(int argc, char **argv) imgpath = NULL; img = NULL; term = 0; - patch = 0; size = 0; speed = B115200; @@ -894,7 +890,7 @@ main(int argc, char **argv) break; case 'p': - patch = 1; + /* nop, for backward compatibility */ break; case 't': @@ -934,9 +930,6 @@ main(int argc, char **argv) if (!bootmsg && !term && !debugmsg) goto usage; - if (patch && !imgpath) - goto usage; - if (argc - optind < 1) goto usage; @@ -949,16 +942,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.32.0