X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=include%2Flinux%2Fmath64.h;h=c87f1528703a68c2dd024d612a203ae4517b5cea;hb=ca31e146d5c2fe51498e619eb3a64782d02e310a;hp=c1a5f81501ff9f3f16edbd9c8e10aec48408aeee;hpb=a15306365a16380f3bafee9e181ba01231d4acd7;p=linux-2.6-omap-h63xx.git diff --git a/include/linux/math64.h b/include/linux/math64.h index c1a5f81501f..c87f1528703 100644 --- a/include/linux/math64.h +++ b/include/linux/math64.h @@ -81,4 +81,25 @@ static inline s64 div_s64(s64 dividend, s32 divisor) } #endif +u32 iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder); + +static __always_inline u32 +__iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder) +{ + u32 ret = 0; + + while (dividend >= divisor) { + /* The following asm() prevents the compiler from + optimising this loop into a modulo operation. */ + asm("" : "+rm"(dividend)); + + dividend -= divisor; + ret++; + } + + *remainder = dividend; + + return ret; +} + #endif /* _LINUX_MATH64_H */