@@ -407,23 +407,24 @@ static DEVICE_API(dma, sam_xdmac_driver_api) = {
407
407
.get_status = sam_xdmac_get_status ,
408
408
};
409
409
410
- /* DMA0 */
411
-
412
- static void dma0_sam_irq_config (void )
413
- {
414
- IRQ_CONNECT (DT_INST_IRQN (0 ), DT_INST_IRQ (0 , priority ), sam_xdmac_isr ,
415
- DEVICE_DT_INST_GET (0 ), 0 );
416
- }
417
-
418
- static const struct sam_xdmac_dev_cfg dma0_sam_config = {
419
- .regs = (Xdmac * )DT_INST_REG_ADDR (0 ),
420
- .irq_config = dma0_sam_irq_config ,
421
- .clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG (0 ),
422
- .irq_id = DT_INST_IRQN (0 ),
423
- };
424
-
425
- static struct sam_xdmac_dev_data dma0_sam_data ;
426
-
427
- DEVICE_DT_INST_DEFINE (0 , sam_xdmac_initialize , NULL ,
428
- & dma0_sam_data , & dma0_sam_config , POST_KERNEL ,
429
- CONFIG_DMA_INIT_PRIORITY , & sam_xdmac_driver_api );
410
+ #define DMA_INIT (n ) \
411
+ static void dma##n##_irq_config(void) \
412
+ { \
413
+ IRQ_CONNECT(DT_INST_IRQN(n), DT_INST_IRQ(n, priority), \
414
+ sam_xdmac_isr, DEVICE_DT_INST_GET(n), 0); \
415
+ } \
416
+ \
417
+ static const struct sam_xdmac_dev_cfg dma##n##_config = { \
418
+ .regs = (Xdmac *)DT_INST_REG_ADDR(n), \
419
+ .irq_config = dma##n##_irq_config, \
420
+ .clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(n), \
421
+ .irq_id = DT_INST_IRQN(n), \
422
+ }; \
423
+ \
424
+ static struct sam_xdmac_dev_data dma##n##_data; \
425
+ \
426
+ DEVICE_DT_INST_DEFINE(n, &sam_xdmac_initialize, NULL, \
427
+ &dma##n##_data, &dma##n##_config, POST_KERNEL, \
428
+ CONFIG_DMA_INIT_PRIORITY, &sam_xdmac_driver_api);
429
+
430
+ DT_INST_FOREACH_STATUS_OKAY (DMA_INIT )
0 commit comments