Blame SOURCES/0177-cxl-list-Hide-0s-in-disabled-decoder-listings.patch

e0018b
From f649df38298043f68e73bc730ccb824de045f42d Mon Sep 17 00:00:00 2001
e0018b
From: Dan Williams <dan.j.williams@intel.com>
e0018b
Date: Thu, 14 Jul 2022 10:02:04 -0700
e0018b
Subject: [PATCH 177/217] cxl/list: Hide 0s in disabled decoder listings
e0018b
e0018b
Trim some redundant information from decoder listings when they are
e0018b
disabled.
e0018b
e0018b
Link: https://lore.kernel.org/r/165781812427.1555691.5252994293073680408.stgit@dwillia2-xfh.jf.intel.com
e0018b
Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
e0018b
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
e0018b
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
e0018b
---
e0018b
 cxl/json.c | 12 ++++++------
e0018b
 1 file changed, 6 insertions(+), 6 deletions(-)
e0018b
e0018b
diff --git a/cxl/json.c b/cxl/json.c
e0018b
index fdc6f73..a213fda 100644
e0018b
--- a/cxl/json.c
e0018b
+++ b/cxl/json.c
e0018b
@@ -442,7 +442,7 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder,
e0018b
 	const char *devname = cxl_decoder_get_devname(decoder);
e0018b
 	struct cxl_port *port = cxl_decoder_get_port(decoder);
e0018b
 	struct json_object *jdecoder, *jobj;
e0018b
-	u64 val;
e0018b
+	u64 val, size;
e0018b
 
e0018b
 	jdecoder = json_object_new_object();
e0018b
 	if (!jdecoder)
e0018b
@@ -452,21 +452,21 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder,
e0018b
 	if (jobj)
e0018b
 		json_object_object_add(jdecoder, "decoder", jobj);
e0018b
 
e0018b
+	size = cxl_decoder_get_size(decoder);
e0018b
 	val = cxl_decoder_get_resource(decoder);
e0018b
-	if (val < ULLONG_MAX) {
e0018b
+	if (size && val < ULLONG_MAX) {
e0018b
 		jobj = util_json_object_hex(val, flags);
e0018b
 		if (jobj)
e0018b
 			json_object_object_add(jdecoder, "resource", jobj);
e0018b
 	}
e0018b
 
e0018b
-	val = cxl_decoder_get_size(decoder);
e0018b
-	if (val < ULLONG_MAX) {
e0018b
-		jobj = util_json_object_size(val, flags);
e0018b
+	if (size && size < ULLONG_MAX) {
e0018b
+		jobj = util_json_object_size(size, flags);
e0018b
 		if (jobj)
e0018b
 			json_object_object_add(jdecoder, "size", jobj);
e0018b
 	}
e0018b
 
e0018b
-	if (val == 0) {
e0018b
+	if (size == 0) {
e0018b
 		jobj = json_object_new_string("disabled");
e0018b
 		if (jobj)
e0018b
 			json_object_object_add(jdecoder, "state", jobj);
e0018b
-- 
e0018b
2.27.0
e0018b