From patchwork Wed Aug 21 10:58:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 820977 Delivered-To: patch@linaro.org Received: by 2002:adf:e98a:0:b0:367:895a:4699 with SMTP id h10csp641283wrm; Wed, 21 Aug 2024 04:03:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXL2Kw2xAOcIMBrzu74F9GkG58HSGD4YWqfamnZBkh0VZq2yI6CRKntVCVHgEUm10O8SeOhyg==@linaro.org X-Google-Smtp-Source: AGHT+IFtZ3HAxktmyC3Xu1U3VwnSxz+SRIHnu1501KmsuRssAC0dkyFl5vhgGLIsOTbZ6iVY9eXV X-Received: by 2002:a05:6402:4404:b0:5be:d913:863b with SMTP id 4fb4d7f45d1cf-5bf1f0a9268mr1658774a12.4.1724238219273; Wed, 21 Aug 2024 04:03:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724238219; cv=none; d=google.com; s=arc-20160816; b=jn2qM0R8r7Rx0tQwyRdcUQhDwpU+ymuNTAwcyYt4TG4LJUk1bjg61qplWcXdzQbTU7 kbUON+U+LXzXHd2yPoDhHLlYCx52TTFAu7wYztVa3GG1N/0TdysW2EOmERReUG0NUhoG D1S0iyOmSvWSahU+hgGgWCOb8MGT1vUtNl8S5I9CpC/sdDpuB0rZKY1exa+Pqs6FMKJr g1gDEnuYzkht7CCl23xPigdAOv+z8CVx2/P8HcqKpfNjqUpYaTPz8RgINN18zJkFiJGm T6y/1AsNSZX2+xce9dUxhAN9TLBSt+8thgu0EokuqQM+hmqhNApA2vu10D+V/I8JcCsB ByLg== 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=/+M87ninzaUgdVHdKAxnu5aHoMaG+GMUgAUQbfKt4Yg=; fh=pnMZGD6unUPoMrkOwzXlkuYg+kVwGnSNRCTlQoWqjVc=; b=hZfg92UpY54FrBysX4pDuSE4LXmBx6spz9L1ZQc2IZ04grLhLcqDNsIBdQQoqhIwSb nChOZOX29zCKo5HD1iiSPy+1lO3VTPc7HgbiSDJWztTej7FMILBVrgJDDYK/yyIROQLT 3h8N5xsWJxiPlnLzeIUN8KyEFqeIjcYESGD+W43r3yGcz+r7iKVUEqrqu3z5kUa3Cke1 EZ+ooURQUTtrVgOqP3EHH1o5IxtHRdOU5XBT1t9MH7Us0woIiIYRuFfZSjOLdVL5iNNN /r8glAFrklFngoUn2RqRp3l3HCRYmqsa8uro+kxDjqvchTZeQxyUvhDXz1xJPdhNl81J M9cw==; 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-5becc4196a9si7165368a12.168.2024.08.21.04.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 04:03:39 -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 918C888C70; Wed, 21 Aug 2024 13:00:46 +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 D8C9F88C60; Wed, 21 Aug 2024 13:00:44 +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 E334288DE0 for ; Wed, 21 Aug 2024 13:00:42 +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 76611DA7; Wed, 21 Aug 2024 04:01:08 -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 152A33F73B; Wed, 21 Aug 2024 04:00:38 -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 , Sughosh Ganu Subject: [PATCH v3 27/27] lmb: add logic to print lmb flag strings Date: Wed, 21 Aug 2024 16:28:39 +0530 Message-Id: <20240821105839.2870293-28-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821105839.2870293-1-sughosh.ganu@linaro.org> References: <20240821105839.2870293-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 V2: * Change the logic to accomodate new value of LMB_NONE(0). * s/print_region_flags()/lmb_print_region_flags(). * s/"LMB_NOMAP"/"no-map". * s/"LMB_NOOVERWRITE"/"no-overwrite". lib/lmb.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index 11959760b6..0379798837 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -26,6 +26,19 @@ DECLARE_GLOBAL_DATA_PTR; static struct lmb lmb; +static void lmb_print_region_flags(enum lmb_flags flags) +{ + uint64_t 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); + 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); + lmb_print_region_flags(flags); } }