Skip to contentSkip to conversation

hwmon: (adm9240) 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 2/4 hwmon: (adm9240) Use DIV_ROUND_CLOSEST to simplify implementation for SCALE

---
 drivers/hwmon/adm9240.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/hwmon/adm9240.c +1 -4
index 98114ce..6e75ff1 100644
@@ -82,10 +82,7 @@ enum chips { adm9240, ds1780, lm81 };
 /* generalised scaling with integer rounding */
 static inline int SCALE(long val, int mul, int div)
 {
-	if (val < 0)
-		return (val * mul - div / 2) / div;
-	else
-		return (val * mul + div / 2) / div;
+	return DIV_ROUND_CLOSEST(val * mul, div);
 }
 
 /* adm9240 internally scales voltage measurements */
Signature · 9 lines
1.9.1




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