From a593a733e838c20a9cef2fe3c83abb17f33ebab3 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Mon, 4 Jul 2022 15:51:20 +1000 Subject: [PATCH] storage: flash_map: handle disabled flash nodes Don't fail to compile when `fixed-partition`'s exist on a flash device that is disabled. This does not fix the case where a `fixed-partition` is on a flash device with `status = "okay"` but with no driver compiled in. Signed-off-by: Jordan Yates --- subsys/storage/flash_map/flash_map.c | 2 +- subsys/storage/flash_map/flash_map_default.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/subsys/storage/flash_map/flash_map.c b/subsys/storage/flash_map/flash_map.c index 1a50b25c993..b75af590428 100644 --- a/subsys/storage/flash_map/flash_map.c +++ b/subsys/storage/flash_map/flash_map.c @@ -37,7 +37,7 @@ int flash_area_open(uint8_t id, const struct flash_area **fap) return -ENOENT; } - if (!device_is_ready(area->fa_dev)) { + if (!area->fa_dev || !device_is_ready(area->fa_dev)) { return -ENODEV; } diff --git a/subsys/storage/flash_map/flash_map_default.c b/subsys/storage/flash_map/flash_map_default.c index add0d41b015..65d2de1137f 100644 --- a/subsys/storage/flash_map/flash_map_default.c +++ b/subsys/storage/flash_map/flash_map_default.c @@ -11,10 +11,10 @@ #include #include -#define FLASH_AREA_FOO(part) \ - {.fa_id = DT_FIXED_PARTITION_ID(part), \ - .fa_off = DT_REG_ADDR(part), \ - .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(part)), \ +#define FLASH_AREA_FOO(part) \ + {.fa_id = DT_FIXED_PARTITION_ID(part), \ + .fa_off = DT_REG_ADDR(part), \ + .fa_dev = DEVICE_DT_GET_OR_NULL(DT_MTD_FROM_FIXED_PARTITION(part)), \ .fa_size = DT_REG_SIZE(part),}, #define FOREACH_PARTITION(n) DT_FOREACH_CHILD(DT_DRV_INST(n), FLASH_AREA_FOO)