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