diff mbox series

[PATCHv4,4/8] linux/kernel: introduce lower_48_bits function

Message ID 20220303201312.3255347-5-kbusch@kernel.org
State Accepted
Commit 7ee8809df990d1de379002973baee1681e8d7dd3
Headers show
Series 64-bit data integrity field support | expand

Commit Message

Keith Busch March 3, 2022, 8:13 p.m. UTC
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 <bvanassche@acm.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 include/linux/kernel.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Bart Van Assche March 3, 2022, 8:48 p.m. UTC | #1
On 3/3/22 12:13, Keith Busch wrote:
> 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.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
diff mbox series

Patch

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 33f47a996513..3877478681b9 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