Skip to content

Commit

Permalink
virtio.h: add new api virtio_has_feature()
Browse files Browse the repository at this point in the history
virtio_has_feature() can be easily used to heck if the virtio device
support a specific feature.

Signed-off-by: Bowen Wang <[email protected]>
  • Loading branch information
CV-Bowen committed Oct 18, 2024
1 parent d0a1f3d commit 3cb3e9c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/include/openamp/virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,23 @@ static inline int virtio_reset_device(struct virtio_device *vdev)
return 0;
}

/**
* @brief Check if the virtio device support a specific feature.
*
* @param vdev Pointer to device structure.
* @param feature_bit Feature bit to check.
*
* @return true if the feature is supported, otherwise false.
*/
static inline bool virtio_has_feature(struct virtio_device *vdev,
unsigned int feature_bit)
{
if (!vdev)
return false;

return (vdev->features & (1UL << feature_bit)) != 0;
}

#if defined __cplusplus
}
#endif
Expand Down

0 comments on commit 3cb3e9c

Please sign in to comment.