All of lore.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@ingics.com>
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] [PATCH 2/4] hwmon: (adm9240) Use DIV_ROUND_CLOSEST to simplify implementation for SCALE
Date: Sat, 19 Jul 2014 03:40:04 +0000	[thread overview]
Message-ID: <1405741204.13406.4.camel@phoenix> (raw)

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

                 reply	other threads:[~2014-07-19  3:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1405741204.13406.4.camel@phoenix \
    --to=axel.lin@ingics.com \
    --cc=lm-sensors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.