From patchwork Mon Mar 30 03:56:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kever Yang X-Patchwork-Id: 1263714 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=jfOpSWB2; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48rJZ039wKz9sPF for ; Mon, 30 Mar 2020 14:57:12 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 04C1A818CF; Mon, 30 Mar 2020 05:56:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jfOpSWB2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2C02C818F4; Mon, 30 Mar 2020 05:56:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 980238120B for ; Mon, 30 Mar 2020 05:56:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kever.yang@gmail.com Received: by mail-pf1-x442.google.com with SMTP id k15so2821092pfh.6 for ; Sun, 29 Mar 2020 20:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=MWbCcRXFqUqprnV0PKJkEwD/9W2PU0uyCJs5+VNcQ1E=; b=jfOpSWB2yL4USqMTPbxEdYHD48dhW1xKzI+nvcAEdxtYpagXQf/ZnwVXiWcWN4Xvru d94FfNQ9kjKHgG12xjSSOUhOHmR5WBlW5t/RKsa36pGowqI35fLdtm2DsvKZO5NjAnAh PJkSAuYsE7hJ88B+IJpaU+2MYNjd2K9c58Mk6S6eO5Y6Lnxdoyg5qhkfhwU+5u6g4yIX gX/FHuZHyHFO4fJiokVFaW00biv2c4bb7MSTCXTN4TMSvfth3Y2JPuB0jZPvVGCkAmdl yQXpdk41Xq1hQVdwe6cjk5FVv/UYf2i48Mpa/z3QzI0cd0dS6FYLrKJJqviaP6FzubO1 yeMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=MWbCcRXFqUqprnV0PKJkEwD/9W2PU0uyCJs5+VNcQ1E=; b=anUa0vS4AxZsnn4Qgwdqf2pRjcNdk0VWqb2ujiCQA6EgPDhK93VZmMoDfSikiUjgK0 Vs/zQGSNitVlkh6qvhGXYhmnF8wiVUcdFXvNumld9Hsf/f+Xf5Hoc1Sm8MCV4C5BbL7f 9uYb4KKjAtn0q7Zuw++dvM11sW6sGxEPcWud+AuOeMmFRDxfnWRa5jHe4oIlqHJo1gXF xB6kPSa+n/E+FQxUhK81WtJUrKzIsvi+1+TJCa3CZ+ktgkv/V2oBVhXlFhynuXS3Actx 0qLaKTPq268SI6GpbAAR93E87T3uIjyXs7TBtjuYkG7KAV9KJj5STJECHuVw2GbwjTXb Ezyg== X-Gm-Message-State: ANhLgQ1SPDbVDtvPcfNfNiuK7yrtJXM+rJ886lyQqdTA1S0sZNdkOclt pNADwISBA1V1gvBkxgj5woLiM5K9 X-Google-Smtp-Source: ADFU+vuS7yi7YKI8G1/AbTSwwj8JVHGu5Ca7oSXukez9b9NZBMAc9wS+RS2vcO5a6Movri0MIGkwdw== X-Received: by 2002:a63:9c4:: with SMTP id 187mr10779235pgj.389.1585540599834; Sun, 29 Mar 2020 20:56:39 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id n100sm8902514pjc.38.2020.03.29.20.56.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Mar 2020 20:56:39 -0700 (PDT) From: Kever Yang To: u-boot@lists.denx.de Cc: chenjh@rock-chips.com, rasmus.villemoes@prevas.dk, trini@konsulko.com, xypron.glpk@gmx.de, punit1.agrawal@toshiba.co.jp, Kever Yang , Chris Packham , Stefan Roese , Young Xiao <92siuyang@gmail.com> Subject: [PATCH v4 4/8] tools: kwbimage: use common ALIGN to do the size align Date: Mon, 30 Mar 2020 11:56:20 +0800 Message-Id: <20200330035625.25164-4-kever.yang@rock-chips.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200330035625.25164-1-kever.yang@rock-chips.com> References: <20200330035625.25164-1-kever.yang@rock-chips.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean The ALIGN() is now available at imagetool.h, migrate to use it. Signed-off-by: Kever Yang Reviewed-by: Punit Agrawal Reviewed-by: Tom Rini Reviewed-by: Stefan Roese --- Changes in v4: None Changes in v3: None Changes in v2: None tools/kwbimage.c | 8 ++++---- tools/kwbimage.h | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index b8f8d38212..02fd0c949f 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1015,7 +1015,7 @@ static size_t image_headersz_v1(int *hasext) * The payload should be aligned on some reasonable * boundary */ - return ALIGN_SUP(headersz, 4096); + return ALIGN(headersz, 4096); } int add_binary_header_v1(uint8_t *cur) @@ -1058,7 +1058,7 @@ int add_binary_header_v1(uint8_t *cur) * up to a 4-byte boundary. Plus 4 bytes for the * next-header byte and 3-byte alignment at the end. */ - binhdrsz = ALIGN_SUP(binhdrsz, 4) + 4; + binhdrsz = ALIGN(binhdrsz, 4) + 4; hdr->headersz_lsb = cpu_to_le16(binhdrsz & 0xFFFF); hdr->headersz_msb = (binhdrsz & 0xFFFF0000) >> 16; @@ -1082,7 +1082,7 @@ int add_binary_header_v1(uint8_t *cur) fclose(bin); - cur += ALIGN_SUP(s.st_size, 4); + cur += ALIGN(s.st_size, 4); /* * For now, we don't support more than one binary @@ -1548,7 +1548,7 @@ static void kwbimage_set_header(void *ptr, struct stat *sbuf, int ifd, } /* The MVEBU BootROM does not allow non word aligned payloads */ - sbuf->st_size = ALIGN_SUP(sbuf->st_size, 4); + sbuf->st_size = ALIGN(sbuf->st_size, 4); version = image_get_version(); switch (version) { diff --git a/tools/kwbimage.h b/tools/kwbimage.h index 25bc08c5ce..0b6d05bef1 100644 --- a/tools/kwbimage.h +++ b/tools/kwbimage.h @@ -29,8 +29,6 @@ #define IBR_HDR_UART_ID 0x69 #define IBR_DEF_ATTRIB 0x00 -#define ALIGN_SUP(x, a) (((x) + (a - 1)) & ~(a - 1)) - /* Structure of the main header, version 0 (Kirkwood, Dove) */ struct main_hdr_v0 { uint8_t blockid; /* 0x0 */