From patchwork Mon Aug 24 11:03:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 31917 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 bilbo.ozlabs.org (Postfix) with ESMTPS id BE636B7B64 for ; Mon, 24 Aug 2009 21:35:50 +1000 (EST) Received: from localhost ([127.0.0.1]:43131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MfXpz-0001Qx-1g for incoming@patchwork.ozlabs.org; Mon, 24 Aug 2009 07:35:47 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MfXNh-0006FU-1V for qemu-devel@nongnu.org; Mon, 24 Aug 2009 07:06:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MfXNb-0006BD-6y for qemu-devel@nongnu.org; Mon, 24 Aug 2009 07:06:31 -0400 Received: from [199.232.76.173] (port=52630 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MfXNa-0006Au-CR for qemu-devel@nongnu.org; Mon, 24 Aug 2009 07:06:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31925) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MfXNZ-0006wy-QR for qemu-devel@nongnu.org; Mon, 24 Aug 2009 07:06:26 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7OB6Pau027027 for ; Mon, 24 Aug 2009 07:06:25 -0400 Received: from localhost.localdomain (vpn2-8-191.ams2.redhat.com [10.36.8.191]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7OB63Uc030007; Mon, 24 Aug 2009 07:06:24 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 24 Aug 2009 13:03:37 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 16/22] usb-ohci: Remove unneeded double indirection of OHCIPCIState 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 Signed-off-by: Juan Quintela --- hw/usb-ohci.c | 34 ++++++++++++++-------------------- 1 files changed, 14 insertions(+), 20 deletions(-) diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c index 4c42ec0..14139b8 100644 --- a/hw/usb-ohci.c +++ b/hw/usb-ohci.c @@ -65,6 +65,7 @@ enum ohci_type { }; typedef struct { + PCIDevice dev; qemu_irq irq; enum ohci_type type; int mem; @@ -1698,41 +1699,34 @@ static void usb_ohci_init(OHCIState *ohci, int num_ports, int devfn, ohci_reset(ohci); } -typedef struct { - PCIDevice pci_dev; - OHCIState state; -} OHCIPCIState; - static void ohci_mapfunc(PCIDevice *pci_dev, int i, uint32_t addr, uint32_t size, int type) { - OHCIPCIState *ohci = (OHCIPCIState *)pci_dev; - cpu_register_physical_memory(addr, size, ohci->state.mem); + OHCIState *ohci = DO_UPCAST(OHCIState, dev, pci_dev); + cpu_register_physical_memory(addr, size, ohci->mem); } void usb_ohci_init_pci(struct PCIBus *bus, int num_ports, int devfn) { - OHCIPCIState *ohci; + PCIDevice *pci_dev = pci_register_device(bus, "OHCI USB", sizeof(OHCIState), + devfn, NULL, NULL); + OHCIState *ohci = DO_UPCAST(OHCIState, dev, pci_dev); - ohci = (OHCIPCIState *)pci_register_device(bus, "OHCI USB", sizeof(*ohci), - devfn, NULL, NULL); if (ohci == NULL) { fprintf(stderr, "usb-ohci: Failed to register PCI device\n"); return; } - pci_config_set_vendor_id(ohci->pci_dev.config, PCI_VENDOR_ID_APPLE); - pci_config_set_device_id(ohci->pci_dev.config, - PCI_DEVICE_ID_APPLE_IPID_USB); - ohci->pci_dev.config[0x09] = 0x10; /* OHCI */ - pci_config_set_class(ohci->pci_dev.config, PCI_CLASS_SERIAL_USB); - ohci->pci_dev.config[0x3d] = 0x01; /* interrupt pin 1 */ + pci_config_set_vendor_id(ohci->dev.config, PCI_VENDOR_ID_APPLE); + pci_config_set_device_id(ohci->dev.config, PCI_DEVICE_ID_APPLE_IPID_USB); + ohci->dev.config[0x09] = 0x10; /* OHCI */ + pci_config_set_class(ohci->dev.config, PCI_CLASS_SERIAL_USB); + ohci->dev.config[0x3d] = 0x01; /* interrupt pin 1 */ - usb_ohci_init(&ohci->state, num_ports, devfn, ohci->pci_dev.irq[0], - OHCI_TYPE_PCI, ohci->pci_dev.name, 0); + usb_ohci_init(ohci, num_ports, devfn, ohci->dev.irq[0], + OHCI_TYPE_PCI, ohci->dev.name, 0); - pci_register_bar((struct PCIDevice *)ohci, 0, 256, - PCI_ADDRESS_SPACE_MEM, ohci_mapfunc); + pci_register_bar(pci_dev, 0, 256, PCI_ADDRESS_SPACE_MEM, ohci_mapfunc); } void usb_ohci_init_pxa(target_phys_addr_t base, int num_ports, int devfn,