]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wil6210: fix temperature debugfs
authorDedy Lansky <dlansky@codeaurora.org>
Tue, 21 Apr 2020 12:40:02 +0000 (13:40 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Apr 2020 06:01:03 +0000 (08:01 +0200)
[ Upstream commit 6d9eb7ebae3d7e951bc0999235ae7028eb4cae4f ]

For negative temperatures, "temp" debugfs is showing wrong values.
Use signed types so proper calculations is done for sub zero
temperatures.

Signed-off-by: Dedy Lansky <dlansky@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/ath/wil6210/debugfs.c

index 6db00c167d2e16f6ac63ad350864f3b2505f395f..3a98f75c5d7e5ce645f18c1eba4b857ad6e9ce21 100644 (file)
@@ -1093,7 +1093,7 @@ static const struct file_operations fops_ssid = {
 };
 
 /*---------temp------------*/
-static void print_temp(struct seq_file *s, const char *prefix, u32 t)
+static void print_temp(struct seq_file *s, const char *prefix, s32 t)
 {
        switch (t) {
        case 0:
@@ -1101,7 +1101,8 @@ static void print_temp(struct seq_file *s, const char *prefix, u32 t)
                seq_printf(s, "%s N/A\n", prefix);
        break;
        default:
-               seq_printf(s, "%s %d.%03d\n", prefix, t / 1000, t % 1000);
+               seq_printf(s, "%s %s%d.%03d\n", prefix, (t < 0 ? "-" : ""),
+                          abs(t / 1000), abs(t % 1000));
                break;
        }
 }
@@ -1109,7 +1110,7 @@ static void print_temp(struct seq_file *s, const char *prefix, u32 t)
 static int wil_temp_debugfs_show(struct seq_file *s, void *data)
 {
        struct wil6210_priv *wil = s->private;
-       u32 t_m, t_r;
+       s32 t_m, t_r;
        int rc = wmi_get_temperature(wil, &t_m, &t_r);
 
        if (rc) {