Skip to content

Commit

Permalink
linux/kernel: introduce lower_48_bits function
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20220303201312.3255347-5-kbusch@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Keith Busch authored and Jens Axboe committed Mar 7, 2022
1 parent c2ea5fc commit 7ee8809
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7ee8809

Please sign in to comment.