diff options
author | Greg Kurz <gkurz@linux.vnet.ibm.com> | 2015-04-24 08:25:12 -0400 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2015-06-01 09:48:53 -0400 |
commit | ab27c07f607253f928cbc8c64d9c0d273df09e6b (patch) | |
tree | b492b4906e6f86b2277d75f41277c78c282d1d71 /drivers/vhost/vhost.h | |
parent | 5da7b160b36a42f161980c5e20d3960d6d076fb8 (diff) |
vhost: introduce vhost_is_little_endian() helper
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'drivers/vhost/vhost.h')
-rw-r--r-- | drivers/vhost/vhost.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 8c1c792900ba..6a499603d856 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h | |||
@@ -173,34 +173,39 @@ static inline bool vhost_has_feature(struct vhost_virtqueue *vq, int bit) | |||
173 | return vq->acked_features & (1ULL << bit); | 173 | return vq->acked_features & (1ULL << bit); |
174 | } | 174 | } |
175 | 175 | ||
176 | static inline bool vhost_is_little_endian(struct vhost_virtqueue *vq) | ||
177 | { | ||
178 | return vhost_has_feature(vq, VIRTIO_F_VERSION_1); | ||
179 | } | ||
180 | |||
176 | /* Memory accessors */ | 181 | /* Memory accessors */ |
177 | static inline u16 vhost16_to_cpu(struct vhost_virtqueue *vq, __virtio16 val) | 182 | static inline u16 vhost16_to_cpu(struct vhost_virtqueue *vq, __virtio16 val) |
178 | { | 183 | { |
179 | return __virtio16_to_cpu(vhost_has_feature(vq, VIRTIO_F_VERSION_1), val); | 184 | return __virtio16_to_cpu(vhost_is_little_endian(vq), val); |
180 | } | 185 | } |
181 | 186 | ||
182 | static inline __virtio16 cpu_to_vhost16(struct vhost_virtqueue *vq, u16 val) | 187 | static inline __virtio16 cpu_to_vhost16(struct vhost_virtqueue *vq, u16 val) |
183 | { | 188 | { |
184 | return __cpu_to_virtio16(vhost_has_feature(vq, VIRTIO_F_VERSION_1), val); | 189 | return __cpu_to_virtio16(vhost_is_little_endian(vq), val); |
185 | } | 190 | } |
186 | 191 | ||
187 | static inline u32 vhost32_to_cpu(struct vhost_virtqueue *vq, __virtio32 val) | 192 | static inline u32 vhost32_to_cpu(struct vhost_virtqueue *vq, __virtio32 val) |
188 | { | 193 | { |
189 | return __virtio32_to_cpu(vhost_has_feature(vq, VIRTIO_F_VERSION_1), val); | 194 | return __virtio32_to_cpu(vhost_is_little_endian(vq), val); |
190 | } | 195 | } |
191 | 196 | ||
192 | static inline __virtio32 cpu_to_vhost32(struct vhost_virtqueue *vq, u32 val) | 197 | static inline __virtio32 cpu_to_vhost32(struct vhost_virtqueue *vq, u32 val) |
193 | { | 198 | { |
194 | return __cpu_to_virtio32(vhost_has_feature(vq, VIRTIO_F_VERSION_1), val); | 199 | return __cpu_to_virtio32(vhost_is_little_endian(vq), val); |
195 | } | 200 | } |
196 | 201 | ||
197 | static inline u64 vhost64_to_cpu(struct vhost_virtqueue *vq, __virtio64 val) | 202 | static inline u64 vhost64_to_cpu(struct vhost_virtqueue *vq, __virtio64 val) |
198 | { | 203 | { |
199 | return __virtio64_to_cpu(vhost_has_feature(vq, VIRTIO_F_VERSION_1), val); | 204 | return __virtio64_to_cpu(vhost_is_little_endian(vq), val); |
200 | } | 205 | } |
201 | 206 | ||
202 | static inline __virtio64 cpu_to_vhost64(struct vhost_virtqueue *vq, u64 val) | 207 | static inline __virtio64 cpu_to_vhost64(struct vhost_virtqueue *vq, u64 val) |
203 | { | 208 | { |
204 | return __cpu_to_virtio64(vhost_has_feature(vq, VIRTIO_F_VERSION_1), val); | 209 | return __cpu_to_virtio64(vhost_is_little_endian(vq), val); |
205 | } | 210 | } |
206 | #endif | 211 | #endif |