aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/asm-generic/div64.h14
-rw-r--r--lib/div64.c6
2 files changed, 20 insertions, 0 deletions
diff --git a/include/asm-generic/div64.h b/include/asm-generic/div64.h
index 163f77999ea4..3de84f64423f 100644
--- a/include/asm-generic/div64.h
+++ b/include/asm-generic/div64.h
@@ -25,6 +25,20 @@
25 25
26#if BITS_PER_LONG == 64 26#if BITS_PER_LONG == 64
27 27
28/**
29 * do_div - returns 2 values: calculate remainder and update new dividend
30 * @n: pointer to uint64_t dividend (will be updated)
31 * @base: uint32_t divisor
32 *
33 * Summary:
34 * ``uint32_t remainder = *n % base;``
35 * ``*n = *n / base;``
36 *
37 * Return: (uint32_t)remainder
38 *
39 * NOTE: macro parameter @n is evaluated multiple times,
40 * beware of side effects!
41 */
28# define do_div(n,base) ({ \ 42# define do_div(n,base) ({ \
29 uint32_t __base = (base); \ 43 uint32_t __base = (base); \
30 uint32_t __rem; \ 44 uint32_t __rem; \
diff --git a/lib/div64.c b/lib/div64.c
index 7f345259c32f..5660e8233293 100644
--- a/lib/div64.c
+++ b/lib/div64.c
@@ -60,6 +60,12 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
60EXPORT_SYMBOL(__div64_32); 60EXPORT_SYMBOL(__div64_32);
61#endif 61#endif
62 62
63/**
64 * div_s64_rem - signed 64bit divide with 64bit divisor and remainder
65 * @dividend: 64bit dividend
66 * @divisor: 64bit divisor
67 * @remainder: 64bit remainder
68 */
63#ifndef div_s64_rem 69#ifndef div_s64_rem
64s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder) 70s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
65{ 71{