Commit 805769d7 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin

virtio_balloon: use LE config space accesses

Balloon is LE, it's cleaner to access it as such directly.
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 035ce421
...@@ -398,12 +398,9 @@ static inline s64 towards_target(struct virtio_balloon *vb) ...@@ -398,12 +398,9 @@ static inline s64 towards_target(struct virtio_balloon *vb)
s64 target; s64 target;
u32 num_pages; u32 num_pages;
virtio_cread(vb->vdev, struct virtio_balloon_config, num_pages,
&num_pages);
/* Legacy balloon config space is LE, unlike all other devices. */ /* Legacy balloon config space is LE, unlike all other devices. */
if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1)) virtio_cread_le(vb->vdev, struct virtio_balloon_config, num_pages,
num_pages = le32_to_cpu((__force __le32)num_pages); &num_pages);
target = num_pages; target = num_pages;
return target - vb->num_pages; return target - vb->num_pages;
...@@ -462,10 +459,7 @@ static void update_balloon_size(struct virtio_balloon *vb) ...@@ -462,10 +459,7 @@ static void update_balloon_size(struct virtio_balloon *vb)
u32 actual = vb->num_pages; u32 actual = vb->num_pages;
/* Legacy balloon config space is LE, unlike all other devices. */ /* Legacy balloon config space is LE, unlike all other devices. */
if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1)) virtio_cwrite_le(vb->vdev, struct virtio_balloon_config, actual,
actual = (__force u32)cpu_to_le32(actual);
virtio_cwrite(vb->vdev, struct virtio_balloon_config, actual,
&actual); &actual);
} }
...@@ -579,12 +573,10 @@ static u32 virtio_balloon_cmd_id_received(struct virtio_balloon *vb) ...@@ -579,12 +573,10 @@ static u32 virtio_balloon_cmd_id_received(struct virtio_balloon *vb)
{ {
if (test_and_clear_bit(VIRTIO_BALLOON_CONFIG_READ_CMD_ID, if (test_and_clear_bit(VIRTIO_BALLOON_CONFIG_READ_CMD_ID,
&vb->config_read_bitmap)) { &vb->config_read_bitmap)) {
virtio_cread(vb->vdev, struct virtio_balloon_config, /* Legacy balloon config space is LE, unlike all other devices. */
virtio_cread_le(vb->vdev, struct virtio_balloon_config,
free_page_hint_cmd_id, free_page_hint_cmd_id,
&vb->cmd_id_received_cache); &vb->cmd_id_received_cache);
/* Legacy balloon config space is LE, unlike all other devices. */
if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1))
vb->cmd_id_received_cache = le32_to_cpu((__force __le32)vb->cmd_id_received_cache);
} }
return vb->cmd_id_received_cache; return vb->cmd_id_received_cache;
...@@ -987,7 +979,7 @@ static int virtballoon_probe(struct virtio_device *vdev) ...@@ -987,7 +979,7 @@ static int virtballoon_probe(struct virtio_device *vdev)
if (!want_init_on_free()) if (!want_init_on_free())
memset(&poison_val, PAGE_POISON, sizeof(poison_val)); memset(&poison_val, PAGE_POISON, sizeof(poison_val));
virtio_cwrite(vb->vdev, struct virtio_balloon_config, virtio_cwrite_le(vb->vdev, struct virtio_balloon_config,
poison_val, &poison_val); poison_val, &poison_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