Skip to content

Commit 32ff571

Browse files
nordic-krchjukkar
authored andcommitted
[nrf fromlist] devicetree: Add DT_PROP_LAST macro
Add macro for getting the last element of an array type property. Upstream PR #: 82133 Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 376150d commit 32ff571

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

include/zephyr/devicetree.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,17 @@
809809
#define DT_PROP_BY_IDX(node_id, prop, idx) \
810810
DT_CAT5(node_id, _P_, prop, _IDX_, idx)
811811

812+
/**
813+
* @brief Get the last element of an array type property
814+
*
815+
* @param node_id node identifier
816+
* @param prop lowercase-and-underscores property name
817+
*
818+
* @return a representation of the last element of the property
819+
*/
820+
#define DT_PROP_LAST(node_id, prop) \
821+
DT_PROP_BY_IDX(node_id, prop, UTIL_DEC(DT_PROP_LEN(node_id, prop)))
822+
812823
/**
813824
* @brief Like DT_PROP(), but with a fallback to @p default_value
814825
*

0 commit comments

Comments
 (0)