Commit cacaf775 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin

virtio_config: cread/write cleanup

Use vars of the correct type instead of casting.
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 5d7d0f38
...@@ -444,53 +444,60 @@ static inline void virtio_cwrite8(struct virtio_device *vdev, ...@@ -444,53 +444,60 @@ static inline void virtio_cwrite8(struct virtio_device *vdev,
static inline u16 virtio_cread16(struct virtio_device *vdev, static inline u16 virtio_cread16(struct virtio_device *vdev,
unsigned int offset) unsigned int offset)
{ {
u16 ret; __virtio16 ret;
might_sleep(); might_sleep();
vdev->config->get(vdev, offset, &ret, sizeof(ret)); vdev->config->get(vdev, offset, &ret, sizeof(ret));
return virtio16_to_cpu(vdev, (__force __virtio16)ret); return virtio16_to_cpu(vdev, 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)
{ {
__virtio16 v;
might_sleep(); might_sleep();
val = (__force u16)cpu_to_virtio16(vdev, val); v = cpu_to_virtio16(vdev, val);
vdev->config->set(vdev, offset, &val, sizeof(val)); vdev->config->set(vdev, offset, &v, sizeof(v));
} }
static inline u32 virtio_cread32(struct virtio_device *vdev, static inline u32 virtio_cread32(struct virtio_device *vdev,
unsigned int offset) unsigned int offset)
{ {
u32 ret; __virtio32 ret;
might_sleep(); might_sleep();
vdev->config->get(vdev, offset, &ret, sizeof(ret)); vdev->config->get(vdev, offset, &ret, sizeof(ret));
return virtio32_to_cpu(vdev, (__force __virtio32)ret); return virtio32_to_cpu(vdev, 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)
{ {
__virtio32 v;
might_sleep(); might_sleep();
val = (__force u32)cpu_to_virtio32(vdev, val); v = cpu_to_virtio32(vdev, val);
vdev->config->set(vdev, offset, &val, sizeof(val)); vdev->config->set(vdev, offset, &v, sizeof(v));
} }
static inline u64 virtio_cread64(struct virtio_device *vdev, static inline u64 virtio_cread64(struct virtio_device *vdev,
unsigned int offset) unsigned int offset)
{ {
u64 ret; __virtio64 ret;
__virtio_cread_many(vdev, offset, &ret, 1, sizeof(ret)); __virtio_cread_many(vdev, offset, &ret, 1, sizeof(ret));
return virtio64_to_cpu(vdev, (__force __virtio64)ret); return virtio64_to_cpu(vdev, 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)
{ {
__virtio64 v;
might_sleep(); might_sleep();
val = (__force u64)cpu_to_virtio64(vdev, val); v = cpu_to_virtio64(vdev, val);
vdev->config->set(vdev, offset, &val, sizeof(val)); vdev->config->set(vdev, offset, &v, sizeof(v));
} }
/* Conditional config space accessors. */ /* Conditional config space accessors. */
......
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