Skip to content

Commit

Permalink
w1: w1_therm: use clamp() in int_to_short()
Browse files Browse the repository at this point in the history
It's slightly cleaner to use the clamp() macro instead of open coding
this.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YEedHNwqEH8fvjkD@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Mar 24, 2021
1 parent f6d706d commit 199c4d0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/w1/slaves/w1_therm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 199c4d0

Please sign in to comment.