From: Axel Lin <axel.lin@ingics.com>
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] [PATCH 3/4] hwmon: (lm85) Use DIV_ROUND_CLOSEST to simplify implementation for SCALE
Date: Sat, 19 Jul 2014 03:41:37 +0000 [thread overview]
Message-ID: <1405741297.13406.6.camel@phoenix> (raw)
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/hwmon/lm85.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index b0129a5..9eb60db 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -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)
--
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:41 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=1405741297.13406.6.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.