add SDHC support in mmc driver
[u-boot-openmoko/mini2440.git] / include / div64.h
blob2e0ba8389e11d992fda785f191d326dfbb74b94a
1 #ifndef _ASM_GENERIC_DIV64_H
2 #define _ASM_GENERIC_DIV64_H
3 /*
4 * Copyright (C) 2003 Bernardo Innocenti <bernie@develer.com>
5 * Based on former asm-ppc/div64.h and asm-m68knommu/div64.h
7 * The semantics of do_div() are:
9 * uint32_t do_div(uint64_t *n, uint32_t base)
10 * {
11 * uint32_t remainder = *n % base;
12 * *n = *n / base;
13 * return remainder;
14 * }
16 * NOTE: macro parameter n is evaluated multiple times,
17 * beware of side effects!
20 #include <linux/types.h>
22 extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
24 /* The unnecessary pointer compare is there
25 * to check for type safety (n must be 64bit)
27 # define do_div(n,base) ({ \
28 uint32_t __base = (base); \
29 uint32_t __rem; \
30 (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
31 if (((n) >> 32) == 0) { \
32 __rem = (uint32_t)(n) % __base; \
33 (n) = (uint32_t)(n) / __base; \
34 } else \
35 __rem = __div64_32(&(n), __base); \
36 __rem; \
39 #endif /* _ASM_GENERIC_DIV64_H */