Skip to contentSkip to conversation

w1: w1_therm: use clamp() in int_to_short()

PATCH New Dan Carpenter 1 participant 1 message Mar 9, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 w1: w1_therm: use clamp() in int_to_short()

It's slightly cleaner to use the clamp() macro instead of open coding this.

---
 drivers/w1/slaves/w1_therm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/w1/slaves/w1_therm.c +1 -2
index 976eea28f268..ad47c164bc05 100644
@@ -906,8 +906,7 @@ static inline int temperature_from_RAM(struct w1_slave *sl, u8 rom[9])
 static inline s8 int_to_short(int i)
 {
 	/* Prepare to cast to short by eliminating out of range values */
-	i = i > MAX_TEMP ? MAX_TEMP : i;
-	i = i < MIN_TEMP ? MIN_TEMP : i;
+	i = clamp(i, MIN_TEMP, MAX_TEMP);
 	return (s8) i;
 }
 
Signature · 1 line
2.30.1