diff options
author | Cornelia Huck <cornelia.huck@de.ibm.com> | 2014-12-11 14:25:05 +0100 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2015-02-26 13:04:07 +0100 |
commit | 0cd09c3a6cc2230ba38c462fc410b4acce59eb6f (patch) | |
tree | 34ac356869acdd46eb089d491b3ee4b2240dac88 /include/hw/virtio | |
parent | a590fd5ba8f01724eee169f097f65603f0c3a8f8 (diff) |
virtio: feature bit manipulation helpers
Add virtio_{add,clear}_feature helper functions for manipulating a
feature bits variable. This has some benefits over open coding:
- add check that the bit is in a sane range
- make it obvious at a glance what is going on
- have a central point to change when we want to extend feature bits
Convert existing code manipulating features to use the new helpers.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'include/hw/virtio')
-rw-r--r-- | include/hw/virtio/virtio.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index d1b416b7ce..85e72d6fd9 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -219,6 +219,18 @@ void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign, void virtio_queue_notify_vq(VirtQueue *vq); void virtio_irq(VirtQueue *vq); +static inline void virtio_add_feature(uint32_t *features, unsigned int fbit) +{ + assert(fbit < 32); + *features |= (1 << fbit); +} + +static inline void virtio_clear_feature(uint32_t *features, unsigned int fbit) +{ + assert(fbit < 32); + *features &= ~(1 << fbit); +} + static inline bool virtio_is_big_endian(VirtIODevice *vdev) { assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN); |