[PATCH v1] platform/x86: intel_pmc_ipc: fix division in 32-bit case

From: Andy Shevchenko
Date: Wed Feb 08 2017 - 11:08:48 EST


On 32-bit x86 platforms we can't do 64-bit divisions:

ERROR: "__udivdi3" [drivers/platform/x86/intel_pmc_ipc.ko] undefined!

Replace plain division by do_div() macro call.

Reported-by: Darren Hart <dvhart@xxxxxxxxxxxxx>
Cc: Shanth Murthy <shanth.murthy@xxxxxxxxx>
Cc: Rajneesh Bhardwaj <rajneesh.bhardwaj@xxxxxxxxx>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
drivers/platform/x86/intel_pmc_ipc.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index 46202b6e7c87..8ad4d7b43423 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -62,7 +62,12 @@
#define GCR_TELEM_SHLW_S0IX_OFFSET 0x1080

/* Residency with clock rate at 19.2MHz to usecs */
-#define S0IX_RESIDENCY_IN_USECS(d, s) (((d) + (s)) * 10 / 192)
+#define S0IX_RESIDENCY_IN_USECS(d, s) \
+({ \
+ u64 result = 10ull * ((d) + (s)); \
+ do_div(result, 192); \
+ result; \
+})

/*
* 16-byte buffer for sending data associated with IPC command.
--
2.11.0