lib: sbi: Use sbi_hart_count() and sbi_for_each_hartindex()

Simplify the code and improve consistency by using the new macros where
possible. sbi_hart_count() obsoletes sbi_scratch_last_hartindex().

Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Samuel Holland
2025-02-20 10:42:30 -08:00
committed by Anup Patel
parent 757f7acafd
commit 949c83a799
9 changed files with 11 additions and 24 deletions

View File

@@ -12,7 +12,6 @@
#include <sbi/riscv_io.h>
#include <sbi/sbi_error.h>
#include <sbi/sbi_heap.h>
#include <sbi/sbi_platform.h>
#include <sbi/sbi_scratch.h>
#include <sbi_utils/fdt/fdt_helper.h>
#include <sbi_utils/irqchip/fdt_irqchip.h>
@@ -66,12 +65,10 @@ static int irqchip_plic_update_context_map(const void *fdt, int nodeoff,
static int irqchip_plic_cold_init(const void *fdt, int nodeoff,
const struct fdt_match *match)
{
struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
int rc;
struct plic_data *pd;
pd = sbi_zalloc(PLIC_DATA_SIZE(plat->hart_count));
pd = sbi_zalloc(PLIC_DATA_SIZE(sbi_hart_count()));
if (!pd)
return SBI_ENOMEM;