From patchwork Mon Jun 24 06:59:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 253671 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 25EAA2C0505 for ; Mon, 24 Jun 2013 17:06:14 +1000 (EST) Received: from localhost ([::1]:49164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur0qp-0007Av-Tp for incoming@patchwork.ozlabs.org; Mon, 24 Jun 2013 03:06:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur0qE-00076w-8K for qemu-devel@nongnu.org; Mon, 24 Jun 2013 03:05:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ur0qD-0007Bt-9e for qemu-devel@nongnu.org; Mon, 24 Jun 2013 03:05:34 -0400 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]:59951) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur0qD-0007Bj-3C for qemu-devel@nongnu.org; Mon, 24 Jun 2013 03:05:33 -0400 Received: by mail-pa0-f46.google.com with SMTP id fa11so10572954pad.33 for ; Mon, 24 Jun 2013 00:05:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=Lyu544LNMulV5aS/ZJZDRcOwbX8AXCYFYftY/va8mmM=; b=ZGWAPYcAdJ0orrJFJh9pWv1a5AQ9sSnKVd1xzaGbqJziGFr1GKjOzMXMarzHqcYwG5 v+ZyR4EjCtZ2/hK6O/oWA0aSoMenasDlhH3OtdDAqnkCGa1mIQRoTcX2E27wYxhmtFly 9MX6HzFYrPQ88mH6dn+0xJ3uBvXWjV6Qmmvg1EcTzbdJEvxSoqwWIKj8qgEwnjxBuqsO I9KrPMKPV+oARAKtILmdFkyJ62XTxNWd3kUqEt4mNx1Hf0FREfXTs/+bAFmdGqy+Oc4R IH0reET7Ne22TLTOR2UbCTcOQMo76jk8W42jVbkAkVtV0DldVkBNyHHQrjza2ApU3Vi+ MadA== X-Received: by 10.66.197.201 with SMTP id iw9mr25635851pac.198.1372057532399; Mon, 24 Jun 2013 00:05:32 -0700 (PDT) Received: from localhost ([203.126.243.116]) by mx.google.com with ESMTPSA id e2sm16792149pbc.23.2013.06.24.00.05.27 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Mon, 24 Jun 2013 00:05:31 -0700 (PDT) From: peter.crosthwaite@xilinx.com To: qemu-devel@nongnu.org Date: Mon, 24 Jun 2013 16:59:29 +1000 Message-Id: <754a2c1bb8f9b99e5e8866950feced91b2334fe9.1372055322.git.peter.crosthwaite@xilinx.com> X-Mailer: git-send-email 1.8.3.rc1.44.gb387c77.dirty In-Reply-To: References: X-Gm-Message-State: ALoCoQkRdUnYkJl9Vd8Bal5cWOESaLDNdJBmU/YIq5+EmFU/Vpi6IKn0L82/UPs3VaEoBI/E6obf X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::22e Cc: pbonzini@redhat.com, afaerber@suse.de, mst@redhat.com Subject: [Qemu-devel] [PATCH v2 13/30] misc/ivshmem: QOM Upcast Sweep X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Crosthwaite Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting. Signed-off-by: Peter Crosthwaite --- hw/misc/ivshmem.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 5658f73..fd40caf 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -48,6 +48,10 @@ #define IVSHMEM_DPRINTF(fmt, ...) #endif +#define TYPE_IVSHMEM "ivshmem" +#define IVSHMEM(obj) \ + OBJECT_CHECK(IVShmemState, (obj), TYPE_IVSHMEM) + typedef struct Peer { int nb_eventfds; EventNotifier *eventfds; @@ -341,7 +345,7 @@ static void create_shared_memory_BAR(IVShmemState *s, int fd) { memory_region_init_ram_ptr(&s->ivshmem, "ivshmem.bar2", s->ivshmem_size, ptr); - vmstate_register_ram(&s->ivshmem, &s->dev.qdev); + vmstate_register_ram(&s->ivshmem, DEVICE(&s->dev)); memory_region_add_subregion(&s->bar, 0, &s->ivshmem); /* region for shared memory */ @@ -469,7 +473,7 @@ static void ivshmem_read(void *opaque, const uint8_t * buf, int flags) incoming_fd, 0); memory_region_init_ram_ptr(&s->ivshmem, "ivshmem.bar2", s->ivshmem_size, map_ptr); - vmstate_register_ram(&s->ivshmem, &s->dev.qdev); + vmstate_register_ram(&s->ivshmem, DEVICE(&s->dev)); IVSHMEM_DPRINTF("guest h/w addr = %" PRIu64 ", size = %" PRIu64 "\n", s->ivshmem_offset, s->ivshmem_size); @@ -534,7 +538,7 @@ static void ivshmem_use_msix(IVShmemState * s) static void ivshmem_reset(DeviceState *d) { - IVShmemState *s = DO_UPCAST(IVShmemState, dev.qdev, d); + IVShmemState *s = IVSHMEM(d); s->intrstatus = 0; ivshmem_use_msix(s); @@ -648,7 +652,7 @@ static int pci_ivshmem_init(PCIDevice *dev) s->ivshmem_size = ivshmem_get_size(s); } - register_savevm(&s->dev.qdev, "ivshmem", 0, 0, ivshmem_save, ivshmem_load, + register_savevm(DEVICE(dev), "ivshmem", 0, 0, ivshmem_save, ivshmem_load, dev); /* IRQFD requires MSI */ @@ -780,10 +784,10 @@ static void pci_ivshmem_uninit(PCIDevice *dev) memory_region_destroy(&s->ivshmem_mmio); memory_region_del_subregion(&s->bar, &s->ivshmem); - vmstate_unregister_ram(&s->ivshmem, &s->dev.qdev); + vmstate_unregister_ram(&s->ivshmem, DEVICE(dev)); memory_region_destroy(&s->ivshmem); memory_region_destroy(&s->bar); - unregister_savevm(&dev->qdev, "ivshmem", s); + unregister_savevm(DEVICE(dev), "ivshmem", s); } static Property ivshmem_properties[] = { @@ -813,7 +817,7 @@ static void ivshmem_class_init(ObjectClass *klass, void *data) } static const TypeInfo ivshmem_info = { - .name = "ivshmem", + .name = TYPE_IVSHMEM, .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(IVShmemState), .class_init = ivshmem_class_init,