From patchwork Wed Aug 14 11:00:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 819135 Delivered-To: patch@linaro.org Received: by 2002:adf:cd01:0:b0:367:895a:4699 with SMTP id w1csp646868wrm; Wed, 14 Aug 2024 04:06:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVpg5AZ5+4NrzjAK5wfGhv9a+XmO93E8OW3pbVqTvaykQAR/WAwRwKSKPCPJ8nQE/NXKUTIHW9PQHrWd7poYE3c X-Google-Smtp-Source: AGHT+IFGyr9iZ+E6+ihF9Yrd2ngDp92aFh/HqoIBJ2ocP0KKIYVAxqlb7y9A4Zrq2vZU1SVFO+Kn X-Received: by 2002:a05:6402:2714:b0:578:60a6:7c69 with SMTP id 4fb4d7f45d1cf-5bea1cac905mr1547871a12.30.1723633588918; Wed, 14 Aug 2024 04:06:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723633588; cv=none; d=google.com; s=arc-20160816; b=nvN4qWVZSBtpTb+zvruTi93npBQs40QWgRdwNZ1vR12hg5OKB7r48xZJm6aErwMwg3 JftAafPfiWQ2xhmndLSYecTKZXk4MkheW21pG1nAHM537Kr174PnrI4S8W4KCaFAGPx5 Rx/j2U50lCVJZZV+x0FqO6PaJ3PD1GoAS2CnGkgiMFUe78LYO9wsk2KbG1ywtvkiWGsX 7xTYRk+mGyZj8QECHNKX9VJLVqdRa7W+gvbI0pxLIPwtxc3B0Rzl8SLZHHBiiopAtIa1 urr9df8h0TKwFtavS3PiS8kA3I3OdBBBAvfA4LHc2+oEljP4ch/qHVVoBv2LOVJQ+/gd prfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=cBBhqJR0sjovqiaeoE5Wbiu9ig0p3HYxyPq7Kf5VDbw=; fh=w4WyT9xL7ErtT1TeetrD/m0Y0mAgjnERgxacGUpGjSg=; b=DeemklAB7lwbgNSd+oNmHloa/OWCk++rwIt+ZA1RUdgFwuyl4eVKh3ithfak9vwlRd 7g0zeOmOsF1k7/tJwZSmBWsSl2nfKBAA8Dk6X+H/hxmKAbZ32bWKctWPuL0u1mwgpa5P 92aUZtrwbr9gKpWj9DftRvNSjvHbOAg3fk5ri1QyQsJGyPGEVApIvZJRY+wMGDxQbQWd HoJJjPyV7ju0Jysng7VD1lGMdFc02f65C/fOS4/2xatMqQgqtrlX5Nf6J8kMO3TyQcij lsl5k7LsNot05ScW4p2ClrTH2ysE0r3jWq2n0Tb7jlt2oodY8+qSEIfI3Em20HHzIYsO HHwQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5bd187f8284si5407987a12.1.2024.08.14.04.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 04:06:28 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 35B2688AC2; Wed, 14 Aug 2024 13:03:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 75A4A88A27; Wed, 14 Aug 2024 13:03:16 +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.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 4F264889D0 for ; Wed, 14 Aug 2024 13:03:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A8BA3DA7; Wed, 14 Aug 2024 04:03:39 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3548D3F58B; Wed, 14 Aug 2024 04:03:08 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Marek Vasut , Tom Rini , Mark Kettenis , Michal Simek , Patrick DELAUNAY , Patrice CHOTARD , Huan Wang , Angelo Dureghello , Daniel Schwierzeck , Thomas Chou , Rick Chen , Max Filippov , Sughosh Ganu Subject: [PATCH v2 32/32] lmb: add logic to print lmb flag strings Date: Wed, 14 Aug 2024 16:30:09 +0530 Message-Id: <20240814110009.45310-33-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240814110009.45310-1-sughosh.ganu@linaro.org> References: <20240814110009.45310-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean Instead of printing the LMB flags as numerical values, print them as strings. This makes it easier to understand what flags are associated with the lmb region. Also make corresponding changes to the bdinfo command's test code. Signed-off-by: Sughosh Ganu Reviewed-by: Simon Glass --- Changes since V1: New patch lib/lmb.c | 18 ++++++++++++++++-- test/cmd/bdinfo.c | 4 ++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index 37d2a72951..5c5b3e9bb5 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -26,6 +26,19 @@ DECLARE_GLOBAL_DATA_PTR; static struct lmb lmb; +static void print_region_flags(enum lmb_flags flags) +{ + uint64_t bitpos; + const char *flag_str[] = { "LMB_NONE", "LMB_NOMAP", "LMB_NOOVERWRITE" }; + + do { + bitpos = fls(flags) - 1; + printf("%s", flag_str[bitpos]); + flags &= ~(1ull << bitpos); + flags ? puts(", ") : puts("\n"); + } while (flags); +} + static void lmb_dump_region(struct alist *lmb_rgn_lst, char *name) { struct lmb_region *rgn = lmb_rgn_lst->data; @@ -41,8 +54,9 @@ static void lmb_dump_region(struct alist *lmb_rgn_lst, char *name) end = base + size - 1; flags = rgn[i].flags; - printf(" %s[%d]\t[0x%llx-0x%llx], 0x%08llx bytes flags: %x\n", - name, i, base, end, size, flags); + printf(" %s[%d]\t[0x%llx-0x%llx], 0x%08llx bytes flags: ", + name, i, base, end, size); + print_region_flags(flags); } } diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index 7dd3f7ca5b..887defc28a 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -120,8 +120,8 @@ static int lmb_test_dump_region(struct unit_test_state *uts, ut_assert_nextlinen(" %s[%d]\t[", name, i); continue; } - ut_assert_nextline(" %s[%d]\t[0x%llx-0x%llx], 0x%08llx bytes flags: %x", - name, i, base, end, size, flags); + ut_assert_nextlinen(" %s[%d]\t[0x%llx-0x%llx], 0x%08llx bytes flags: ", + name, i, base, end, size); } return 0;