From: Chaitanya Kulkarni Date: Sun, 26 Feb 2017 07:34:42 +0000 (-0800) Subject: nvme-cli: smart-log: Allow negative values for temp sensors. X-Git-Tag: v1.2~16 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2ead59720ecfd799979e3e463f7f81e8c5201b5d;p=users%2Fsagi%2Fnvme-cli.git nvme-cli: smart-log: Allow negative values for temp sensors. HGST devices allowed to produce valid negative values for "Temperature Sensor 1" of the smart-log command. Change the temperature sensor value from unsigned to signed so that negative values will be printed correctly. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Sagi Grimberg Signed-off-by: Keith Busch --- diff --git a/nvme-print.c b/nvme-print.c index b466aeef..d4dd7d57 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -805,8 +805,8 @@ void show_smart_log(struct nvme_smart_log *smart, unsigned int nsid, const char printf("Warning Temperature Time : %u\n", le32_to_cpu(smart->warning_temp_time)); printf("Critical Composite Temperature Time : %u\n", le32_to_cpu(smart->critical_comp_time)); for (c=0; c < 8; c++) { - __u16 temp = le16_to_cpu(smart->temp_sensor[c]); - printf("Temperature Sensor %d : %u C\n", c + 1, + __s32 temp = le16_to_cpu(smart->temp_sensor[c]); + printf("Temperature Sensor %d : %d C\n", c + 1, temp ? temp - 273 : 0); } }