[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 19/31] usb/ehci-pci: dynamic type generation
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 19/31] usb/ehci-pci: dynamic type generation |
Date: |
Thu, 1 Nov 2012 16:54:32 +0100 |
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb/hcd-ehci-pci.c | 66 ++++++++++++++++++++++++++-----------------------
1 files changed, 35 insertions(+), 31 deletions(-)
diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
index daac41d..df137cc 100644
--- a/hw/usb/hcd-ehci-pci.c
+++ b/hw/usb/hcd-ehci-pci.c
@@ -23,6 +23,13 @@ typedef struct EHCIPCIState {
EHCIState ehci;
} EHCIPCIState;
+typedef struct EHCIPCIInfo {
+ const char *name;
+ uint16_t vendor_id;
+ uint16_t device_id;
+ uint8_t revision;
+} EHCIPCIInfo;
+
static int usb_ehci_pci_initfn(PCIDevice *dev)
{
EHCIPCIState *i = DO_UPCAST(EHCIPCIState, pcidev, dev);
@@ -91,48 +98,45 @@ static void ehci_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+ EHCIPCIInfo *i = data;
k->init = usb_ehci_pci_initfn;
- k->vendor_id = PCI_VENDOR_ID_INTEL;
- k->device_id = PCI_DEVICE_ID_INTEL_82801D; /* ich4 */
- k->revision = 0x10;
+ k->vendor_id = i->vendor_id;
+ k->device_id = i->device_id;
+ k->revision = i->revision;
k->class_id = PCI_CLASS_SERIAL_USB;
dc->vmsd = &vmstate_ehci;
dc->props = ehci_pci_properties;
}
-static TypeInfo ehci_info = {
- .name = "usb-ehci",
- .parent = TYPE_PCI_DEVICE,
- .instance_size = sizeof(EHCIState),
- .class_init = ehci_class_init,
-};
-
-static void ich9_ehci_class_init(ObjectClass *klass, void *data)
-{
- DeviceClass *dc = DEVICE_CLASS(klass);
- PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
-
- k->init = usb_ehci_pci_initfn;
- k->vendor_id = PCI_VENDOR_ID_INTEL;
- k->device_id = PCI_DEVICE_ID_INTEL_82801I_EHCI1;
- k->revision = 0x03;
- k->class_id = PCI_CLASS_SERIAL_USB;
- dc->vmsd = &vmstate_ehci;
- dc->props = ehci_pci_properties;
-}
-
-static TypeInfo ich9_ehci_info = {
- .name = "ich9-usb-ehci1",
- .parent = TYPE_PCI_DEVICE,
- .instance_size = sizeof(EHCIState),
- .class_init = ich9_ehci_class_init,
+static struct EHCIPCIInfo ehci_pci_info[] = {
+ {
+ .name = "usb-ehci",
+ .vendor_id = PCI_VENDOR_ID_INTEL,
+ .device_id = PCI_DEVICE_ID_INTEL_82801D, /* ich4 */
+ .revision = 0x10,
+ },{
+ .name = "ich9-usb-ehci1",
+ .vendor_id = PCI_VENDOR_ID_INTEL,
+ .device_id = PCI_DEVICE_ID_INTEL_82801I_EHCI1,
+ .revision = 0x03,
+ }
};
static void ehci_pci_register_types(void)
{
- type_register_static(&ehci_info);
- type_register_static(&ich9_ehci_info);
+ TypeInfo ehci_type_info = {
+ .parent = TYPE_PCI_DEVICE,
+ .instance_size = sizeof(EHCIPCIState),
+ .class_init = ehci_class_init,
+ };
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(ehci_pci_info); i++) {
+ ehci_type_info.name = ehci_pci_info[i].name;
+ ehci_type_info.class_data = ehci_pci_info + i;
+ type_register(&ehci_type_info);
+ }
}
type_init(ehci_pci_register_types)
--
1.7.1
- [Qemu-devel] [PATCH 28/31] usb-redir: Add an usbredir_setup_usb_eps() helper function, (continued)
- [Qemu-devel] [PATCH 28/31] usb-redir: Add an usbredir_setup_usb_eps() helper function, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 05/31] xhci: add xhci_port_reset, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 12/31] usb/ehci: Guard definition of EHCI_DEBUG, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 16/31] uhci: dynamic type generation, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 31/31] usb-redir: Allow redirecting super speed devices to high speed controllers, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 30/31] usb-redir: Allow to attach USB 2.0 devices to 1.1 host controller, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 24/31] usb: Add packet combining functions, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 14/31] usb/ehci: add sysbus variant, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 22/31] uhci: Add a uhci_handle_td_error() helper function, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 27/31] usb-redir: Add support for input pipelining, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 19/31] usb/ehci-pci: dynamic type generation,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 13/31] usb/ehci: split into multiple source files, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 15/31] xilinx_zynq: add USB controllers, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 23/31] uhci: Don't crash on device disconnect, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 17/31] uhci: stick irq routing info into UHCIInfo too., Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 25/31] combined-packet: Add a workaround for Linux usbfs + live migration, Gerd Hoffmann, 2012/11/01