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 f0a3ae8d18d599b62327de3c027d95bcb85ec96d
Author: wangjinjing1 <[email protected]>
AuthorDate: Mon Nov 9 16:10:53 2026 +0800

    drivers/vhost/vhost-can: use the CAN features negotiated at probe
    
    The TX path reads the negotiated features from the shared resource table
    for every frame. vhost_get_features() at probe already refreshes
    hdev->features with the negotiated set, so check that cached set
    instead.
    
    Signed-off-by: wangjinjing1 <[email protected]>
---
 drivers/vhost/vhost-can.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/vhost/vhost-can.c b/drivers/vhost/vhost-can.c
index 9093f61b9f3..4e8a7adee1a 100644
--- a/drivers/vhost/vhost-can.c
+++ b/drivers/vhost/vhost-can.c
@@ -219,7 +219,6 @@ static size_t vhost_can_wire2frame(FAR struct 
vhost_can_priv_s *priv,
                                    FAR void **frame)
 {
   FAR struct canfd_frame *cfd;
-  uint64_t features;
   uint32_t flags;
   uint32_t canid;
   uint16_t len;
@@ -247,29 +246,20 @@ static size_t vhost_can_wire2frame(FAR struct 
vhost_can_priv_s *priv,
   canid = le32toh(out->can_id);
   len   = le16toh(out->length);
 
-  /* The negotiated set lives in the shared resource table; the cached
-   * vdev->features field is not maintained for the device role.
-   */
-
-  if (vhost_get_features(priv->hdev, &features) < 0)
-    {
-      return 0;
-    }
-
   /* Reject a frame type that was not negotiated, and an out of range
    * can_id or sdu length.  The spec forbids scheduling any of these.
+   * hdev->features holds the negotiated set, refreshed at probe.
    */
 
-  if ((features & (1ULL << ((flags & VIRTIO_CAN_FLAGS_FD) != 0 ?
-                            VIRTIO_CAN_F_CAN_FD :
-                            VIRTIO_CAN_F_CAN_CLASSIC))) == 0)
+  if (!vhost_has_feature(priv->hdev, (flags & VIRTIO_CAN_FLAGS_FD) != 0 ?
+                         VIRTIO_CAN_F_CAN_FD : VIRTIO_CAN_F_CAN_CLASSIC))
     {
       return 0;
     }
 
   if ((flags & VIRTIO_CAN_FLAGS_RTR) != 0 &&
       ((flags & VIRTIO_CAN_FLAGS_FD) != 0 ||
-       (features & (1ULL << VIRTIO_CAN_F_RTR_FRAMES)) == 0))
+       !vhost_has_feature(priv->hdev, VIRTIO_CAN_F_RTR_FRAMES)))
     {
       return 0;
     }

Reply via email to