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

commit b8850e4eb3f7e5793edcb0fe9df68270d895b180
Author: zhanghongyu <[email protected]>
AuthorDate: Thu Oct 30 15:50:37 2025 +0800

    conn_lock: inline conn_lock/conn_dev_lock
    
    modify functions that are simple but frequently called into inline
    functions, thereby reducing CPU loading without significantly changing
    the code size.
    
    Signed-off-by: zhanghongyu <[email protected]>
---
 net/utils/net_lock.c | 40 ----------------------------------------
 net/utils/utils.h    | 36 ++++++++++++++++++++++++++++++------
 2 files changed, 30 insertions(+), 46 deletions(-)

diff --git a/net/utils/net_lock.c b/net/utils/net_lock.c
index 60fe754ee88..913bedd6485 100644
--- a/net/utils/net_lock.c
+++ b/net/utils/net_lock.c
@@ -395,43 +395,3 @@ FAR struct iob_s *net_ioballoc(bool throttled)
   return net_iobtimedalloc(throttled, UINT_MAX);
 }
 #endif
-
-/****************************************************************************
- * Name: conn_lock, conn_unlock, conn_dev_lock, conn_dev_unlock
- *
- * Description:
- *   Lock and unlock the connection and device.
- *
- ****************************************************************************/
-
-void conn_lock(FAR struct socket_conn_s *sconn)
-{
-  nxrmutex_lock(&sconn->s_lock);
-}
-
-void conn_unlock(FAR struct socket_conn_s *sconn)
-{
-  nxrmutex_unlock(&sconn->s_lock);
-}
-
-void conn_dev_lock(FAR struct socket_conn_s *sconn,
-                   FAR struct net_driver_s *dev)
-{
-  if (dev != NULL)
-    {
-      netdev_lock(dev);
-    }
-
-  nxrmutex_lock(&sconn->s_lock);
-}
-
-void conn_dev_unlock(FAR struct socket_conn_s *sconn,
-                     FAR struct net_driver_s *dev)
-{
-  nxrmutex_unlock(&sconn->s_lock);
-
-  if (dev != NULL)
-    {
-      netdev_unlock(dev);
-    }
-}
diff --git a/net/utils/utils.h b/net/utils/utils.h
index 0eacf0a59b7..899d918ddbf 100644
--- a/net/utils/utils.h
+++ b/net/utils/utils.h
@@ -32,6 +32,7 @@
 
 #include <stdlib.h>
 
+#include <nuttx/mutex.h>
 #include <nuttx/net/net.h>
 #include <nuttx/net/ip.h>
 #include <nuttx/net/netdev.h>
@@ -614,14 +615,37 @@ FAR void *cmsg_append(FAR struct msghdr *msg, int level, 
int type,
  *
  ****************************************************************************/
 
-void conn_lock(FAR struct socket_conn_s *sconn);
-void conn_unlock(FAR struct socket_conn_s *sconn);
+static inline_function void conn_lock(FAR struct socket_conn_s *sconn)
+{
+  nxrmutex_lock(&sconn->s_lock);
+}
+
+static inline_function void conn_unlock(FAR struct socket_conn_s *sconn)
+{
+  nxrmutex_unlock(&sconn->s_lock);
+}
 
-void conn_dev_lock(FAR struct socket_conn_s *sconn,
-                   FAR struct net_driver_s *dev);
+static inline_function void conn_dev_lock(FAR struct socket_conn_s *sconn,
+                                          FAR struct net_driver_s *dev)
+{
+  if (dev != NULL)
+    {
+      netdev_lock(dev);
+    }
 
-void conn_dev_unlock(FAR struct socket_conn_s *sconn,
-                     FAR struct net_driver_s *dev);
+  nxrmutex_lock(&sconn->s_lock);
+}
+
+static inline_function void conn_dev_unlock(FAR struct socket_conn_s *sconn,
+                                            FAR struct net_driver_s *dev)
+{
+  nxrmutex_unlock(&sconn->s_lock);
+
+  if (dev != NULL)
+    {
+      netdev_unlock(dev);
+    }
+}
 
 #undef EXTERN
 #ifdef __cplusplus

Reply via email to