diff mbox

[ndctl,2/2] ndctl, list: add 'id' to the dimm listing

Message ID 146171505042.32030.8733064490141646370.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit 9ad5e48df496
Headers show

Commit Message

Dan Williams April 26, 2016, 11:57 p.m. UTC
Emit the ACPI 6.1 defined DIMM identfier if available.

# ndctl list -D -d nmem0
{
  "dev":"nmem0",
  "id":"cdab-ffffffff"
}

Cc: Toshi Kani <toshi.kani@hpe.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 util/json.c |    8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox

Patch

diff --git a/util/json.c b/util/json.c
index 4e2d902a183e..1d914da318fa 100644
--- a/util/json.c
+++ b/util/json.c
@@ -53,6 +53,7 @@  struct json_object *util_bus_to_json(struct ndctl_bus *bus)
 struct json_object *util_dimm_to_json(struct ndctl_dimm *dimm)
 {
 	struct json_object *jdimm = json_object_new_object();
+	const char *id = ndctl_dimm_get_unique_id(dimm);
 	struct json_object *jobj;
 
 	if (!jdimm)
@@ -63,6 +64,13 @@  struct json_object *util_dimm_to_json(struct ndctl_dimm *dimm)
 		goto err;
 	json_object_object_add(jdimm, "dev", jobj);
 
+	if (id) {
+		jobj = json_object_new_string(id);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jdimm, "id", jobj);
+	}
+
 	if (!ndctl_dimm_is_enabled(dimm)) {
 		jobj = json_object_new_string("disabled");
 		if (!jobj)