Commit 5da7b160 authored by Greg Kurz's avatar Greg Kurz Committed by Michael S. Tsirkin

vringh: introduce vringh_is_little_endian() helper

Signed-off-by: default avatarGreg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Acked-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
parent 5b11e15f
...@@ -226,33 +226,38 @@ static inline void vringh_notify(struct vringh *vrh) ...@@ -226,33 +226,38 @@ static inline void vringh_notify(struct vringh *vrh)
vrh->notify(vrh); vrh->notify(vrh);
} }
static inline bool vringh_is_little_endian(const struct vringh *vrh)
{
return vrh->little_endian;
}
static inline u16 vringh16_to_cpu(const struct vringh *vrh, __virtio16 val) static inline u16 vringh16_to_cpu(const struct vringh *vrh, __virtio16 val)
{ {
return __virtio16_to_cpu(vrh->little_endian, val); return __virtio16_to_cpu(vringh_is_little_endian(vrh), val);
} }
static inline __virtio16 cpu_to_vringh16(const struct vringh *vrh, u16 val) static inline __virtio16 cpu_to_vringh16(const struct vringh *vrh, u16 val)
{ {
return __cpu_to_virtio16(vrh->little_endian, val); return __cpu_to_virtio16(vringh_is_little_endian(vrh), val);
} }
static inline u32 vringh32_to_cpu(const struct vringh *vrh, __virtio32 val) static inline u32 vringh32_to_cpu(const struct vringh *vrh, __virtio32 val)
{ {
return __virtio32_to_cpu(vrh->little_endian, val); return __virtio32_to_cpu(vringh_is_little_endian(vrh), val);
} }
static inline __virtio32 cpu_to_vringh32(const struct vringh *vrh, u32 val) static inline __virtio32 cpu_to_vringh32(const struct vringh *vrh, u32 val)
{ {
return __cpu_to_virtio32(vrh->little_endian, val); return __cpu_to_virtio32(vringh_is_little_endian(vrh), val);
} }
static inline u64 vringh64_to_cpu(const struct vringh *vrh, __virtio64 val) static inline u64 vringh64_to_cpu(const struct vringh *vrh, __virtio64 val)
{ {
return __virtio64_to_cpu(vrh->little_endian, val); return __virtio64_to_cpu(vringh_is_little_endian(vrh), val);
} }
static inline __virtio64 cpu_to_vringh64(const struct vringh *vrh, u64 val) static inline __virtio64 cpu_to_vringh64(const struct vringh *vrh, u64 val)
{ {
return __cpu_to_virtio64(vrh->little_endian, val); return __cpu_to_virtio64(vringh_is_little_endian(vrh), val);
} }
#endif /* _LINUX_VRINGH_H */ #endif /* _LINUX_VRINGH_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment