Use vars of the correct type instead of casting.

Signed-off-by: Michael S. Tsirkin <m...@redhat.com>
---
 include/linux/virtio_config.h | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index c68f58f3bf34..5c3b02245ecd 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -444,53 +444,60 @@ static inline void virtio_cwrite8(struct virtio_device 
*vdev,
 static inline u16 virtio_cread16(struct virtio_device *vdev,
                                 unsigned int offset)
 {
-       u16 ret;
+       __virtio16 ret;
 
        might_sleep();
        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,
                                   unsigned int offset, u16 val)
 {
+       __virtio16 v;
+
        might_sleep();
-       val = (__force u16)cpu_to_virtio16(vdev, val);
-       vdev->config->set(vdev, offset, &val, sizeof(val));
+       v = cpu_to_virtio16(vdev, val);
+       vdev->config->set(vdev, offset, &v, sizeof(v));
 }
 
 static inline u32 virtio_cread32(struct virtio_device *vdev,
                                 unsigned int offset)
 {
-       u32 ret;
+       __virtio32 ret;
 
        might_sleep();
        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,
                                   unsigned int offset, u32 val)
 {
+       __virtio32 v;
+
        might_sleep();
-       val = (__force u32)cpu_to_virtio32(vdev, val);
-       vdev->config->set(vdev, offset, &val, sizeof(val));
+       v = cpu_to_virtio32(vdev, val);
+       vdev->config->set(vdev, offset, &v, sizeof(v));
 }
 
 static inline u64 virtio_cread64(struct virtio_device *vdev,
                                 unsigned int offset)
 {
-       u64 ret;
+       __virtio64 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,
                                   unsigned int offset, u64 val)
 {
+       __virtio64 v;
+
        might_sleep();
-       val = (__force u64)cpu_to_virtio64(vdev, val);
-       vdev->config->set(vdev, offset, &val, sizeof(val));
+       v = cpu_to_virtio64(vdev, val);
+       vdev->config->set(vdev, offset, &v, sizeof(v));
 }
 
 /* Conditional config space accessors. */
-- 
MST

Reply via email to