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 572961b607395b2569b368805d12d1d8f6632b89
Author: wangjinjing1 <[email protected]>
AuthorDate: Mon Nov 16 15:00:08 2026 +0800

    net/can: add can ioctl cmd SIOCCANOFLUSH
    
    Add SIOCCANOFLUSH so an application can discard frames that have been
    written to a CAN socket but not yet transmitted, for example to drop
    stale data after an error or before changing the controller state.  The
    command is dispatched to the driver through the common CAN ioctl path in
    netdev_ioctl.c.
    
    The command number differs from the original downstream change: 0x0045
    is already taken by SIOCGCANERRORS upstream, so the next free slot
    0x0048 is used instead.
    
    Signed-off-by: wangjinjing <[email protected]>
---
 include/nuttx/net/ioctl.h | 1 +
 net/netdev/netdev_ioctl.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/include/nuttx/net/ioctl.h b/include/nuttx/net/ioctl.h
index b1519dddff5..b532e44afe8 100644
--- a/include/nuttx/net/ioctl.h
+++ b/include/nuttx/net/ioctl.h
@@ -129,6 +129,7 @@
 #define SIOCSCANSTATE      _SIOC(0x0042)  /* Set the LIN/CAN controller state 
*/
 #define SIOCGCANERRORS     _SIOC(0x0045)  /* Get CAN error counters and fault
                                            * confinement state */
+#define SIOCCANOFLUSH      _SIOC(0x0048)  /* Flush data written but not 
transmitted */
 
 /* Network socket control ***************************************************/
 
diff --git a/net/netdev/netdev_ioctl.c b/net/netdev/netdev_ioctl.c
index 03b744a5086..be2aa60463a 100644
--- a/net/netdev/netdev_ioctl.c
+++ b/net/netdev/netdev_ioctl.c
@@ -788,6 +788,7 @@ static ssize_t net_ioctl_ifreq_arglen(uint8_t domain, int 
cmd)
       case SIOCGCANSTATE:
       case SIOCSCANSTATE:
       case SIOCGCANERRORS:
+      case SIOCCANOFLUSH:
       case SIOCSIFNAME:
       case SIOCGIFNAME:
       case SIOCGIFINDEX:
@@ -1374,6 +1375,7 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int 
cmd,
       case SIOCGCANSTATE:      /* Get state from a CAN/LIN controller */
       case SIOCSCANSTATE:      /* Set the LIN/CAN controller state */
       case SIOCGCANERRORS:     /* Get CAN error counters and state */
+      case SIOCCANOFLUSH:      /* Flush data written but not transmitted */
         if (dev->d_ioctl)
           {
             /* Every CAN ioctl argument struct is a member of the

Reply via email to