storage/flash_map: Switch flash_area_layout to use flash_area_open

The function should use flash_area_open rather than directly
using get_flash_area_from_id.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
Dominik Ermel 2021-06-29 09:38:26 +00:00 committed by Christopher Friedt
commit 51e8db228b

View file

@ -126,13 +126,10 @@ static int flash_area_layout(int idx, uint32_t *cnt, void *ret,
flash_page_cb cb, struct layout_data *cb_data)
{
const struct device *flash_dev;
cb_data->area_idx = idx;
const struct flash_area *fa;
int rc = flash_area_open(idx, &fa);
fa = get_flash_area_from_id(idx);
if (fa == NULL) {
if (rc < 0 || fa == NULL) {
return -EINVAL;
}
@ -146,6 +143,7 @@ flash_page_cb cb, struct layout_data *cb_data)
cb_data->status = 0;
flash_dev = device_get_binding(fa->fa_dev_name);
flash_area_close(fa);
if (flash_dev == NULL) {
return -ENODEV;
}