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>
This commit is contained in:
parent
ce7243986f
commit
1aa0c0c748
|
@ -1843,35 +1843,46 @@ static int usb_ohci_init(OHCIState *ohci, DeviceState *dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TYPE_PCI_OHCI "pci-ohci"
|
||||||
|
#define PCI_OHCI(obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PCIDevice pci_dev;
|
/*< private >*/
|
||||||
|
PCIDevice parent_obj;
|
||||||
|
/*< public >*/
|
||||||
|
|
||||||
OHCIState state;
|
OHCIState state;
|
||||||
char *masterbus;
|
char *masterbus;
|
||||||
uint32_t num_ports;
|
uint32_t num_ports;
|
||||||
uint32_t firstport;
|
uint32_t firstport;
|
||||||
} OHCIPCIState;
|
} 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 */
|
dev->config[PCI_CLASS_PROG] = 0x10; /* OHCI */
|
||||||
ohci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */
|
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,
|
ohci->masterbus, ohci->firstport,
|
||||||
pci_get_address_space(dev)) != 0) {
|
pci_get_address_space(dev)) != 0) {
|
||||||
return -1;
|
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(dev, 0, 0, &ohci->state.mem);
|
||||||
pci_register_bar(&ohci->pci_dev, 0, 0, &ohci->state.mem);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TYPE_SYSBUS_OHCI "sysbus-ohci"
|
||||||
|
#define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj), TYPE_SYSBUS_OHCI)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SysBusDevice busdev;
|
/*< private >*/
|
||||||
|
SysBusDevice parent_obj;
|
||||||
|
/*< public >*/
|
||||||
|
|
||||||
OHCIState ohci;
|
OHCIState ohci;
|
||||||
uint32_t num_ports;
|
uint32_t num_ports;
|
||||||
dma_addr_t dma_offset;
|
dma_addr_t dma_offset;
|
||||||
|
@ -1879,10 +1890,10 @@ typedef struct {
|
||||||
|
|
||||||
static int ohci_init_pxa(SysBusDevice *dev)
|
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 */
|
/* 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);
|
&address_space_memory);
|
||||||
sysbus_init_irq(dev, &s->ohci.irq);
|
sysbus_init_irq(dev, &s->ohci.irq);
|
||||||
sysbus_init_mmio(dev, &s->ohci.mem);
|
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 = {
|
static const TypeInfo ohci_pci_info = {
|
||||||
.name = "pci-ohci",
|
.name = TYPE_PCI_OHCI,
|
||||||
.parent = TYPE_PCI_DEVICE,
|
.parent = TYPE_PCI_DEVICE,
|
||||||
.instance_size = sizeof(OHCIPCIState),
|
.instance_size = sizeof(OHCIPCIState),
|
||||||
.class_init = ohci_pci_class_init,
|
.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 = {
|
static const TypeInfo ohci_sysbus_info = {
|
||||||
.name = "sysbus-ohci",
|
.name = TYPE_SYSBUS_OHCI,
|
||||||
.parent = TYPE_SYS_BUS_DEVICE,
|
.parent = TYPE_SYS_BUS_DEVICE,
|
||||||
.instance_size = sizeof(OHCISysBusState),
|
.instance_size = sizeof(OHCISysBusState),
|
||||||
.class_init = ohci_sysbus_class_init,
|
.class_init = ohci_sysbus_class_init,
|
||||||
|
|
Loading…
Reference in a new issue