diff --git a/sbin/nvmecontrol/logpage.c b/sbin/nvmecontrol/logpage.c index f7a6ef311a40..4ed941e5f045 100644 --- a/sbin/nvmecontrol/logpage.c +++ b/sbin/nvmecontrol/logpage.c @@ -319,11 +319,16 @@ print_log_error(const struct nvme_controller_data *cdata __unused, void *buf, ui } void -print_temp(uint16_t t) +print_temp_K(uint16_t t) { printf("%u K, %2.2f C, %3.2f F\n", t, (float)t - 273.15, (float)t * 9 / 5 - 459.67); } +void +print_temp_C(uint16_t t) +{ + printf("%2.2f K, %u C, %3.2f F\n", (float)t + 273.15, t, (float)t * 9 / 5 + 32); +} static void print_log_health(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused) @@ -350,7 +355,7 @@ print_log_health(const struct nvme_controller_data *cdata __unused, void *buf, u printf(" Volatile memory backup: %d\n", !!(warning & NVME_CRIT_WARN_ST_VOLATILE_MEMORY_BACKUP)); printf("Temperature: "); - print_temp(health->temperature); + print_temp_K(health->temperature); printf("Available spare: %u\n", health->available_spare); printf("Available spare threshold: %u\n", @@ -385,7 +390,7 @@ print_log_health(const struct nvme_controller_data *cdata __unused, void *buf, u if (health->temp_sensor[i] == 0) continue; printf("Temperature Sensor %d: ", i + 1); - print_temp(health->temp_sensor[i]); + print_temp_K(health->temp_sensor[i]); } printf("Temperature 1 Transition Count: %d\n", health->tmt1tc); printf("Temperature 2 Transition Count: %d\n", health->tmt2tc); diff --git a/sbin/nvmecontrol/modules/intel/intel.c b/sbin/nvmecontrol/modules/intel/intel.c index 8e3ed9e06cb9..895ffe30683f 100644 --- a/sbin/nvmecontrol/modules/intel/intel.c +++ b/sbin/nvmecontrol/modules/intel/intel.c @@ -64,17 +64,17 @@ print_intel_temp_stats(const struct nvme_controller_data *cdata __unused, void * printf("=====================\n"); printf("Current: "); - print_temp(temp->current); + print_temp_C(temp->current); printf("Overtemp Last Flags %#jx\n", (uintmax_t)temp->overtemp_flag_last); printf("Overtemp Lifetime Flags %#jx\n", (uintmax_t)temp->overtemp_flag_life); printf("Max Temperature "); - print_temp(temp->max_temp); + print_temp_C(temp->max_temp); printf("Min Temperature "); - print_temp(temp->min_temp); + print_temp_C(temp->min_temp); printf("Max Operating Temperature "); - print_temp(temp->max_oper_temp); + print_temp_C(temp->max_oper_temp); printf("Min Operating Temperature "); - print_temp(temp->min_oper_temp); + print_temp_C(temp->min_oper_temp); printf("Estimated Temperature Offset: %ju C/K\n", (uintmax_t)temp->est_offset); } diff --git a/sbin/nvmecontrol/modules/samsung/samsung.c b/sbin/nvmecontrol/modules/samsung/samsung.c index 497acf46e01c..d07732967b54 100644 --- a/sbin/nvmecontrol/modules/samsung/samsung.c +++ b/sbin/nvmecontrol/modules/samsung/samsung.c @@ -143,7 +143,7 @@ print_samsung_extended_smart(const struct nvme_controller_data *cdata __unused, uint128_to_str(to128(temp->lur), cbuf, sizeof(cbuf))); printf(" Lifetime Retired Block Count : %u\n", le32dec(&temp->lrbc)); printf(" Current Temperature : "); - print_temp(le16dec(&temp->ct)); + print_temp_K(le16dec(&temp->ct)); printf(" Capacitor Health : %u\n", le16dec(&temp->ch)); printf(" Reserved Erase Block Count : %u\n", le32dec(&temp->luurb)); printf(" Read Reclaim Count : %ju\n", (uintmax_t) le64dec(&temp->rrc)); diff --git a/sbin/nvmecontrol/nvmecontrol.h b/sbin/nvmecontrol/nvmecontrol.h index c1daaf6730d3..4b587c48d9a0 100644 --- a/sbin/nvmecontrol/nvmecontrol.h +++ b/sbin/nvmecontrol/nvmecontrol.h @@ -76,7 +76,8 @@ void print_hex(void *data, uint32_t length); void print_namespace(struct nvme_namespace_data *nsdata); void read_logpage(int fd, uint8_t log_page, uint32_t nsid, uint8_t lsp, uint16_t lsi, uint8_t rae, void *payload, uint32_t payload_size); -void print_temp(uint16_t t); +void print_temp_C(uint16_t t); +void print_temp_K(uint16_t t); void print_intel_add_smart(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused); /* Utility Routines */