Commit 92e6d743 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin

virtio_config: endian conversion for v1.0

We (ab)use virtio conversion functions for device-specific
config space accesses.

Based on original patches by Cornelia and Rusty.
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: default avatarDavid Hildenbrand <dahi@linux.vnet.com>


parent 00e6f3d9
...@@ -318,12 +318,13 @@ static inline u16 virtio_cread16(struct virtio_device *vdev, ...@@ -318,12 +318,13 @@ static inline u16 virtio_cread16(struct virtio_device *vdev,
{ {
u16 ret; u16 ret;
vdev->config->get(vdev, offset, &ret, sizeof(ret)); vdev->config->get(vdev, offset, &ret, sizeof(ret));
return ret; return virtio16_to_cpu(vdev, (__force __virtio16)ret);
} }
static inline void virtio_cwrite16(struct virtio_device *vdev, static inline void virtio_cwrite16(struct virtio_device *vdev,
unsigned int offset, u16 val) unsigned int offset, u16 val)
{ {
val = (__force u16)cpu_to_virtio16(vdev, val);
vdev->config->set(vdev, offset, &val, sizeof(val)); vdev->config->set(vdev, offset, &val, sizeof(val));
} }
...@@ -332,12 +333,13 @@ static inline u32 virtio_cread32(struct virtio_device *vdev, ...@@ -332,12 +333,13 @@ static inline u32 virtio_cread32(struct virtio_device *vdev,
{ {
u32 ret; u32 ret;
vdev->config->get(vdev, offset, &ret, sizeof(ret)); vdev->config->get(vdev, offset, &ret, sizeof(ret));
return ret; return virtio32_to_cpu(vdev, (__force __virtio32)ret);
} }
static inline void virtio_cwrite32(struct virtio_device *vdev, static inline void virtio_cwrite32(struct virtio_device *vdev,
unsigned int offset, u32 val) unsigned int offset, u32 val)
{ {
val = (__force u32)cpu_to_virtio32(vdev, val);
vdev->config->set(vdev, offset, &val, sizeof(val)); vdev->config->set(vdev, offset, &val, sizeof(val));
} }
...@@ -346,12 +348,13 @@ static inline u64 virtio_cread64(struct virtio_device *vdev, ...@@ -346,12 +348,13 @@ static inline u64 virtio_cread64(struct virtio_device *vdev,
{ {
u64 ret; u64 ret;
vdev->config->get(vdev, offset, &ret, sizeof(ret)); vdev->config->get(vdev, offset, &ret, sizeof(ret));
return ret; return virtio64_to_cpu(vdev, (__force __virtio64)ret);
} }
static inline void virtio_cwrite64(struct virtio_device *vdev, static inline void virtio_cwrite64(struct virtio_device *vdev,
unsigned int offset, u64 val) unsigned int offset, u64 val)
{ {
val = (__force u64)cpu_to_virtio64(vdev, val);
vdev->config->set(vdev, offset, &val, sizeof(val)); vdev->config->set(vdev, offset, &val, sizeof(val));
} }
......
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