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

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


The following commit(s) were added to refs/heads/master by this push:
     new f56ea304790 drivers/rpmsg: refactor internal APIs to private header
f56ea304790 is described below

commit f56ea304790d88daf74a4208578464ffdba1e28c
Author: Yongrong Wang <[email protected]>
AuthorDate: Wed Feb 26 16:50:51 2025 +0800

    drivers/rpmsg: refactor internal APIs to private header
    
    Move rpmsg internal APIs from public header include/nuttx/rpmsg/rpmsg.h
    to private header drivers/rpmsg/rpmsg.h. These APIs are only used within
    the rpmsg driver implementation and should not be exposed to external
    modules.
    
    Moved APIs:
    - rpmsg_modify_signals()
    - rpmsg_ns_bind() / rpmsg_ns_unbind()
    - rpmsg_device_created() / rpmsg_device_destory()
    - rpmsg_register() / rpmsg_unregister()
    
    Signed-off-by: Yongrong Wang <[email protected]>
    Signed-off-by: Bowen Wang <[email protected]>
---
 drivers/rpmsg/rpmsg.c                     |  2 +-
 drivers/rpmsg/{rpmsg_router.h => rpmsg.h} | 59 ++++++++++++++++---------------
 drivers/rpmsg/rpmsg_port.h                |  3 +-
 drivers/rpmsg/rpmsg_router.h              |  2 +-
 drivers/rpmsg/rpmsg_virtio.c              |  3 +-
 drivers/rpmsg/rpmsg_virtio_lite.c         |  2 ++
 include/nuttx/rpmsg/rpmsg.h               | 25 -------------
 7 files changed, 38 insertions(+), 58 deletions(-)

diff --git a/drivers/rpmsg/rpmsg.c b/drivers/rpmsg/rpmsg.c
index ae2f786019e..58bc6744e84 100644
--- a/drivers/rpmsg/rpmsg.c
+++ b/drivers/rpmsg/rpmsg.c
@@ -31,8 +31,8 @@
 #include <nuttx/mutex.h>
 #include <nuttx/rwsem.h>
 #include <nuttx/semaphore.h>
-#include <nuttx/rpmsg/rpmsg.h>
 
+#include "rpmsg.h"
 #include "rpmsg_ping.h"
 #include "rpmsg_router.h"
 #include "rpmsg_test.h"
diff --git a/drivers/rpmsg/rpmsg_router.h b/drivers/rpmsg/rpmsg.h
similarity index 56%
copy from drivers/rpmsg/rpmsg_router.h
copy to drivers/rpmsg/rpmsg.h
index cb799cd253b..0fad854e42b 100644
--- a/drivers/rpmsg/rpmsg_router.h
+++ b/drivers/rpmsg/rpmsg.h
@@ -1,7 +1,5 @@
 /****************************************************************************
- * drivers/rpmsg/rpmsg_router.h
- *
- * SPDX-License-Identifier: Apache-2.0
+ * drivers/rpmsg/rpmsg.h
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -20,43 +18,46 @@
  *
  ****************************************************************************/
 
-#ifndef __DRIVERS_RPMSG_RPMSG_ROUTER_H
-#define __DRIVERS_RPMSG_RPMSG_ROUTER_H
+#ifndef __DRIVERS_RPMSG_RPMSG_H
+#define __DRIVERS_RPMSG_RPMSG_H
 
 /****************************************************************************
  * Included Files
  ****************************************************************************/
 
+#ifdef CONFIG_RPMSG
+
 #include <nuttx/rpmsg/rpmsg.h>
 
 /****************************************************************************
- * Pre-processor Definitions
+ * Public Function Prototypes
  ****************************************************************************/
 
-#define RPMSG_ROUTER_NAME            "router:"
-#define RPMSG_ROUTER_NAME_LEN        7
-#define RPMSG_ROUTER_NAME_PREFIX     "r:"
-#define RPMSG_ROUTER_NAME_PREFIX_LEN 2
-#define RPMSG_ROUTER_CPUNAME_LEN     8
+static inline FAR struct rpmsg_device *
+rpmsg_get_rdev_by_rpmsg(FAR struct rpmsg_s *rpmsg)
+{
+  if (!rpmsg)
+    {
+      return NULL;
+    }
 
-#define RPMSG_ROUTER_CREATE          1
-#define RPMSG_ROUTER_DESTROY         2
-#define RPMSG_ROUTER_SUSPEND         3
-#define RPMSG_ROUTER_RESUME          4
+  return (FAR struct rpmsg_device *)(rpmsg + 1);
+}
 
-#ifdef CONFIG_RPMSG_ROUTER
+void rpmsg_modify_signals(FAR struct rpmsg_s *rpmsg,
+                          int setflags, int clrflags);
 
-/****************************************************************************
- * Public Types
- ****************************************************************************/
+void rpmsg_ns_bind(FAR struct rpmsg_device *rdev,
+                   FAR const char *name, uint32_t dest);
+void rpmsg_ns_unbind(FAR struct rpmsg_device *rdev,
+                     FAR const char *name, uint32_t dest);
 
