Skip to content

Commit c6b6c62

Browse files
lyakhkartben
authored andcommitted
arch: xtensa: (cosmetic) simplify function prototypes
Several static functions in ptables.c always return 0, make them void to improve readability. Signed-off-by: Guennadi Liakhovetski <[email protected]>
1 parent acbb894 commit c6b6c62

File tree

1 file changed

+22
-32
lines changed

1 file changed

+22
-32
lines changed

arch/xtensa/core/ptables.c

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -847,11 +847,9 @@ int arch_mem_domain_init(struct k_mem_domain *domain)
847847
return ret;
848848
}
849849

850-
static int region_map_update(uint32_t *ptables, uintptr_t start,
850+
static void region_map_update(uint32_t *ptables, uintptr_t start,
851851
size_t size, uint32_t ring, uint32_t flags)
852852
{
853-
int ret = 0;
854-
855853
for (size_t offset = 0; offset < size; offset += CONFIG_MMU_PAGE_SIZE) {
856854
uint32_t *l2_table, pte;
857855
uint32_t page = start + offset;
@@ -873,15 +871,11 @@ static int region_map_update(uint32_t *ptables, uintptr_t start,
873871

874872
xtensa_dtlb_vaddr_invalidate((void *)page);
875873
}
876-
877-
return ret;
878874
}
879875

880-
static inline int update_region(uint32_t *ptables, uintptr_t start,
881-
size_t size, uint32_t ring, uint32_t flags,
882-
uint32_t option)
876+
static void update_region(uint32_t *ptables, uintptr_t start, size_t size,
877+
uint32_t ring, uint32_t flags, uint32_t option)
883878
{
884-
int ret;
885879
k_spinlock_key_t key;
886880

887881
key = k_spin_lock(&xtensa_mmu_lock);
@@ -901,13 +895,10 @@ static inline int update_region(uint32_t *ptables, uintptr_t start,
901895
new_flags_uc = (flags & ~XTENSA_MMU_PTE_ATTR_CACHED_MASK);
902896
new_flags = new_flags_uc | XTENSA_MMU_CACHED_WB;
903897

904-
ret = region_map_update(ptables, va, size, ring, new_flags);
905-
906-
if (ret == 0) {
907-
ret = region_map_update(ptables, va_uc, size, ring, new_flags_uc);
908-
}
898+
region_map_update(ptables, va, size, ring, new_flags);
899+
region_map_update(ptables, va_uc, size, ring, new_flags_uc);
909900
#else
910-
ret = region_map_update(ptables, start, size, ring, flags);
901+
region_map_update(ptables, start, size, ring, flags);
911902
#endif /* CONFIG_XTENSA_MMU_DOUBLE_MAP */
912903

913904
#if CONFIG_MP_MAX_NUM_CPUS > 1
@@ -918,14 +909,12 @@ static inline int update_region(uint32_t *ptables, uintptr_t start,
918909

919910
sys_cache_data_flush_and_invd_all();
920911
k_spin_unlock(&xtensa_mmu_lock, key);
921-
922-
return ret;
923912
}
924913

925-
static inline int reset_region(uint32_t *ptables, uintptr_t start, size_t size, uint32_t option)
914+
static inline void reset_region(uint32_t *ptables, uintptr_t start, size_t size, uint32_t option)
926915
{
927-
return update_region(ptables, start, size,
928-
XTENSA_MMU_KERNEL_RING, XTENSA_MMU_PERM_W, option);
916+
update_region(ptables, start, size,
917+
XTENSA_MMU_KERNEL_RING, XTENSA_MMU_PERM_W, option);
929918
}
930919

931920
void xtensa_user_stack_perms(struct k_thread *thread)
@@ -950,8 +939,9 @@ int arch_mem_domain_partition_remove(struct k_mem_domain *domain,
950939
struct k_mem_partition *partition = &domain->partitions[partition_id];
951940

952941
/* Reset the partition's region back to defaults */
953-
return reset_region(domain->arch.ptables, partition->start,
954-
partition->size, 0);
942+
reset_region(domain->arch.ptables, partition->start, partition->size, 0);
943+
944+
return 0;
955945
}
956946

957947
int arch_mem_domain_partition_add(struct k_mem_domain *domain,
@@ -961,14 +951,14 @@ int arch_mem_domain_partition_add(struct k_mem_domain *domain,
961951
uint32_t ring = K_MEM_PARTITION_IS_USER(partition->attr) ? XTENSA_MMU_USER_RING :
962952
XTENSA_MMU_KERNEL_RING;
963953

964-
return update_region(domain->arch.ptables, partition->start,
965-
partition->size, ring, partition->attr, 0);
954+
update_region(domain->arch.ptables, partition->start,
955+
partition->size, ring, partition->attr, 0);
956+
return 0;
966957
}
967958

968959
/* These APIs don't need to do anything */
969960
int arch_mem_domain_thread_add(struct k_thread *thread)
970961
{
971-
int ret = 0;
972962
bool is_user, is_migration;
973963
uint32_t *old_ptables;
974964
struct k_mem_domain *domain;
@@ -992,9 +982,7 @@ int arch_mem_domain_thread_add(struct k_thread *thread)
992982
/* and reset thread's stack permission in
993983
* the old page tables.
994984
*/
995-
ret = reset_region(old_ptables,
996-
thread->stack_info.start,
997-
thread->stack_info.size, 0);
985+
reset_region(old_ptables, thread->stack_info.start, thread->stack_info.size, 0);
998986
}
999987

1000988
/* Need to switch to new page tables if this is
@@ -1018,7 +1006,7 @@ int arch_mem_domain_thread_add(struct k_thread *thread)
10181006
}
10191007
#endif
10201008

1021-
return ret;
1009+
return 0;
10221010
}
10231011

10241012
int arch_mem_domain_thread_remove(struct k_thread *thread)
@@ -1046,9 +1034,11 @@ int arch_mem_domain_thread_remove(struct k_thread *thread)
10461034
* adding it back to another. So there is no need to send TLB IPI
10471035
* at this point.
10481036
*/
1049-
return reset_region(domain->arch.ptables,
1050-
thread->stack_info.start,
1051-
thread->stack_info.size, OPTION_NO_TLB_IPI);
1037+
reset_region(domain->arch.ptables,
1038+
thread->stack_info.start,
1039+
thread->stack_info.size, OPTION_NO_TLB_IPI);
1040+
1041+
return 0;
10521042
}
10531043

10541044
static bool page_validate(uint32_t *ptables, uint32_t page, uint8_t ring, bool write)

0 commit comments

Comments
 (0)