[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 16/22] usb-ohci: Remove unneeded double indirection
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 16/22] usb-ohci: Remove unneeded double indirection of OHCIPCIState |
Date: |
Mon, 24 Aug 2009 13:03:37 +0200 |
Signed-off-by: Juan Quintela <address@hidden>
---
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,
--
1.6.2.5
- [Qemu-devel] [PATCH 06/22] ne2000: pci_dev has this very value with the right type, (continued)
- [Qemu-devel] [PATCH 06/22] ne2000: pci_dev has this very value with the right type, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 09/22] pci: remove casts from void *, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 08/22] ne2000: change pci_dev to is_pci, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 11/22] rtl8139: remove pointless cast from void *, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 10/22] rtl8139: Remove unneeded double indirection of PCIRTL8139State, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 12/22] lsi53c895a: remove pointless cast from void *, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 13/22] lsi53c895a: use DO_UPCAST to cast from PCIDevice, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 14/22] lsi53c895a: rename PCIDevice field from pci_dev to dev (consistence), Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 15/22] lsi53c895a: LSIState is a PCIDevice is a DeviceHost, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 16/22] usb-ohci: Remove unneeded double indirection of OHCIPCIState,
Juan Quintela <=
- [Qemu-devel] [PATCH 17/22] cirrus_vga: Remove unneeded double indirection of PCICirrusVGAState, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 18/22] cirrus_vga: remove pointless cast from void *, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 19/22] cirrus_vga: change use of pci_dev for is_pci, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 20/22] Introduce vga_common_reset() to be able to typcheck vga_reset(), Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 21/22] vga: Rename vga_state -> vga, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 22/22] Everything outside of vga.c should use VGACommonState, Juan Quintela, 2009/08/24
- Re: [Qemu-devel] [PATCH 00/22] Indirection Cleanup, Gerd Hoffmann, 2009/08/24