Skip to content

Commit 29cbf82

Browse files
tobluxDaniel Lezcano
authored andcommitted
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 <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
1 parent 8f271fe commit 29cbf82

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

drivers/thermal/broadcom/brcmstb_thermal.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/irqreturn.h>
1717
#include <linux/interrupt.h>
1818
#include <linux/kernel.h>
19+
#include <linux/minmax.h>
1920
#include <linux/module.h>
2021
#include <linux/of.h>
2122
#include <linux/platform_device.h>
@@ -154,7 +155,7 @@ static int brcmstb_get_temp(struct thermal_zone_device *tz, int *temp)
154155
{
155156
struct brcmstb_thermal_priv *priv = thermal_zone_device_priv(tz);
156157
u32 val;
157-
long t;
158+
int t;
158159

159160
val = __raw_readl(priv->tmon_base + AVS_TMON_STATUS);
160161

@@ -164,10 +165,7 @@ static int brcmstb_get_temp(struct thermal_zone_device *tz, int *temp)
164165
val = (val & AVS_TMON_STATUS_data_msk) >> AVS_TMON_STATUS_data_shift;
165166

166167
t = avs_tmon_code_to_temp(priv, val);
167-
if (t < 0)
168-
*temp = 0;
169-
else
170-
*temp = t;
168+
*temp = max(0, t);
171169

172170
return 0;
173171
}

0 commit comments

Comments
 (0)