forked from Mirrors/opensbi
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:

committed by
Anup Patel

parent
757f7acafd
commit
949c83a799
@@ -770,11 +770,9 @@ int sbi_domain_finalize(struct sbi_scratch *scratch)
|
||||
|
||||
int sbi_domain_init(struct sbi_scratch *scratch, u32 cold_hartid)
|
||||
{
|
||||
u32 i;
|
||||
int rc;
|
||||
struct sbi_hartmask *root_hmask;
|
||||
struct sbi_domain_memregion *root_memregs;
|
||||
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
||||
|
||||
SBI_INIT_LIST_HEAD(&domain_list);
|
||||
|
||||
@@ -855,7 +853,7 @@ int sbi_domain_init(struct sbi_scratch *scratch, u32 cold_hartid)
|
||||
root.next_mode = scratch->next_mode;
|
||||
|
||||
/* Root domain possible and assigned HARTs */
|
||||
for (i = 0; i < plat->hart_count; i++)
|
||||
sbi_for_each_hartindex(i)
|
||||
sbi_hartmask_set_hartindex(i, root_hmask);
|
||||
|
||||
/* Finally register the root domain */
|
||||
|
@@ -238,7 +238,6 @@ static void hsm_device_hart_resume(void)
|
||||
|
||||
int sbi_hsm_init(struct sbi_scratch *scratch, bool cold_boot)
|
||||
{
|
||||
u32 i;
|
||||
struct sbi_scratch *rscratch;
|
||||
struct sbi_hsm_data *hdata;
|
||||
|
||||
@@ -248,7 +247,7 @@ int sbi_hsm_init(struct sbi_scratch *scratch, bool cold_boot)
|
||||
return SBI_ENOMEM;
|
||||
|
||||
/* Initialize hart state data for every hart */
|
||||
for (i = 0; i <= sbi_scratch_last_hartindex(); i++) {
|
||||
sbi_for_each_hartindex(i) {
|
||||
rscratch = sbi_hartindex_to_scratch(i);
|
||||
if (!rscratch)
|
||||
continue;
|
||||
|
@@ -54,7 +54,6 @@ int sbi_scratch_init(struct sbi_scratch *scratch)
|
||||
|
||||
unsigned long sbi_scratch_alloc_offset(unsigned long size)
|
||||
{
|
||||
u32 i;
|
||||
void *ptr;
|
||||
unsigned long ret = 0;
|
||||
struct sbi_scratch *rscratch;
|
||||
@@ -86,7 +85,7 @@ done:
|
||||
spin_unlock(&extra_lock);
|
||||
|
||||
if (ret) {
|
||||
for (i = 0; i <= sbi_scratch_last_hartindex(); i++) {
|
||||
sbi_for_each_hartindex(i) {
|
||||
rscratch = sbi_hartindex_to_scratch(i);
|
||||
if (!rscratch)
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user