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 1a875b138d2d32ddc5fcd345f3e01658f65514a1 Author: p-szafonimateusz <[email protected]> AuthorDate: Mon Nov 9 11:51:10 2026 +0100 net/can: Move can_poll.c into can.c. Move the code of can_poll.c into can.c without changes and remove can_poll.c. Only the include lists and the file guards are merged; the functions are copied as they are. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: p-szafonimateusz <[email protected]> --- .github/CODEOWNERS | 1 - Documentation/os/networking/socketcan.rst | 3 +- net/can/CMakeLists.txt | 2 +- net/can/Make.defs | 1 - net/can/can.c | 46 ++++++++++++++++ net/can/can_poll.c | 89 ------------------------------- 6 files changed, 48 insertions(+), 94 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ca6e0183c82..f00c229aa9e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -15894,7 +15894,6 @@ net/can/can.c [email protected] [email protected] [email protected] anchao net/can/can.h [email protected] [email protected] [email protected] [email protected] [email protected] net/can/can_getsockopt.c [email protected] [email protected] [email protected] [email protected] [email protected] net/can/can_notifier.c [email protected] [email protected] -net/can/can_poll.c [email protected] [email protected] [email protected] [email protected] [email protected] net/can/can_recvmsg.c [email protected] [email protected] [email protected] [email protected] [email protected] net/can/can_sendmsg.c [email protected] [email protected] [email protected] [email protected] [email protected] net/can/can_setsockopt.c [email protected] [email protected] [email protected] [email protected] [email protected] diff --git a/Documentation/os/networking/socketcan.rst b/Documentation/os/networking/socketcan.rst index dbee99409ab..f9ab6842927 100644 --- a/Documentation/os/networking/socketcan.rst +++ b/Documentation/os/networking/socketcan.rst @@ -92,12 +92,11 @@ Files supporting SocketCAN can be found in the following locations: - **Header File**: ``include/nuttx/net/can.h`` - **Main Modules**: - - ``can.c`` - Connection management, input and callbacks + - ``can.c`` - Connection management, input, callbacks and polling - ``can_sockif.c`` - Socket interface implementation - ``can_sendmsg.c`` - Message transmission - ``can_sendmsg_buffered.c`` - Message transmission with buffering - ``can_recvmsg.c`` - Message reception - - ``can_poll.c`` - Polling support Configuration Options --------------------- diff --git a/net/can/CMakeLists.txt b/net/can/CMakeLists.txt index 93797acd90e..694abcbad62 100644 --- a/net/can/CMakeLists.txt +++ b/net/can/CMakeLists.txt @@ -43,7 +43,7 @@ if(CONFIG_NET_CAN) list(APPEND SRCS can_bufpool.c) endif() - list(APPEND SRCS can.c can_poll.c) + list(APPEND SRCS can.c) target_sources(net PRIVATE ${SRCS}) endif() diff --git a/net/can/Make.defs b/net/can/Make.defs index e2085265cef..0372afb9d63 100644 --- a/net/can/Make.defs +++ b/net/can/Make.defs @@ -50,7 +50,6 @@ endif endif NET_CSRCS += can.c -NET_CSRCS += can_poll.c # Include can build support diff --git a/net/can/can.c b/net/can/can.c index 798c9bcf237..227ae61856c 100644 --- a/net/can/can.c +++ b/net/can/can.c @@ -537,6 +537,52 @@ int can_input(FAR struct net_driver_s *dev) return ret; } +/**************************************************************************** + * Name: can_poll + * + * Description: + * Poll a packet "connection" structure for availability of TX data + * + * Input Parameters: + * dev - The device driver structure to use in the send operation + * conn - The packet "connection" to poll for TX data + * + * Returned Value: + * None + * + * Assumptions: + * The network is locked. + * dev is not NULL. + * conn is not NULL. + * The connection (conn) is bound to the polling device (dev). + * + ****************************************************************************/ + +void can_poll(FAR struct net_driver_s *dev, FAR struct can_conn_s *conn) +{ + DEBUGASSERT(dev != NULL && conn != NULL && dev == conn->dev); + + /* Setup for the application callback */ + + dev->d_len = 0; + dev->d_sndlen = 0; + + /* Perform the application callback */ + + can_callback(dev, conn, CAN_POLL); + + /* Check if the application has data to send */ + + if (dev->d_sndlen > 0) + { + return; + } + + /* Make sure that d_len is zero meaning that there is nothing to be sent */ + + dev->d_len = 0; +} + /**************************************************************************** * Name: can_alloc() * diff --git a/net/can/can_poll.c b/net/can/can_poll.c deleted file mode 100644 index b45d00f3edf..00000000000 --- a/net/can/can_poll.c +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** - * net/can/can_poll.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> -#if defined(CONFIG_NET) && defined(CONFIG_NET_CAN) - -#include <assert.h> -#include <nuttx/debug.h> - -#include <nuttx/net/netconfig.h> -#include <nuttx/net/netdev.h> - -#include "devif/devif.h" -#include "can/can.h" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: can_poll - * - * Description: - * Poll a packet "connection" structure for availability of TX data - * - * Input Parameters: - * dev - The device driver structure to use in the send operation - * conn - The packet "connection" to poll for TX data - * - * Returned Value: - * None - * - * Assumptions: - * The network is locked. - * dev is not NULL. - * conn is not NULL. - * The connection (conn) is bound to the polling device (dev). - * - ****************************************************************************/ - -void can_poll(FAR struct net_driver_s *dev, FAR struct can_conn_s *conn) -{ - DEBUGASSERT(dev != NULL && conn != NULL && dev == conn->dev); - - /* Setup for the application callback */ - - dev->d_len = 0; - dev->d_sndlen = 0; - - /* Perform the application callback */ - - can_callback(dev, conn, CAN_POLL); - - /* Check if the application has data to send */ - - if (dev->d_sndlen > 0) - { - return; - } - - /* Make sure that d_len is zero meaning that there is nothing to be sent */ - - dev->d_len = 0; -} - -#endif /* CONFIG_NET && CONFIG_NET_CAN */
