[PATCH 2/3] hw/virtio: rename virtio_is_big_endian to virtio_vdev_is_big_endian

Pierrick Bouvier posted 3 patches 1 month, 4 weeks ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowang@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>
There is a newer version of this series
[PATCH 2/3] hw/virtio: rename virtio_is_big_endian to virtio_vdev_is_big_endian
Posted by Pierrick Bouvier 1 month, 4 weeks ago
Renaming this function removes the confusion with
existing virtio_is_big_endian cpu ops.

Indeed, virtio_vdev_is_big_endian is *not* calling cpu
virtio_is_big_endian everytime.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 include/hw/virtio/virtio-access.h | 2 +-
 include/hw/virtio/virtio.h        | 2 +-
 hw/net/virtio-net.c               | 4 ++--
 hw/virtio/vhost.c                 | 4 ++--
 hw/virtio/virtio-pci.c            | 8 ++++----
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h
index 324ba907e93..0c5514178e4 100644
--- a/include/hw/virtio/virtio-access.h
+++ b/include/hw/virtio/virtio-access.h
@@ -28,7 +28,7 @@
 static inline bool virtio_access_is_big_endian(VirtIODevice *vdev)
 {
 #if defined(LEGACY_VIRTIO_IS_BIENDIAN)
-    return virtio_is_big_endian(vdev);
+    return virtio_vdev_is_big_endian(vdev);
 #elif TARGET_BIG_ENDIAN
     if (virtio_vdev_is_modern(vdev)) {
         return false;
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 8f1e4323599..ed1a0967ed8 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -478,7 +478,7 @@ static inline bool virtio_vdev_is_legacy(const VirtIODevice *vdev)
     return !virtio_vdev_is_modern(vdev);
 }
 
-static inline bool virtio_is_big_endian(VirtIODevice *vdev)
+static inline bool virtio_vdev_is_big_endian(VirtIODevice *vdev)
 {
     if (virtio_vdev_is_legacy(vdev)) {
         assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN);
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 313d3b88400..ec85e5a949a 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -301,7 +301,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
         if (n->needs_vnet_hdr_swap) {
             error_report("backend does not support %s vnet headers; "
                          "falling back on userspace virtio",
-                         virtio_is_big_endian(vdev) ? "BE" : "LE");
+                         virtio_vdev_is_big_endian(vdev) ? "BE" : "LE");
             return;
         }
 
@@ -343,7 +343,7 @@ static int virtio_net_set_vnet_endian_one(VirtIODevice *vdev,
                                           NetClientState *peer,
                                           bool enable)
 {
-    if (virtio_is_big_endian(vdev)) {
+    if (virtio_vdev_is_big_endian(vdev)) {
         return qemu_set_vnet_be(peer, enable);
     } else {
         return qemu_set_vnet_le(peer, enable);
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 70a112242b0..1f5e70ad197 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1306,7 +1306,7 @@ int vhost_virtqueue_start(struct vhost_dev *dev,
 
     if (vhost_needs_vring_endian(vdev)) {
         r = vhost_virtqueue_set_vring_endian_legacy(dev,
-                                                    virtio_is_big_endian(vdev),
+                                                    virtio_vdev_is_big_endian(vdev),
                                                     vhost_vq_index);
         if (r) {
             return r;
@@ -1423,7 +1423,7 @@ static int do_vhost_virtqueue_stop(struct vhost_dev *dev,
      */
     if (vhost_needs_vring_endian(vdev)) {
         vhost_virtqueue_set_vring_endian_legacy(dev,
-                                                !virtio_is_big_endian(vdev),
+                                                !virtio_vdev_is_big_endian(vdev),
                                                 vhost_vq_index);
     }
 
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 6126187a164..33c5cec01cd 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -586,13 +586,13 @@ static uint64_t virtio_pci_config_read(void *opaque, hwaddr addr,
         break;
     case 2:
         val = virtio_config_readw(vdev, addr);
-        if (virtio_is_big_endian(vdev)) {
+        if (virtio_vdev_is_big_endian(vdev)) {
             val = bswap16(val);
         }
         break;
     case 4:
         val = virtio_config_readl(vdev, addr);
-        if (virtio_is_big_endian(vdev)) {
+        if (virtio_vdev_is_big_endian(vdev)) {
             val = bswap32(val);
         }
         break;
@@ -625,13 +625,13 @@ static void virtio_pci_config_write(void *opaque, hwaddr addr,
         virtio_config_writeb(vdev, addr, val);
         break;
     case 2:
-        if (virtio_is_big_endian(vdev)) {
+        if (virtio_vdev_is_big_endian(vdev)) {
             val = bswap16(val);
         }
         virtio_config_writew(vdev, addr, val);
         break;
     case 4:
-        if (virtio_is_big_endian(vdev)) {
+        if (virtio_vdev_is_big_endian(vdev)) {
             val = bswap32(val);
         }
         virtio_config_writel(vdev, addr, val);
-- 
2.47.3
Re: [PATCH 2/3] hw/virtio: rename virtio_is_big_endian to virtio_vdev_is_big_endian
Posted by Philippe Mathieu-Daudé 1 month, 3 weeks ago
On 13/2/26 00:46, Pierrick Bouvier wrote:
> Renaming this function removes the confusion with
> existing virtio_is_big_endian cpu ops.
> 
> Indeed, virtio_vdev_is_big_endian is *not* calling cpu
> virtio_is_big_endian everytime.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   include/hw/virtio/virtio-access.h | 2 +-
>   include/hw/virtio/virtio.h        | 2 +-
>   hw/net/virtio-net.c               | 4 ++--
>   hw/virtio/vhost.c                 | 4 ++--
>   hw/virtio/virtio-pci.c            | 8 ++++----
>   5 files changed, 10 insertions(+), 10 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>