anitazha / rpms / ndctl

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