Skip to content

Commit 3fe9883

Browse files
nvlsianpucarlescufi
authored andcommitted
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 <[email protected]>
1 parent 2320973 commit 3fe9883

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/flash_map.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ int flash_area_get_sectors(int fa_id, u32_t *count,
8888
*/
8989
int flash_area_has_driver(const struct flash_area *fa);
9090

91+
/**
92+
* Get driver for given flash area.
93+
*
94+
* @param fa Flash area.
95+
*
96+
* @return device driver.
97+
*/
98+
struct device *flash_area_get_device(const struct flash_area *fa);
99+
91100
#ifdef __cplusplus
92101
}
93102
#endif

subsys/storage/flash_map/flash_map.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,8 @@ int flash_area_has_driver(const struct flash_area *fa)
247247

248248
return 1;
249249
}
250+
251+
struct device *flash_area_get_device(const struct flash_area *fa)
252+
{
253+
return device_get_binding(fa->fa_dev_name);
254+
}

0 commit comments

Comments
 (0)