Skip to content

Commit

Permalink
devicetree: add DT_INST_NUM_IRQS()
Browse files Browse the repository at this point in the history
Add `DT_INST_NUM_IRQS()` to get the number of interrupt lines
of the current `DT_DRV_COMPAT`

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
(cherry picked from commit ee08ebd)
  • Loading branch information
ycsin authored and nashif committed Sep 23, 2024
1 parent f2ef1c8 commit 331ad99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/zephyr/devicetree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4215,6 +4215,14 @@
*/
#define DT_INST_REG_SIZE(inst) DT_INST_REG_SIZE_BY_IDX(inst, 0)

/**
* @brief Get a `DT_DRV_COMPAT`'s number of interrupts
*
* @param inst instance number
* @return number of interrupts
*/
#define DT_INST_NUM_IRQS(inst) DT_NUM_IRQS(DT_DRV_INST(inst))

/**
* @brief Get a `DT_DRV_COMPAT` interrupt level
*
Expand Down
3 changes: 3 additions & 0 deletions tests/lib/devicetree/api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,9 @@ ZTEST(devicetree_api, test_irq)
/* DT_INST */
zassert_equal(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT), 1, "");

/* DT_INST_NUM_IRQS */
zassert_equal(DT_INST_NUM_IRQS(0), 3);

/* DT_INST_IRQ_HAS_IDX */
zassert_equal(DT_INST_IRQ_HAS_IDX(0, 0), 1, "");
zassert_equal(DT_INST_IRQ_HAS_IDX(0, 1), 1, "");
Expand Down

0 comments on commit 331ad99

Please sign in to comment.