This is an automated email from the ASF dual-hosted git repository.

wes3 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new f1229062c hw/mcu/dialog: added critical section to dma acquire 
peripheral
f1229062c is described below

commit f1229062c75b318bde7442a51245027a90e3a39b
Author: Dustin Franco <dustfra...@gmail.com>
AuthorDate: Thu Sep 28 11:27:39 2023 -0700

    hw/mcu/dialog: added critical section to dma acquire peripheral
---
 hw/mcu/dialog/da1469x/src/da1469x_dma.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/hw/mcu/dialog/da1469x/src/da1469x_dma.c 
b/hw/mcu/dialog/da1469x/src/da1469x_dma.c
index 6e8f39e20..de5f8c230 100644
--- a/hw/mcu/dialog/da1469x/src/da1469x_dma.c
+++ b/hw/mcu/dialog/da1469x/src/da1469x_dma.c
@@ -164,17 +164,22 @@ int
 da1469x_dma_acquire_periph(int cidx, uint8_t periph,
                            struct da1469x_dma_regs *chans[2])
 {
+    int sr;
+    int rc = 0;
     assert(cidx < MCU_DMA_CHAN_MAX && periph < MCU_DMA_PERIPH_NONE);
+    OS_ENTER_CRITICAL(sr);
 
     if (cidx < 0) {
         cidx = find_free_pair();
         if (cidx < 0) {
-            return SYS_ENOENT;
+            rc = SYS_ENOENT;
+            goto out;
         }
     } else {
         cidx &= 0xfe;
         if (g_da1469x_dma_acquired & (3 << cidx)) {
-            return SYS_EBUSY;
+            rc = SYS_EBUSY;
+            goto out;
         }
     }
 
@@ -191,8 +196,9 @@ da1469x_dma_acquire_periph(int cidx, uint8_t periph,
 
     chans[0]->DMA_CTRL_REG |= DMA_DMA0_CTRL_REG_DREQ_MODE_Msk;
     chans[1]->DMA_CTRL_REG |= DMA_DMA0_CTRL_REG_DREQ_MODE_Msk;
-
-    return 0;
+out:
+    OS_EXIT_CRITICAL(sr);
+    return rc;
 }
 
 int

Reply via email to