From: "Darrick J. Wong" <djwong@us.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: mhoffman@lightlink.com, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org
Subject: [PATCH] ibmaem: Fix 64-bit division on 32-bit platforms
Date: Thu, 8 May 2008 21:55:27 -0700 [thread overview]
Message-ID: <20080509045527.GI16404@tree.beaverton.ibm.com> (raw)
In-Reply-To: <20080508163443.a1e9ffe7.akpm@linux-foundation.org>
On Thu, May 08, 2008 at 04:34:43PM -0700, Andrew Morton wrote:
> This driver is littered with 64-bit divides and doesn't link on i386.
> I'll make it depend on CONFIG_64BIT for now.
Oops, sorry, I didn't remember that one can't do 64-bit division on
i386. The patch below fixes that.
---
ibmaem: Fix 64-bit division on 32-bit platforms
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---
drivers/hwmon/ibmaem.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
index 22fa7d6..f808ca3 100644
--- a/drivers/hwmon/ibmaem.c
+++ b/drivers/hwmon/ibmaem.c
@@ -31,6 +31,7 @@
#include <linux/idr.h>
#include <linux/sched.h>
#include <linux/platform_device.h>
+#include <linux/math64.h>
#define REFRESH_INTERVAL (HZ)
#define IPMI_TIMEOUT (30 * HZ)
@@ -864,9 +865,10 @@ static ssize_t aem_show_power(struct device *dev,
mutex_unlock(&data->lock);
time = timespec_to_ns(&a) - timespec_to_ns(&b);
- time /= 1000;
+ time = div_u64(time, 1000);
- return sprintf(buf, "%llu\n", (after - before) * 1000000000 / time);
+ return sprintf(buf, "%llu\n",
+ div64_u64((after - before) * 1000000000, time));
}
/* Display energy use */
next prev parent reply other threads:[~2008-05-09 4:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-08 18:08 [PATCH v3] ibmaem: New driver for power/energy/temp meters in IBM System X hardware Darrick J. Wong
2008-05-08 23:34 ` Andrew Morton
2008-05-09 4:55 ` Darrick J. Wong [this message]
2008-05-14 22:27 ` [PATCH] ibmaem: Fix 64-bit division on 32-bit platforms Adrian Bunk
2008-05-14 23:11 ` Carlos R. Mafra
2008-05-15 21:18 ` [PATCH v2] " Darrick J. Wong
2008-05-15 22:49 ` Carlos R. Mafra
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=20080509045527.GI16404@tree.beaverton.ibm.com \
--to=djwong@us.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
--cc=mhoffman@lightlink.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox