From patchwork Thu Mar 18 09:42:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 48016 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CBE34B7D0A for ; Thu, 18 Mar 2010 21:01:44 +1100 (EST) Received: from localhost ([127.0.0.1]:59580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsCUY-0004bp-BQ for incoming@patchwork.ozlabs.org; Thu, 18 Mar 2010 05:58:14 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NsCIv-0005Wu-96 for qemu-devel@nongnu.org; Thu, 18 Mar 2010 05:46:13 -0400 Received: from [199.232.76.173] (port=59695 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsCIu-0005WO-DW for qemu-devel@nongnu.org; Thu, 18 Mar 2010 05:46:12 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NsCIt-000371-6l for qemu-devel@nongnu.org; Thu, 18 Mar 2010 05:46:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6145) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NsCIs-00036r-N5 for qemu-devel@nongnu.org; Thu, 18 Mar 2010 05:46:11 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2I9k9Ne021694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Mar 2010 05:46:09 -0400 Received: from redhat.com (vpn1-6-158.ams2.redhat.com [10.36.6.158]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o2I9k7po020150; Thu, 18 Mar 2010 05:46:08 -0400 Date: Thu, 18 Mar 2010 11:42:45 +0200 From: "Michael S. Tsirkin" To: quintela@redhat.com, qemu-devel@nongnu.org Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCHv2 3/5] virtio-serial: remove struct layout assumptions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 cf6f979..cba60f1 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)); }