[Accel-config] [PATCH v1 6/6] accel-config: Call new op_cap API in json implementation

ramesh.thomas at intel.com
Newsgroups dev.linux.lists.accel-config
Message-ID <[email protected]>
From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Call the new op_cap API that supports 256 bits to populate json objects
used in listing and saving the op_cap value.

Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 util/json.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/util/json.c b/util/json.c
index e6e12e4..4fb43d2 100644
--- a/util/json.c
+++ b/util/json.c
@@ -131,6 +131,7 @@ struct json_object *util_device_to_json(struct accfg_device *device,
 	struct json_object *jdevice = json_object_new_object();
 	struct json_object *jobj;
 	struct accfg_error *error;
+	struct accfg_op_cap op_cap;
 	enum accfg_device_state dev_state;
 	int int_val;
 	uint64_t ulong_val;
@@ -228,6 +229,19 @@ struct json_object *util_device_to_json(struct accfg_device *device,
 		json_object_object_add(jdevice, "errors", jobj);
 	}
 
+	if (!accfg_device_get_op_cap(device, &op_cap)) {
+		jobj = json_object_new_array();
+		if (!jobj)
+			goto err;
+		for (int i = 0; i < 4; i++) {
+			struct json_object *json_oc;
+
+			json_oc = util_json_object_hex(op_cap.bits[i], flags);
+			json_object_array_add(jobj, json_oc);
+		}
+		json_object_object_add(jdevice, "op_cap", jobj);
+	}
+
 	jobj = util_json_object_hex(accfg_device_get_gen_cap(device), flags);
 	if (!jobj)
 		goto err;
-- 
2.26.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.