Skip to contentSkip to conversation

hwmon: (lm85) Use DIV_ROUND_CLOSEST to simplify implementation for SCALE

PATCH In review Axel Lin 1 participant 1 message Jul 19, 2014 Hardware monitoring

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 3/4 hwmon: (lm85) Use DIV_ROUND_CLOSEST to simplify implementation for SCALE

---
 drivers/hwmon/lm85.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/lm85.c +1 -1
index b0129a5..9eb60db 100644
@@ -133,7 +133,7 @@ static const int lm85_scaling[] = {  /* .001 Volts */
 	2500, 2250, 3300, 5000, 12000,
 	3300, 1500, 1800 /*EMC6D100*/
 };
-#define SCALE(val, from, to)	(((val) * (to) + ((from) / 2)) / (from))
+#define SCALE(val, from, to)	DIV_ROUND_CLOSEST((val) * (to), (from))
 
 #define INS_TO_REG(n, val)	\
 		clamp_val(SCALE(val, lm85_scaling[n], 192), 0, 255)
Signature · 9 lines
1.9.1




_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors