From patchwork Mon Aug 26 11:59:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 822461 Delivered-To: patch@linaro.org Received: by 2002:adf:e044:0:b0:367:895a:4699 with SMTP id w4csp1478908wrh; Mon, 26 Aug 2024 05:04:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVee4s9YuPK+MpTH97uDG3tItYLB3Cu7Ekyq2qvfnzlvTNsvqVgRhwkNr0G7XiyAG5aX0kbXQ==@linaro.org X-Google-Smtp-Source: AGHT+IEs49EGdg/WHXow5Zy8eyTNgty9FeN4a912oC+ESbHviAqxPqR6RrOLBxh+9qqpt2qWULT5 X-Received: by 2002:a5d:44c9:0:b0:368:3ac6:1fff with SMTP id ffacd0b85a97d-37310ec8e04mr5083953f8f.20.1724673882183; Mon, 26 Aug 2024 05:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724673882; cv=none; d=google.com; s=arc-20160816; b=i8wo03Kstje0ZRGFJavF0UysSvQuwGumBpkzAq6TFcuIwy09vYJ4uJlz+NOnxSGwud 4mRdg6JILhjmD/egQsz8+W+/FzBmehfgI/l3JX0PzZQPnXD2a46lZ+xFMXj3t/+DYguq w798FF6xhc1ykpCQaGJfaLUr317n0+hE3fjLqgSYbWo+7shrNM6J6w4EIIOzBlAhNitK pExc0RpljQYNVDvpUIYrRfii5SHHUQxTZh31EL3xyL1xlQ/HI3JOzdfJ9ZC/5EM7EbOy E6hV3ZX8U4nEHHGdB9cLg3YzlMEMGwUr1AEYPew+Oe79imeYUDXQ7HNQ4rq0HiCq2lL/ uL9A== 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=WfkrbRrRtd2fSky6XVooChRTJAmaqhWB1/PAUf/LPmw=; fh=8IbOOFAUJYCfGYrzM0jWqtoOP7AaZuPOmdHZ5mvNk1Q=; b=zBqM+PFFM8ibBu4d180nfu172l05YMSGy4yLRTlcrc/GAOItu+fij8NWlsx1sFz5L/ 4Ql77xWbQ+V66LBiJiUNLt04WptjUWwYT8WvAR4mlHmGlSftKdGdQ1PqdZkwZsH1BfMK EWwKVHUnBNos/+ps5CnCn6CaitVYcpFVvJG08/iKYMHr3uG1mwOGm6tIRZ1E3GXTGQGv WFLkxoMfl5Ln8p0Cjhq4edZKo7IUzN0ZgWNUsY5dkqMftN5S1971im2po2mE+OwTGxBc 8lmli5MrceZF/66DzMJuOM8gopGGzuE7hSaDcW9kRp47+LyjmUvlFu6Hfpza1irzsWO3 i85w==; 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 ffacd0b85a97d-3730826f196si3605110f8f.794.2024.08.26.05.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 05:04:42 -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 385A588C4B; Mon, 26 Aug 2024 14:02:04 +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 6918D866EB; Mon, 26 Aug 2024 14:02:03 +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 6BEF788C1C for ; Mon, 26 Aug 2024 14:02:01 +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 19D53DA7; Mon, 26 Aug 2024 05:02:27 -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 3DFC53F762; Mon, 26 Aug 2024 05:01:56 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Simon Glass , Tom Rini , Ilias Apalodimas , Heinrich Schuchardt , Marek Vasut , Mark Kettenis , Michal Simek , Patrick DELAUNAY , Patrice CHOTARD , =?utf-8?q?Marek_Beh=C3=BAn?= , Sughosh Ganu Subject: [PATCH v4 27/27] lmb: add logic to print lmb flag strings Date: Mon, 26 Aug 2024 17:29:40 +0530 Message-Id: <20240826115940.3233167-28-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240826115940.3233167-1-sughosh.ganu@linaro.org> References: <20240826115940.3233167-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 V3: * Put the tertiary expression in the puts() function call as suggested by Simon Glass. * s/uin64_t/u64 in lmb_print_region_flags() as suggested by checkpatch. lib/lmb.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index 9f1bb5ec7d..3ed570fb29 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -27,6 +27,19 @@ DECLARE_GLOBAL_DATA_PTR; static struct lmb lmb; +static void lmb_print_region_flags(enum lmb_flags flags) +{ + u64 bitpos; + const char *flag_str[] = { "none", "no-map", "no-overwrite" }; + + do { + bitpos = flags ? fls(flags) - 1 : 0; + printf("%s", flag_str[bitpos]); + flags &= ~(1ull << bitpos); + puts(flags ? ", " : "\n"); + } while (flags); +} + static void lmb_dump_region(struct alist *lmb_rgn_lst, char *name) { struct lmb_region *rgn = lmb_rgn_lst->data; @@ -42,8 +55,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); + lmb_print_region_flags(flags); } }