]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
virtio_balloon: use LE config space accesses
authorMichael S. Tsirkin <mst@redhat.com>
Tue, 4 Aug 2020 21:51:35 +0000 (17:51 -0400)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 5 Aug 2020 15:08:41 +0000 (11:08 -0400)
Balloon is LE, it's cleaner to access it as such directly.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/virtio/virtio_balloon.c

index 8bc1704ffdf3beb354110a150a695b7af9be565f..31cc97f2f515e5b5016b220bd246ddc40277517c 100644 (file)
@@ -398,12 +398,9 @@ static inline s64 towards_target(struct virtio_balloon *vb)
        s64 target;
        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. */
-       if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1))
-               num_pages = le32_to_cpu((__force __le32)num_pages);
+       virtio_cread_le(vb->vdev, struct virtio_balloon_config, num_pages,
+                       &num_pages);
 
        target = num_pages;
        return target - vb->num_pages;
@@ -462,11 +459,8 @@ static void update_balloon_size(struct virtio_balloon *vb)
        u32 actual = vb->num_pages;
 
        /* Legacy balloon config space is LE, unlike all other devices. */
-       if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1))
-               actual = (__force u32)cpu_to_le32(actual);
-
-       virtio_cwrite(vb->vdev, struct virtio_balloon_config, actual,
-                     &actual);
+       virtio_cwrite_le(vb->vdev, struct virtio_balloon_config, actual,
+                        &actual);
 }
 
 static void update_balloon_stats_func(struct work_struct *work)
@@ -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,
                               &vb->config_read_bitmap)) {
-               virtio_cread(vb->vdev, struct virtio_balloon_config,
-                            free_page_hint_cmd_id,
-                            &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);
+               virtio_cread_le(vb->vdev, struct virtio_balloon_config,
+                               free_page_hint_cmd_id,
+                               &vb->cmd_id_received_cache);
        }
 
        return vb->cmd_id_received_cache;
@@ -987,8 +979,8 @@ static int virtballoon_probe(struct virtio_device *vdev)
                if (!want_init_on_free())
                        memset(&poison_val, PAGE_POISON, sizeof(poison_val));
 
-               virtio_cwrite(vb->vdev, struct virtio_balloon_config,
-                             poison_val, &poison_val);
+               virtio_cwrite_le(vb->vdev, struct virtio_balloon_config,
+                                poison_val, &poison_val);
        }
 
        vb->pr_dev_info.report = virtballoon_free_page_report;