Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
2 | * Generic __div64_32 wrapper for __xdiv64_32. | ||||
3 | */ | ||||
4 | |||||
5 | #include <linux/types.h> | ||||
Paul Mundt | fa43972 | 2008-09-04 18:53:58 +0900 | [diff] [blame] | 6 | #include <asm/div64.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | |
Paul Mundt | 075fc19 | 2007-07-13 12:27:13 +0900 | [diff] [blame] | 8 | extern uint64_t __xdiv64_32(u64 n, u32 d); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Paul Mundt | 04c7d95 | 2007-07-06 10:58:04 +0900 | [diff] [blame] | 10 | uint32_t __div64_32(u64 *xp, u32 y) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | { |
Paul Mundt | 04c7d95 | 2007-07-06 10:58:04 +0900 | [diff] [blame] | 12 | uint32_t rem; |
Paul Mundt | 075fc19 | 2007-07-13 12:27:13 +0900 | [diff] [blame] | 13 | uint64_t q = __xdiv64_32(*xp, y); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
15 | rem = *xp - q * y; | ||||
16 | *xp = q; | ||||
17 | |||||
18 | return rem; | ||||
19 | } |