From c67e0e7ff6c1d1ab7a8fe2e7c94e405cc495bbb3 Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Sun, 30 Jun 2024 15:56:27 +0900 Subject: [PATCH] nvme-print-json: add get-feature command fahrenheit temperature output Add temperature threshold and host controlled thermal management outputs. Signed-off-by: Tokunori Ikegami --- nvme-print-json.c | 6 +++--- nvme-print.c | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/nvme-print-json.c b/nvme-print-json.c index ec04f79b..414af8e6 100644 --- a/nvme-print-json.c +++ b/nvme-print-json.c @@ -3297,7 +3297,7 @@ static void json_feature_show_fields_temp_thresh(struct json_object *r, unsigned obj_add_uint(r, "Threshold Temperature Select (TMPSEL)", field); obj_add_str(r, "TMPSEL description", nvme_feature_temp_sel_to_string(field)); - sprintf(json_str, "%ld Celsius", kelvin_to_celsius(result & 0xffff)); + sprintf(json_str, "%s", nvme_degrees_string(result & 0xffff)); obj_add_str(r, "Temperature Threshold (TMPTH)", json_str); sprintf(json_str, "%u K", result & 0xffff); @@ -3467,13 +3467,13 @@ static void json_feature_show_fields_hctm(struct json_object *r, unsigned int re sprintf(json_str, "%u K", result >> 16); obj_add_str(r, "Thermal Management Temperature 1 (TMT1)", json_str); - sprintf(json_str, "%ld Celsius", kelvin_to_celsius(result >> 16)); + sprintf(json_str, "%s", nvme_degrees_string(result >> 16)); obj_add_str(r, "TMT1 celsius", json_str); sprintf(json_str, "%u K", result & 0xffff); obj_add_str(r, "Thermal Management Temperature 2", json_str); - sprintf(json_str, "%ld Celsius", kelvin_to_celsius(result & 0xffff)); + sprintf(json_str, "%s", nvme_degrees_string(result & 0xffff)); obj_add_str(r, "TMT2 celsius", json_str); } diff --git a/nvme-print.c b/nvme-print.c index f2b9988a..3165ab92 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -813,8 +813,10 @@ const char *nvme_degrees_string(long t) if (fahrenheit) val = kelvin_to_fahrenheit(t); - sprintf(str, "%ld °%s", val, fahrenheit ? "F" : "C"); - + if (nvme_is_output_format_json()) + sprintf(str, "%ld %s", val, fahrenheit ? "Fahrenheit" : "Celsius"); + else + sprintf(str, "%ld °%s", val, fahrenheit ? "F" : "C"); return str; } -- 2.50.1