lib: Don't use sbi_platform_hart_count() API

We don't need to use sbi_platform_hart_count() in sbi_init and
sbi_scratch because checking sbi_platform_hart_disabled() or
return value of sbi_hartid_to_scratch() is sufficient.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
Anup Patel
2020-03-14 19:43:26 +05:30
committed by Anup Patel
parent 814f38dc1d
commit 75eec9dd3f
2 changed files with 5 additions and 13 deletions

View File

@@ -26,7 +26,7 @@ int sbi_scratch_init(struct sbi_scratch *scratch)
u32 i;
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
for (i = 0; i < sbi_platform_hart_count(plat); i++) {
for (i = 0; i < SBI_HARTMASK_MAX_BITS; i++) {
if (sbi_platform_hart_disabled(plat, i))
continue;
hartid_to_scratch_table[i] =
@@ -41,8 +41,7 @@ unsigned long sbi_scratch_alloc_offset(unsigned long size, const char *owner)
u32 i;
void *ptr;
unsigned long ret = 0;
struct sbi_scratch *scratch, *rscratch;
const struct sbi_platform *plat;
struct sbi_scratch *rscratch;
/*
* We have a simple brain-dead allocator which never expects
@@ -71,9 +70,7 @@ done:
spin_unlock(&extra_lock);
if (ret) {
scratch = sbi_scratch_thishart_ptr();
plat = sbi_platform_ptr(scratch);
for (i = 0; i < sbi_platform_hart_count(plat); i++) {
for (i = 0; i < SBI_HARTMASK_MAX_BITS; i++) {
rscratch = sbi_hartid_to_scratch(i);
if (!rscratch)
continue;