|
4919 | 4919 | UTIL_NOT(IS_EMPTY( \
|
4920 | 4920 | DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_ANY_INST_HAS_BOOL_STATUS_OKAY_, prop)))
|
4921 | 4921 |
|
| 4922 | +/** |
| 4923 | + * @brief Check if all `DT_DRV_COMPAT` node with status `okay` has a given |
| 4924 | + * boolean property that exists. If all nodes are disabled, this |
| 4925 | + * will return 1. |
| 4926 | + * * |
| 4927 | + * @param prop lowercase-and-underscores property name |
| 4928 | + * |
| 4929 | + * Example devicetree overlay: |
| 4930 | + * |
| 4931 | + * @code{.dts} |
| 4932 | + * &i2c0 { |
| 4933 | + * sensor0: sensor@0 { |
| 4934 | + * compatible = "vnd,some-sensor"; |
| 4935 | + * status = "okay"; |
| 4936 | + * reg = <0>; |
| 4937 | + * foo; |
| 4938 | + * bar; |
| 4939 | + * }; |
| 4940 | + * |
| 4941 | + * sensor1: sensor@1 { |
| 4942 | + * compatible = "vnd,some-sensor"; |
| 4943 | + * status = "okay"; |
| 4944 | + * reg = <1>; |
| 4945 | + * foo; |
| 4946 | + * }; |
| 4947 | + * |
| 4948 | + * sensor2: sensor@2 { |
| 4949 | + * compatible = "vnd,some-sensor"; |
| 4950 | + * status = "disabled"; |
| 4951 | + * reg = <2>; |
| 4952 | + * baz; |
| 4953 | + * }; |
| 4954 | + * }; |
| 4955 | + * @endcode |
| 4956 | + * |
| 4957 | + * Example usage: |
| 4958 | + * |
| 4959 | + * @code{.c} |
| 4960 | + * #define DT_DRV_COMPAT vnd_some_sensor |
| 4961 | + * |
| 4962 | + * DT_ALL_INST_HAS_BOOL_STATUS_OKAY(foo) // 1 |
| 4963 | + * DT_ALL_INST_HAS_BOOL_STATUS_OKAY(bar) // 0 |
| 4964 | + * DT_ALL_INST_HAS_BOOL_STATUS_OKAY(baz) // 0 |
| 4965 | + * @endcode |
| 4966 | + */ |
| 4967 | +#define DT_ALL_INST_HAS_BOOL_STATUS_OKAY(prop) \ |
| 4968 | + IS_EMPTY(DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_ALL_INST_HAS_BOOL_STATUS_OKAY_, prop)) |
| 4969 | + |
4922 | 4970 | /**
|
4923 | 4971 | * @brief Call @p fn on all nodes with compatible `DT_DRV_COMPAT`
|
4924 | 4972 | * and status `okay`
|
|
5217 | 5265 | #define DT_ANY_INST_HAS_BOOL_STATUS_OKAY_(idx, prop) \
|
5218 | 5266 | IF_ENABLED(DT_INST_PROP(idx, prop), (1,))
|
5219 | 5267 |
|
| 5268 | +/** @brief Helper for DT_ALL_INST_HAS_BOOL_STATUS_OKAY |
| 5269 | + * |
| 5270 | + * This macro generates token "1," for instance of a device, |
| 5271 | + * identified by index @p idx, if instance has no boolean property |
| 5272 | + * @p prop with value 1. |
| 5273 | + * |
| 5274 | + * @param idx instance number |
| 5275 | + * @param prop property to check for |
| 5276 | + * |
| 5277 | + * @return Macro evaluates to `1,` if instance property value is 0, |
| 5278 | + * otherwise it evaluates to literal nothing. |
| 5279 | + */ |
| 5280 | +#define DT_ALL_INST_HAS_BOOL_STATUS_OKAY_(idx, prop) \ |
| 5281 | + IF_DISABLED(DT_INST_PROP(idx, prop), (1,)) |
| 5282 | + |
5220 | 5283 | #define DT_PATH_INTERNAL(...) \
|
5221 | 5284 | UTIL_CAT(DT_ROOT, MACRO_MAP_CAT(DT_S_PREFIX, __VA_ARGS__))
|
5222 | 5285 | /** @brief DT_PATH_INTERNAL() helper: prepends _S_ to a node name
|
|
0 commit comments