From: Keith Busch Date: Sat, 14 May 2016 16:51:31 +0000 (-0400) Subject: Use correct power scale bits X-Git-Tag: v0.7~5 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=5cb0521582504ebeec75ff74b57345773551f5ec;p=users%2Fsagi%2Fnvme-cli.git Use correct power scale bits 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 --- diff --git a/linux/nvme.h b/linux/nvme.h index e2546d49..7220b43c 100644 --- a/linux/nvme.h +++ b/linux/nvme.h @@ -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, diff --git a/nvme-print.c b/nvme-print.c index 646f1daa..b7a7d1e4 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -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"); }