diff mbox series

[ndctl,v2,3/3] cxl: Fix the checking value when listing device's health info

Message ID 20230807063549.5942-4-jehoon.park@samsung.com
State New, archived
Headers show
Series [ndctl,v2,1/3] libcxl: Update a revision by CXL 3.0 specification | expand

Commit Message

Jehoon Park Aug. 7, 2023, 6:35 a.m. UTC
Fix the value for checking device's life used and temperature fields are
implemented.

Signed-off-by: Jehoon Park <jehoon.park@samsung.com>
---
 cxl/json.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff mbox series

Patch

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);