Message ID | 165765286159.435671.9172753303612160309.stgit@dwillia2-xfh (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | cxl: Region provisioning foundation | expand |
On Tue, 12 Jul 2022, Dan Williams wrote: >Trim some redundant information from decoder listings when they are >disabled. > Reviewed-by: Davidlohr Bueso <dave@stgolabs.net> >Signed-off-by: Dan Williams <dan.j.williams@intel.com> >--- > cxl/json.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > >diff --git a/cxl/json.c b/cxl/json.c >index fdc6f73a86c1..a213fdad55fd 100644 >--- a/cxl/json.c >+++ b/cxl/json.c >@@ -442,7 +442,7 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder, > const char *devname = cxl_decoder_get_devname(decoder); > struct cxl_port *port = cxl_decoder_get_port(decoder); > struct json_object *jdecoder, *jobj; >- u64 val; >+ u64 val, size; > > jdecoder = json_object_new_object(); > if (!jdecoder) >@@ -452,21 +452,21 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder, > if (jobj) > json_object_object_add(jdecoder, "decoder", jobj); > >+ size = cxl_decoder_get_size(decoder); > val = cxl_decoder_get_resource(decoder); >- if (val < ULLONG_MAX) { >+ if (size && val < ULLONG_MAX) { > jobj = util_json_object_hex(val, flags); > if (jobj) > json_object_object_add(jdecoder, "resource", jobj); > } > >- val = cxl_decoder_get_size(decoder); >- if (val < ULLONG_MAX) { >- jobj = util_json_object_size(val, flags); >+ if (size && size < ULLONG_MAX) { >+ jobj = util_json_object_size(size, flags); > if (jobj) > json_object_object_add(jdecoder, "size", jobj); > } > >- if (val == 0) { >+ if (size == 0) { > jobj = json_object_new_string("disabled"); > if (jobj) > json_object_object_add(jdecoder, "state", jobj); >
diff --git a/cxl/json.c b/cxl/json.c index fdc6f73a86c1..a213fdad55fd 100644 --- a/cxl/json.c +++ b/cxl/json.c @@ -442,7 +442,7 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder, const char *devname = cxl_decoder_get_devname(decoder); struct cxl_port *port = cxl_decoder_get_port(decoder); struct json_object *jdecoder, *jobj; - u64 val; + u64 val, size; jdecoder = json_object_new_object(); if (!jdecoder) @@ -452,21 +452,21 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder, if (jobj) json_object_object_add(jdecoder, "decoder", jobj); + size = cxl_decoder_get_size(decoder); val = cxl_decoder_get_resource(decoder); - if (val < ULLONG_MAX) { + if (size && val < ULLONG_MAX) { jobj = util_json_object_hex(val, flags); if (jobj) json_object_object_add(jdecoder, "resource", jobj); } - val = cxl_decoder_get_size(decoder); - if (val < ULLONG_MAX) { - jobj = util_json_object_size(val, flags); + if (size && size < ULLONG_MAX) { + jobj = util_json_object_size(size, flags); if (jobj) json_object_object_add(jdecoder, "size", jobj); } - if (val == 0) { + if (size == 0) { jobj = json_object_new_string("disabled"); if (jobj) json_object_object_add(jdecoder, "state", jobj);
Trim some redundant information from decoder listings when they are disabled. Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- cxl/json.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)