You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/11/01 11:57:40 UTC

[incubator-nuttx] 02/02: rptun: add ns_unbind_notify support

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

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 9cb994e6dcc188e1fcc32dd8d7437dfc6ce6f0f3
Author: ligd <li...@xiaomi.com>
AuthorDate: Tue Jul 20 17:43:46 2021 +0800

    rptun: add ns_unbind_notify support
    
    Signed-off-by: ligd <li...@xiaomi.com>
---
 drivers/rptun/rptun.c | 37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/rptun/rptun.c b/drivers/rptun/rptun.c
index 31b90ff..0be24b5 100644
--- a/drivers/rptun/rptun.c
+++ b/drivers/rptun/rptun.c
@@ -377,6 +377,31 @@ static void rptun_ns_bind(FAR struct rpmsg_device *rdev,
     }
 }
 
+static void rptun_ns_unbind(FAR struct rpmsg_device *rdev,
+                            FAR const char *name, uint32_t dest)
+{
+  FAR struct rptun_priv_s *priv = rptun_get_priv_by_rdev(rdev);
+  FAR struct metal_list *node;
+
+  nxsem_wait(&g_rptun_sem);
+
+  metal_list_for_each(&priv->bind, node)
+    {
+      struct rptun_bind_s *bind;
+
+      bind = metal_container_of(node, struct rptun_bind_s, node);
+
+      if (bind->dest == dest && !strncmp(bind->name, name, RPMSG_NAME_SIZE))
+        {
+          metal_list_del(node);
+          kmm_free(bind);
+          break;
+        }
+    }
+
+  nxsem_post(&g_rptun_sem);
+}
+
 static int rptun_dev_start(FAR struct remoteproc *rproc)
 {
   FAR struct rptun_priv_s *priv = rproc->priv;
@@ -493,6 +518,8 @@ static int rptun_dev_start(FAR struct remoteproc *rproc)
       return ret;
     }
 
+  priv->vdev.rdev.ns_unbind_cb = rptun_ns_unbind;
+
   /* Remote proc start */
 
   ret = remoteproc_start(rproc);
@@ -566,16 +593,6 @@ static int rptun_dev_stop(FAR struct remoteproc *rproc)
   remoteproc_remove_virtio(rproc, priv->vdev.vdev);
   rpmsg_deinit_vdev(&priv->vdev);
 
-  /* Free bind list */
-
-  metal_list_for_each(&priv->bind, node)
-    {
-      struct rptun_bind_s *bind;
-
-      bind = metal_container_of(node, struct rptun_bind_s, node);
-      kmm_free(bind);
-    }
-
   return 0;
 }