]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
thermal/drivers/brcmstb_thermal: Use max to simplify brcmstb_get_temp
authorThorsten Blum <thorsten.blum@linux.dev>
Thu, 2 Apr 2026 16:56:18 +0000 (18:56 +0200)
committerDaniel Lezcano <daniel.lezcano@kernel.org>
Thu, 2 Apr 2026 17:23:54 +0000 (19:23 +0200)
Use max() to simplify brcmstb_get_temp() and improve its readability.
Since avs_tmon_code_to_temp() returns an int, change the data type of
the local variable 't' from long to int.  No functional changes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20260402165616.895305-3-thorsten.blum@linux.dev
drivers/thermal/broadcom/brcmstb_thermal.c

index f46f2ddc174ea5ab6e459755921d6bd219442788..a9ffa596f7c0da1fa438c26b818ad53cc6ec9f0c 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/irqreturn.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/minmax.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
@@ -154,7 +155,7 @@ static int brcmstb_get_temp(struct thermal_zone_device *tz, int *temp)
 {
        struct brcmstb_thermal_priv *priv = thermal_zone_device_priv(tz);
        u32 val;
-       long t;
+       int t;
 
        val = __raw_readl(priv->tmon_base + AVS_TMON_STATUS);
 
@@ -164,10 +165,7 @@ static int brcmstb_get_temp(struct thermal_zone_device *tz, int *temp)
        val = (val & AVS_TMON_STATUS_data_msk) >> AVS_TMON_STATUS_data_shift;
 
        t = avs_tmon_code_to_temp(priv, val);
-       if (t < 0)
-               *temp = 0;
-       else
-               *temp = t;
+       *temp = max(0, t);
 
        return 0;
 }