From f3b940b1123c78f40bdaa95ad8aff16fde6bc843 Mon Sep 17 00:00:00 2001 From: Oza Pawandeep Date: Wed, 18 Nov 2026 13:55:43 -0800 Subject: [PATCH] include: sbi/sbi_hartmask: add equality helper Add sbi_hartmask_equal() to check whether two hartmasks contain the same hart indexes. Reviewed-by: Rahul Pathak Reviewed-by: Anup Patel Signed-off-by: Oza Pawandeep Link: https://lore.kernel.org/r/20261118215549.2499040-3-pawandeep.oza@oss.qualcomm.com Signed-off-by: Anup Patel --- include/sbi/sbi_hartmask.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/sbi/sbi_hartmask.h b/include/sbi/sbi_hartmask.h index da6821ee..e6fce323 100644 --- a/include/sbi/sbi_hartmask.h +++ b/include/sbi/sbi_hartmask.h @@ -206,4 +206,25 @@ static inline int sbi_hartmask_weight(const struct sbi_hartmask *srcp) (__i) < SBI_HARTMASK_MAX_BITS; \ (__i) = find_next_bit((__m)->bits, SBI_HARTMASK_MAX_BITS, (__i) + 1)) + +/** + * Check whether two hartmasks are equal + * @param a the first hartmask to compare + * @param b the second hartmask to compare + * + * Return: true if both hartmasks contain the same harts, false otherwise + */ +static inline bool sbi_hartmask_equal(const struct sbi_hartmask *a, + const struct sbi_hartmask *b) +{ + u32 i; + + for (i = 0; i < BITS_TO_LONGS(SBI_HARTMASK_MAX_BITS); i++) { + if (a->bits[i] != b->bits[i]) + return false; + } + + return true; +} + #endif