Skip to content

Commit 419f90c

Browse files
mem: use Zephyr's macro for virtual memory regions iteration
Zephyr provides a special macro, SYS_MM_DRV_MEMORY_REGION_FOREACH for iteration through all memory regions. This commit use this macro instead of a for loop that requires information about number of virtual memory regions provided by Zephyr. Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
1 parent f7d9991 commit 419f90c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

zephyr/lib/regions_mm.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,14 @@ struct vmh_heap *vmh_init_heap(const struct vmh_heap_config *cfg, bool allocatin
6161

6262
k_mutex_init(&new_heap->lock);
6363
struct vmh_heap_config new_config = {0};
64+
const struct sys_mm_drv_region *region;
6465

65-
/* Search for matching attribute so we place heap on shared virtual region */
66-
for (i = CONFIG_MP_MAX_NUM_CPUS;
67-
i < CONFIG_MP_MAX_NUM_CPUS + VIRTUAL_REGION_COUNT; i++) {
68-
69-
if (virtual_memory_regions[i].attr == MEM_REG_ATTR_SHARED_HEAP) {
70-
new_heap->virtual_region = &virtual_memory_regions[i];
66+
SYS_MM_DRV_MEMORY_REGION_FOREACH(virtual_memory_regions, region) {
67+
if (region->attr == MEM_REG_ATTR_SHARED_HEAP) {
68+
new_heap->virtual_region = region;
7169
break;
7270
}
7371
}
74-
7572
if (!new_heap->virtual_region)
7673
goto fail;
7774

0 commit comments

Comments
 (0)