devicetree: add DT_HAS_DRV_INST(instance_number)

Convenience macro for checking the existence of a node by instance
number.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2020-03-24 10:18:15 -07:00 committed by Kumar Gala
commit 49f97f64dd
2 changed files with 17 additions and 0 deletions

View file

@ -1281,6 +1281,16 @@
*/
#define DT_INST_BUS_LABEL(inst) DT_BUS_LABEL(DT_DRV_INST(inst))
/**
* @brief Does the devicetree have a particular instance number?
*
* This is equivalent to DT_HAS_NODE(DT_DRV_INST(inst)).
* @param inst instance number
* @return 1 if the devicetree has that numbered instance,
* 0 otherwise.
*/
#define DT_HAS_DRV_INST(inst) DT_HAS_NODE(DT_DRV_INST(inst))
/**
* @brief Test if a DT_DRV_COMPAT's bus type is a given type
* This is equivalent to DT_ON_BUS(DT_DRV_INST(inst), bus).