mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-28 20:37:27 +00:00
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: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.com>
This commit is contained in:
parent
00e6f3d9d9
commit
92e6d7438e
@ -318,12 +318,13 @@ static inline u16 virtio_cread16(struct virtio_device *vdev,
|
||||
{
|
||||
u16 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,
|
||||
unsigned int offset, u16 val)
|
||||
{
|
||||
val = (__force u16)cpu_to_virtio16(vdev, val);
|
||||
vdev->config->set(vdev, offset, &val, sizeof(val));
|
||||
}
|
||||
|
||||
@ -332,12 +333,13 @@ static inline u32 virtio_cread32(struct virtio_device *vdev,
|
||||
{
|
||||
u32 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,
|
||||
unsigned int offset, u32 val)
|
||||
{
|
||||
val = (__force u32)cpu_to_virtio32(vdev, val);
|
||||
vdev->config->set(vdev, offset, &val, sizeof(val));
|
||||
}
|
||||
|
||||
@ -346,12 +348,13 @@ static inline u64 virtio_cread64(struct virtio_device *vdev,
|
||||
{
|
||||
u64 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,
|
||||
unsigned int offset, u64 val)
|
||||
{
|
||||
val = (__force u64)cpu_to_virtio64(vdev, val);
|
||||
vdev->config->set(vdev, offset, &val, sizeof(val));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user