aboutsummaryrefslogtreecommitdiffstats
path: root/lib/reciprocal_div.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/reciprocal_div.c')
-rw-r--r--lib/reciprocal_div.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/reciprocal_div.c b/lib/reciprocal_div.c
new file mode 100644
index 0000000..6a3bd48
--- /dev/null
+++ b/lib/reciprocal_div.c
@@ -0,0 +1,9 @@
+#include <asm/div64.h>
+#include <linux/reciprocal_div.h>
+
+u32 reciprocal_value(u32 k)
+{
+ u64 val = (1LL << 32) + (k - 1);
+ do_div(val, k);
+ return (u32)val;
+}