diff --git a/include/zephyr/storage/flash_map.h b/include/zephyr/storage/flash_map.h index dda7f78a513..1cac47bebf5 100644 --- a/include/zephyr/storage/flash_map.h +++ b/include/zephyr/storage/flash_map.h @@ -118,7 +118,8 @@ int flash_area_check_int_sha256(const struct flash_area *fa, * @p ID is unknown, it will be NULL on output. * * @return 0 on success, -EACCES if the flash_map is not available , - * -ENOENT if @p ID is unknown. + * -ENOENT if @p ID is unknown, -EDEV if there is not driver attached + * to the area. */ int flash_area_open(uint8_t id, const struct flash_area **fa); diff --git a/subsys/storage/flash_map/flash_map.c b/subsys/storage/flash_map/flash_map.c index d36f8d5db31..2821df5ad7e 100644 --- a/subsys/storage/flash_map/flash_map.c +++ b/subsys/storage/flash_map/flash_map.c @@ -37,7 +37,12 @@ int flash_area_open(uint8_t id, const struct flash_area **fap) return -ENOENT; } + if (device_get_binding(area->fa_dev_name) == NULL) { + return -ENODEV; + } + *fap = area; + return 0; }