This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit f5a36a9f32d2c389f82ff662bba07636b303660e Author: zhanghongyu <[email protected]> AuthorDate: Thu Oct 30 11:46:19 2025 +0800 netdev_lock: change netdev_lock and netdev_unlock to a macro definition netdev_lock() and netdev_unlock() were out-of-line functions in net/netdev/netdev_lock.c. Since d_lock is already an rmutex, turn them into macros over nxrmutex_lock()/nxrmutex_unlock() on d_lock and remove netdev_lock.c, avoiding the extra call for a trivial wrapper. Signed-off-by: zhanghongyu <[email protected]> --- include/nuttx/net/net.h | 25 ++++---------------- net/netdev/CMakeLists.txt | 3 +-- net/netdev/Make.defs | 2 +- net/netdev/netdev_lock.c | 59 ----------------------------------------------- 4 files changed, 7 insertions(+), 82 deletions(-) diff --git a/include/nuttx/net/net.h b/include/nuttx/net/net.h index edc7c0aca82..3bfbdbfef50 100644 --- a/include/nuttx/net/net.h +++ b/include/nuttx/net/net.h @@ -96,6 +96,11 @@ #define _PS_INITD(psock) (_SS_INITD((psock)->s_flags)) #define _PS_VALID(psock) (_PS_ALLOCD(psock) && _PS_INITD(psock)) +/* Network device locking macros */ + +#define netdev_lock(dev) nxrmutex_lock(&(dev)->d_lock) +#define netdev_unlock(dev) nxrmutex_unlock(&(dev)->d_lock) + /**************************************************************************** * Public Types ****************************************************************************/ @@ -1501,26 +1506,6 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype); int netdev_unregister(FAR struct net_driver_s *dev); -/**************************************************************************** - * Name: netdev_lock - * - * Description: - * Lock the network device. - * - ****************************************************************************/ - -void netdev_lock(FAR struct net_driver_s *dev); - -/**************************************************************************** - * Name: netdev_unlock - * - * Description: - * Unlock the network device. - * - ****************************************************************************/ - -void netdev_unlock(FAR struct net_driver_s *dev); - /**************************************************************************** * Name: netdev_findbyname * diff --git a/net/netdev/CMakeLists.txt b/net/netdev/CMakeLists.txt index 09073152739..f79bc9ec861 100644 --- a/net/netdev/CMakeLists.txt +++ b/net/netdev/CMakeLists.txt @@ -34,8 +34,7 @@ set(SRCS netdev_carrier.c netdev_default.c netdev_verify.c - netdev_lladdrsize.c - netdev_lock.c) + netdev_lladdrsize.c) if(CONFIG_MM_IOB) list(APPEND SRCS netdev_input.c netdev_iob.c) diff --git a/net/netdev/Make.defs b/net/netdev/Make.defs index 03611206814..a07dbd45697 100644 --- a/net/netdev/Make.defs +++ b/net/netdev/Make.defs @@ -26,7 +26,7 @@ NETDEV_CSRCS += netdev_register.c netdev_ioctl.c netdev_txnotify.c NETDEV_CSRCS += netdev_findbyname.c netdev_findbyaddr.c netdev_findbyindex.c NETDEV_CSRCS += netdev_count.c netdev_ifconf.c netdev_foreach.c NETDEV_CSRCS += netdev_unregister.c netdev_carrier.c netdev_default.c -NETDEV_CSRCS += netdev_verify.c netdev_lladdrsize.c netdev_lock.c +NETDEV_CSRCS += netdev_verify.c netdev_lladdrsize.c ifeq ($(CONFIG_MM_IOB),y) NETDEV_CSRCS += netdev_input.c netdev_iob.c diff --git a/net/netdev/netdev_lock.c b/net/netdev/netdev_lock.c deleted file mode 100644 index 69b80918719..00000000000 --- a/net/netdev/netdev_lock.c +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** - * net/netdev/netdev_lock.c - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <nuttx/net/netdev.h> - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: netdev_lock - * - * Description: - * Lock the network device. - * - ****************************************************************************/ - -void netdev_lock(FAR struct net_driver_s *dev) -{ - nxrmutex_lock(&dev->d_lock); -} - -/**************************************************************************** - * Name: netdev_unlock - * - * Description: - * Unlock the network device. - * - ****************************************************************************/ - -void netdev_unlock(FAR struct net_driver_s *dev) -{ - nxrmutex_unlock(&dev->d_lock); -}
