thermal/drivers/brcmstb_thermal: Use max to simplify brcmstb_get_temp
PATCH RESEND 1/1 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.
Reviewed-by Florian Fainelli <[email protected]>
Signed-off-by Thorsten Blum <[email protected]>
--- drivers/thermal/broadcom/brcmstb_thermal.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/thermal/broadcom/brcmstb_thermal.c +3 -5
@@ -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 ; }
Signature · 2 lines
Thorsten Blum <[email protected]> GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4