Fix the value for checking device's life used and temperature fields are
implemented.

Signed-off-by: Jehoon Park <[email protected]>
---
 cxl/json.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/cxl/json.c b/cxl/json.c
index 7678d02..102bfaf 100644
--- a/cxl/json.c
+++ b/cxl/json.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (C) 2015-2021 Intel Corporation. All rights reserved.
+#include <errno.h>
 #include <limits.h>
 #include <util/json.h>
 #include <uuid/uuid.h>
@@ -238,15 +239,15 @@ static struct json_object *util_cxl_memdev_health_to_json(
                json_object_object_add(jhealth, "ext_corrected_persistent", 
jobj);
 
        /* other fields */
-       field = cxl_cmd_health_info_get_life_used(cmd);
-       if (field != 0xff) {
-               jobj = json_object_new_int(field);
+       rc = cxl_cmd_health_info_get_life_used(cmd);
+       if (rc != -EOPNOTSUPP) {
+               jobj = json_object_new_int(rc);
                if (jobj)
                        json_object_object_add(jhealth, "life_used_percent", 
jobj);
        }
 
        field = cxl_cmd_health_info_get_temperature(cmd);
-       if (field != 0xffff) {
+       if (field != INT_MAX) {
                jobj = json_object_new_int(field);
                if (jobj)
                        json_object_object_add(jhealth, "temperature", jobj);
-- 
2.17.1


Reply via email to