From d8c7dc9cb038369b1ac92d3306476df6375e3037 Mon Sep 17 00:00:00 2001 From: Anup Patel Date: Sat, 25 Apr 2026 16:10:45 +0530 Subject: [PATCH] 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 Reviewed-by: Nicholas Piggin Link: https://lore.kernel.org/r/20260425104048.2335262-2-anup.patel@oss.qualcomm.com Signed-off-by: Anup Patel --- include/sbi/sbi_scratch.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/sbi/sbi_scratch.h b/include/sbi/sbi_scratch.h index a6edeb2d..06097c8a 100644 --- a/include/sbi/sbi_scratch.h +++ b/include/sbi/sbi_scratch.h @@ -171,9 +171,11 @@ do { \ = (__type)(__ptr); \ } 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 */ -#define current_hartindex() \ - (sbi_scratch_thishart_ptr()->hartindex) +#define current_hartindex() sbi_scratch_hartindex(sbi_scratch_thishart_ptr()) /** Number of harts managed by this OpenSBI instance */ extern u32 sbi_scratch_hart_count;