Skip to content

Commit 8849530

Browse files
tomchynashif
authored andcommitted
flash_map: Add a macro to fetch controller ID
Add a macro that allows to get the node identifier of the flash controller the area/partition resides on. Signed-off-by: Tomasz Chyrowicz <[email protected]>
1 parent 8f13b37 commit 8849530

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

include/zephyr/storage/flash_map.h

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
* @defgroup flash_area_api flash area Interface
2121
* @since 1.11
22-
* @version 1.0.0
22+
* @version 1.1.0
2323
* @ingroup storage_apis
2424
* @{
2525
*/
@@ -465,6 +465,32 @@ uint8_t flash_area_erased_val(const struct flash_area *fa);
465465
(DT_MTD_FROM_FIXED_SUBPARTITION(node)), \
466466
(DT_MTD_FROM_FIXED_PARTITION(node))))
467467

468+
/**
469+
* Get the node identifier of the flash controller the area/partition resides on
470+
*
471+
* @param label DTS node label of a partition
472+
*
473+
* @return Pointer to a device.
474+
*/
475+
#define FIXED_PARTITION_MTD(label) \
476+
COND_CODE_1( \
477+
DT_FIXED_SUBPARTITION_EXISTS(DT_NODELABEL(label)), \
478+
(DT_MTD_FROM_FIXED_SUBPARTITION(DT_NODELABEL(label))), \
479+
(DT_MTD_FROM_FIXED_PARTITION(DT_NODELABEL(label))))
480+
481+
/**
482+
* Get the node identifier of the flash controller the area/partition resides on
483+
*
484+
* @param node DTS node of a partition
485+
*
486+
* @return Pointer to a device.
487+
*/
488+
#define FIXED_PARTITION_NODE_MTD(node) \
489+
COND_CODE_1( \
490+
DT_FIXED_SUBPARTITION_EXISTS(node), \
491+
(DT_MTD_FROM_FIXED_SUBPARTITION(node)), \
492+
(DT_MTD_FROM_FIXED_PARTITION(node)))
493+
468494
/**
469495
* Get pointer to flash_area object by partition label
470496
*

0 commit comments

Comments
 (0)