]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Use correct power scale bits
authorKeith Busch <keith.busch@intel.com>
Sat, 14 May 2016 16:51:31 +0000 (12:51 -0400)
committerKeith Busch <keith.busch@intel.com>
Sat, 14 May 2016 16:51:31 +0000 (12:51 -0400)
The active and idle power scales occupy the upper 2 bits of their byte
fields. Shift the scales to use these bits when decoding their values.

Issue: https://github.com/linux-nvme/nvme-cli/issues/85
Signed-off-by: Keith Busch <keith.busch@intel.com>
linux/nvme.h
nvme-print.c

index e2546d494597e22b8fe36a6076659d3669dca350..7220b43c07e75f45920fa4317ad2c8dca80cee8a 100644 (file)
@@ -54,6 +54,9 @@ struct nvme_id_power_state {
        __u8                    rsvd23[9];
 };
 
+/* idle and active power scales occupy the last 2 bits of the field */
+#define POWER_SCALE(s) ((s) >> 6)
+
 enum {
        NVME_PS_FLAGS_MAX_POWER_SCALE   = 1 << 0,
        NVME_PS_FLAGS_NON_OP_STATE      = 1 << 1,
index 646f1daa28f44443e2fa20019afafd209a3b22cd..b7a7d1e4e8fe9b85864dfadfe04c2f2bab526b4b 100644 (file)
@@ -563,10 +563,10 @@ static void show_nvme_id_ctrl_power(struct nvme_id_ctrl *ctrl, unsigned int mode
                        ctrl->psd[i].read_tput, ctrl->psd[i].read_lat,
                        ctrl->psd[i].write_tput, ctrl->psd[i].write_lat);
                print_ps_power_and_scale(ctrl->psd[i].idle_power,
-                                        ctrl->psd[i].idle_scale);
+                                        POWER_SCALE(ctrl->psd[i].idle_scale));
                printf(" active_power:");
                print_ps_power_and_scale(ctrl->psd[i].active_power,
-                                        ctrl->psd[i].active_work_scale);
+                                        POWER_SCALE(ctrl->psd[i].active_work_scale));
                printf("\n");
 
        }