From: Keith Busch Date: Thu, 3 Mar 2022 20:13:08 +0000 (-0800) Subject: linux/kernel: introduce lower_48_bits function X-Git-Tag: v5.18-rc1~101^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7ee8809df990d1de379002973baee1681e8d7dd3;p=thirdparty%2Fkernel%2Flinux.git linux/kernel: introduce lower_48_bits function Recent data integrity field enhancements allow reference tags to be up to 48 bits. Introduce an inline helper function since this will be a repeated operation. Suggested-by: Bart Van Assche Signed-off-by: Keith Busch Reviewed-by: Bart Van Assche Link: https://lore.kernel.org/r/20220303201312.3255347-5-kbusch@kernel.org Signed-off-by: Jens Axboe --- diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 33f47a9965132..3877478681b98 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -63,6 +63,15 @@ } \ ) +/** + * lower_48_bits() - return bits 0-47 of a number + * @n: the number we're accessing + */ +static inline u64 lower_48_bits(u64 n) +{ + return n & ((1ull << 48) - 1); +} + /** * upper_32_bits - return bits 32-63 of a number * @n: the number we're accessing