diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-05-02 09:02:16 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-05-02 09:02:16 +0300 |
commit | d2cb798d2d8ceb0d194721a2cb0e577b4b927573 (patch) | |
tree | 81f20ac7647c63d13e2f6ff2c357648abd759018 /include/linux/math.h | |
parent | 7f0020417b7bceaa10cf9e1efe2b3f5c554d972e (diff) | |
parent | aeaee199900ee618e676698d21e4ac788f54572f (diff) | |
download | linux-rolling-stable.tar.xz |
Merge v6.14.5linux-rolling-stable
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/math.h')
-rw-r--r-- | include/linux/math.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/math.h b/include/linux/math.h index f5f18dc3616b..0198c92cbe3e 100644 --- a/include/linux/math.h +++ b/include/linux/math.h @@ -34,6 +34,18 @@ */ #define round_down(x, y) ((x) & ~__round_mask(x, y)) +/** + * DIV_ROUND_UP_POW2 - divide and round up + * @n: numerator + * @d: denominator (must be a power of 2) + * + * Divides @n by @d and rounds up to next multiple of @d (which must be a power + * of 2). Avoids integer overflows that may occur with __KERNEL_DIV_ROUND_UP(). + * Performance is roughly equivalent to __KERNEL_DIV_ROUND_UP(). + */ +#define DIV_ROUND_UP_POW2(n, d) \ + ((n) / (d) + !!((n) & ((d) - 1))) + #define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP #define DIV_ROUND_DOWN_ULL(ll, d) \ |