From patchwork Mon Oct 25 08:06:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dong Du X-Patchwork-Id: 1545603 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=IpnR2JNA; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hd6yb08gNz9sXN for ; Mon, 25 Oct 2021 19:08:07 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=bo5EUwpilnvbPIO1PrsFst03tJkAVXZK/70QboZ1vzY=; b=IpnR2JNArW/eNO kcYh+uFTl7FJ54xlai26CZFbYKsaHZU0M7LKzrzWWNyusDtImCihlAJKK7Qt7zqKUAmHZqI62Nwhy eSQikbXf5MTCA5it3IsI7eZtXoyzlHlgUTNUvRR6NuFn5qkR9pGVVwmqPSr+KIpIbUzm8tHRZcy1X xk+Mfo3b4V2nfVxP34sccbBYzzQskzCElop4uE2MUfY/4ypYBpVlQ6eXpHQ4YS5eEmRYnHq23t6nG nC0F491Sa2MSk6KdIf43MM0p1cIxeli2sc2O81UnTbtH+Z58yltxTZyoHeEUL23FYv2JQuHUhrZiK NOvGvwsJ+bzTiBPSduRg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mev1Q-00FisR-IP; Mon, 25 Oct 2021 08:07:56 +0000 Received: from smtp181.sjtu.edu.cn ([202.120.2.181]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mev0W-00FiRm-Ts for opensbi@lists.infradead.org; Mon, 25 Oct 2021 08:07:03 +0000 Received: from proxy02.sjtu.edu.cn (smtp188.sjtu.edu.cn [202.120.2.188]) by smtp181.sjtu.edu.cn (Postfix) with ESMTPS id 334351008CBC1; Mon, 25 Oct 2021 16:06:48 +0800 (CST) Received: from localhost (localhost.localdomain [127.0.0.1]) by proxy02.sjtu.edu.cn (Postfix) with ESMTP id 85A24200BFDA6; Mon, 25 Oct 2021 16:06:45 +0800 (CST) X-Virus-Scanned: amavisd-new at Received: from proxy02.sjtu.edu.cn ([127.0.0.1]) by localhost (proxy02.sjtu.edu.cn [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id TrzpBsoF3NJD; Mon, 25 Oct 2021 16:06:44 +0800 (CST) Received: from dd-PC7.ipads-lab.se.sjtu.edu.cn (unknown [202.120.40.82]) (Authenticated sender: Dd_nirvana@sjtu.edu.cn) by proxy02.sjtu.edu.cn (Postfix) with ESMTPSA id 8B025200BFDA9; Mon, 25 Oct 2021 16:06:38 +0800 (CST) From: Dong Du To: anup.patel@wdc.com Cc: bmeng.cn@gmail.com, atish.patra@wdc.com, opensbi@lists.infradead.org, Dong Du Subject: [PATCH] lib: sbi: Refine addr format in sbi_printf Date: Mon, 25 Oct 2021 16:06:15 +0800 Message-Id: <20211025080615.4881-1-Dd_nirvana@sjtu.edu.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211025_010701_200839_E1AA9ECA X-CRM114-Status: UNSURE ( 5.30 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 1.5 (+) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Although we have PRILX to help us print unsigned long without considering the 32bit/64bit differences, there are still some places using 08lx and 016lx manually --- leading to redundant code. This commit fixes the issue by using PRILX all the time. Content analysis details: (1.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.5 RCVD_IN_SORBS_WEB RBL: SORBS: sender is an abusable web server [202.120.40.82 listed in dnsbl.sorbs.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Although we have PRILX to help us print unsigned long without considering the 32bit/64bit differences, there are still some places using 08lx and 016lx manually --- leading to redundant code. This commit fixes the issue by using PRILX all the time. Signed-off-by: Dong Du Reviewed-by: Anup Patel --- lib/sbi/sbi_domain.c | 18 +++--------------- lib/sbi/sbi_hart.c | 11 ++--------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c index 3096af0..33d7ad5 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -328,11 +328,7 @@ void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix) rend = (reg->order < __riscv_xlen) ? rstart + ((1UL << reg->order) - 1) : -1UL; -#if __riscv_xlen == 32 - sbi_printf("Domain%d Region%02d %s: 0x%08lx-0x%08lx ", -#else - sbi_printf("Domain%d Region%02d %s: 0x%016lx-0x%016lx ", -#endif + sbi_printf("Domain%d Region%02d %s: 0x%" PRILX "-0x%" PRILX " ", dom->index, i, suffix, rstart, rend); k = 0; @@ -351,18 +347,10 @@ void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix) i++; } -#if __riscv_xlen == 32 - sbi_printf("Domain%d Next Address%s: 0x%08lx\n", -#else - sbi_printf("Domain%d Next Address%s: 0x%016lx\n", -#endif + sbi_printf("Domain%d Next Address%s: 0x%" PRILX "\n", dom->index, suffix, dom->next_addr); -#if __riscv_xlen == 32 - sbi_printf("Domain%d Next Arg1 %s: 0x%08lx\n", -#else - sbi_printf("Domain%d Next Arg1 %s: 0x%016lx\n", -#endif + sbi_printf("Domain%d Next Arg1 %s: 0x%" PRILX "\n", dom->index, suffix, dom->next_arg1); sbi_printf("Domain%d Next Mode %s: ", dom->index, suffix); diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index 6254452..8eb0c38 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -150,17 +150,10 @@ void sbi_hart_delegation_dump(struct sbi_scratch *scratch, /* No delegation possible as mideleg does not exist*/ return; -#if __riscv_xlen == 32 - sbi_printf("%sMIDELEG%s: 0x%08lx\n", + sbi_printf("%sMIDELEG%s: 0x%" PRILX "\n", prefix, suffix, csr_read(CSR_MIDELEG)); - sbi_printf("%sMEDELEG%s: 0x%08lx\n", + sbi_printf("%sMEDELEG%s: 0x%" PRILX "\n", prefix, suffix, csr_read(CSR_MEDELEG)); -#else - sbi_printf("%sMIDELEG%s: 0x%016lx\n", - prefix, suffix, csr_read(CSR_MIDELEG)); - sbi_printf("%sMEDELEG%s: 0x%016lx\n", - prefix, suffix, csr_read(CSR_MEDELEG)); -#endif } unsigned int sbi_hart_mhpm_count(struct sbi_scratch *scratch)