All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jamin Lin <jamin_lin@aspeedtech.com>
To: "Cédric Le Goater" <clg@kaod.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Kane Chen" <kane_chen@aspeedtech.com>,
	"open list:ASPEED BMCs" <qemu-arm@nongnu.org>,
	"open list:All patches CC here" <qemu-devel@nongnu.org>
Cc: Jamin Lin <jamin_lin@aspeedtech.com>, Troy Lee <troy_lee@aspeedtech.com>
Subject: [PATCH v1 2/3] hw/usb/hcd-ehci-pci: Use DEFINE_TYPES
Date: Wed, 25 Nov 2026 03:12:28 +0000	[thread overview]
Message-ID: <20261125031225.3810653-3-jamin_lin@aspeedtech.com> (raw)
In-Reply-To: <20261125031225.3810653-1-jamin_lin@aspeedtech.com>

Register the EHCI PCI types with one TypeInfo array and DEFINE_TYPES().
This is the current QEMU style for registering types.

No functional change.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
 hw/usb/hcd-ehci-pci.c | 99 ++++++++++++++++++++++---------------------
 1 file changed, 50 insertions(+), 49 deletions(-)

diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
index fd35d25340..c35529eece 100644
--- a/hw/usb/hcd-ehci-pci.c
+++ b/hw/usb/hcd-ehci-pci.c
@@ -23,7 +23,6 @@
 #include "qemu/range.h"
 
 typedef struct EHCIPCIInfo {
-    const char *name;
     uint16_t vendor_id;
     uint16_t device_id;
     uint8_t  revision;
@@ -164,20 +163,6 @@ static void ehci_class_init(ObjectClass *klass, const void *data)
     device_class_set_legacy_reset(dc, usb_ehci_pci_reset);
 }
 
-static const TypeInfo ehci_pci_type_info = {
-    .name = TYPE_PCI_EHCI,
-    .parent = TYPE_PCI_DEVICE,
-    .instance_size = sizeof(EHCIPCIState),
-    .instance_init = usb_ehci_pci_init,
-    .instance_finalize = usb_ehci_pci_finalize,
-    .abstract = true,
-    .class_init = ehci_class_init,
-    .interfaces = (const InterfaceInfo[]) {
-        { INTERFACE_CONVENTIONAL_PCI_DEVICE },
-        { },
-    },
-};
-
 static void ehci_data_class_init(ObjectClass *klass, const void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
@@ -193,42 +178,58 @@ static void ehci_data_class_init(ObjectClass *klass, const void *data)
     }
 }
 
-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", /* 00:1d.7 */
-        .vendor_id = PCI_VENDOR_ID_INTEL,
-        .device_id = PCI_DEVICE_ID_INTEL_82801I_EHCI1,
-        .revision  = 0x03,
-        .companion = true,
-    },{
-        .name      = "ich9-usb-ehci2", /* 00:1a.7 */
-        .vendor_id = PCI_VENDOR_ID_INTEL,
-        .device_id = PCI_DEVICE_ID_INTEL_82801I_EHCI2,
-        .revision  = 0x03,
-        .companion = true,
-    }
+static const EHCIPCIInfo usb_ehci_info = {
+    .vendor_id = PCI_VENDOR_ID_INTEL,
+    .device_id = PCI_DEVICE_ID_INTEL_82801D, /* ich4 */
+    .revision  = 0x10,
 };
 
-static void ehci_pci_register_types(void)
-{
-    TypeInfo ehci_type_info = {
-        .parent        = TYPE_PCI_EHCI,
-        .class_init    = ehci_data_class_init,
-    };
-    int i;
+static const EHCIPCIInfo ich9_usb_ehci1_info = {
+    .vendor_id = PCI_VENDOR_ID_INTEL,
+    .device_id = PCI_DEVICE_ID_INTEL_82801I_EHCI1,
+    .revision  = 0x03,
+    .companion = true,
+};
 
-    type_register_static(&ehci_pci_type_info);
+static const EHCIPCIInfo ich9_usb_ehci2_info = {
+    .vendor_id = PCI_VENDOR_ID_INTEL,
+    .device_id = PCI_DEVICE_ID_INTEL_82801I_EHCI2,
+    .revision  = 0x03,
+    .companion = true,
+};
 
-    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_static(&ehci_type_info);
-    }
-}
+static const TypeInfo ehci_pci_types[] = {
+    {
+        .name          = TYPE_PCI_EHCI,
+        .parent        = TYPE_PCI_DEVICE,
+        .instance_size = sizeof(EHCIPCIState),
+        .instance_init = usb_ehci_pci_init,
+        .instance_finalize = usb_ehci_pci_finalize,
+        .abstract      = true,
+        .class_init    = ehci_class_init,
+        .interfaces    = (const InterfaceInfo[]) {
+            { INTERFACE_CONVENTIONAL_PCI_DEVICE },
+            { },
+        },
+    },
+    {
+        .name          = "usb-ehci",
+        .parent        = TYPE_PCI_EHCI,
+        .class_init    = ehci_data_class_init,
+        .class_data    = &usb_ehci_info,
+    },
+    {
+        .name          = "ich9-usb-ehci1", /* 00:1d.7 */
+        .parent        = TYPE_PCI_EHCI,
+        .class_init    = ehci_data_class_init,
+        .class_data    = &ich9_usb_ehci1_info,
+    },
+    {
+        .name          = "ich9-usb-ehci2", /* 00:1a.7 */
+        .parent        = TYPE_PCI_EHCI,
+        .class_init    = ehci_data_class_init,
+        .class_data    = &ich9_usb_ehci2_info,
+    },
+};
 
-type_init(ehci_pci_register_types)
+DEFINE_TYPES(ehci_pci_types)
-- 
2.53.0


  parent reply	other threads:[~2026-11-25  3:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  3:12 [PATCH v1 0/3] Add the AST2700 PCIe EHCI Jamin Lin
2026-11-25  3:12 ` [PATCH v1 1/3] hw/pci-host/aspeed_pcie: Fix lost INTx interrupts Jamin Lin
2026-11-25  3:12 ` Jamin Lin [this message]
2026-11-25  3:12 ` [PATCH v1 3/3] hw/usb/hcd-ehci-pci-aspeed: Add the AST2700 PCIe EHCI Jamin Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261125031225.3810653-3-jamin_lin@aspeedtech.com \
    --to=jamin_lin@aspeedtech.com \
    --cc=clg@kaod.org \
    --cc=kane_chen@aspeedtech.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=troy_lee@aspeedtech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.