projects
/
project
/
bcm63xx
/
u-boot.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ce48079
)
linux/kernel.h: import DIV_ROUND_CLOSEST_ULL from Linux
author
Masahiro Yamada
<
[email protected]
>
Wed, 19 Dec 2018 11:03:16 +0000
(20:03 +0900)
committer
Masahiro Yamada
<
[email protected]
>
Sat, 29 Dec 2018 02:38:36 +0000
(11:38 +0900)
Copied from Linux v4.20-rc7.
Signed-off-by: Masahiro Yamada <
[email protected]
>
include/linux/kernel.h
patch
|
blob
|
history
diff --git
a/include/linux/kernel.h
b/include/linux/kernel.h
index bd88483b9f6d915f3927094967e6968b1470c9d7..a85c15d8dc28d31e7a1b7be06ac1b61d1f84f419 100644
(file)
--- 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