Skip to content

Commit 359f27c

Browse files
committed
[nrf fromlist] 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. Upstream PR #: 99800 Signed-off-by: Tomasz Chyrowicz <[email protected]>
1 parent 8116dbc commit 359f27c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

include/zephyr/storage/flash_map.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,31 @@ uint8_t flash_area_erased_val(const struct flash_area *fa);
469469
(DT_MTD_FROM_FIXED_SUBPARTITION(node)), \
470470
(DT_MTD_FROM_FIXED_PARTITION(node))))
471471

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

0 commit comments

Comments
 (0)