include: sbi: Add sbi_scratch_hartindex() macro

Add helper macro to extract hart index from scratch pointer. This
can be used to check whether scratch pointer belongs to a particular
hart or not.

Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Link: https://lore.kernel.org/r/20260425104048.2335262-2-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Anup Patel
2026-04-25 16:10:45 +05:30
committed by Anup Patel
parent f34cf05347
commit d8c7dc9cb0
+4 -2
View File
@@ -171,9 +171,11 @@ do { \
= (__type)(__ptr); \ = (__type)(__ptr); \
} while (0) } while (0)
/** Get the hart index of a particular sbi_scratch */
#define sbi_scratch_hartindex(__scratch) ((__scratch)->hartindex)
/** Get the hart index of the current hart */ /** Get the hart index of the current hart */
#define current_hartindex() \ #define current_hartindex() sbi_scratch_hartindex(sbi_scratch_thishart_ptr())
(sbi_scratch_thishart_ptr()->hartindex)
/** Number of harts managed by this OpenSBI instance */ /** Number of harts managed by this OpenSBI instance */
extern u32 sbi_scratch_hart_count; extern u32 sbi_scratch_hart_count;