From 3fe98838c9f07d7e916d6c0f7c6b7c949b62da08 Mon Sep 17 00:00:00 2001 From: Andrzej Puzdrowski Date: Tue, 12 Feb 2019 09:50:27 +0100 Subject: [PATCH] storage/flash_map: API for get driver belongs to the flash_area. Introduce API for get driver structure belongs to the flash_area. Some more complex operation on flash areas might want to be done using driver directly. It not make sense to wrap every possible flash related operation by flash_map API. For instance mcuboot will require this patch. Signed-off-by: Andrzej Puzdrowski --- include/flash_map.h | 9 +++++++++ subsys/storage/flash_map/flash_map.c | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/include/flash_map.h b/include/flash_map.h index e6f40f962bd..5aaa93d4a38 100644 --- a/include/flash_map.h +++ b/include/flash_map.h @@ -88,6 +88,15 @@ int flash_area_get_sectors(int fa_id, u32_t *count, */ int flash_area_has_driver(const struct flash_area *fa); +/** + * Get driver for given flash area. + * + * @param fa Flash area. + * + * @return device driver. + */ +struct device *flash_area_get_device(const struct flash_area *fa); + #ifdef __cplusplus } #endif diff --git a/subsys/storage/flash_map/flash_map.c b/subsys/storage/flash_map/flash_map.c index ee4eb024a53..b4224fbe890 100644 --- a/subsys/storage/flash_map/flash_map.c +++ b/subsys/storage/flash_map/flash_map.c @@ -247,3 +247,8 @@ int flash_area_has_driver(const struct flash_area *fa) return 1; } + +struct device *flash_area_get_device(const struct flash_area *fa) +{ + return device_get_binding(fa->fa_dev_name); +}