flash_map: add function to iterate over areas

A new foreach iterator to go over all flash areas in a flash map.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2019-02-10 11:41:18 -05:00 committed by Kumar Gala
commit 1e5d02fcd2
2 changed files with 25 additions and 0 deletions

View file

@ -41,6 +41,13 @@ static struct flash_area const *get_flash_area_from_id(int idx)
return NULL;
}
void flash_area_foreach(flash_area_cb_t user_cb, void *user_data)
{
for (int i = 0; i < flash_map_entries; i++) {
user_cb(&flash_map[i], user_data);
}
}
int flash_area_open(u8_t id, const struct flash_area **fap)
{
const struct flash_area *area;