Re: [PATCH 06/32] hw/usb/hcd-uhci: Introduce TYPE_ defines for device models

2022-12-04 Thread Philippe Mathieu-Daudé

On 4/12/22 20:05, Bernhard Beschow wrote:

Suggested-by: Mark Cave-Ayland 
Signed-off-by: Bernhard Beschow 
Message-Id: <20221022150508.26830-10-shen...@gmail.com>
---
  hw/i386/pc_piix.c |  3 ++-
  hw/i386/pc_q35.c  | 13 +++--
  hw/isa/piix4.c|  2 +-
  hw/usb/hcd-uhci.c | 16 
  hw/usb/hcd-uhci.h |  4 
  5 files changed, 22 insertions(+), 16 deletions(-)


Reviewed-by: Philippe Mathieu-Daudé 




[PATCH 06/32] hw/usb/hcd-uhci: Introduce TYPE_ defines for device models

2022-12-04 Thread Bernhard Beschow
Suggested-by: Mark Cave-Ayland 
Signed-off-by: Bernhard Beschow 
Message-Id: <20221022150508.26830-10-shen...@gmail.com>
---
 hw/i386/pc_piix.c |  3 ++-
 hw/i386/pc_q35.c  | 13 +++--
 hw/isa/piix4.c|  2 +-
 hw/usb/hcd-uhci.c | 16 
 hw/usb/hcd-uhci.h |  4 
 5 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index e26509a935..caa983d76e 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -50,6 +50,7 @@
 #include "exec/memory.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/piix4.h"
+#include "hw/usb/hcd-uhci.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "sysemu/xen.h"
@@ -291,7 +292,7 @@ static void pc_init1(MachineState *machine,
 #endif
 
 if (pcmc->pci_enabled && machine_usb(machine)) {
-pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
+pci_create_simple(pci_bus, piix3_devfn + 2, TYPE_PIIX3_USB_UHCI);
 }
 
 if (pcmc->pci_enabled && x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index a496bd6e74..1da6d34339 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -48,6 +48,7 @@
 #include "hw/ide/pci.h"
 #include "hw/ide/ahci.h"
 #include "hw/usb.h"
+#include "hw/usb/hcd-uhci.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "sysemu/numa.h"
@@ -65,15 +66,15 @@ struct ehci_companions {
 };
 
 static const struct ehci_companions ich9_1d[] = {
-{ .name = "ich9-usb-uhci1", .func = 0, .port = 0 },
-{ .name = "ich9-usb-uhci2", .func = 1, .port = 2 },
-{ .name = "ich9-usb-uhci3", .func = 2, .port = 4 },
+{ .name = TYPE_ICH9_USB_UHCI(1), .func = 0, .port = 0 },
+{ .name = TYPE_ICH9_USB_UHCI(2), .func = 1, .port = 2 },
+{ .name = TYPE_ICH9_USB_UHCI(3), .func = 2, .port = 4 },
 };
 
 static const struct ehci_companions ich9_1a[] = {
-{ .name = "ich9-usb-uhci4", .func = 0, .port = 0 },
-{ .name = "ich9-usb-uhci5", .func = 1, .port = 2 },
-{ .name = "ich9-usb-uhci6", .func = 2, .port = 4 },
+{ .name = TYPE_ICH9_USB_UHCI(4), .func = 0, .port = 0 },
+{ .name = TYPE_ICH9_USB_UHCI(5), .func = 1, .port = 2 },
+{ .name = TYPE_ICH9_USB_UHCI(6), .func = 2, .port = 4 },
 };
 
 static int ehci_create_ich9_with_companions(PCIBus *bus, int slot)
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index 0d23e11a39..aceb21ee3e 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -280,7 +280,7 @@ static void piix4_init(Object *obj)
 
 object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC);
 object_initialize_child(obj, "ide", &s->ide, TYPE_PIIX4_IDE);
-object_initialize_child(obj, "uhci", &s->uhci, "piix4-usb-uhci");
+object_initialize_child(obj, "uhci", &s->uhci, TYPE_PIIX4_USB_UHCI);
 
 object_initialize_child(obj, "pm", &s->pm, TYPE_PIIX4_PM);
 qdev_prop_set_uint32(DEVICE(&s->pm), "smb_io_base", 0x1100);
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index d1b5657d72..30ae0104bb 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -1292,56 +1292,56 @@ void uhci_data_class_init(ObjectClass *klass, void 
*data)
 
 static UHCIInfo uhci_info[] = {
 {
-.name   = "piix3-usb-uhci",
+.name  = TYPE_PIIX3_USB_UHCI,
 .vendor_id = PCI_VENDOR_ID_INTEL,
 .device_id = PCI_DEVICE_ID_INTEL_82371SB_2,
 .revision  = 0x01,
 .irq_pin   = 3,
 .unplug= true,
 },{
-.name  = "piix4-usb-uhci",
+.name  = TYPE_PIIX4_USB_UHCI,
 .vendor_id = PCI_VENDOR_ID_INTEL,
 .device_id = PCI_DEVICE_ID_INTEL_82371AB_2,
 .revision  = 0x01,
 .irq_pin   = 3,
 .unplug= true,
 },{
-.name  = "ich9-usb-uhci1", /* 00:1d.0 */
+.name  = TYPE_ICH9_USB_UHCI(1), /* 00:1d.0 */
 .vendor_id = PCI_VENDOR_ID_INTEL,
 .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI1,
 .revision  = 0x03,
 .irq_pin   = 0,
 .unplug= false,
 },{
-.name  = "ich9-usb-uhci2", /* 00:1d.1 */
+.name  = TYPE_ICH9_USB_UHCI(2), /* 00:1d.1 */
 .vendor_id = PCI_VENDOR_ID_INTEL,
 .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI2,
 .revision  = 0x03,
 .irq_pin   = 1,
 .unplug= false,
 },{
-.name  = "ich9-usb-uhci3", /* 00:1d.2 */
+.name  = TYPE_ICH9_USB_UHCI(3), /* 00:1d.2 */
 .vendor_id = PCI_VENDOR_ID_INTEL,
 .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI3,
 .revision  = 0x03,
 .irq_pin   = 2,
 .unplug= false,
 },{
-.name  = "ich9-usb-uhci4", /* 00:1a.0 */
+.name  = TYPE_ICH9_USB_UHCI(4), /* 00:1a.0 */
 .vendor_id = PCI_VENDOR_ID_INTEL,
 .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI4,
 .revision  = 0x03,
 .irq_pin   = 0,
 .unplug= false,
 },{
-.name  = "ich9-usb-uhci5", /* 00:1a.1 */
+