From patchwork Thu Mar 18 07:21:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3/5] virtio-serial: remove struct layout assumptions Date: Wed, 17 Mar 2010 21:21:44 -0000 From: "Michael S. Tsirkin" X-Patchwork-Id: 48007 Message-Id: <8f6fb0d006890db91a7961363d770ca3103324cb.1268896694.git.mst@redhat.com> To: quintela@redhat.com, qemu-devel@nongnu.org Cc: Use container_of and remove assumption that vdev is 1st member of structure. Signed-off-by: Michael S. Tsirkin --- 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)); }