From patchwork Tue Jun 11 06:52:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 250465 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 88DB32C0099 for ; Tue, 11 Jun 2013 16:58:49 +1000 (EST) Received: from localhost ([::1]:40046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UmIXX-0006qe-Gr for incoming@patchwork.ozlabs.org; Tue, 11 Jun 2013 02:58:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UmIWu-0006Mx-8z for qemu-devel@nongnu.org; Tue, 11 Jun 2013 02:58:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UmIWs-0008PK-9H for qemu-devel@nongnu.org; Tue, 11 Jun 2013 02:58:08 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:45708) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UmIWr-0008PE-Vb for qemu-devel@nongnu.org; Tue, 11 Jun 2013 02:58:06 -0400 Received: by mail-pd0-f180.google.com with SMTP id 10so8275957pdi.39 for ; Mon, 10 Jun 2013 23:58:05 -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=oZgc8dxHJyehNVSoNPsitjMlvTEcHCt/TkdrOlLaQ7U=; b=ZAEOgJE/81c16pVFp88TGAsx+nS4/U/vDfKQ2vpBfKRIgcrvLgeIrGUwGwRG6DtylP HHgsW7272TC+Slz0FKs8dLyXv51qh/e5iZkFZjFsHHKWofdmeyCR5TROqaR4xFCPqLy5 ZKfAf7seobDTyfGkq3DgPfNnS2t6pBlUF6X64CuB/RJXpjrBpMKsWPQ1L+L7PGcMUcSC KErVRHiiP7k/zO6XelIvXH/rcvl/WcTbuLKc+/rY7iaRosJ3gE8aXceZDX3qyXTAWoRB AqGCuY3xoMhYD8uRt7ZK4VseXHwu2avj0kGsbLWJJSIqDJfaYb2UxVr82idPkyuURRtm 3bsg== X-Received: by 10.66.248.228 with SMTP id yp4mr17268850pac.158.1370933885081; Mon, 10 Jun 2013 23:58:05 -0700 (PDT) Received: from localhost ([203.126.243.116]) by mx.google.com with ESMTPSA id pq5sm9512427pbc.7.2013.06.10.23.57.58 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Mon, 10 Jun 2013 23:58:04 -0700 (PDT) From: peter.crosthwaite@xilinx.com To: qemu-devel@nongnu.org Date: Tue, 11 Jun 2013 16:52:53 +1000 Message-Id: <31c91172b4278d468e500912772ef232f1070b74.1370931825.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: ALoCoQl+lYCDiizq2KUHKG5gLUJjtrUZe7XzDqBL1GxgTHQoRjuVCsmft4SIJ2aHBehxFZPd6Dal X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.180 Cc: pbonzini@redhat.com, aliguori@us.ibm.com, afaerber@suse.de Subject: [Qemu-devel] [RFT PATCH v1 17/30] pci/*: QOM casting 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 Use standard QOM cast macro. Remove usages of DO_UPCAST, container_of() and direct -> style upcasting. Signed-off-by: Peter Crosthwaite --- hw/pci/pci-hotplug.c | 18 ++++++++++-------- hw/pci/pci.c | 17 +++++++++-------- hw/pci/pcie.c | 4 ++-- hw/pci/shpc.c | 8 ++++---- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c index 12287d1..0009190 100644 --- a/hw/pci/pci-hotplug.c +++ b/hw/pci/pci-hotplug.c @@ -129,7 +129,7 @@ int pci_drive_hot_add(Monitor *mon, const QDict *qdict, DriveInfo *dinfo) monitor_printf(mon, "no pci device with address %s\n", pci_addr); goto err; } - if (scsi_hot_add(mon, &dev->qdev, dinfo, 1) != 0) { + if (scsi_hot_add(mon, DEVICE(dev), dinfo, 1) != 0) { goto err; } break; @@ -193,11 +193,12 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, switch (type) { case IF_SCSI: dev = pci_create(bus, devfn, "lsi53c895a"); - if (qdev_init(&dev->qdev) < 0) + if (qdev_init(DEVICE(dev)) < 0) { dev = NULL; + } if (dev && dinfo) { - if (scsi_hot_add(mon, &dev->qdev, dinfo, 0) != 0) { - qdev_unplug(&dev->qdev, NULL); + if (scsi_hot_add(mon, DEVICE(dev), dinfo, 0) != 0) { + qdev_unplug(DEVICE(dev), NULL); dev = NULL; } } @@ -208,13 +209,14 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, return NULL; } dev = pci_create(bus, devfn, "virtio-blk-pci"); - if (qdev_prop_set_drive(&dev->qdev, "drive", dinfo->bdrv) < 0) { - qdev_free(&dev->qdev); + if (qdev_prop_set_drive(DEVICE(dev), "drive", dinfo->bdrv) < 0) { + qdev_free(DEVICE(dev)); dev = NULL; break; } - if (qdev_init(&dev->qdev) < 0) + if (qdev_init(DEVICE(dev)) < 0) { dev = NULL; + } break; default: dev = NULL; @@ -276,7 +278,7 @@ static int pci_device_hot_remove(Monitor *mon, const char *pci_addr) return -1; } - qdev_unplug(&d->qdev, &local_err); + qdev_unplug(DEVICE(d), &local_err); if (error_is_set(&local_err)) { monitor_printf(mon, "%s\n", error_get_pretty(local_err)); error_free(local_err); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index bb3879b..01a754d 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -177,7 +177,7 @@ void pci_device_reset(PCIDevice *dev) { int r; - qdev_reset_all(&dev->qdev); + qdev_reset_all(DEVICE(dev)); dev->irq_state = 0; pci_update_irq_status(dev); @@ -1449,6 +1449,7 @@ static PciBridgeInfo *qmp_query_pci_bridge(PCIDevice *dev, PCIBus *bus, static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus, int bus_num) { + DeviceState *d = DEVICE(dev); const pci_class_desc *desc; PciDeviceInfo *info; uint8_t type; @@ -1470,7 +1471,7 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus, info->id.vendor = pci_get_word(dev->config + PCI_VENDOR_ID); info->id.device = pci_get_word(dev->config + PCI_DEVICE_ID); info->regions = qmp_query_pci_regions(dev); - info->qdev_id = g_strdup(dev->qdev.id ? dev->qdev.id : ""); + info->qdev_id = g_strdup(d->id ? d->id : ""); if (dev->config[PCI_INTERRUPT_PIN] != 0) { info->has_irq = true; @@ -1594,7 +1595,7 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model, } pci_dev = pci_create(bus, devfn, pci_nic_names[i]); - dev = &pci_dev->qdev; + dev = DEVICE(pci_dev); qdev_set_nic_properties(dev, nd); if (qdev_init(dev) < 0) return NULL; @@ -1734,7 +1735,7 @@ static int pci_qdev_init(DeviceState *qdev) qdev->hotplugged ? PCI_HOTPLUG_ENABLED: PCI_COLDPLUG_ENABLED); if (rc != 0) { - int r = pci_unregister_device(&pci_dev->qdev); + int r = pci_unregister_device(DEVICE(pci_dev)); assert(!r); return rc; } @@ -1771,7 +1772,7 @@ PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn, const char *name) { PCIDevice *dev = pci_create_multifunction(bus, devfn, multifunction, name); - qdev_init_nofail(&dev->qdev); + qdev_init_nofail(DEVICE(dev)); return dev; } @@ -1949,7 +1950,7 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom) } pdev->has_rom = true; memory_region_init_ram(&pdev->rom, name, size); - vmstate_register_ram(&pdev->rom, &pdev->qdev); + vmstate_register_ram(&pdev->rom, DEVICE(pdev)); ptr = memory_region_get_ram_ptr(&pdev->rom); load_image(path, ptr); g_free(path); @@ -1969,7 +1970,7 @@ static void pci_del_option_rom(PCIDevice *pdev) if (!pdev->has_rom) return; - vmstate_unregister_ram(&pdev->rom, &pdev->qdev); + vmstate_unregister_ram(&pdev->rom, DEVICE(pdev)); memory_region_destroy(&pdev->rom); pdev->has_rom = false; } @@ -2129,7 +2130,7 @@ static char *pcibus_get_fw_dev_path(DeviceState *dev) static char *pcibus_get_dev_path(DeviceState *dev) { - PCIDevice *d = container_of(dev, PCIDevice, qdev); + PCIDevice *d = PCI_DEVICE(dev); PCIDevice *t; int slot_depth; /* Path format: Domain:00:Slot.Function:Slot.Function....:Slot.Function. diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 62bd0b8..db4bca8 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -251,7 +251,7 @@ static int pcie_cap_slot_hotplug(DeviceState *qdev, PCI_EXP_SLTSTA_PDS); pcie_cap_slot_event(d, PCI_EXP_HP_EV_PDC); } else { - qdev_free(&pci_dev->qdev); + qdev_free(DEVICE(pci_dev)); pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA, PCI_EXP_SLTSTA_PDS); pcie_cap_slot_event(d, PCI_EXP_HP_EV_PDC); @@ -306,7 +306,7 @@ void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot) dev->exp.hpev_notified = false; pci_bus_hotplug(pci_bridge_get_sec_bus(DO_UPCAST(PCIBridge, dev, dev)), - pcie_cap_slot_hotplug, &dev->qdev); + pcie_cap_slot_hotplug, DEVICE(dev)); } void pcie_cap_slot_reset(PCIDevice *dev) diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c index d35c2ee..aa45e77 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -252,9 +252,9 @@ static void shpc_free_devices_in_slot(SHPCDevice *shpc, int slot) for (devfn = PCI_DEVFN(pci_slot, 0); devfn <= PCI_DEVFN(pci_slot, PCI_FUNC_MAX - 1); ++devfn) { - PCIDevice *affected_dev = shpc->sec_bus->devices[devfn]; + DeviceState *affected_dev = DEVICE(shpc->sec_bus->devices[devfn]); if (affected_dev) { - qdev_free(&affected_dev->qdev); + qdev_free(affected_dev); } } } @@ -497,7 +497,7 @@ static int shpc_device_hotplug(DeviceState *qdev, PCIDevice *affected_dev, int pci_slot = PCI_SLOT(affected_dev->devfn); uint8_t state; uint8_t led; - PCIDevice *d = DO_UPCAST(PCIDevice, qdev, qdev); + PCIDevice *d = PCI_DEVICE(qdev); SHPCDevice *shpc = d->shpc; int slot = SHPC_PCI_TO_IDX(pci_slot); if (pci_slot < SHPC_IDX_TO_PCI(0) || slot >= shpc->nslots) { @@ -616,7 +616,7 @@ int shpc_init(PCIDevice *d, PCIBus *sec_bus, MemoryRegion *bar, unsigned offset) SHPC_SIZEOF(d)); shpc_cap_update_dword(d); memory_region_add_subregion(bar, offset, &shpc->mmio); - pci_bus_hotplug(sec_bus, shpc_device_hotplug, &d->qdev); + pci_bus_hotplug(sec_bus, shpc_device_hotplug, DEVICE(d)); d->cap_present |= QEMU_PCI_CAP_SHPC; return 0;