From 4494ea291455b670ebf6c61c11439e347f105edc Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Wed, 1 Jan 2025 00:16:44 +0900 Subject: [PATCH] nvme-print-json: update id-ctrl print code to use libnvme definition Use libnvme register definitions instead of the shift operator. Signed-off-by: Tokunori Ikegami --- nvme-print-json.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nvme-print-json.c b/nvme-print-json.c index c11008f65f..8cc3f424f1 100644 --- a/nvme-print-json.c +++ b/nvme-print-json.c @@ -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);