devicetree: fix DT_NUM_INST() when the answer is 0

Use UTIL_AND() so it works even when there are no instances.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2020-03-25 14:40:19 -07:00 committed by Kumar Gala
commit 9d15e98643
2 changed files with 8 additions and 3 deletions

View file

@ -851,7 +851,9 @@
* @param compat lowercase-and-underscores version of a compatible
* @return Number of enabled instances
*/
#define DT_NUM_INST(compat) UTIL_CAT(DT_N_INST, DT_DASH(compat, NUM))
#define DT_NUM_INST(compat) \
UTIL_AND(DT_HAS_COMPAT(compat), \
UTIL_CAT(DT_N_INST, DT_DASH(compat, NUM)))
/**
* @brief Test if the devicetree has a /chosen node