From: Masahiro Yamada Date: Wed, 19 Dec 2018 11:03:16 +0000 (+0900) Subject: linux/kernel.h: import DIV_ROUND_CLOSEST_ULL from Linux X-Git-Tag: baikal/mips/sdk5.9~1194^2~5 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=78fb9d29f6789ab3e1394a8545484413edd7714f;p=uboot.git linux/kernel.h: import DIV_ROUND_CLOSEST_ULL from Linux Copied from Linux v4.20-rc7. Signed-off-by: Masahiro Yamada --- diff --git a/include/linux/kernel.h b/include/linux/kernel.h index bd88483b9f..a85c15d8dc 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -102,6 +102,18 @@ (((__x) - ((__d) / 2)) / (__d)); \ } \ ) +/* + * 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; \ +} \ +) /* * Multiplies an integer by a fraction, while avoiding unnecessary