From: Tokunori Ikegami Date: Tue, 31 Dec 2024 15:16:44 +0000 (+0900) Subject: nvme-print-json: update id-ctrl print code to use libnvme definition X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=21e45d848a58736e67719aa8f4123e1359f888e5;p=users%2Fsagi%2Fnvme-cli.git 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 --- diff --git a/nvme-print-json.c b/nvme-print-json.c index c11008f6..8cc3f424 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);