qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 3/5] virtio-serial: remove struct layout assumptions


From: Michael S. Tsirkin
Subject: [Qemu-devel] [PATCH 3/5] virtio-serial: remove struct layout assumptions
Date: Thu, 18 Mar 2010 09:21:44 +0200
User-agent: Mutt/1.5.19 (2009-01-05)

Use container_of and remove assumption that vdev
is 1st member of structure.

Signed-off-by: Michael S. Tsirkin <address@hidden>
---
 hw/virtio-serial-bus.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 72425f3..6da6449 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -282,7 +282,7 @@ static void control_out(VirtIODevice *vdev, VirtQueue *vq)
     VirtQueueElement elem;
     VirtIOSerial *vser;
 
-    vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+    vser = container_of(vdev, VirtIOSerial, vdev);
 
     while (virtqueue_pop(vq, &elem)) {
         handle_control_message(vser, elem.out_sg[0].iov_base);
@@ -297,7 +297,7 @@ static void handle_output(VirtIODevice *vdev, VirtQueue *vq)
     VirtIOSerial *vser;
     VirtQueueElement elem;
 
-    vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+    vser = container_of(vdev, VirtIOSerial, vdev);
 
     while (virtqueue_pop(vq, &elem)) {
         VirtIOSerialPort *port;
@@ -335,7 +335,7 @@ static void handle_input(VirtIODevice *vdev, VirtQueue *vq)
 
 static uint32_t get_features(VirtIODevice *vdev, uint32_t features)
 {
-    VirtIOSerial *vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+    VirtIOSerial *vser = container_of(vdev, VirtIOSerial, vdev);
     if (vser->bus->max_nr_ports > 1) {
         features |= (1 << VIRTIO_CONSOLE_F_MULTIPORT);
     }
@@ -347,7 +347,7 @@ static void get_config(VirtIODevice *vdev, uint8_t 
*config_data)
 {
     VirtIOSerial *vser;
 
-    vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+    vser = container_of(vdev, VirtIOSerial, vdev);
     memcpy(config_data, &vser->config, sizeof(struct virtio_console_config));
 }
 
-- 
1.7.0.2.280.gc6f05





reply via email to

[Prev in Thread] Current Thread [Next in Thread]