anchao commented on code in PR #18428:
URL: https://github.com/apache/nuttx/pull/18428#discussion_r2846433159


##########
drivers/usbdev/rndis.c:
##########
@@ -2752,6 +2752,22 @@ static void usbclass_resetconfig(FAR struct rndis_dev_s 
*priv)
     }
 }
 
+/****************************************************************************
+ * Name: rndis_carrier_on_work
+ *
+ * Description:
+ *   Schedule to work queue because netdev_carrier_on API can't be used in
+ *   interrupt context
+ *
+ ****************************************************************************/
+
+static void rndis_carrier_on_work(FAR void *arg)
+{
+  FAR struct rndis_dev_s *priv = (FAR struct rndis_dev_s *)arg;

Review Comment:
   how about change netlink_device_notify() ISR safe?
   
   ```
   diff --git a/include/nuttx/net/netdev.h b/include/nuttx/net/netdev.h
   index 23a3f2f5e5..25394f48a0 100644
   --- a/include/nuttx/net/netdev.h
   +++ b/include/nuttx/net/netdev.h
   @@ -535,6 +535,10 @@ struct net_driver_s
      struct timespec d_rxtime;
    #endif
    
   +#ifndef CONFIG_NETLINK_DISABLE_GETLINK
   +  struct work_s d_nlwork;
   +#endif
   +
      /* Application callbacks:
       *
       * Network device event handlers are retained in a 'list' and are called
   diff --git a/net/netlink/netlink_route.c b/net/netlink/netlink_route.c
   index b8f3293a84..d264496937 100644
   --- a/net/netlink/netlink_route.c
   +++ b/net/netlink/netlink_route.c
   @@ -1510,11 +1510,10 @@ ssize_t netlink_route_sendto(NETLINK_HANDLE handle,
     
****************************************************************************/
    
    #ifndef CONFIG_NETLINK_DISABLE_GETLINK
   -void netlink_device_notify(FAR struct net_driver_s *dev)
   +static void netlink_device_notify_internal(FAR void *arg)
    {
      FAR struct netlink_response_s *resp;
   -
   -  DEBUGASSERT(dev != NULL);
   +  FAR struct net_driver_s *dev = arg;
    
      resp = netlink_get_device(dev, NULL);
      if (resp != NULL)
   @@ -1523,6 +1522,21 @@ void netlink_device_notify(FAR struct net_driver_s 
*dev)
          netlink_add_terminator(NULL, NULL, RTNLGRP_LINK);
        }
    }
   +
   +void netlink_device_notify(FAR struct net_driver_s *dev)
   +{
   +  DEBUGASSERT(dev != NULL);
   +
   +  if (up_interrupt_context())
   +    {
   +      work_queue(LPWORK, &dev->d_nlwork,
   +                 netlink_device_notify_internal, dev, 0);
   +    }
   +  else
   +    {
   +      netlink_device_notify_internal(dev);
   +    }
   +}
    #endif
    
    
/****************************************************************************
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to