diff options
author | Hu Tao <hutao@cn.fujitsu.com> | 2013-07-01 18:18:18 +0800 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2013-07-23 00:37:34 +0200 |
commit | 1aa0c0c748ad05cde80b4d6f2907a70bc4089883 (patch) | |
tree | ac02e4d357c0b9d637b02f489f9f808360f470a7 /hw/usb/hcd-ohci.c | |
parent | ce7243986fe69be831ec893127282fa5a045c985 (diff) |
ohci: QOM'ify some more
Introduce type constant and avoid DO_UPCAST().
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
[AF: Avoid remaining OHCIPCIState::pci_dev uses, rename parent fields]
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/usb/hcd-ohci.c')
-rw-r--r-- | hw/usb/hcd-ohci.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index a096ecf214..7da256409c 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -1843,35 +1843,46 @@ static int usb_ohci_init(OHCIState *ohci, DeviceState *dev, return 0; } +#define TYPE_PCI_OHCI "pci-ohci" +#define PCI_OHCI(obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI) + typedef struct { - PCIDevice pci_dev; + /*< private >*/ + PCIDevice parent_obj; + /*< public >*/ + OHCIState state; char *masterbus; uint32_t num_ports; uint32_t firstport; } OHCIPCIState; -static int usb_ohci_initfn_pci(struct PCIDevice *dev) +static int usb_ohci_initfn_pci(PCIDevice *dev) { - OHCIPCIState *ohci = DO_UPCAST(OHCIPCIState, pci_dev, dev); + OHCIPCIState *ohci = PCI_OHCI(dev); - ohci->pci_dev.config[PCI_CLASS_PROG] = 0x10; /* OHCI */ - ohci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */ + dev->config[PCI_CLASS_PROG] = 0x10; /* OHCI */ + dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */ - if (usb_ohci_init(&ohci->state, &dev->qdev, ohci->num_ports, 0, + if (usb_ohci_init(&ohci->state, DEVICE(dev), ohci->num_ports, 0, ohci->masterbus, ohci->firstport, pci_get_address_space(dev)) != 0) { return -1; } - ohci->state.irq = ohci->pci_dev.irq[0]; + ohci->state.irq = dev->irq[0]; - /* TODO: avoid cast below by using dev */ - pci_register_bar(&ohci->pci_dev, 0, 0, &ohci->state.mem); + pci_register_bar(dev, 0, 0, &ohci->state.mem); return 0; } +#define TYPE_SYSBUS_OHCI "sysbus-ohci" +#define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj), TYPE_SYSBUS_OHCI) + typedef struct { - SysBusDevice busdev; + /*< private >*/ + SysBusDevice parent_obj; + /*< public >*/ + OHCIState ohci; uint32_t num_ports; dma_addr_t dma_offset; @@ -1879,10 +1890,10 @@ typedef struct { static int ohci_init_pxa(SysBusDevice *dev) { - OHCISysBusState *s = FROM_SYSBUS(OHCISysBusState, dev); + OHCISysBusState *s = SYSBUS_OHCI(dev); /* Cannot fail as we pass NULL for masterbus */ - usb_ohci_init(&s->ohci, &dev->qdev, s->num_ports, s->dma_offset, NULL, 0, + usb_ohci_init(&s->ohci, DEVICE(dev), s->num_ports, s->dma_offset, NULL, 0, &address_space_memory); sysbus_init_irq(dev, &s->ohci.irq); sysbus_init_mmio(dev, &s->ohci.mem); @@ -1912,7 +1923,7 @@ static void ohci_pci_class_init(ObjectClass *klass, void *data) } static const TypeInfo ohci_pci_info = { - .name = "pci-ohci", + .name = TYPE_PCI_OHCI, .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(OHCIPCIState), .class_init = ohci_pci_class_init, @@ -1935,7 +1946,7 @@ static void ohci_sysbus_class_init(ObjectClass *klass, void *data) } static const TypeInfo ohci_sysbus_info = { - .name = "sysbus-ohci", + .name = TYPE_SYSBUS_OHCI, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(OHCISysBusState), .class_init = ohci_sysbus_class_init, |