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

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

commit 894c8d5946cdcb48bff4277285c1241fd687078e
Author: yintao <[email protected]>
AuthorDate: Wed Nov 11 22:13:12 2026 +0800

    drivers/rptun: use the nuttx list and container_of instead of metal
    
    rptun is a NuttX driver, so use the NuttX list, container_of() and
    syslog() rather than the libmetal wrappers, and drop the
    metal/utilities.h include.
    
    Signed-off-by: yintao <[email protected]>
    Signed-off-by: Bowen Wang <[email protected]>
---
 drivers/rptun/rptun.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/rptun/rptun.c b/drivers/rptun/rptun.c
index 6823a8cec4d..714132ca5e7 100644
--- a/drivers/rptun/rptun.c
+++ b/drivers/rptun/rptun.c
@@ -34,10 +34,10 @@
 #include <sys/param.h>
 #include <sys/wait.h>
 
-#include <metal/utilities.h>
 #include <nuttx/clock.h>
 #include <nuttx/kmalloc.h>
 #include <nuttx/kthread.h>
+#include <nuttx/list.h>
 #include <nuttx/mm/mm.h>
 #include <nuttx/nuttx.h>
 #include <nuttx/rpmsg/rpmsg_virtio.h>
@@ -78,7 +78,7 @@ struct rptun_priv_s
 {
   FAR struct rptun_dev_s      *dev;
   struct remoteproc           rproc;
-  struct metal_list           node;
+  struct list_node            node;
   bool                        rreset;
   bool                        stop;
   pid_t                       pid;
@@ -199,7 +199,7 @@ static const struct virtio_memory_ops g_rptun_mmops =
   .unmap        = rptun_unmap_buf,
 };
 
-static struct metal_list g_rptun_priv = METAL_INIT_LIST(g_rptun_priv);
+static struct list_node g_rptun_priv = LIST_INITIAL_VALUE(g_rptun_priv);
 static rmutex_t g_rptun_lock = NXRMUTEX_INITIALIZER;
 
 static struct notifier_block g_rptun_panic_nb =
@@ -623,7 +623,7 @@ static int rptun_create_device(FAR struct rptun_priv_s 
*priv,
       metal_mutex_acquire(&rproc->lock);
       metal_list_for_each(&rproc->vdevs, node)
         {
-          rvdev = metal_container_of(node, struct remoteproc_virtio, node);
+          rvdev = container_of(node, struct remoteproc_virtio, node);
           if (rvdev->vdev_rsc == vdev_rsc)
             {
               ret = -EEXIST;
@@ -805,7 +805,7 @@ static void rptun_remove_devices(FAR struct rptun_priv_s 
*priv)
   metal_mutex_acquire(&rproc->lock);
   metal_list_for_each_safe(&rproc->vdevs, temp, node)
     {
-      rvdev = metal_container_of(node, struct remoteproc_virtio, node);
+      rvdev = container_of(node, struct remoteproc_virtio, node);
       rptun_unregister_device(&rvdev->vdev);
       rptun_remove_device(priv, &rvdev->vdev);
     }
@@ -912,9 +912,9 @@ static void rptun_check_peer_status(FAR struct rptun_priv_s 
*priv)
 
   if (RPTUN_STATUS_CHECK(status, BOARDIOC_SOFTRESETCAUSE_PANIC))
     {
-      metal_log(METAL_LOG_EMERGENCY,
-                "FATAL: Panic by remote core: %s\n",
-                RPTUN_GET_CPUNAME(priv->dev));
+      syslog(LOG_EMERG,
+             "FATAL: Panic by remote core: %s\n",
+             RPTUN_GET_CPUNAME(priv->dev));
       PANIC();
     }
 #ifdef CONFIG_BOARDCTL_RESET
@@ -1165,7 +1165,7 @@ static int rptun_dev_ioctl(FAR struct file *filep, int 
cmd,
 static int rptun_ioctl_foreach(FAR const char *cpuname, int cmd,
                                unsigned long value)
 {
-  FAR struct metal_list *node;
+  FAR struct rptun_priv_s *priv;
   int ret = OK;
 
   if (!up_interrupt_context())
@@ -1173,12 +1173,8 @@ static int rptun_ioctl_foreach(FAR const char *cpuname, 
int cmd,
       nxrmutex_lock(&g_rptun_lock);
     }
 
-  metal_list_for_each(&g_rptun_priv, node)
+  list_for_every_entry(&g_rptun_priv, priv, struct rptun_priv_s, node)
     {
-      FAR struct rptun_priv_s *priv;
-
-      priv = metal_container_of(node, struct rptun_priv_s, node);
-
       if (!cpuname || !strcmp(RPTUN_GET_CPUNAME(priv->dev), cpuname))
         {
           ret = rptun_do_ioctl(priv, cmd, value);
@@ -1383,7 +1379,7 @@ int rptun_initialize(FAR struct rptun_dev_s *dev)
               register_reboot_notifier(&g_rptun_reboot_nb);
 
               nxrmutex_lock(&g_rptun_lock);
-              metal_list_add_tail(&g_rptun_priv, &priv->node);
+              list_add_tail(&g_rptun_priv, &priv->node);
               nxrmutex_unlock(&g_rptun_lock);
             }
         }

Reply via email to