xiaoxiang781216 commented on code in PR #18759:
URL: https://github.com/apache/nuttx/pull/18759#discussion_r3130885702


##########
drivers/can/can.c:
##########
@@ -305,12 +323,15 @@ static int can_close(FAR struct file *filep)
 
   flags = enter_critical_section(); /* Disable interrupts */
 
+  priv = (FAR struct can_reader_s *)filep->f_priv;

Review Comment:
   merge to line 09 and 310



##########
drivers/can/can.c:
##########
@@ -347,16 +376,33 @@ static int can_close(FAR struct file *filep)
 
   /* Now we wait for the sender to clear */
 
-  while (!TX_EMPTY(&dev->cd_sender))
     {
-      nxsched_usleep(HALF_SECOND_USEC);
+      for (n = 0;
+           !TX_EMPTY(&dev->cd_sender) && n < CAN_CLOSE_DRAIN_LOOPS;
+           n++)
+        {
+          nxsched_usleep(HALF_SECOND_USEC);
+        }
+
+      if (!TX_EMPTY(&dev->cd_sender))
+        {
+          canerr("CAN close: SW TX queue still not empty after timeout\n");
+        }
     }
 
   /* And wait for the hardware sender to drain */
 
-  while (!dev_txempty(dev))
     {

Review Comment:
   remove {}



##########
drivers/can/can.c:
##########
@@ -347,16 +376,33 @@ static int can_close(FAR struct file *filep)
 
   /* Now we wait for the sender to clear */
 
-  while (!TX_EMPTY(&dev->cd_sender))
     {

Review Comment:
   remove {}



-- 
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