aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/virtio_config.h
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-10-22 09:59:01 -0400
committerMichael S. Tsirkin <mst@redhat.com>2014-12-09 05:05:25 -0500
commit92e6d7438ee631aac85258ee3d4de8c860d8c32f (patch)
treebdec7feb1fcb7fd3bbfa563b4686f1b61a655f94 /include/linux/virtio_config.h
parent00e6f3d9d9e356dbf08369ffc4576f79438d51ea (diff)
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>
Diffstat (limited to 'include/linux/virtio_config.h')
-rw-r--r--include/linux/virtio_config.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 02f0acb549d6..1fa5faa26440 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -318,12 +318,13 @@ static inline u16 virtio_cread16(struct virtio_device *vdev,
318{ 318{
319 u16 ret; 319 u16 ret;
320 vdev->config->get(vdev, offset, &ret, sizeof(ret)); 320 vdev->config->get(vdev, offset, &ret, sizeof(ret));
321 return ret; 321 return virtio16_to_cpu(vdev, (__force __virtio16)ret);
322} 322}
323 323
324static inline void virtio_cwrite16(struct virtio_device *vdev, 324static inline void virtio_cwrite16(struct virtio_device *vdev,
325 unsigned int offset, u16 val) 325 unsigned int offset, u16 val)
326{ 326{
327 val = (__force u16)cpu_to_virtio16(vdev, val);
327 vdev->config->set(vdev, offset, &val, sizeof(val)); 328 vdev->config->set(vdev, offset, &val, sizeof(val));
328} 329}
329 330
@@ -332,12 +333,13 @@ static inline u32 virtio_cread32(struct virtio_device *vdev,
332{ 333{
333 u32 ret; 334 u32 ret;
334 vdev->config->get(vdev, offset, &ret, sizeof(ret)); 335 vdev->config->get(vdev, offset, &ret, sizeof(ret));
335 return ret; 336 return virtio32_to_cpu(vdev, (__force __virtio32)ret);
336} 337}
337 338
338static inline void virtio_cwrite32(struct virtio_device *vdev, 339static inline void virtio_cwrite32(struct virtio_device *vdev,
339 unsigned int offset, u32 val) 340 unsigned int offset, u32 val)
340{ 341{
342 val = (__force u32)cpu_to_virtio32(vdev, val);
341 vdev->config->set(vdev, offset, &val, sizeof(val)); 343 vdev->config->set(vdev, offset, &val, sizeof(val));
342} 344}
343 345
@@ -346,12 +348,13 @@ static inline u64 virtio_cread64(struct virtio_device *vdev,
346{ 348{
347 u64 ret; 349 u64 ret;
348 vdev->config->get(vdev, offset, &ret, sizeof(ret)); 350 vdev->config->get(vdev, offset, &ret, sizeof(ret));
349 return ret; 351 return virtio64_to_cpu(vdev, (__force __virtio64)ret);
350} 352}
351 353
352static inline void virtio_cwrite64(struct virtio_device *vdev, 354static inline void virtio_cwrite64(struct virtio_device *vdev,
353 unsigned int offset, u64 val) 355 unsigned int offset, u64 val)
354{ 356{
357 val = (__force u64)cpu_to_virtio64(vdev, val);
355 vdev->config->set(vdev, offset, &val, sizeof(val)); 358 vdev->config->set(vdev, offset, &val, sizeof(val));
356} 359}
357 360