From: Guan Junxiong Date: Wed, 21 Jun 2017 05:09:23 +0000 (+0800) Subject: nvme-cli: add temperature sensor fields in json_smart_log X-Git-Tag: v1.4~42 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=683e930ce27f85e3dc99f353c4785beb4c256603;p=users%2Fsagi%2Fnvme-cli.git nvme-cli: add temperature sensor fields in json_smart_log Signed-off-by: Guan Junxiong --- diff --git a/nvme-print.c b/nvme-print.c index 6005e065..f2fa67fe 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -1645,6 +1645,8 @@ void json_fw_log(struct nvme_firmware_log_page *fw_log, const char *devname) void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid, const char *devname) { struct json_object *root; + int c; + char key[21]; unsigned int temperature = ((smart->temperature[1] << 8) | smart->temperature[0]); @@ -1681,6 +1683,16 @@ void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid, const char le32_to_cpu(smart->warning_temp_time)); json_object_add_value_int(root, "critical_comp_time", le32_to_cpu(smart->critical_comp_time)); + + for (c=0; c < 8; c++) { + __s32 temp = le16_to_cpu(smart->temp_sensor[c]); + + if (temp == 0) + continue; + sprintf(key, "temperature_sensor_%d",c+1); + json_object_add_value_int(root, key, temp); + } + json_object_add_value_int(root, "thm_temp1_trans_count", le32_to_cpu(smart->thm_temp1_trans_count)); json_object_add_value_int(root, "thm_temp2_trans_count",