OceanfromXiaomi commented on code in PR #17694:
URL: https://github.com/apache/nuttx/pull/17694#discussion_r2659297555
##########
drivers/can/can.c:
##########
@@ -595,6 +595,25 @@ static int can_xmit(FAR struct can_dev_s *dev)
}
}
+#ifdef CONFIG_CAN_TXCANCEL
+ if (TX_PENDING(&dev->cd_sender) && can_txneed_cancel(&dev->cd_sender))
Review Comment:
This change does not introduce excessive linked-list operations or
unnecessary abort operations.
The reasons are as follows:
The prerequisite of this PR is the following loop:
`while (TX_PENDING(&dev->cd_sender) && dev_txready(dev))`
When this loop finishes, it means that either the hardware transmit buffer
is full, there are no more frames in the pending list, or an error occurred
during dev_send.
After that, the cancel condition is evaluated:
`if (TX_PENDING(&dev->cd_sender) && can_txneed_cancel(&dev->cd_sender))`
Only when there are still pending frames in the pending list and the
can_txneed_cancel condition is satisfied will the cancel logic be executed.
Therefore, the cancel mechanism is triggered only when necessary, avoiding
excessive list operations and unnecessary abort actions.
--
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]