virtio_config: add virtio_cread_le_feature
authorMichael S. Tsirkin <mst@redhat.com>
Wed, 5 Aug 2020 13:17:38 +0000 (09:17 -0400)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 5 Aug 2020 15:08:41 +0000 (11:08 -0400)
Mirrors virtio_cread_feature but for LE fields.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
include/linux/virtio_config.h

index 5b5196fec8992e4701fb86d29311f13e27f2194d..cc7a2b1fd7b204560fa9734c25b5e64ecf3053fd 100644 (file)
@@ -555,4 +555,14 @@ static inline void virtio_cwrite64(struct virtio_device *vdev,
                _r;                                                     \
        })
 
+/* Conditional config space accessors. */
+#define virtio_cread_le_feature(vdev, fbit, structname, member, ptr)   \
+       ({                                                              \
+               int _r = 0;                                             \
+               if (!virtio_has_feature(vdev, fbit))                    \
+                       _r = -ENOENT;                                   \
+               else                                                    \
+                       virtio_cread_le((vdev), structname, member, ptr); \
+               _r;                                                     \
+       })
 #endif /* _LINUX_VIRTIO_CONFIG_H */