All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH 2/4] hwmon: (adm9240) Use DIV_ROUND_CLOSEST to simplify implementation for SCALE
@ 2014-07-19  3:40 Axel Lin
  0 siblings, 0 replies; only message in thread
From: Axel Lin @ 2014-07-19  3:40 UTC (permalink / raw)
  To: lm-sensors

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/hwmon/adm9240.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index 98114ce..6e75ff1 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -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 */
-- 
1.9.1




_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-07-19  3:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-19  3:40 [lm-sensors] [PATCH 2/4] hwmon: (adm9240) Use DIV_ROUND_CLOSEST to simplify implementation for SCALE Axel Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.