From: Thorsten Blum Date: Thu, 2 Apr 2026 16:56:18 +0000 (+0200) Subject: thermal/drivers/brcmstb_thermal: Use max to simplify brcmstb_get_temp X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=29cbf826d5674a0ea1b101c13861416c7f217304;p=thirdparty%2Fkernel%2Flinux.git thermal/drivers/brcmstb_thermal: Use max to simplify brcmstb_get_temp 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 Signed-off-by: Daniel Lezcano Reviewed-by: Florian Fainelli Link: https://patch.msgid.link/20260402165616.895305-3-thorsten.blum@linux.dev --- diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/broadcom/brcmstb_thermal.c index f46f2ddc174ea..a9ffa596f7c0d 100644 --- a/drivers/thermal/broadcom/brcmstb_thermal.c +++ b/drivers/thermal/broadcom/brcmstb_thermal.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -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; }