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/05/19 08:11:29 UTC

[mynewt-core] 02/02: hw/drivers/spiram: Fix build warning for non bus driver build

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

commit 46037d61581ecdae196a69d177e7d3dfa5a5b530
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Wed May 19 09:00:55 2021 +0200

    hw/drivers/spiram: Fix build warning for non bus driver build
    
    label end was used only in bus driver build.
    goto is now removed and ifs are used instead.
---
 hw/drivers/ram/spiram/src/spiram.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/hw/drivers/ram/spiram/src/spiram.c b/hw/drivers/ram/spiram/src/spiram.c
index c684bd4..29212e0 100644
--- a/hw/drivers/ram/spiram/src/spiram.c
+++ b/hw/drivers/ram/spiram/src/spiram.c
@@ -167,16 +167,15 @@ spiram_write(struct spiram_dev *dev, uint32_t addr, void *buf, uint32_t size)
 #if MYNEWT_VAL(BUS_DRIVER_PRESENT)
         rc = bus_node_lock((struct os_dev *)&dev->dev,
                            BUS_NODE_LOCK_DEFAULT_TIMEOUT);
-        if (rc) {
-            goto end;
-        }
-        rc = bus_node_write((struct os_dev *)&dev->dev,
-                            cmd, dev->characteristics->address_bytes + 1,
-                            BUS_NODE_LOCK_DEFAULT_TIMEOUT, BUS_F_NOSTOP);
         if (rc == 0) {
-            rc = bus_node_simple_write((struct os_dev *)&dev->dev, buf, size);
+            rc = bus_node_write((struct os_dev *)&dev->dev,
+                                cmd, dev->characteristics->address_bytes + 1,
+                                BUS_NODE_LOCK_DEFAULT_TIMEOUT, BUS_F_NOSTOP);
+            if (rc == 0) {
+                rc = bus_node_simple_write((struct os_dev *)&dev->dev, buf, size);
+            }
+            (void)bus_node_unlock((struct os_dev *)&dev->dev);
         }
-        (void)bus_node_unlock((struct os_dev *)&dev->dev);
 #else
         spiram_cs_activate(dev);
         rc = hal_spi_txrx(dev->spi_num, cmd, NULL, dev->characteristics->address_bytes + 1);
@@ -186,7 +185,6 @@ spiram_write(struct spiram_dev *dev, uint32_t addr, void *buf, uint32_t size)
         spiram_cs_deactivate(dev);
 #endif
     }
-end:
     if (locked) {
         spiram_unlock(dev);
     }