projects
/
linux-2.6-microblaze.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(from parent 1:
f6d706d
)
w1: w1_therm: use clamp() in int_to_short()
author
Dan Carpenter
<dan.carpenter@oracle.com>
Tue, 9 Mar 2021 16:06:52 +0000
(19:06 +0300)
committer
Greg Kroah-Hartman
<gregkh@linuxfoundation.org>
Wed, 24 Mar 2021 07:26:30 +0000
(08:26 +0100)
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>
drivers/w1/slaves/w1_therm.c
patch
|
blob
|
history
diff --git
a/drivers/w1/slaves/w1_therm.c
b/drivers/w1/slaves/w1_therm.c
index
976eea2
..
ad47c16
100644
(file)
--- a/
drivers/w1/slaves/w1_therm.c
+++ b/
drivers/w1/slaves/w1_therm.c
@@
-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;
}