diff mbox

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

Message ID 8f6fb0d006890db91a7961363d770ca3103324cb.1268896694.git.mst@redhat.com
State New
Headers show

Commit Message

Michael S. Tsirkin March 18, 2010, 7:21 a.m. UTC
Use container_of and remove assumption that vdev
is 1st member of structure.

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

Patch

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));
 }