-begin_packed_struct struct rpmsg_router_s
-{
-  uint32_t cmd;
-  uint32_t tx_len;
-  uint32_t rx_len;
-  char     cpuname[RPMSG_ROUTER_CPUNAME_LEN];
-} end_packed_struct;
-
-#endif /* CONFIG_RPMSG_ROUTER */
-#endif /* __DRIVERS_RPMSG_RPMSG_ROUTER_H */
+void rpmsg_device_created(FAR struct rpmsg_s *rpmsg);
+void rpmsg_device_destory(FAR struct rpmsg_s *rpmsg);
+
+int rpmsg_register(FAR const char *path, FAR struct rpmsg_s *rpmsg,
+                   FAR const struct rpmsg_ops_s *ops);
+void rpmsg_unregister(FAR const char *path, FAR struct rpmsg_s *rpmsg);
+
+#endif /* CONFIG_RPMSG */
+#endif /* __DRIVERS_RPMSG_RPMSG_H */
diff --git a/drivers/rpmsg/rpmsg_port.h b/drivers/rpmsg/rpmsg_port.h
index 94d514982ab..0245c2c1c1c 100644
--- a/drivers/rpmsg/rpmsg_port.h
+++ b/drivers/rpmsg/rpmsg_port.h
@@ -32,9 +32,10 @@
 #include <nuttx/list.h>
 #include <nuttx/spinlock.h>
 #include <nuttx/semaphore.h>
-#include <nuttx/rpmsg/rpmsg.h>
 #include <nuttx/rpmsg/rpmsg_port.h>
 
+#include "rpmsg.h"
+
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
diff --git a/drivers/rpmsg/rpmsg_router.h b/drivers/rpmsg/rpmsg_router.h
index cb799cd253b..dc80617ab53 100644
--- a/drivers/rpmsg/rpmsg_router.h
+++ b/drivers/rpmsg/rpmsg_router.h
@@ -27,7 +27,7 @@
  * Included Files
  ****************************************************************************/
 
-#include <nuttx/rpmsg/rpmsg.h>
+#include "rpmsg.h"
 
 /****************************************************************************
  * Pre-processor Definitions
diff --git a/drivers/rpmsg/rpmsg_virtio.c b/drivers/rpmsg/rpmsg_virtio.c
index 66a44fe0840..2983d624b1f 100644
--- a/drivers/rpmsg/rpmsg_virtio.c
+++ b/drivers/rpmsg/rpmsg_virtio.c
@@ -31,7 +31,6 @@
 #include <nuttx/kmalloc.h>
 #include <nuttx/kthread.h>
 #include <nuttx/power/pm.h>
-#include <nuttx/rpmsg/rpmsg.h>
 #include <nuttx/rpmsg/rpmsg_virtio.h>
 #include <nuttx/semaphore.h>
 #include <nuttx/spinlock.h>
@@ -40,6 +39,8 @@
 #include <metal/utilities.h>
 #include <openamp/rpmsg_virtio.h>
 
+#include "rpmsg.h"
+
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
diff --git a/drivers/rpmsg/rpmsg_virtio_lite.c 
b/drivers/rpmsg/rpmsg_virtio_lite.c
index 65bf52a59e6..4f08432c46f 100644
--- a/drivers/rpmsg/rpmsg_virtio_lite.c
+++ b/drivers/rpmsg/rpmsg_virtio_lite.c
@@ -38,6 +38,8 @@
 #include <nuttx/semaphore.h>
 #include <nuttx/rpmsg/rpmsg_virtio_lite.h>
 
+#include "rpmsg.h"
+
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
diff --git a/include/nuttx/rpmsg/rpmsg.h b/include/nuttx/rpmsg/rpmsg.h
index 86d11f195b0..08ef10da8c6 100644
--- a/include/nuttx/rpmsg/rpmsg.h
+++ b/include/nuttx/rpmsg/rpmsg.h
@@ -107,25 +107,12 @@ extern "C"
 #define EXTERN extern
 #endif
 
-static inline FAR struct rpmsg_device *
-rpmsg_get_rdev_by_rpmsg(FAR struct rpmsg_s *rpmsg)
-{
-  if (!rpmsg)
-    {
-      return NULL;
-    }
-
-  return (FAR struct rpmsg_device *)(rpmsg + 1);
-}
-
 int rpmsg_wait(FAR struct rpmsg_endpoint *ept, FAR sem_t *sem);
 int rpmsg_post(FAR struct rpmsg_endpoint *ept, FAR sem_t *sem);
 
 FAR const char *rpmsg_get_local_cpuname(FAR struct rpmsg_device *rdev);
 FAR const char *rpmsg_get_cpuname(FAR struct rpmsg_device *rdev);
 int rpmsg_get_signals(FAR struct rpmsg_device *rdev);
-void rpmsg_modify_signals(FAR struct rpmsg_s *rpmsg,
-                          int setflags, int clrflags);
 
 static inline_function bool rpmsg_is_running(FAR struct rpmsg_device *rdev)
 {
@@ -143,18 +130,6 @@ void rpmsg_unregister_callback(FAR void *priv,
                                rpmsg_match_cb_t ns_match,
                                rpmsg_bind_cb_t ns_bind);
 
-void rpmsg_ns_bind(FAR struct rpmsg_device *rdev,
-                   FAR const char *name, uint32_t dest);
-void rpmsg_ns_unbind(FAR struct rpmsg_device *rdev,
-                     FAR const char *name, uint32_t dest);
-
-void rpmsg_device_created(FAR struct rpmsg_s *rpmsg);
-void rpmsg_device_destory(FAR struct rpmsg_s *rpmsg);
-
-int rpmsg_register(FAR const char *path, FAR struct rpmsg_s *rpmsg,
-                   FAR const struct rpmsg_ops_s *ops);
-void rpmsg_unregister(FAR const char *path, FAR struct rpmsg_s *rpmsg);
-
 int rpmsg_ioctl(FAR const char *cpuname, int cmd, unsigned long arg);
 int rpmsg_panic(FAR const char *cpuname);
 void rpmsg_dump_all(void);

Reply via email to