blob: 60e76aa8b53eceb6aaac7edf548c4c3a857d5827 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Generic __div64_32 wrapper for __xdiv64_32.
3 */
4
5#include <linux/types.h>
Paul Mundtfa439722008-09-04 18:53:58 +09006#include <asm/div64.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
Paul Mundt075fc192007-07-13 12:27:13 +09008extern uint64_t __xdiv64_32(u64 n, u32 d);
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Paul Mundt04c7d952007-07-06 10:58:04 +090010uint32_t __div64_32(u64 *xp, u32 y)
Linus Torvalds1da177e2005-04-16 15:20:36 -070011{
Paul Mundt04c7d952007-07-06 10:58:04 +090012 uint32_t rem;
Paul Mundt075fc192007-07-13 12:27:13 +090013 uint64_t q = __xdiv64_32(*xp, y);
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
15 rem = *xp - q * y;
16 *xp = q;
17
18 return rem;
19}