]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-print-json: update id-ctrl print code to use libnvme definition
authorTokunori Ikegami <ikegami.t@gmail.com>
Tue, 31 Dec 2024 15:16:44 +0000 (00:16 +0900)
committerDaniel Wagner <wagi@monom.org>
Fri, 3 Jan 2025 13:59:49 +0000 (14:59 +0100)
Use libnvme register definitions instead of the shift operator.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
nvme-print-json.c

index c11008f65f60f4cea8f0c157924c45bf209c7f17..8cc3f424f11c96ae7271e6e756758b866d783776 100644 (file)
@@ -450,8 +450,9 @@ void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl,
                struct json_object *psd = json_create_object();
 
                obj_add_int(psd, "max_power", le16_to_cpu(ctrl->psd[i].mp));
-               obj_add_int(psd, "max_power_scale", ctrl->psd[i].flags & 0x1);
-               obj_add_int(psd, "non-operational_state", (ctrl->psd[i].flags & 2) >> 1);
+               obj_add_int(psd, "max_power_scale", ctrl->psd[i].flags & NVME_PSD_FLAGS_MXPS);
+               obj_add_int(psd, "non-operational_state",
+                           !!(ctrl->psd[i].flags & NVME_PSD_FLAGS_NOPS));
                obj_add_uint(psd, "entry_lat", le32_to_cpu(ctrl->psd[i].enlat));
                obj_add_uint(psd, "exit_lat", le32_to_cpu(ctrl->psd[i].exlat));
                obj_add_int(psd, "read_tput", ctrl->psd[i].rrt);