We already have DIV_ROUND_CLOSEST, but no DIV_ROUND_CLOSEST_ULL. Import the latter for use by later commits. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- include/linux/kernel.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index b320f7e902f0..23c23a73f588 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -6,6 +6,7 @@ #include <linux/bug.h> #include <linux/barebox-wrapper.h> #include <linux/limits.h> +#include <asm-generic/div64.h> #define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1) #define ALIGN_DOWN(x, a) ALIGN((x) - ((a) - 1), (a)) @@ -41,6 +42,18 @@ (((x) + ((__divisor) / 2)) / (__divisor)); \ } \ ) +/* + * Same as above but for u64 dividends. divisor must be a 32-bit + * number. + */ +#define DIV_ROUND_CLOSEST_ULL(x, divisor)( \ +{ \ + typeof(divisor) __d = divisor; \ + unsigned long long _tmp = (x) + (__d) / 2; \ + do_div(_tmp, __d); \ + _tmp; \ +} \ +) /** * upper_32_bits - return bits 32-63 of a number -- 2.26.0.rc2 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox