You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2021/06/21 19:35:18 UTC

[mynewt-core] branch master updated: i2s: Assure open fails in case of driver error

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

jerzy 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 8c153b1  i2s: Assure open fails in case of driver error
8c153b1 is described below

commit 8c153b11290b752fdb95959b8eed48c2ce44b3e4
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Thu Jun 17 10:54:11 2021 +0200

    i2s: Assure open fails in case of driver error
    
    When device is not configured correctly i2s_start for
    I2S output device may fail.
    i2s_start() returning I2S_ERR_NO_BUFFER is rather expected
    while other errors may indicate some serious configuration
    problem.
    
    With this change failing i2s_start will stop user code form
    openning device since it will probably not work anyway.
---
 hw/drivers/i2s/src/i2s.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/hw/drivers/i2s/src/i2s.c b/hw/drivers/i2s/src/i2s.c
index 7930c56..d8d9d83 100644
--- a/hw/drivers/i2s/src/i2s.c
+++ b/hw/drivers/i2s/src/i2s.c
@@ -32,6 +32,7 @@ i2s_open_handler(struct os_dev *dev, uint32_t timout, void *arg)
     struct i2s *i2s;
     struct i2s_client *client = (struct i2s_client *)arg;
     struct i2s_sample_buffer *buffer;
+    int rc;
 
     if (dev->od_flags & OS_DEV_F_STATUS_OPEN) {
         return OS_EBUSY;
@@ -52,7 +53,14 @@ i2s_open_handler(struct os_dev *dev, uint32_t timout, void *arg)
             i2s_buffer_put(i2s, buffer);
         }
     } else {
-        i2s_start(i2s);
+        rc = i2s_start(i2s);
+        /*
+         * No buffers on opening output I2S stream is to be expected
+         * and is not error preventing device usage.
+         */
+        if (rc != OS_OK && rc != I2S_ERR_NO_BUFFER) {
+            return rc;
+        }
     }
 
     return OS_OK;