All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends
@ 2021-08-06 21:11 Eduardo Habkost
  2021-08-06 21:11   ` Eduardo Habkost
                   ` (12 more replies)
  0 siblings, 13 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Daniel P. Berrange

This series gets rid of all manual usage of OBJECT_CHECK,
OBJECT_CLASS_CHECK, and OBJECT_GET_CLASS.

All type check macros defined manually are replaced with
DEFINE_*CHECKER* or OBJECT_DECLARE* macros.

All manual usage of OBJECT_CHECK/OBJECT_CLASS_CHECK/OBJECT_GET_CLASS
is manually replaced with the corresponding type-specific wrappers.

For a git tree containing all dependencies, see:
  https://gitlab.com/ehabkost/qemu.git work/qom-automated-declare-type-pass2

This series is based on multiple other series I have submitted
recently, including:

  Date: Thu,  5 Aug 2021 15:34:25 -0400
  Subject: [PATCH for-6.2 0/6] qom: Fix broken OBJECT_CHECK usage
  Message-Id: <20210805193431.307761-1-ehabkost@redhat.com>
  https://lore.kernel.org/qemu-devel/20210805193431.307761-1-ehabkost@redhat.com

  Date: Thu,  5 Aug 2021 17:47:39 -0400
  Subject: [PATCH] bcm2836: Remove redundant typedef and macros
  Message-Id: <20210805214739.390613-1-ehabkost@redhat.com>
  https://lore.kernel.org/qemu-devel/20210805214739.390613-1-ehabkost@redhat.com

  Date: Thu,  5 Aug 2021 22:31:19 -0400
  Subject: [PATCH for-6.2] sbsa-ref: Rename SBSA_GWDT enum value
  Message-Id: <20210806023119.431680-1-ehabkost@redhat.com>
  https://lore.kernel.org/qemu-devel/20210806023119.431680-1-ehabkost@redhat.com

Based-on: <20210805193431.307761-1-ehabkost@redhat.com>
Based-on: <20210805214739.390613-1-ehabkost@redhat.com>
Based-on: <20210806023119.431680-1-ehabkost@redhat.com>

Eduardo Habkost (12):
  accel: Rename TYPE_ACCEL to TYPE_ACCEL_BASE
  qom: Use DEVICE_*CLASS instead of OBJECT_*CLASS
  scripts/codeconverter: Update to latest version
  [automated] Add struct names to typedefs used by QOM types
  [automated] Move QOM typedefs and add missing includes
  [automated] Split QOM "typedef struct T { ... } T" declarations
  [automated] Use DECLARE_*CHECKER* macros when possible
  npcm7xx_clk: Use DECLARE_INSTANCE_CHECKER
  npcm7xx_otp: Use DECLARE_CLASS_CHECKERS
  [automated] Use DECLARE_OBJ_CHECKERS when possible
  [automated] Use OBJECT_DECLARE_TYPE when possible
  [automated] Use OBJECT_DECLARE_SIMPLE_TYPE when possible

 hw/core/machine.c                             |   2 +-
 hw/nvme/nvme.h                                |  24 +-
 hw/usb/hcd-uhci.h                             |   6 +-
 hw/usb/hcd-xhci-pci.h                         |   8 +-
 hw/usb/hcd-xhci-sysbus.h                      |   8 +-
 hw/usb/u2f.h                                  |  17 +-
 include/crypto/tlscreds.h                     |   5 +-
 include/hw/acpi/acpi_dev_interface.h          |   2 +-
 include/hw/adc/npcm7xx_adc.h                  |   8 +-
 include/hw/arm/linux-boot-if.h                |   2 +-
 include/hw/arm/npcm7xx.h                      |  36 ++-
 include/hw/char/shakti_uart.h                 |   8 +-
 include/hw/core/accel-cpu.h                   |   6 +-
 include/hw/dma/sifive_pdma.h                  |   8 +-
 include/hw/dma/xlnx_csu_dma.h                 |   8 +-
 include/hw/fw-path-provider.h                 |   2 +-
 include/hw/gpio/npcm7xx_gpio.h                |  10 +-
 include/hw/gpio/sifive_gpio.h                 |   4 +-
 include/hw/hotplug.h                          |   2 +-
 include/hw/i2c/npcm7xx_smbus.h                |  10 +-
 include/hw/intc/intc.h                        |   2 +-
 include/hw/intc/m68k_irqc.h                   |   8 +-
 include/hw/intc/sifive_clint.h                |   8 +-
 include/hw/intc/sifive_plic.h                 |   4 +-
 include/hw/ipmi/ipmi.h                        |   2 +-
 include/hw/mem/memory-device.h                |   2 +-
 include/hw/mem/npcm7xx_mc.h                   |   9 +-
 include/hw/misc/aspeed_lpc.h                  |   7 +-
 include/hw/misc/bcm2835_cprman.h              |  21 +-
 include/hw/misc/bcm2835_cprman_internals.h    |  13 +-
 include/hw/misc/led.h                         |   3 +-
 include/hw/misc/mchp_pfsoc_dmc.h              |  17 +-
 include/hw/misc/mchp_pfsoc_ioscb.h            |   8 +-
 include/hw/misc/mchp_pfsoc_sysreg.h           |   9 +-
 include/hw/misc/npcm7xx_clk.h                 |  18 +-
 include/hw/misc/npcm7xx_gcr.h                 |   7 +-
 include/hw/misc/npcm7xx_mft.h                 |   7 +-
 include/hw/misc/npcm7xx_pwm.h                 |   4 +-
 include/hw/misc/npcm7xx_rng.h                 |   9 +-
 include/hw/misc/sifive_e_prci.h               |   4 +-
 include/hw/misc/sifive_test.h                 |   4 +-
 include/hw/misc/sifive_u_otp.h                |   4 +-
 include/hw/misc/sifive_u_prci.h               |   4 +-
 include/hw/misc/xlnx-versal-xramc.h           |   8 +-
 include/hw/net/npcm7xx_emc.h                  |   5 +-
 include/hw/net/xlnx-zynqmp-can.h              |   8 +-
 include/hw/nmi.h                              |   2 +-
 include/hw/nvram/npcm7xx_otp.h                |  12 +-
 include/hw/ppc/spapr_drc.h                    |  23 +-
 include/hw/ppc/spapr_xive.h                   |  15 +-
 include/hw/ppc/vof.h                          |   1 +
 include/hw/rdma/rdma.h                        |   2 +-
 include/hw/register.h                         |   3 +-
 include/hw/riscv/microchip_pfsoc.h            |  18 +-
 include/hw/riscv/shakti_c.h                   |  15 +-
 include/hw/riscv/sifive_e.h                   |  17 +-
 include/hw/riscv/sifive_u.h                   |  17 +-
 include/hw/rtc/m48t59.h                       |   2 +-
 include/hw/sd/cadence_sdhci.h                 |   8 +-
 include/hw/ssi/npcm7xx_fiu.h                  |   4 +-
 include/hw/ssi/sifive_spi.h                   |   7 +-
 include/hw/stream.h                           |   2 +-
 include/hw/timer/npcm7xx_timer.h              |   4 +-
 include/hw/tricore/tricore_testdevice.h       |   8 +-
 include/hw/usb/hcd-dwc3.h                     |   8 +-
 include/hw/usb/msd.h                          |   1 +
 include/hw/usb/xlnx-usb-subsystem.h           |  10 +-
 include/hw/usb/xlnx-versal-usb2-ctrl-regs.h   |   8 +-
 include/hw/vmstate-if.h                       |   2 +-
 include/hw/watchdog/sbsa_gwdt.h               |  10 +-
 include/qemu/accel.h                          |  20 +-
 include/qom/object_interfaces.h               |   2 +-
 include/sysemu/tpm.h                          |   2 +-
 target/arm/idau.h                             |   2 +-
 target/hexagon/cpu.h                          |  19 +-
 accel/accel-common.c                          |   4 +-
 accel/accel-softmmu.c                         |   4 +-
 accel/accel-user.c                            |   2 +-
 accel/hvf/hvf-accel-ops.c                     |   4 +-
 accel/kvm/kvm-all.c                           |   4 +-
 accel/qtest/qtest.c                           |   4 +-
 accel/tcg/tcg-all.c                           |   5 +-
 accel/xen/xen-all.c                           |   4 +-
 bsd-user/main.c                               |   2 +-
 chardev/char-parallel.c                       |  17 +-
 hw/arm/bcm2836.c                              |   1 +
 hw/block/fdc-sysbus.c                         |   5 +-
 hw/i2c/i2c_mux_pca954x.c                      |   9 +-
 hw/m68k/mcf5206.c                             |   7 +-
 hw/mem/sparse-mem.c                           |   9 +-
 hw/mips/boston.c                              |   4 +-
 hw/mips/loongson3_virt.c                      |   1 +
 hw/misc/npcm7xx_clk.c                         |  10 +-
 hw/misc/sbsa_ec.c                             |   9 +-
 hw/net/can/ctucan_pci.c                       |   5 +-
 hw/nvram/npcm7xx_otp.c                        |   6 +-
 hw/pci/pci.c                                  |   3 +-
 hw/s390x/vhost-user-fs-ccw.c                  |   8 +-
 hw/sensor/adm1272.c                           |   7 +-
 hw/sensor/max34451.c                          |   7 +-
 hw/usb/hcd-ehci-pci.c                         |   2 +-
 hw/usb/u2f-emulated.c                         |   5 +-
 hw/usb/u2f-passthru.c                         |   5 +-
 hw/virtio/vhost-user-i2c-pci.c                |   1 +
 linux-user/main.c                             |   2 +-
 migration/savevm.c                            |   3 +-
 monitor/misc.c                                |   3 +-
 .../codeconverter/codeconverter/patching.py   |  18 +-
 .../codeconverter/codeconverter/qom_macros.py | 187 +++++++++++--
 .../codeconverter/qom_type_info.py            | 247 +++++++++++++++++-
 .../codeconverter/codeconverter/regexps.py    |   3 +-
 softmmu/memory.c                              |   2 +-
 softmmu/qdev-monitor.c                        |   3 +-
 softmmu/vl.c                                  |   6 +-
 target/i386/hax/hax-all.c                     |   4 +-
 target/i386/nvmm/nvmm-all.c                   |   4 +-
 target/i386/whpx/whpx-all.c                   |   4 +-
 tests/qtest/pnv-xscom-test.c                  |   5 +-
 tests/unit/check-qom-interface.c              |   2 +-
 ui/vdagent.c                                  |   1 +
 120 files changed, 805 insertions(+), 458 deletions(-)

-- 
2.31.1




^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 01/12] accel: Rename TYPE_ACCEL to TYPE_ACCEL_BASE
  2021-08-06 21:11 [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Eduardo Habkost
@ 2021-08-06 21:11   ` Eduardo Habkost
  2021-08-06 21:11 ` [PATCH for-6.2 02/12] qom: Use DEVICE_*CLASS instead of OBJECT_*CLASS Eduardo Habkost
                     ` (11 subsequent siblings)
  12 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrange, Paolo Bonzini, Richard Henderson,
	Cameron Esfahani, Roman Bolshakov, Thomas Huth, Laurent Vivier,
	Stefano Stabellini, Anthony Perard, Paul Durrant, Warner Losh,
	Kyle Evans, Marcel Apfelbaum, Peter Xu, David Hildenbrand,
	Wenchao Wang, Colin Xu, Kamil Rytarowski, Reinoud Zandijk,
	Sunil Muthuswamy, kvm, xen-devel, haxm-team

The ACCEL name conflicts with a Windows API typedef name, and it
is difficult to work around this because windows.h needs to be
included by osdep.h.  This prevents us from replacing the
existing ACCEL macro with an inline function generated by
OBJECT_DEFINE_TYPE.

Work around the conflict by renaming TYPE_ACCEL to TYPE_ACCEL_BASE.

Note that the actual QOM type name is still "accel", because QOM
type names are user-visible and I don't want to make any
user-visible change here.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Notes about name alternatives:

I have considered using the name "CPU_ACCEL" as Daniel suggested,
but this would lead to a parent class named CPU_ACCEL, while
the subclasses would be still named KVM_ACCEL, HVF_ACCEL,
TCG_ACCEL, etc.  I that this would be confusing, because it
would look like CPU_ACCEL is just another type of accel, not the
parent type of all other *_ACCEL types.

Renaming KVM_ACCEL/HVF_ACCEL/TCG_ACCEL to
KVM_CPU_ACCEL/HVF_CPU_ACCEL/TCG_CPU_ACCEL would be clearer, but I
believe it would be too intrusive and the resulting type names
would be too long.

Renaming the base classe ACCEL_BASE sounds like a reasonable
alternative, as there are other examples in QEMU where abstract
base classes are called *_BASE: TYPE_VIRTIO_GPU_PCI_BASE,
TYPE_VIRTIO_GPU_BASE, TYPE_E1000_BASE, TYPE_RISCV_CPU_BASE,
TYPE_MEGASAS_BASE, TYPE_SCSI_DISK_BASE, etc.
---
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Cameron Esfahani <dirty@apple.com>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Paul Durrant <paul@xen.org>
Cc: Warner Losh <imp@bsdimp.com>
Cc: Kyle Evans <kevans@freebsd.org>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Wenchao Wang <wenchao.wang@intel.com>
Cc: Colin Xu <colin.xu@intel.com>
Cc: Kamil Rytarowski <kamil@netbsd.org>
Cc: Reinoud Zandijk <reinoud@netbsd.org>
Cc: Sunil Muthuswamy <sunilmut@microsoft.com>
Cc: qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org
Cc: xen-devel@lists.xenproject.org
Cc: haxm-team@intel.com
---
 hw/core/machine.c           |  2 +-
 include/qemu/accel.h        | 16 ++++++++--------
 accel/accel-common.c        |  4 ++--
 accel/accel-softmmu.c       |  4 ++--
 accel/accel-user.c          |  2 +-
 accel/hvf/hvf-accel-ops.c   |  4 ++--
 accel/kvm/kvm-all.c         |  4 ++--
 accel/qtest/qtest.c         |  4 ++--
 accel/tcg/tcg-all.c         |  4 ++--
 accel/xen/xen-all.c         |  4 ++--
 bsd-user/main.c             |  2 +-
 linux-user/main.c           |  2 +-
 softmmu/memory.c            |  2 +-
 softmmu/vl.c                |  6 +++---
 target/i386/hax/hax-all.c   |  4 ++--
 target/i386/nvmm/nvmm-all.c |  4 ++--
 target/i386/whpx/whpx-all.c |  4 ++--
 17 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 943974d411c..fdb1f886ce8 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1268,7 +1268,7 @@ void machine_run_board_init(MachineState *machine)
                                    "on", false);
     }
 
-    accel_init_interfaces(ACCEL_GET_CLASS(machine->accelerator));
+    accel_init_interfaces(ACCEL_BASE_GET_CLASS(machine->accelerator));
     machine_class->init(machine);
     phase_advance(PHASE_MACHINE_INITIALIZED);
 }
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 4f4c283f6fc..cc915720494 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -54,17 +54,17 @@ typedef struct AccelClass {
     GPtrArray *compat_props;
 } AccelClass;
 
-#define TYPE_ACCEL "accel"
+#define TYPE_ACCEL_BASE "accel"
 
-#define ACCEL_CLASS_SUFFIX  "-" TYPE_ACCEL
+#define ACCEL_CLASS_SUFFIX  "-" TYPE_ACCEL_BASE
 #define ACCEL_CLASS_NAME(a) (a ACCEL_CLASS_SUFFIX)
 
-#define ACCEL_CLASS(klass) \
-    OBJECT_CLASS_CHECK(AccelClass, (klass), TYPE_ACCEL)
-#define ACCEL(obj) \
-    OBJECT_CHECK(AccelState, (obj), TYPE_ACCEL)
-#define ACCEL_GET_CLASS(obj) \
-    OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL)
+#define ACCEL_BASE_CLASS(klass) \
+    OBJECT_CLASS_CHECK(AccelClass, (klass), TYPE_ACCEL_BASE)
+#define ACCEL_BASE(obj) \
+    OBJECT_CHECK(AccelState, (obj), TYPE_ACCEL_BASE)
+#define ACCEL_BASE_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL_BASE)
 
 AccelClass *accel_find(const char *opt_name);
 AccelState *current_accel(void);
diff --git a/accel/accel-common.c b/accel/accel-common.c
index 7b8ec7e0f72..c4e268c8a74 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -34,7 +34,7 @@
 #endif /* !CONFIG_USER_ONLY */
 
 static const TypeInfo accel_type = {
-    .name = TYPE_ACCEL,
+    .name = TYPE_ACCEL_BASE,
     .parent = TYPE_OBJECT,
     .class_size = sizeof(AccelClass),
     .instance_size = sizeof(AccelState),
@@ -44,7 +44,7 @@ static const TypeInfo accel_type = {
 AccelClass *accel_find(const char *opt_name)
 {
     char *class_name = g_strdup_printf(ACCEL_CLASS_NAME("%s"), opt_name);
-    AccelClass *ac = ACCEL_CLASS(module_object_class_by_name(class_name));
+    AccelClass *ac = ACCEL_BASE_CLASS(module_object_class_by_name(class_name));
     g_free(class_name);
     return ac;
 }
diff --git a/accel/accel-softmmu.c b/accel/accel-softmmu.c
index 67276e4f522..792bdc44940 100644
--- a/accel/accel-softmmu.c
+++ b/accel/accel-softmmu.c
@@ -32,7 +32,7 @@
 
 int accel_init_machine(AccelState *accel, MachineState *ms)
 {
-    AccelClass *acc = ACCEL_GET_CLASS(accel);
+    AccelClass *acc = ACCEL_BASE_GET_CLASS(accel);
     int ret;
     ms->accelerator = accel;
     *(acc->allowed) = true;
@@ -55,7 +55,7 @@ AccelState *current_accel(void)
 void accel_setup_post(MachineState *ms)
 {
     AccelState *accel = ms->accelerator;
-    AccelClass *acc = ACCEL_GET_CLASS(accel);
+    AccelClass *acc = ACCEL_BASE_GET_CLASS(accel);
     if (acc->setup_post) {
         acc->setup_post(ms, accel);
     }
diff --git a/accel/accel-user.c b/accel/accel-user.c
index 22b6a1a1a89..492480847e5 100644
--- a/accel/accel-user.c
+++ b/accel/accel-user.c
@@ -18,7 +18,7 @@ AccelState *current_accel(void)
         AccelClass *ac = accel_find("tcg");
 
         g_assert(ac != NULL);
-        accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac)));
+        accel = ACCEL_BASE(object_new_with_class(OBJECT_CLASS(ac)));
     }
     return accel;
 }
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index d1691be9896..af09bfd1acb 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -329,7 +329,7 @@ static int hvf_accel_init(MachineState *ms)
 
 static void hvf_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     ac->name = "HVF";
     ac->init_machine = hvf_accel_init;
     ac->allowed = &hvf_allowed;
@@ -337,7 +337,7 @@ static void hvf_accel_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo hvf_accel_type = {
     .name = TYPE_HVF_ACCEL,
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .class_init = hvf_accel_class_init,
 };
 
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 0125c17edb8..381ba59a970 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -3618,7 +3618,7 @@ static void kvm_accel_instance_init(Object *obj)
 
 static void kvm_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     ac->name = "KVM";
     ac->init_machine = kvm_init;
     ac->has_memory = kvm_accel_has_memory;
@@ -3645,7 +3645,7 @@ static void kvm_accel_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo kvm_accel_type = {
     .name = TYPE_KVM_ACCEL,
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .instance_init = kvm_accel_instance_init,
     .class_init = kvm_accel_class_init,
     .instance_size = sizeof(KVMState),
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 7e6b8110d52..10b9b56b0e5 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -32,7 +32,7 @@ static int qtest_init_accel(MachineState *ms)
 
 static void qtest_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     ac->name = "QTest";
     ac->init_machine = qtest_init_accel;
     ac->allowed = &qtest_allowed;
@@ -42,7 +42,7 @@ static void qtest_accel_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo qtest_accel_type = {
     .name = TYPE_QTEST_ACCEL,
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .class_init = qtest_accel_class_init,
 };
 module_obj(TYPE_QTEST_ACCEL);
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index d6336a9c966..c0812e5dfd6 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -210,7 +210,7 @@ static void tcg_set_splitwx(Object *obj, bool value, Error **errp)
 
 static void tcg_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     ac->name = "tcg";
     ac->init_machine = tcg_init_machine;
     ac->allowed = &tcg_allowed;
@@ -233,7 +233,7 @@ static void tcg_accel_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo tcg_accel_type = {
     .name = TYPE_TCG_ACCEL,
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .instance_init = tcg_accel_instance_init,
     .class_init = tcg_accel_class_init,
     .instance_size = sizeof(TCGState),
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index 69aa7d018b2..42b83f35d8c 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -186,7 +186,7 @@ static int xen_init(MachineState *ms)
 
 static void xen_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     static GlobalProperty compat[] = {
         { "migration", "store-global-state", "off" },
         { "migration", "send-configuration", "off" },
@@ -211,7 +211,7 @@ static void xen_accel_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo xen_accel_type = {
     .name = TYPE_XEN_ACCEL,
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .class_init = xen_accel_class_init,
 };
 
diff --git a/bsd-user/main.c b/bsd-user/main.c
index fe66204b6b7..f26eefd3b39 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -793,7 +793,7 @@ int main(int argc, char **argv)
     cpu_type = parse_cpu_option(cpu_model);
     /* init tcg before creating CPUs and to get qemu_host_page_size */
     {
-        AccelClass *ac = ACCEL_GET_CLASS(current_accel());
+        AccelClass *ac = ACCEL_BASE_GET_CLASS(current_accel());
 
         accel_init_interfaces(ac);
         ac->init_machine(NULL);
diff --git a/linux-user/main.c b/linux-user/main.c
index 37ed50d98e2..d9dd14e07bc 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -723,7 +723,7 @@ int main(int argc, char **argv, char **envp)
 
     /* init tcg before creating CPUs and to get qemu_host_page_size */
     {
-        AccelClass *ac = ACCEL_GET_CLASS(current_accel());
+        AccelClass *ac = ACCEL_BASE_GET_CLASS(current_accel());
 
         accel_init_interfaces(ac);
         ac->init_machine(NULL);
diff --git a/softmmu/memory.c b/softmmu/memory.c
index bfedaf9c4df..a24fa8c0475 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -3261,7 +3261,7 @@ void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabled)
         };
         GArray *fv_address_spaces;
         GHashTable *views = g_hash_table_new(g_direct_hash, g_direct_equal);
-        AccelClass *ac = ACCEL_GET_CLASS(current_accel());
+        AccelClass *ac = ACCEL_BASE_GET_CLASS(current_accel());
 
         if (ac->has_memory) {
             fvi.ac = ac;
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 5ca11e74694..b7a20da366b 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2305,7 +2305,7 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
         }
         return 0;
     }
-    accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac)));
+    accel = ACCEL_BASE(object_new_with_class(OBJECT_CLASS(ac)));
     object_apply_compat_props(OBJECT(accel));
     qemu_opt_foreach(opts, accelerator_set_property,
                      accel,
@@ -2386,7 +2386,7 @@ static void configure_accelerators(const char *progname)
     }
 
     if (init_failed && !qtest_chrdev) {
-        AccelClass *ac = ACCEL_GET_CLASS(current_accel());
+        AccelClass *ac = ACCEL_BASE_GET_CLASS(current_accel());
         error_report("falling back to %s", ac->name);
     }
 
@@ -3315,7 +3315,7 @@ void qemu_init(int argc, char **argv, char **envp)
                 optarg = qemu_opt_get(accel_opts, "accel");
                 if (!optarg || is_help_option(optarg)) {
                     printf("Accelerators supported in QEMU binary:\n");
-                    GSList *el, *accel_list = object_class_get_list(TYPE_ACCEL,
+                    GSList *el, *accel_list = object_class_get_list(TYPE_ACCEL_BASE,
                                                                     false);
                     for (el = accel_list; el; el = el->next) {
                         gchar *typename = g_strdup(object_class_get_name(
diff --git a/target/i386/hax/hax-all.c b/target/i386/hax/hax-all.c
index bf65ed6fa92..37d18d7ea98 100644
--- a/target/i386/hax/hax-all.c
+++ b/target/i386/hax/hax-all.c
@@ -1120,7 +1120,7 @@ void hax_reset_vcpu_state(void *opaque)
 
 static void hax_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     ac->name = "HAX";
     ac->init_machine = hax_accel_init;
     ac->allowed = &hax_allowed;
@@ -1128,7 +1128,7 @@ static void hax_accel_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo hax_accel_type = {
     .name = ACCEL_CLASS_NAME("hax"),
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .class_init = hax_accel_class_init,
 };
 
diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c
index dfa690d65da..be66baa9d2f 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -1205,7 +1205,7 @@ nvmm_enabled(void)
 static void
 nvmm_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     ac->name = "NVMM";
     ac->init_machine = nvmm_accel_init;
     ac->allowed = &nvmm_allowed;
@@ -1213,7 +1213,7 @@ nvmm_accel_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo nvmm_accel_type = {
     .name = ACCEL_CLASS_NAME("nvmm"),
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .class_init = nvmm_accel_class_init,
 };
 
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index f832f286ac3..5cf77f916c1 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -1873,7 +1873,7 @@ bool whpx_apic_in_platform(void) {
 
 static void whpx_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     ac->name = "WHPX";
     ac->init_machine = whpx_accel_init;
     ac->allowed = &whpx_allowed;
@@ -1896,7 +1896,7 @@ static void whpx_accel_instance_init(Object *obj)
 
 static const TypeInfo whpx_accel_type = {
     .name = ACCEL_CLASS_NAME("whpx"),
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .instance_init = whpx_accel_instance_init,
     .class_init = whpx_accel_class_init,
 };
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 01/12] accel: Rename TYPE_ACCEL to TYPE_ACCEL_BASE
@ 2021-08-06 21:11   ` Eduardo Habkost
  0 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: kvm, Paul Durrant, Peter Xu, haxm-team, Colin Xu, Warner Losh,
	Stefano Stabellini, David Hildenbrand, Kamil Rytarowski,
	Reinoud Zandijk, Anthony Perard, xen-devel, Laurent Vivier,
	Thomas Huth, Kyle Evans, Richard Henderson, Cameron Esfahani,
	Roman Bolshakov, Sunil Muthuswamy, Daniel P. Berrange,
	Wenchao Wang, Paolo Bonzini

The ACCEL name conflicts with a Windows API typedef name, and it
is difficult to work around this because windows.h needs to be
included by osdep.h.  This prevents us from replacing the
existing ACCEL macro with an inline function generated by
OBJECT_DEFINE_TYPE.

Work around the conflict by renaming TYPE_ACCEL to TYPE_ACCEL_BASE.

Note that the actual QOM type name is still "accel", because QOM
type names are user-visible and I don't want to make any
user-visible change here.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Notes about name alternatives:

I have considered using the name "CPU_ACCEL" as Daniel suggested,
but this would lead to a parent class named CPU_ACCEL, while
the subclasses would be still named KVM_ACCEL, HVF_ACCEL,
TCG_ACCEL, etc.  I that this would be confusing, because it
would look like CPU_ACCEL is just another type of accel, not the
parent type of all other *_ACCEL types.

Renaming KVM_ACCEL/HVF_ACCEL/TCG_ACCEL to
KVM_CPU_ACCEL/HVF_CPU_ACCEL/TCG_CPU_ACCEL would be clearer, but I
believe it would be too intrusive and the resulting type names
would be too long.

Renaming the base classe ACCEL_BASE sounds like a reasonable
alternative, as there are other examples in QEMU where abstract
base classes are called *_BASE: TYPE_VIRTIO_GPU_PCI_BASE,
TYPE_VIRTIO_GPU_BASE, TYPE_E1000_BASE, TYPE_RISCV_CPU_BASE,
TYPE_MEGASAS_BASE, TYPE_SCSI_DISK_BASE, etc.
---
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Cameron Esfahani <dirty@apple.com>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Paul Durrant <paul@xen.org>
Cc: Warner Losh <imp@bsdimp.com>
Cc: Kyle Evans <kevans@freebsd.org>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Wenchao Wang <wenchao.wang@intel.com>
Cc: Colin Xu <colin.xu@intel.com>
Cc: Kamil Rytarowski <kamil@netbsd.org>
Cc: Reinoud Zandijk <reinoud@netbsd.org>
Cc: Sunil Muthuswamy <sunilmut@microsoft.com>
Cc: qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org
Cc: xen-devel@lists.xenproject.org
Cc: haxm-team@intel.com
---
 hw/core/machine.c           |  2 +-
 include/qemu/accel.h        | 16 ++++++++--------
 accel/accel-common.c        |  4 ++--
 accel/accel-softmmu.c       |  4 ++--
 accel/accel-user.c          |  2 +-
 accel/hvf/hvf-accel-ops.c   |  4 ++--
 accel/kvm/kvm-all.c         |  4 ++--
 accel/qtest/qtest.c         |  4 ++--
 accel/tcg/tcg-all.c         |  4 ++--
 accel/xen/xen-all.c         |  4 ++--
 bsd-user/main.c             |  2 +-
 linux-user/main.c           |  2 +-
 softmmu/memory.c            |  2 +-
 softmmu/vl.c                |  6 +++---
 target/i386/hax/hax-all.c   |  4 ++--
 target/i386/nvmm/nvmm-all.c |  4 ++--
 target/i386/whpx/whpx-all.c |  4 ++--
 17 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 943974d411c..fdb1f886ce8 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1268,7 +1268,7 @@ void machine_run_board_init(MachineState *machine)
                                    "on", false);
     }
 
-    accel_init_interfaces(ACCEL_GET_CLASS(machine->accelerator));
+    accel_init_interfaces(ACCEL_BASE_GET_CLASS(machine->accelerator));
     machine_class->init(machine);
     phase_advance(PHASE_MACHINE_INITIALIZED);
 }
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 4f4c283f6fc..cc915720494 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -54,17 +54,17 @@ typedef struct AccelClass {
     GPtrArray *compat_props;
 } AccelClass;
 
-#define TYPE_ACCEL "accel"
+#define TYPE_ACCEL_BASE "accel"
 
-#define ACCEL_CLASS_SUFFIX  "-" TYPE_ACCEL
+#define ACCEL_CLASS_SUFFIX  "-" TYPE_ACCEL_BASE
 #define ACCEL_CLASS_NAME(a) (a ACCEL_CLASS_SUFFIX)
 
-#define ACCEL_CLASS(klass) \
-    OBJECT_CLASS_CHECK(AccelClass, (klass), TYPE_ACCEL)
-#define ACCEL(obj) \
-    OBJECT_CHECK(AccelState, (obj), TYPE_ACCEL)
-#define ACCEL_GET_CLASS(obj) \
-    OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL)
+#define ACCEL_BASE_CLASS(klass) \
+    OBJECT_CLASS_CHECK(AccelClass, (klass), TYPE_ACCEL_BASE)
+#define ACCEL_BASE(obj) \
+    OBJECT_CHECK(AccelState, (obj), TYPE_ACCEL_BASE)
+#define ACCEL_BASE_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL_BASE)
 
 AccelClass *accel_find(const char *opt_name);
 AccelState *current_accel(void);
diff --git a/accel/accel-common.c b/accel/accel-common.c
index 7b8ec7e0f72..c4e268c8a74 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -34,7 +34,7 @@
 #endif /* !CONFIG_USER_ONLY */
 
 static const TypeInfo accel_type = {
-    .name = TYPE_ACCEL,
+    .name = TYPE_ACCEL_BASE,
     .parent = TYPE_OBJECT,
     .class_size = sizeof(AccelClass),
     .instance_size = sizeof(AccelState),
@@ -44,7 +44,7 @@ static const TypeInfo accel_type = {
 AccelClass *accel_find(const char *opt_name)
 {
     char *class_name = g_strdup_printf(ACCEL_CLASS_NAME("%s"), opt_name);
-    AccelClass *ac = ACCEL_CLASS(module_object_class_by_name(class_name));
+    AccelClass *ac = ACCEL_BASE_CLASS(module_object_class_by_name(class_name));
     g_free(class_name);
     return ac;
 }
diff --git a/accel/accel-softmmu.c b/accel/accel-softmmu.c
index 67276e4f522..792bdc44940 100644
--- a/accel/accel-softmmu.c
+++ b/accel/accel-softmmu.c
@@ -32,7 +32,7 @@
 
 int accel_init_machine(AccelState *accel, MachineState *ms)
 {
-    AccelClass *acc = ACCEL_GET_CLASS(accel);
+    AccelClass *acc = ACCEL_BASE_GET_CLASS(accel);
     int ret;
     ms->accelerator = accel;
     *(acc->allowed) = true;
@@ -55,7 +55,7 @@ AccelState *current_accel(void)
 void accel_setup_post(MachineState *ms)
 {
     AccelState *accel = ms->accelerator;
-    AccelClass *acc = ACCEL_GET_CLASS(accel);
+    AccelClass *acc = ACCEL_BASE_GET_CLASS(accel);
     if (acc->setup_post) {
         acc->setup_post(ms, accel);
     }
diff --git a/accel/accel-user.c b/accel/accel-user.c
index 22b6a1a1a89..492480847e5 100644
--- a/accel/accel-user.c
+++ b/accel/accel-user.c
@@ -18,7 +18,7 @@ AccelState *current_accel(void)
         AccelClass *ac = accel_find("tcg");
 
         g_assert(ac != NULL);
-        accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac)));
+        accel = ACCEL_BASE(object_new_with_class(OBJECT_CLASS(ac)));
     }
     return accel;
 }
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index d1691be9896..af09bfd1acb 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -329,7 +329,7 @@ static int hvf_accel_init(MachineState *ms)
 
 static void hvf_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     ac->name = "HVF";
     ac->init_machine = hvf_accel_init;
     ac->allowed = &hvf_allowed;
@@ -337,7 +337,7 @@ static void hvf_accel_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo hvf_accel_type = {
     .name = TYPE_HVF_ACCEL,
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .class_init = hvf_accel_class_init,
 };
 
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 0125c17edb8..381ba59a970 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -3618,7 +3618,7 @@ static void kvm_accel_instance_init(Object *obj)
 
 static void kvm_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     ac->name = "KVM";
     ac->init_machine = kvm_init;
     ac->has_memory = kvm_accel_has_memory;
@@ -3645,7 +3645,7 @@ static void kvm_accel_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo kvm_accel_type = {
     .name = TYPE_KVM_ACCEL,
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .instance_init = kvm_accel_instance_init,
     .class_init = kvm_accel_class_init,
     .instance_size = sizeof(KVMState),
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 7e6b8110d52..10b9b56b0e5 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -32,7 +32,7 @@ static int qtest_init_accel(MachineState *ms)
 
 static void qtest_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     ac->name = "QTest";
     ac->init_machine = qtest_init_accel;
     ac->allowed = &qtest_allowed;
@@ -42,7 +42,7 @@ static void qtest_accel_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo qtest_accel_type = {
     .name = TYPE_QTEST_ACCEL,
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .class_init = qtest_accel_class_init,
 };
 module_obj(TYPE_QTEST_ACCEL);
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index d6336a9c966..c0812e5dfd6 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -210,7 +210,7 @@ static void tcg_set_splitwx(Object *obj, bool value, Error **errp)
 
 static void tcg_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     ac->name = "tcg";
     ac->init_machine = tcg_init_machine;
     ac->allowed = &tcg_allowed;
@@ -233,7 +233,7 @@ static void tcg_accel_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo tcg_accel_type = {
     .name = TYPE_TCG_ACCEL,
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .instance_init = tcg_accel_instance_init,
     .class_init = tcg_accel_class_init,
     .instance_size = sizeof(TCGState),
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index 69aa7d018b2..42b83f35d8c 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -186,7 +186,7 @@ static int xen_init(MachineState *ms)
 
 static void xen_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     static GlobalProperty compat[] = {
         { "migration", "store-global-state", "off" },
         { "migration", "send-configuration", "off" },
@@ -211,7 +211,7 @@ static void xen_accel_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo xen_accel_type = {
     .name = TYPE_XEN_ACCEL,
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .class_init = xen_accel_class_init,
 };
 
diff --git a/bsd-user/main.c b/bsd-user/main.c
index fe66204b6b7..f26eefd3b39 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -793,7 +793,7 @@ int main(int argc, char **argv)
     cpu_type = parse_cpu_option(cpu_model);
     /* init tcg before creating CPUs and to get qemu_host_page_size */
     {
-        AccelClass *ac = ACCEL_GET_CLASS(current_accel());
+        AccelClass *ac = ACCEL_BASE_GET_CLASS(current_accel());
 
         accel_init_interfaces(ac);
         ac->init_machine(NULL);
diff --git a/linux-user/main.c b/linux-user/main.c
index 37ed50d98e2..d9dd14e07bc 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -723,7 +723,7 @@ int main(int argc, char **argv, char **envp)
 
     /* init tcg before creating CPUs and to get qemu_host_page_size */
     {
-        AccelClass *ac = ACCEL_GET_CLASS(current_accel());
+        AccelClass *ac = ACCEL_BASE_GET_CLASS(current_accel());
 
         accel_init_interfaces(ac);
         ac->init_machine(NULL);
diff --git a/softmmu/memory.c b/softmmu/memory.c
index bfedaf9c4df..a24fa8c0475 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -3261,7 +3261,7 @@ void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabled)
         };
         GArray *fv_address_spaces;
         GHashTable *views = g_hash_table_new(g_direct_hash, g_direct_equal);
-        AccelClass *ac = ACCEL_GET_CLASS(current_accel());
+        AccelClass *ac = ACCEL_BASE_GET_CLASS(current_accel());
 
         if (ac->has_memory) {
             fvi.ac = ac;
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 5ca11e74694..b7a20da366b 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2305,7 +2305,7 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
         }
         return 0;
     }
-    accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac)));
+    accel = ACCEL_BASE(object_new_with_class(OBJECT_CLASS(ac)));
     object_apply_compat_props(OBJECT(accel));
     qemu_opt_foreach(opts, accelerator_set_property,
                      accel,
@@ -2386,7 +2386,7 @@ static void configure_accelerators(const char *progname)
     }
 
     if (init_failed && !qtest_chrdev) {
-        AccelClass *ac = ACCEL_GET_CLASS(current_accel());
+        AccelClass *ac = ACCEL_BASE_GET_CLASS(current_accel());
         error_report("falling back to %s", ac->name);
     }
 
@@ -3315,7 +3315,7 @@ void qemu_init(int argc, char **argv, char **envp)
                 optarg = qemu_opt_get(accel_opts, "accel");
                 if (!optarg || is_help_option(optarg)) {
                     printf("Accelerators supported in QEMU binary:\n");
-                    GSList *el, *accel_list = object_class_get_list(TYPE_ACCEL,
+                    GSList *el, *accel_list = object_class_get_list(TYPE_ACCEL_BASE,
                                                                     false);
                     for (el = accel_list; el; el = el->next) {
                         gchar *typename = g_strdup(object_class_get_name(
diff --git a/target/i386/hax/hax-all.c b/target/i386/hax/hax-all.c
index bf65ed6fa92..37d18d7ea98 100644
--- a/target/i386/hax/hax-all.c
+++ b/target/i386/hax/hax-all.c
@@ -1120,7 +1120,7 @@ void hax_reset_vcpu_state(void *opaque)
 
 static void hax_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     ac->name = "HAX";
     ac->init_machine = hax_accel_init;
     ac->allowed = &hax_allowed;
@@ -1128,7 +1128,7 @@ static void hax_accel_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo hax_accel_type = {
     .name = ACCEL_CLASS_NAME("hax"),
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .class_init = hax_accel_class_init,
 };
 
diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c
index dfa690d65da..be66baa9d2f 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -1205,7 +1205,7 @@ nvmm_enabled(void)
 static void
 nvmm_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     ac->name = "NVMM";
     ac->init_machine = nvmm_accel_init;
     ac->allowed = &nvmm_allowed;
@@ -1213,7 +1213,7 @@ nvmm_accel_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo nvmm_accel_type = {
     .name = ACCEL_CLASS_NAME("nvmm"),
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .class_init = nvmm_accel_class_init,
 };
 
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index f832f286ac3..5cf77f916c1 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -1873,7 +1873,7 @@ bool whpx_apic_in_platform(void) {
 
 static void whpx_accel_class_init(ObjectClass *oc, void *data)
 {
-    AccelClass *ac = ACCEL_CLASS(oc);
+    AccelClass *ac = ACCEL_BASE_CLASS(oc);
     ac->name = "WHPX";
     ac->init_machine = whpx_accel_init;
     ac->allowed = &whpx_allowed;
@@ -1896,7 +1896,7 @@ static void whpx_accel_instance_init(Object *obj)
 
 static const TypeInfo whpx_accel_type = {
     .name = ACCEL_CLASS_NAME("whpx"),
-    .parent = TYPE_ACCEL,
+    .parent = TYPE_ACCEL_BASE,
     .instance_init = whpx_accel_instance_init,
     .class_init = whpx_accel_class_init,
 };
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 02/12] qom: Use DEVICE_*CLASS instead of OBJECT_*CLASS
  2021-08-06 21:11 [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Eduardo Habkost
  2021-08-06 21:11   ` Eduardo Habkost
@ 2021-08-06 21:11 ` Eduardo Habkost
  2021-08-07  8:17   ` Philippe Mathieu-Daudé
  2021-08-10 11:56   ` Juan Quintela
  2021-08-06 21:11 ` [PATCH for-6.2 03/12] scripts/codeconverter: Update to latest version Eduardo Habkost
                   ` (10 subsequent siblings)
  12 siblings, 2 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrange, Juan Quintela, Michael S. Tsirkin,
	Dr. David Alan Gilbert, Markus Armbruster, Gerd Hoffmann,
	Paolo Bonzini

There are multiple functions where OBJECT_GET_CLASS or
OBJECT_CLASS_CHECK are being used directly for
DeviceClass/TYPE_DEVICE, instead of the DEVICE_GET_CLASS or
DEVICE_CLASS wrappers.  There's no reason to not use the
wrappers, so use them.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Juan Quintela <quintela@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org
---
 hw/pci/pci.c           | 3 +--
 hw/usb/hcd-ehci-pci.c  | 2 +-
 migration/savevm.c     | 3 +--
 monitor/misc.c         | 3 +--
 softmmu/qdev-monitor.c | 3 +--
 5 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 23d2ae2ab23..9af32ef4cb8 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1915,8 +1915,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
     list = object_class_get_list_sorted(TYPE_PCI_DEVICE, false);
     pci_nic_models = g_ptr_array_new();
     while (list) {
-        DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, list->data,
-                                             TYPE_DEVICE);
+        DeviceClass *dc = DEVICE_CLASS(list->data);
         GSList *next;
         if (test_bit(DEVICE_CATEGORY_NETWORK, dc->categories) &&
             dc->user_creatable) {
diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
index 4c37c8e2271..345444a5739 100644
--- a/hw/usb/hcd-ehci-pci.c
+++ b/hw/usb/hcd-ehci-pci.c
@@ -74,7 +74,7 @@ static void usb_ehci_pci_realize(PCIDevice *dev, Error **errp)
 
 static void usb_ehci_pci_init(Object *obj)
 {
-    DeviceClass *dc = OBJECT_GET_CLASS(DeviceClass, obj, TYPE_DEVICE);
+    DeviceClass *dc = DEVICE_GET_CLASS(obj);
     EHCIPCIState *i = PCI_EHCI(obj);
     EHCIState *s = &i->ehci;
 
diff --git a/migration/savevm.c b/migration/savevm.c
index 7b7b64bd13e..23cc55b8533 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -663,8 +663,7 @@ void dump_vmstate_json_to_file(FILE *out_file)
     first = true;
     list = object_class_get_list(TYPE_DEVICE, true);
     for (elt = list; elt; elt = elt->next) {
-        DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data,
-                                             TYPE_DEVICE);
+        DeviceClass *dc = DEVICE_CLASS(elt->data);
         const char *name;
         int indent = 2;
 
diff --git a/monitor/misc.c b/monitor/misc.c
index ffe79668706..98202d12e7f 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -1549,8 +1549,7 @@ void device_add_completion(ReadLineState *rs, int nb_args, const char *str)
     list = elt = object_class_get_list(TYPE_DEVICE, false);
     while (elt) {
         const char *name;
-        DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data,
-                                             TYPE_DEVICE);
+        DeviceClass *dc = DEVICE_CLASS(elt->data);
         name = object_class_get_name(OBJECT_CLASS(dc));
 
         if (dc->user_creatable
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index 721dec2d820..82d164c6539 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -165,8 +165,7 @@ static void qdev_print_devinfos(bool show_no_user)
     for (i = 0; i <= DEVICE_CATEGORY_MAX; i++) {
         cat_printed = false;
         for (elt = list; elt; elt = elt->next) {
-            DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data,
-                                                 TYPE_DEVICE);
+            DeviceClass *dc = DEVICE_CLASS(elt->data);
             if ((i < DEVICE_CATEGORY_MAX
                  ? !test_bit(i, dc->categories)
                  : !bitmap_empty(dc->categories, DEVICE_CATEGORY_MAX))
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 03/12] scripts/codeconverter: Update to latest version
  2021-08-06 21:11 [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Eduardo Habkost
  2021-08-06 21:11   ` Eduardo Habkost
  2021-08-06 21:11 ` [PATCH for-6.2 02/12] qom: Use DEVICE_*CLASS instead of OBJECT_*CLASS Eduardo Habkost
@ 2021-08-06 21:11 ` Eduardo Habkost
  2021-08-06 21:11   ` Eduardo Habkost
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Daniel P. Berrange

I'm not documenting every single change in the codeconverter
script because most of that code will be deleted once we finish
the QOM code conversion.  This patch updates the script to the
latest version that was used to perform changes in the QOM code.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 .../codeconverter/codeconverter/patching.py   |  18 +-
 .../codeconverter/codeconverter/qom_macros.py | 187 +++++++++++--
 .../codeconverter/qom_type_info.py            | 247 +++++++++++++++++-
 .../codeconverter/codeconverter/regexps.py    |   3 +-
 4 files changed, 405 insertions(+), 50 deletions(-)

diff --git a/scripts/codeconverter/codeconverter/patching.py b/scripts/codeconverter/codeconverter/patching.py
index 9e92505d394..b4f0029f17e 100644
--- a/scripts/codeconverter/codeconverter/patching.py
+++ b/scripts/codeconverter/codeconverter/patching.py
@@ -59,11 +59,11 @@ def name(self) -> str:
     def compiled_re(klass):
         return re.compile(klass.regexp, re.MULTILINE)
 
-    def start(self) -> int:
-        return self.match.start()
+    def start(self, *args) -> int:
+        return self.match.start(*args)
 
-    def end(self) -> int:
-        return self.match.end()
+    def end(self, *args) -> int:
+        return self.match.end(*args)
 
     def line_col(self) -> LineAndColumn:
         return self.file.line_col(self.start())
@@ -114,9 +114,6 @@ def make_patch(self, replacement: str) -> 'Patch':
         """Make patch replacing the content of this match"""
         return Patch(self.start(), self.end(), replacement)
 
-    def make_subpatch(self, start: int, end: int, replacement: str) -> 'Patch':
-        return Patch(self.start() + start, self.start() + end, replacement)
-
     def make_removal_patch(self) -> 'Patch':
         """Make patch removing contents of match completely"""
         return self.make_patch('')
@@ -377,8 +374,8 @@ def scan_for_matches(self, class_names: Optional[List[str]]=None) -> Iterable[Fi
         DBG("class_names: %r", class_names)
         for cn in class_names:
             matches = self.matches_of_type(class_dict[cn])
-            DBG('%d matches found for %s: %s',
-                    len(matches), cn, ' '.join(names(matches)))
+            INFO('%d matches found for %s: %s',
+                 len(matches), cn, ' '.join(names(matches)))
             yield from matches
 
     def apply_patches(self) -> None:
@@ -407,9 +404,6 @@ def show_diff(self) -> None:
             f.flush()
             subprocess.call(['diff', '-u', self.filename, f.name])
 
-    def ref(self):
-        return TypeInfoReference
-
 class FileList(RegexpScanner):
     def __init__(self):
         super().__init__()
diff --git a/scripts/codeconverter/codeconverter/qom_macros.py b/scripts/codeconverter/codeconverter/qom_macros.py
index 2d2f2055a3d..61570620bd8 100644
--- a/scripts/codeconverter/codeconverter/qom_macros.py
+++ b/scripts/codeconverter/codeconverter/qom_macros.py
@@ -112,7 +112,9 @@ class SimpleTypedefMatch(TypedefMatch):
 
 # This doesn't parse the struct definitions completely, it just assumes
 # the closing brackets are going to be in an unindented line:
-RE_FULL_STRUCT = S('struct', SP, M(RE_IDENTIFIER, n='?', name='structname'), SP,
+RE_FULL_STRUCT = S(NAMED('structtype',
+                         'struct', M(SP, NAMED('structname', RE_IDENTIFIER), n='?')),
+                   SP,
                    NAMED('body', r'{\n',
                          # acceptable inside the struct body:
                          # - lines starting with space or tab
@@ -165,6 +167,10 @@ def split_typedef(self) -> Iterator[Patch]:
         yield self.strip_typedef()
         yield self.append(self.make_simple_typedef())
 
+    def add_struct_name(self, structname: str) -> Iterator[Patch]:
+        yield Patch(self.start('structtype'), self.end('structtype'),
+                                 f'struct {structname}')
+
 class StructTypedefSplit(FullStructTypedefMatch):
     """split struct+typedef declaration"""
     def gen_patches(self) -> Iterator[Patch]:
@@ -191,32 +197,42 @@ def gen_patches(self) -> Iterable[Patch]:
                 if self.group('typedef_type') == 'struct '+td.group('structname'):
                     yield td.strip_typedef()
 
+def typedef_used_by_qom(files: FileList, typedef_name: str) -> bool:
+    qom_macros = [TypeCheckMacro, DeclareInstanceChecker, DeclareInterfaceChecker, DeclareClassCheckers, DeclareObjCheckers, DeclareInterfaceCheckers]
+    qom_matches = chain(*(files.matches_of_type(t) for t in qom_macros))
+    in_use = any(RequiredIdentifier('type', typedef_name) in m.required_identifiers()
+                 for m in qom_matches)
+    return in_use
+
 class QOMDuplicatedTypedefs(DuplicatedTypedefs):
     """Delete duplicate typedefs if used by QOM type"""
     def gen_patches(self) -> Iterable[Patch]:
-        qom_macros = [TypeCheckMacro, DeclareInstanceChecker, DeclareClassCheckers, DeclareObjCheckers]
-        qom_matches = chain(*(self.file.matches_of_type(t) for t in qom_macros))
-        in_use = any(RequiredIdentifier('type', self.name) in m.required_identifiers()
-                     for m in qom_matches)
-        if in_use:
+        if typedef_used_by_qom(self.allfiles, self.name):
             yield from DuplicatedTypedefs.gen_patches(self)
 
 class QOMStructTypedefSplit(FullStructTypedefMatch):
     """split struct+typedef declaration if used by QOM type"""
     def gen_patches(self) -> Iterator[Patch]:
-        qom_macros = [TypeCheckMacro, DeclareInstanceChecker, DeclareClassCheckers, DeclareObjCheckers]
-        qom_matches = chain(*(self.file.matches_of_type(t) for t in qom_macros))
-        in_use = any(RequiredIdentifier('type', self.name) in m.required_identifiers()
-                     for m in qom_matches)
-        if in_use:
+        if typedef_used_by_qom(self.allfiles, self.name):
             yield from self.split_typedef()
 
-def typedefs(file: FileInfo) -> Iterable[TypedefMatch]:
-    return (cast(TypedefMatch, m)
-            for m in chain(file.matches_of_type(SimpleTypedefMatch),
-                           file.matches_of_type(FullStructTypedefMatch)))
+class AddNamesToTypedefs(FullStructTypedefMatch):
+    """Add struct names to typedef declaration if used by QOM type"""
+    def gen_patches(self) -> Iterable['Patch']:
+        if self.group('structname'):
+            return
+
+        if not typedef_used_by_qom(self.allfiles, self.name):
+            return
+
+        yield from self.add_struct_name(self.make_structname())
+
+
+def typedefs(file: RegexpScanner) -> Iterable[TypedefMatch]:
+    return chain(file.matches_of_type(SimpleTypedefMatch),
+                 file.matches_of_type(FullStructTypedefMatch))
 
-def find_typedef(f: FileInfo, name: Optional[str]) -> Optional[TypedefMatch]:
+def find_typedef(f: RegexpScanner, name: Optional[str]) -> Optional[TypedefMatch]:
     if not name:
         return None
     for td in typedefs(f):
@@ -280,6 +296,17 @@ def find_matching_macros(self) -> List['TypeCheckMacro']:
                    and (my_ids.uppercase == m.type_identifiers.uppercase
                         or my_ids.typename == m.type_identifiers.typename)]
 
+    def find_conflicting_declarations(self) -> List['TypeCheckerDeclaration']:
+        """Find declarations that conflict with this one"""
+        my_ids = self.type_identifiers
+        assert my_ids
+        uppercase = my_ids.uppercase
+        if uppercase is None:
+            return []
+        matching = list(self.find_matching_macros())
+        other = list(find_type_checkers(self.allfiles, uppercase))
+        return list(o for o in other if not any(m for m in matching if m == o))
+
     def merge_ids(self, matches: List['TypeCheckMacro']) -> Optional[TypeIdentifiers]:
         """Try to merge info about type identifiers from all matches in a list"""
         if not matches:
@@ -361,6 +388,12 @@ def gen_patches(self) -> Iterable[Patch]:
             DBG("skipping %s (will patch when handling %s)", self.name, matches[0].name)
             return
 
+        conflicting = self.find_conflicting_declarations()
+        if conflicting:
+            self.warn("macro %s has conflicting declarations", self.name)
+            for c in conflicting:
+                c.warn("conflict here")
+            return
 
         ids = self.merge_ids(matches)
         if ids is None:
@@ -418,7 +451,11 @@ def gen_patches(self) -> Iterable[Patch]:
                     self.info("typedef %s found in typedefs.h", t)
                     continue
 
-                issues.append("couldn't find typedef %s" % (t))
+                td = find_typedef(self.allfiles, t)
+                if td:
+                    issues.append("typedef %s is defined in another file (%s)" % (t, td.file.filename))
+                else:
+                    issues.append("couldn't find typedef %s" % (t))
             elif td.start() > self.start():
                 issues.append("typedef %s need to be moved earlier in the file" % (td.name))
 
@@ -441,7 +478,7 @@ class InterfaceCheckMacro(FileMatch):
     """
     regexp = S(RE_MACRO_DEFINE,
                'INTERFACE_CHECK',
-               r'\s*\(\s*', OR(NAMED('instancetype', RE_IDENTIFIER), RE_TYPE, name='c_type'),
+               r'\s*\(\s*', NAMED('instancetype', RE_IDENTIFIER),
                r'\s*,', CPP_SPACE,
                OPTIONAL_PARS(RE_IDENTIFIER), r',', CPP_SPACE,
                NAMED('qom_typename', RE_IDENTIFIER), r'\s*\)\n')
@@ -571,6 +608,21 @@ def required_identifiers(self) -> Iterable[RequiredIdentifier]:
         yield RequiredIdentifier('type', self.group('classtype'))
         yield RequiredIdentifier('type', self.group('instancetype'))
 
+class DeclareInterfaceCheckers(TypeCheckerDeclaration):
+    """DECLARE_INTERFACE_CHECKERS use"""
+    regexp = S(r'^[ \t]*DECLARE_INTERFACE_CHECKERS\s*\(\s*',
+               NAMED('instancetype', RE_TYPE), r'\s*,\s*',
+               NAMED('classtype', RE_TYPE), r'\s*,\s*',
+               NAMED('uppercase', RE_IDENTIFIER), r'\s*,\s*',
+               OR(RE_IDENTIFIER, RE_STRING, RE_MACRO_CONCAT, RE_FUN_CALL, name='typename'), SP,
+               r'\)[ \t]*;?[ \t]*\n')
+
+    def required_identifiers(self) -> Iterable[RequiredIdentifier]:
+        yield RequiredIdentifier('include', '"qom/object.h"')
+        yield RequiredIdentifier('constant', self.group('typename'))
+        yield RequiredIdentifier('type', self.group('classtype'))
+        yield RequiredIdentifier('type', self.group('instancetype'))
+
 class TypeDeclarationFixup(FileMatch):
     """Common base class for code that will look at a set of type declarations"""
     regexp = RE_FILE_BEGIN
@@ -581,8 +633,9 @@ def gen_patches(self) -> Iterable[Patch]:
 
         # group checkers by uppercase name:
         decl_types: List[Type[TypeDeclaration]] = [DeclareInstanceChecker, DeclareInstanceType,
+                                                   DeclareInterfaceChecker,
                                                    DeclareClassCheckers, DeclareClassType,
-                                                   DeclareObjCheckers]
+                                                   DeclareObjCheckers, DeclareInterfaceCheckers]
         checker_dict: Dict[str, List[TypeDeclaration]] = {}
         for t in decl_types:
             for m in self.file.matches_of_type(t):
@@ -607,19 +660,19 @@ def find_conflicts(self, uppercase: str, checkers: List[TypeDeclaration]) -> boo
         conflicting: List[FileMatch] = []
         # conflicts in the same file:
         conflicting.extend(chain(self.file.find_matches(DefineDirective, uppercase),
-                                 self.file.find_matches(DeclareInterfaceChecker, uppercase, 'uppercase'),
                                  self.file.find_matches(DeclareClassType, uppercase, 'uppercase'),
                                  self.file.find_matches(DeclareInstanceType, uppercase, 'uppercase')))
 
         # conflicts in another file:
         conflicting.extend(o for o in chain(self.allfiles.find_matches(DeclareInstanceChecker, uppercase, 'uppercase'),
+                                            self.allfiles.find_matches(DeclareInterfaceChecker, uppercase, 'uppercase'),
                                             self.allfiles.find_matches(DeclareClassCheckers, uppercase, 'uppercase'),
                                             self.allfiles.find_matches(DeclareInterfaceChecker, uppercase, 'uppercase'),
                                             self.allfiles.find_matches(DefineDirective, uppercase))
-                           if o is not None and o.file != self.file
+                           if o is not None and o.file.filename != self.file.filename
                                # if both are .c files, there's no conflict at all:
                                and not (o.file.filename.suffix == '.c' and
-                                       self.file.filename.suffix == '.c'))
+                                        self.file.filename.suffix == '.c'))
 
         if conflicting:
             for c in checkers:
@@ -667,6 +720,84 @@ def gen_patches_for_type(self, uppercase: str,
         #    yield c.make_removal_patch()
         #yield last_checker.append(s)
 
+class AddDeclareObjCheckers(TypeDeclarationFixup):
+    """Replace DECLARE_INSTANCE_CHECKER/DECLARE_CLASS_CHECKERS with DECLARE_OBJ_CHECKERS"""
+    regexp = RE_FILE_BEGIN
+    def gen_patches_for_type(self, uppercase: str,
+                             checkers: List[TypeDeclaration],
+                             fields: Dict[str, Optional[str]]) -> Iterable[Patch]:
+        if self.find_conflicts(uppercase, checkers):
+            return
+
+        if not fields.get('instancetype') or not fields.get('classtype'):
+            self.info("skipping %s", uppercase)
+            return
+
+        if any(isinstance(c, DeclareObjCheckers) for c in checkers):
+            self.info("DECLARE_OBJ_CHECKERS already in use for %s", uppercase)
+            return
+
+        _,first_checker = min((m.start(), m) for m in checkers)
+        _,last_checker = max((m.start(), m) for m in checkers)
+
+        assert self.file.original_content
+        macro_re = r'\b'+OR(uppercase, f'{uppercase}_CLASS', f'{uppercase}_GET_CLASS')+r'\b'
+        # make sure the macros are not used between the first declaration and the last one
+        if re.search(macro_re, self.file.original_content[first_checker.end():last_checker.start()]):
+            self.info("macro %s is used", uppercase)
+            return
+
+        for c in checkers:
+            if isinstance(c, DeclareClassCheckers):
+                yield c.make_removal_patch()
+            if isinstance(c, DeclareInstanceChecker):
+                yield c.make_removal_patch()
+
+        s = (f"DECLARE_OBJ_CHECKERS({fields['instancetype']}, {fields['classtype']},\n"+
+             f"                     {fields['uppercase']}, {fields['typename']})\n")
+        yield last_checker.append(s)
+
+
+class AddDeclareInterfaceCheckers(TypeDeclarationFixup):
+    """Replace DECLARE_INTERFACE_CHECKER/DECLARE_CLASS_CHECKERS with DECLARE_INTERFACE_CHECKERS"""
+    regexp = RE_FILE_BEGIN
+    def gen_patches_for_type(self, uppercase: str,
+                             checkers: List[TypeDeclaration],
+                             fields: Dict[str, Optional[str]]) -> Iterable[Patch]:
+        if not any(isinstance(c, DeclareInterfaceChecker) for c in checkers):
+            return
+
+        if self.find_conflicts(uppercase, checkers):
+            return
+
+        if not fields.get('instancetype') or not fields.get('classtype'):
+            self.info("skipping %s", uppercase)
+            return
+
+        if any(isinstance(c, DeclareInterfaceCheckers) for c in checkers):
+            self.info("DECLARE_INTERFACE_CHECKERS already in use for %s", uppercase)
+            return
+
+        _,first_checker = min((m.start(), m) for m in checkers)
+        _,last_checker = max((m.start(), m) for m in checkers)
+
+        assert self.file.original_content
+        macro_re = r'\b'+OR(uppercase, f'{uppercase}_CLASS', f'{uppercase}_GET_CLASS')+r'\b'
+        # make sure the macros are not used between the first declaration and the last one
+        if re.search(macro_re, self.file.original_content[first_checker.end():last_checker.start()]):
+            self.info("macro %s is used", uppercase)
+            return
+
+        for c in checkers:
+            if isinstance(c, DeclareClassCheckers):
+                yield c.make_removal_patch()
+            if isinstance(c, DeclareInterfaceChecker):
+                yield c.make_removal_patch()
+
+        s = (f"DECLARE_INTERFACE_CHECKERS({fields['instancetype']}, {fields['classtype']},\n"+
+             f"                           {fields['uppercase']}, {fields['typename']})\n")
+        yield last_checker.append(s)
+
 
 class AddDeclareTypeName(TypeDeclarationFixup):
     """Add DECLARE_TYPE_NAME declarations if necessary"""
@@ -727,6 +858,14 @@ class ObjectDeclareSimpleType(TypeCheckerDeclaration):
                NAMED('uppercase', RE_IDENTIFIER), SP,
                r'\)[ \t]*;?[ \t]*\n')
 
+class ObjectDeclareInterfaceType(TypeCheckerDeclaration):
+    """OBJECT_DECLARE_INTERFACE_TYPE usage"""
+    regexp = S(r'^[ \t]*OBJECT_DECLARE_INTERFACE_TYPE\s*\(',
+               NAMED('instancetype', RE_TYPE), r'\s*,\s*',
+               NAMED('classtype', RE_TYPE), r'\s*,\s*',
+               NAMED('uppercase', RE_IDENTIFIER), SP,
+               r'\)[ \t]*;?[ \t]*\n')
+
 class OldStyleObjectDeclareSimpleType(TypeCheckerDeclaration):
     """OBJECT_DECLARE_SIMPLE_TYPE usage (old API)"""
     regexp = S(r'^[ \t]*OBJECT_DECLARE_SIMPLE_TYPE\s*\(',
@@ -754,7 +893,8 @@ def find_typename_uppercase(files: FileList, typename: str) -> Optional[str]:
 def find_type_checkers(files:FileList, name:str, group:str='uppercase') -> Iterable[TypeCheckerDeclaration]:
     """Find usage of DECLARE*CHECKER macro"""
     c: Type[TypeCheckerDeclaration]
-    for c in (DeclareInstanceChecker, DeclareClassCheckers, DeclareObjCheckers, ObjectDeclareType, ObjectDeclareSimpleType):
+    for c in (DeclareInstanceChecker, DeclareClassCheckers, DeclareObjCheckers,
+              ObjectDeclareType, ObjectDeclareSimpleType, ObjectDeclareInterfaceType):
         yield from files.find_matches(c, name=name, group=group)
 
 class Include(FileMatch):
@@ -853,7 +993,6 @@ def gen_patches(self) -> Iterator[Patch]:
                 definition.warn("definition of %s %s needs to be moved earlier in the file", i.type, i.name)
                 earliest.warn("definition of %s %s is used here", i.type, i.name)
 
-
 class EmptyPreprocessorConditional(FileMatch):
     """Delete empty preprocessor conditionals"""
     regexp = r'^[ \t]*#(if|ifdef)[ \t].*\n+[ \t]*#endif[ \t]*\n'
diff --git a/scripts/codeconverter/codeconverter/qom_type_info.py b/scripts/codeconverter/codeconverter/qom_type_info.py
index 255cb59923d..1c1834a2daa 100644
--- a/scripts/codeconverter/codeconverter/qom_type_info.py
+++ b/scripts/codeconverter/codeconverter/qom_type_info.py
@@ -12,7 +12,8 @@
 from .qom_macros import *
 
 TI_FIELDS = [ 'name', 'parent', 'abstract', 'interfaces',
-    'instance_size', 'instance_init', 'instance_post_init', 'instance_finalize',
+    'instance_size', 'instance_align',
+    'instance_init', 'instance_post_init', 'instance_finalize',
     'class_size', 'class_init', 'class_base_init', 'class_data']
 
 RE_TI_FIELD_NAME = OR(*TI_FIELDS)
@@ -78,7 +79,7 @@ def uppercase(self) -> Optional[str]:
         return self.group('uppercase')
 
     @property
-    def parent_uppercase(self) -> str:
+    def parent_uppercase(self) -> Optional[str]:
         return self.group('parent_uppercase')
 
     @property
@@ -86,11 +87,11 @@ def initializers(self) -> Optional[TypeInfoInitializers]:
         if getattr(self, '_inititalizers', None):
             self._initializers: TypeInfoInitializers
             return self._initializers
+        d = None
         fields = self.group('fields')
-        if fields is None:
-            return None
-        d = dict((fm.group('field'), fm)
-                  for fm in self.group_finditer(FieldInitializer, 'fields'))
+        if fields:
+            d = dict((fm.group('field'), fm)
+                      for fm in self.group_finditer(FieldInitializer, 'fields'))
         self._initializers = d # type: ignore
         return self._initializers
 
@@ -138,6 +139,15 @@ def uppercase(self) -> Optional[str]:
             return None
         return typename[len('TYPE_'):]
 
+    @property
+    def parent_uppercase(self) -> Optional[str]:
+        typename = self.get_raw_initializer_value('parent')
+        if not typename:
+            return None
+        if not typename.startswith('TYPE_'):
+            return None
+        return typename[len('TYPE_'):]
+
     @property
     def classtype(self) -> Optional[str]:
         class_size = self.get_raw_initializer_value('class_size')
@@ -343,6 +353,13 @@ def gen_patches(self) -> Iterable[Patch]:
 
         ok = True
 
+        if is_interface_type(self):
+            decl = self.allfiles.find_match(ObjectDeclareInterfaceType, uppercase, 'uppercase')
+            if decl:
+                instancetype = decl.instancetype
+            else:
+                self.warn("can't find OBJECT_DECLARE_INTERFACE_TYPE for interface type (%s)", uppercase)
+
         #checkers: List[TypeCheckerDeclaration] = list(find_type_checkers(self.allfiles, uppercase))
         #for c in checkers:
         #    c.info("instance type checker declaration (%s) is here", c.group('uppercase'))
@@ -449,9 +466,9 @@ class ObjectDefineType(TypeDefinition):
 
 def find_type_definitions(files: FileList, uppercase: str) -> Iterable[TypeDefinition]:
     types: List[Type[TypeDefinition]] = [TypeInfoVar, ObjectDefineType, ObjectDefineTypeExtended]
-    for t in types:
-        for m in files.matches_of_type(t):
-            m.debug("uppercase: %s", m.uppercase)
+    #for t in types:
+    #    for m in files.matches_of_type(t):
+    #        m.debug("uppercase: %s", m.uppercase)
     yield from (m for t in types
                   for m in files.matches_of_type(t)
                 if m.uppercase == uppercase)
@@ -554,7 +571,7 @@ def gen_patches(self) -> Iterable[Patch]:
             if not self.file.force:
                 return
 
-        decl_types: List[Type[TypeDeclaration]] = [DeclareClassCheckers, DeclareObjCheckers]
+        decl_types: List[Type[TypeDeclaration]] = [DeclareClassCheckers, DeclareObjCheckers, DeclareInterfaceCheckers]
         class_decls = [m for t in decl_types
                        for m in self.allfiles.find_matches(t, uppercase, 'uppercase')]
 
@@ -600,8 +617,90 @@ def gen_patches(self) -> Iterable[Patch]:
         c = (f'OBJECT_DECLARE_TYPE({instancetype}, {classtype}, {uppercase})\n')
         yield self.make_patch(c)
 
+class AddObjectDeclareInterface(DeclareInterfaceCheckers):
+    """Will add OBJECT_DECLARE_INTERFACE(...) if possible"""
+    def gen_patches(self) -> Iterable[Patch]:
+        uppercase = self.uppercase
+        typename = self.group('typename')
+        instancetype = self.group('instancetype')
+        classtype = self.group('classtype')
+
+        if typename != f'TYPE_{uppercase}':
+            self.warn("type name mismatch: %s vs %s", typename, uppercase)
+            return
+
+        typedefs = [(t,self.allfiles.find_matches(SimpleTypedefMatch, t))
+                    for t in (instancetype, classtype)]
+        for t,tds in typedefs:
+            if not tds:
+                self.warn("typedef %s not found", t)
+                return
+            for td in tds:
+                td_type = td.group('typedef_type')
+                if td_type != f'struct {t}':
+                    self.warn("typedef mismatch: %s is defined as %s", t, td_type)
+                    td.warn("typedef is here")
+                    return
+
+        # look for reuse of same struct type
+        other_instance_checkers = [c for c in find_type_checkers(self.allfiles, instancetype, 'instancetype')
+                                if c.uppercase != uppercase]
+        if other_instance_checkers:
+            self.warn("typedef %s is being reused", instancetype)
+            for ic in other_instance_checkers:
+                ic.warn("%s is reused here", instancetype)
+            if not self.file.force:
+                return
+
+        decl_types: List[Type[TypeDeclaration]] = [DeclareClassCheckers, DeclareObjCheckers, DeclareInterfaceCheckers]
+        class_decls = [m for t in decl_types
+                       for m in self.allfiles.find_matches(t, uppercase, 'uppercase')]
+
+        defs = list(find_type_definitions(self.allfiles, uppercase))
+        if len(defs) > 1:
+            self.warn("multiple definitions for %s", uppercase)
+            for d in defs:
+                d.warn("definition found here")
+            if not self.file.force:
+                return
+        elif len(defs) == 0:
+            self.warn("type definition for %s not found", uppercase)
+            if not self.file.force:
+                return
+        else:
+            d = defs[0]
+            if d.instancetype and d.instancetype != 'void':
+                self.warn("instance type shouldn't be set for interface type %s (%s)", uppercase, instancetype)
+                d.warn("instance type declared here (%s)", d.instancetype)
+                if not self.file.force:
+                    return
+            if d.classtype != classtype:
+                self.warn("mismatching class type for %s (%s)", uppercase, classtype)
+                d.warn("class type declared here (%s)", d.classtype)
+                if not self.file.force:
+                    return
+
+        assert self.file.original_content
+        for t,tds in typedefs:
+            assert tds
+            for td in tds:
+                if td.file is not self.file:
+                    continue
+
+                # delete typedefs that are truly redundant:
+                # 1) defined after DECLARE_INTERFACE_CHECKERS
+                if td.start() > self.start():
+                    yield td.make_removal_patch()
+                # 2) defined before DECLARE_INTERFACE_CHECKERS, but unused
+                elif not re.search(r'\b'+t+r'\b', self.file.original_content[td.end():self.start()]):
+                    yield td.make_removal_patch()
+
+        c = (f'OBJECT_DECLARE_INTERFACE({instancetype}, {classtype}, {uppercase})\n')
+        yield self.make_patch(c)
+
+
 class AddObjectDeclareSimpleType(DeclareInstanceChecker):
-    """Will add OBJECT_DECLARE_SIMPLE_TYPE(...) if possible"""
+    """Convert DECLARE_INSTANCE_CHECKER to OBJECT_DECLARE_SIMPLE_TYPE(...) if possible"""
     def gen_patches(self) -> Iterable[Patch]:
         uppercase = self.uppercase
         typename = self.group('typename')
@@ -634,7 +733,7 @@ def gen_patches(self) -> Iterable[Patch]:
             if not self.file.force:
                 return
 
-        decl_types: List[Type[TypeDeclaration]] = [DeclareClassCheckers, DeclareObjCheckers]
+        decl_types: List[Type[TypeDeclaration]] = [DeclareClassCheckers, DeclareObjCheckers, DeclareInterfaceCheckers]
         class_decls = [m for t in decl_types
                        for m in self.allfiles.find_matches(t, uppercase, 'uppercase')]
         if class_decls:
@@ -686,6 +785,104 @@ def gen_patches(self) -> Iterable[Patch]:
         yield self.make_patch(c)
 
 
+def is_interface_type(d: TypeDefinition) -> bool:
+    uppercase = d.uppercase
+    while True:
+        if not d.parent_uppercase:
+            return False
+        if d.parent_uppercase == 'INTERFACE':
+            return True
+        parents = list(find_type_definitions(d.allfiles, d.parent_uppercase))
+        if len(parents) != 1:
+            d.warn("type definition for %s (parent of %s) not found",
+                   d.parent_uppercase, uppercase)
+            for p in parents:
+                p.warn("multiple matches found for %s", d.parent_uppercase)
+            return False
+        d = parents[0]
+
+class AddObjectDeclareInterfaceType(DeclareInterfaceCheckers):
+    """Will add OBJECT_DECLARE_INTERFACE_TYPE(...) if possible"""
+    def gen_patches(self) -> Iterable[Patch]:
+        uppercase = self.uppercase
+        typename = self.group('typename')
+        instancetype = self.group('instancetype')
+        classtype = self.group('classtype')
+
+        if typename != f'TYPE_{uppercase}':
+            self.warn("type name mismatch: %s vs %s", typename, uppercase)
+            return
+
+        typedefs = [(t,self.allfiles.find_matches(SimpleTypedefMatch, t))
+                    for t in (instancetype, classtype)]
+        for t,tds in typedefs:
+            if not tds:
+                self.warn("typedef %s not found", t)
+                return
+            for td in tds:
+                td_type = td.group('typedef_type')
+                if td_type != f'struct {t}':
+                    self.warn("typedef mismatch: %s is defined as %s", t, td_type)
+                    td.warn("typedef is here")
+                    return
+
+        # look for reuse of same struct type, just for safety
+        other_instance_checkers = [c for c in find_type_checkers(self.allfiles, instancetype, 'instancetype')
+                                if c.uppercase != uppercase]
+        if other_instance_checkers:
+            self.warn("typedef %s is being reused", instancetype)
+            for ic in other_instance_checkers:
+                ic.warn("%s is reused here", instancetype)
+            if not self.file.force:
+                return
+
+        decl_types: List[Type[TypeDeclaration]] = [DeclareClassCheckers, DeclareObjCheckers]
+        class_decls = [m for t in decl_types
+                       for m in self.allfiles.find_matches(t, uppercase, 'uppercase')]
+
+        defs = list(find_type_definitions(self.allfiles, uppercase))
+        if len(defs) > 1:
+            self.warn("multiple definitions for %s", uppercase)
+            for d in defs:
+                d.warn("definition found here")
+            if not self.file.force:
+                return
+        elif len(defs) == 0:
+            self.warn("type definition for %s not found", uppercase)
+            if not self.file.force:
+                return
+        else:
+            d = defs[0]
+            if not is_interface_type(d):
+                self.info("%s is not declared as interface type")
+                return
+
+            if d.classtype != classtype:
+                self.warn("mismatching class type for %s (%s)", uppercase, classtype)
+                d.warn("class type declared here (%s)", d.classtype)
+                if not self.file.force:
+                    return
+
+        assert self.file.original_content
+        for t,tds in typedefs:
+            assert tds
+            for td in tds:
+                if td.file is not self.file:
+                    continue
+
+                # delete typedefs that are truly redundant:
+                # 1) defined after DECLARE_OBJ_CHECKERS
+                if td.start() > self.start():
+                    yield td.make_removal_patch()
+                # 2) defined before DECLARE_OBJ_CHECKERS, but unused
+                elif not re.search(r'\b'+t+r'\b', self.file.original_content[td.end():self.start()]):
+                    yield td.make_removal_patch()
+
+        c = (f'OBJECT_DECLARE_INTERFACE_TYPE({instancetype}, {classtype},\n'
+             f'                              {uppercase})\n')
+        yield self.make_patch(c)
+
+
 class TypeInfoStringName(TypeInfoVar):
     """Replace hardcoded type names with TYPE_ constant"""
     def gen_patches(self) -> Iterable[Patch]:
@@ -812,10 +1009,12 @@ class DeleteEmptyTypeInitFunc(TypeInitMacro):
     def gen_patches(self) -> Iterable[Patch]:
         fn = self.file.find_match(StaticVoidFunction, self.name)
         DBG("function for %s: %s", self.name, fn)
-        if fn and fn.body == '':
+        if fn and fn.is_empty():
             yield fn.make_patch('')
             yield self.make_patch('')
 
+RE_EMPTY_LINES = r'(\s*\n)*'
+
 class StaticVoidFunction(FileMatch):
     """simple static void function
     (no replacement rules)
@@ -839,6 +1038,9 @@ class StaticVoidFunction(FileMatch):
     def body(self) -> str:
         return self.group('body')
 
+    def is_empty(self) -> bool:
+        return bool(re.fullmatch(RE_EMPTY_LINES, self.body, re.MULTILINE))
+
     def has_preprocessor_directive(self) -> bool:
         return bool(re.search(r'^[ \t]*#', self.body, re.MULTILINE))
 
@@ -959,6 +1161,25 @@ def gen_patches(self) -> Iterable[Patch]:
         #     f'                           MODULE_OBJ_NAME, ParentClassType)\n')
         #yield self.make_patch(c)
 
+class SetInstanceSizeInterfaces(TypeInfoVar):
+    """Set instance type for interface TypeInfo variables"""
+    def gen_patches(self) -> Iterable[Patch]:
+        if not is_interface_type(self):
+            return
+        if 'instance_size' in self.get_initializers():
+            return
+
+        uppercase = self.uppercase
+        if not uppercase:
+            self.info("no uppercase name")
+            return
+
+        decl = self.allfiles.find_match(ObjectDeclareInterfaceType, uppercase, 'uppercase')
+        if not decl:
+            self.warn("can't find OBJECT_DECLARE_INTERFACE_TYPE for interface type (%s)", uppercase)
+            return
+        yield self.append_field('instance_size', f'sizeof({decl.instancetype})')
+
 def type_infos(file: FileInfo) -> Iterable[TypeInfoVar]:
     return file.matches_of_type(TypeInfoVar)
 
diff --git a/scripts/codeconverter/codeconverter/regexps.py b/scripts/codeconverter/codeconverter/regexps.py
index 77993cc3b97..25af23fe9f9 100644
--- a/scripts/codeconverter/codeconverter/regexps.py
+++ b/scripts/codeconverter/codeconverter/regexps.py
@@ -101,6 +101,7 @@ def test_optional_pars():
 
 RE_FUN_CALL = S(RE_IDENTIFIER, r'\s*\(\s*', RE_SIMPLE_VALUE, r'\s*\)')
 RE_SIZEOF = S(r'sizeof\s*\(\s*', NAMED('sizeoftype', RE_TYPE), r'\s*\)')
+RE_ALIGNOF = S(r'__alignof__\s*\(\s*', NAMED('alignoftype', RE_TYPE), r'\s*\)')
 
 RE_ADDRESS = S(r'&\s*', RE_IDENTIFIER)
 
@@ -113,6 +114,6 @@ def test_optional_pars():
 
 # NOTE: this covers a very small subset of valid expressions
 
-RE_EXPRESSION = OR(RE_SIZEOF, RE_FUN_CALL, RE_MACRO_CONCAT, RE_SIMPLE_VALUE,
+RE_EXPRESSION = OR(RE_SIZEOF, RE_ALIGNOF, RE_FUN_CALL, RE_MACRO_CONCAT, RE_SIMPLE_VALUE,
                    RE_ARRAY, RE_ADDRESS)
 
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 04/12] [automated] Add struct names to typedefs used by QOM types
  2021-08-06 21:11 [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Eduardo Habkost
@ 2021-08-06 21:11   ` Eduardo Habkost
  2021-08-06 21:11 ` [PATCH for-6.2 02/12] qom: Use DEVICE_*CLASS instead of OBJECT_*CLASS Eduardo Habkost
                     ` (11 subsequent siblings)
  12 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrange, qemu-riscv, Thomas Huth, Bastian Koppelmann,
	Havard Skinnemoen, Tyrone Ting, qemu-arm, Marc-André Lureau,
	Vijai Kumar K, Paolo Bonzini

Anonymous structs on QOM typedefs make the code harder to convert
to OBJECT_DEFINE* macros, as the macros expect the struct name to
exist.

Use a codeconverter rule to automatically add names to the
structs used in QOM typedefs.

Generated using:

 $ ./scripts/codeconverter/converter.py -i \
   --pattern=AddNamesToTypedefs $(git grep -l '' -- '*.[ch]')

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Thomas Huth <huth@tuxfamily.org>
Cc: Havard Skinnemoen <hskinnemoen@google.com>
Cc: Tyrone Ting <kfting@nuvoton.com>
Cc: Vijai Kumar K <vijai@behindbytes.com>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org
Cc: qemu-riscv@nongnu.org
---
 include/hw/adc/npcm7xx_adc.h            | 2 +-
 include/hw/char/shakti_uart.h           | 2 +-
 include/hw/tricore/tricore_testdevice.h | 2 +-
 chardev/char-parallel.c                 | 4 ++--
 hw/m68k/mcf5206.c                       | 2 +-
 hw/misc/sbsa_ec.c                       | 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/hw/adc/npcm7xx_adc.h b/include/hw/adc/npcm7xx_adc.h
index 7d8442107ae..8e5a1897b4b 100644
--- a/include/hw/adc/npcm7xx_adc.h
+++ b/include/hw/adc/npcm7xx_adc.h
@@ -42,7 +42,7 @@
  * @iref: The internal reference voltage, initialized at launch time.
  * @rv: The calibrated output values of 0.5V and 1.5V for the ADC.
  */
-typedef struct {
+typedef struct NPCM7xxADCState {
     SysBusDevice parent;
 
     MemoryRegion iomem;
diff --git a/include/hw/char/shakti_uart.h b/include/hw/char/shakti_uart.h
index 526c408233f..25f7cbcaa55 100644
--- a/include/hw/char/shakti_uart.h
+++ b/include/hw/char/shakti_uart.h
@@ -51,7 +51,7 @@
 #define SHAKTI_UART(obj) \
     OBJECT_CHECK(ShaktiUartState, (obj), TYPE_SHAKTI_UART)
 
-typedef struct {
+typedef struct ShaktiUartState {
     /* <private> */
     SysBusDevice parent_obj;
 
diff --git a/include/hw/tricore/tricore_testdevice.h b/include/hw/tricore/tricore_testdevice.h
index 2c56c51bcb8..e93c883872d 100644
--- a/include/hw/tricore/tricore_testdevice.h
+++ b/include/hw/tricore/tricore_testdevice.h
@@ -26,7 +26,7 @@
 #define TRICORE_TESTDEVICE(obj) \
     OBJECT_CHECK(TriCoreTestDeviceState, (obj), TYPE_TRICORE_TESTDEVICE)
 
-typedef struct {
+typedef struct TriCoreTestDeviceState {
     /* <private> */
     SysBusDevice parent_obj;
 
diff --git a/chardev/char-parallel.c b/chardev/char-parallel.c
index 05e7efbd6ca..acf9fb8afa0 100644
--- a/chardev/char-parallel.c
+++ b/chardev/char-parallel.c
@@ -49,7 +49,7 @@
 
 #if defined(__linux__)
 
-typedef struct {
+typedef struct ParallelChardev {
     Chardev parent;
     int fd;
     int mode;
@@ -177,7 +177,7 @@ static void qemu_chr_open_pp_fd(Chardev *chr,
 
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
 
-typedef struct {
+typedef struct ParallelChardev {
     Chardev parent;
     int fd;
 } ParallelChardev;
diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c
index 6d93d761a5e..72a815dbbd0 100644
--- a/hw/m68k/mcf5206.c
+++ b/hw/m68k/mcf5206.c
@@ -160,7 +160,7 @@ static m5206_timer_state *m5206_timer_init(qemu_irq irq)
 
 /* System Integration Module.  */
 
-typedef struct {
+typedef struct m5206_mbar_state {
     SysBusDevice parent_obj;
 
     M68kCPU *cpu;
diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c
index 83020fe9ac9..9e3c40a23dc 100644
--- a/hw/misc/sbsa_ec.c
+++ b/hw/misc/sbsa_ec.c
@@ -16,7 +16,7 @@
 #include "hw/sysbus.h"
 #include "sysemu/runstate.h"
 
-typedef struct {
+typedef struct SECUREECState {
     SysBusDevice parent_obj;
     MemoryRegion iomem;
 } SECUREECState;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 04/12] [automated] Add struct names to typedefs used by QOM types
@ 2021-08-06 21:11   ` Eduardo Habkost
  0 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrange, Paolo Bonzini, Marc-André Lureau,
	Thomas Huth, Havard Skinnemoen, Tyrone Ting, Vijai Kumar K,
	Bastian Koppelmann, qemu-arm, qemu-riscv

Anonymous structs on QOM typedefs make the code harder to convert
to OBJECT_DEFINE* macros, as the macros expect the struct name to
exist.

Use a codeconverter rule to automatically add names to the
structs used in QOM typedefs.

Generated using:

 $ ./scripts/codeconverter/converter.py -i \
   --pattern=AddNamesToTypedefs $(git grep -l '' -- '*.[ch]')

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Thomas Huth <huth@tuxfamily.org>
Cc: Havard Skinnemoen <hskinnemoen@google.com>
Cc: Tyrone Ting <kfting@nuvoton.com>
Cc: Vijai Kumar K <vijai@behindbytes.com>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org
Cc: qemu-riscv@nongnu.org
---
 include/hw/adc/npcm7xx_adc.h            | 2 +-
 include/hw/char/shakti_uart.h           | 2 +-
 include/hw/tricore/tricore_testdevice.h | 2 +-
 chardev/char-parallel.c                 | 4 ++--
 hw/m68k/mcf5206.c                       | 2 +-
 hw/misc/sbsa_ec.c                       | 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/hw/adc/npcm7xx_adc.h b/include/hw/adc/npcm7xx_adc.h
index 7d8442107ae..8e5a1897b4b 100644
--- a/include/hw/adc/npcm7xx_adc.h
+++ b/include/hw/adc/npcm7xx_adc.h
@@ -42,7 +42,7 @@
  * @iref: The internal reference voltage, initialized at launch time.
  * @rv: The calibrated output values of 0.5V and 1.5V for the ADC.
  */
-typedef struct {
+typedef struct NPCM7xxADCState {
     SysBusDevice parent;
 
     MemoryRegion iomem;
diff --git a/include/hw/char/shakti_uart.h b/include/hw/char/shakti_uart.h
index 526c408233f..25f7cbcaa55 100644
--- a/include/hw/char/shakti_uart.h
+++ b/include/hw/char/shakti_uart.h
@@ -51,7 +51,7 @@
 #define SHAKTI_UART(obj) \
     OBJECT_CHECK(ShaktiUartState, (obj), TYPE_SHAKTI_UART)
 
-typedef struct {
+typedef struct ShaktiUartState {
     /* <private> */
     SysBusDevice parent_obj;
 
diff --git a/include/hw/tricore/tricore_testdevice.h b/include/hw/tricore/tricore_testdevice.h
index 2c56c51bcb8..e93c883872d 100644
--- a/include/hw/tricore/tricore_testdevice.h
+++ b/include/hw/tricore/tricore_testdevice.h
@@ -26,7 +26,7 @@
 #define TRICORE_TESTDEVICE(obj) \
     OBJECT_CHECK(TriCoreTestDeviceState, (obj), TYPE_TRICORE_TESTDEVICE)
 
-typedef struct {
+typedef struct TriCoreTestDeviceState {
     /* <private> */
     SysBusDevice parent_obj;
 
diff --git a/chardev/char-parallel.c b/chardev/char-parallel.c
index 05e7efbd6ca..acf9fb8afa0 100644
--- a/chardev/char-parallel.c
+++ b/chardev/char-parallel.c
@@ -49,7 +49,7 @@
 
 #if defined(__linux__)
 
-typedef struct {
+typedef struct ParallelChardev {
     Chardev parent;
     int fd;
     int mode;
@@ -177,7 +177,7 @@ static void qemu_chr_open_pp_fd(Chardev *chr,
 
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
 
-typedef struct {
+typedef struct ParallelChardev {
     Chardev parent;
     int fd;
 } ParallelChardev;
diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c
index 6d93d761a5e..72a815dbbd0 100644
--- a/hw/m68k/mcf5206.c
+++ b/hw/m68k/mcf5206.c
@@ -160,7 +160,7 @@ static m5206_timer_state *m5206_timer_init(qemu_irq irq)
 
 /* System Integration Module.  */
 
-typedef struct {
+typedef struct m5206_mbar_state {
     SysBusDevice parent_obj;
 
     M68kCPU *cpu;
diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c
index 83020fe9ac9..9e3c40a23dc 100644
--- a/hw/misc/sbsa_ec.c
+++ b/hw/misc/sbsa_ec.c
@@ -16,7 +16,7 @@
 #include "hw/sysbus.h"
 #include "sysemu/runstate.h"
 
-typedef struct {
+typedef struct SECUREECState {
     SysBusDevice parent_obj;
     MemoryRegion iomem;
 } SECUREECState;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 05/12] [automated] Move QOM typedefs and add missing includes
  2021-08-06 21:11 [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Eduardo Habkost
@ 2021-08-06 21:11   ` Eduardo Habkost
  2021-08-06 21:11 ` [PATCH for-6.2 02/12] qom: Use DEVICE_*CLASS instead of OBJECT_*CLASS Eduardo Habkost
                     ` (11 subsequent siblings)
  12 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Michael S. Tsirkin, Alexey Kardashevskiy,
	Andrew Jeffery, Jason Wang, Bin Meng, David Hildenbrand,
	Laurent Vivier, Vijai Kumar K, Taylor Simpson, Alistair Francis,
	Gerd Hoffmann, Klaus Jensen, Edgar E. Iglesias, Vikram Garhwal,
	qemu-block, Juan Quintela, qemu-ppc, Huacai Chen,
	Havard Skinnemoen, Stefan Berger, Halil Pasic,
	Christian Borntraeger, Hervé Poussineau, Joel Stanley,
	Marc-André Lureau, Pavel Pisa, Aleksandar Rikalo,
	Corey Minyard, qemu-s390x, Richard Henderson, Greg Kurz,
	Dr. David Alan Gilbert, Alexander Bulekov, Bandan Das, qemu-arm,
	Cédric Le Goater, Stefan Hajnoczi, Paolo Bonzini,
	Keith Busch, qemu-riscv, David Gibson, Daniel P. Berrange,
	Francisco Iglesias, Thomas Huth, Bastian Koppelmann,
	Cornelia Huck, Philippe Mathieu-Daudé,
	Andrew Baumann, Tyrone Ting, Palmer Dabbelt, Igor Mammedov,
	Aurelien Jarno

Some typedefs and macros are defined after the type check macros.
This makes it difficult to automatically replace their
definitions with OBJECT_DECLARE_TYPE.

Patch generated using:

 $ ./scripts/codeconverter/converter.py -i --pattern=MoveSymbols \
    $(git grep -l '' -- '*.[ch]')

which will:
- split "typdef struct { ... } TypedefName" declarations
- move the typedefs and #defines above the type check macros
- add missing #include "qom/object.h" lines if necessary

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Thomas Huth <huth@tuxfamily.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Alexander Bulekov <alxndr@bu.edu>
Cc: Bandan Das <bsd@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
Cc: Havard Skinnemoen <hskinnemoen@google.com>
Cc: Tyrone Ting <kfting@nuvoton.com>
Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Klaus Jensen <its@irrelevant.dk>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: Halil Pasic <pasic@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Vijai Kumar K <vijai@behindbytes.com>
Cc: Alistair Francis <Alistair.Francis@wdc.com>
Cc: Bin Meng <bin.meng@windriver.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: Laurent Vivier <laurent@vivier.eu>
Cc: Corey Minyard <minyard@acm.org>
Cc: "Cédric Le Goater" <clg@kaod.org>
Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Greg Kurz <groug@kaod.org>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: "Hervé Poussineau" <hpoussin@reactos.org>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: Juan Quintela <quintela@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>
Cc: Taylor Simpson <tsimpson@quicinc.com>
Cc: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org
Cc: qemu-block@nongnu.org
Cc: qemu-s390x@nongnu.org
Cc: qemu-riscv@nongnu.org
Cc: qemu-ppc@nongnu.org
---
 hw/nvme/nvme.h                              |  6 ++++--
 hw/usb/hcd-uhci.h                           |  1 +
 hw/usb/hcd-xhci-pci.h                       |  6 ++++--
 hw/usb/hcd-xhci-sysbus.h                    |  6 ++++--
 hw/usb/u2f.h                                |  6 ++++--
 include/hw/acpi/acpi_dev_interface.h        |  2 +-
 include/hw/adc/npcm7xx_adc.h                |  1 +
 include/hw/arm/linux-boot-if.h              |  2 +-
 include/hw/arm/npcm7xx.h                    | 11 +++++++----
 include/hw/char/shakti_uart.h               |  6 ++++--
 include/hw/core/accel-cpu.h                 |  1 +
 include/hw/dma/sifive_pdma.h                |  1 +
 include/hw/dma/xlnx_csu_dma.h               |  1 +
 include/hw/fw-path-provider.h               |  2 +-
 include/hw/gpio/npcm7xx_gpio.h              |  1 +
 include/hw/hotplug.h                        |  2 +-
 include/hw/i2c/npcm7xx_smbus.h              |  1 +
 include/hw/intc/intc.h                      |  2 +-
 include/hw/intc/m68k_irqc.h                 |  6 ++++--
 include/hw/intc/sifive_clint.h              |  6 ++++--
 include/hw/ipmi/ipmi.h                      |  2 +-
 include/hw/mem/memory-device.h              |  2 +-
 include/hw/mem/npcm7xx_mc.h                 |  1 +
 include/hw/misc/aspeed_lpc.h                |  6 ++++--
 include/hw/misc/bcm2835_cprman.h            |  1 +
 include/hw/misc/bcm2835_cprman_internals.h  |  1 +
 include/hw/misc/mchp_pfsoc_dmc.h            |  1 +
 include/hw/misc/mchp_pfsoc_ioscb.h          |  1 +
 include/hw/misc/mchp_pfsoc_sysreg.h         |  1 +
 include/hw/misc/npcm7xx_clk.h               |  1 +
 include/hw/misc/npcm7xx_gcr.h               |  1 +
 include/hw/misc/npcm7xx_pwm.h               |  1 +
 include/hw/misc/npcm7xx_rng.h               |  1 +
 include/hw/misc/xlnx-versal-xramc.h         |  6 ++++--
 include/hw/net/npcm7xx_emc.h                |  1 +
 include/hw/net/xlnx-zynqmp-can.h            |  6 ++++--
 include/hw/nmi.h                            |  2 +-
 include/hw/nvram/npcm7xx_otp.h              |  1 +
 include/hw/ppc/spapr_drc.h                  | 15 +++++++++------
 include/hw/ppc/spapr_xive.h                 | 11 +++++++----
 include/hw/ppc/vof.h                        |  1 +
 include/hw/rdma/rdma.h                      |  2 +-
 include/hw/riscv/microchip_pfsoc.h          |  1 +
 include/hw/riscv/shakti_c.h                 | 11 +++++++----
 include/hw/riscv/sifive_e.h                 |  6 ++++--
 include/hw/riscv/sifive_u.h                 | 11 +++++++----
 include/hw/rtc/m48t59.h                     |  2 +-
 include/hw/sd/cadence_sdhci.h               |  1 +
 include/hw/ssi/npcm7xx_fiu.h                |  1 +
 include/hw/ssi/sifive_spi.h                 |  6 ++++--
 include/hw/stream.h                         |  2 +-
 include/hw/timer/npcm7xx_timer.h            |  1 +
 include/hw/tricore/tricore_testdevice.h     |  6 ++++--
 include/hw/usb/hcd-dwc3.h                   |  6 ++++--
 include/hw/usb/msd.h                        |  1 +
 include/hw/usb/xlnx-usb-subsystem.h         |  6 ++++--
 include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  6 ++++--
 include/hw/vmstate-if.h                     |  2 +-
 include/hw/watchdog/sbsa_gwdt.h             |  6 ++++--
 include/qom/object_interfaces.h             |  2 +-
 include/sysemu/tpm.h                        |  2 +-
 target/arm/idau.h                           |  2 +-
 target/hexagon/cpu.h                        | 11 +++++++----
 accel/tcg/tcg-all.c                         |  1 +
 chardev/char-parallel.c                     |  1 +
 hw/arm/bcm2836.c                            |  1 +
 hw/m68k/mcf5206.c                           |  1 +
 hw/mem/sparse-mem.c                         |  6 ++++--
 hw/mips/loongson3_virt.c                    |  1 +
 hw/misc/npcm7xx_clk.c                       |  1 +
 hw/misc/sbsa_ec.c                           |  1 +
 hw/net/can/ctucan_pci.c                     |  1 +
 hw/nvram/npcm7xx_otp.c                      |  1 +
 hw/s390x/vhost-user-fs-ccw.c                |  1 +
 hw/sensor/adm1272.c                         |  6 ++++--
 hw/sensor/max34451.c                        |  6 ++++--
 hw/usb/u2f-emulated.c                       |  1 +
 hw/usb/u2f-passthru.c                       |  1 +
 hw/virtio/vhost-user-i2c-pci.c              |  1 +
 tests/unit/check-qom-interface.c            |  2 +-
 ui/vdagent.c                                |  1 +
 81 files changed, 179 insertions(+), 82 deletions(-)

diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
index 83ffabade4c..5ddcd783055 100644
--- a/hw/nvme/nvme.h
+++ b/hw/nvme/nvme.h
@@ -23,6 +23,7 @@
 #include "hw/block/block.h"
 
 #include "block/nvme.h"
+#include "qom/object.h"
 
 #define NVME_MAX_CONTROLLERS 32
 #define NVME_MAX_NAMESPACES  256
@@ -41,10 +42,11 @@ typedef struct NvmeBus {
 } NvmeBus;
 
 #define TYPE_NVME_SUBSYS "nvme-subsys"
+typedef struct NvmeSubsystem NvmeSubsystem;
 #define NVME_SUBSYS(obj) \
     OBJECT_CHECK(NvmeSubsystem, (obj), TYPE_NVME_SUBSYS)
 
-typedef struct NvmeSubsystem {
+struct NvmeSubsystem {
     DeviceState parent_obj;
     NvmeBus     bus;
     uint8_t     subnqn[256];
@@ -55,7 +57,7 @@ typedef struct NvmeSubsystem {
     struct {
         char *nqn;
     } params;
-} NvmeSubsystem;
+};
 
 int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp);
 void nvme_subsys_unregister_ctrl(NvmeSubsystem *subsys, NvmeCtrl *n);
diff --git a/hw/usb/hcd-uhci.h b/hw/usb/hcd-uhci.h
index e61d8fcb192..57d0d574644 100644
--- a/hw/usb/hcd-uhci.h
+++ b/hw/usb/hcd-uhci.h
@@ -32,6 +32,7 @@
 #include "qemu/timer.h"
 #include "hw/pci/pci.h"
 #include "hw/usb.h"
+#include "qom/object.h"
 
 typedef struct UHCIQueue UHCIQueue;
 
diff --git a/hw/usb/hcd-xhci-pci.h b/hw/usb/hcd-xhci-pci.h
index c193f794439..0cfe630a5ce 100644
--- a/hw/usb/hcd-xhci-pci.h
+++ b/hw/usb/hcd-xhci-pci.h
@@ -26,19 +26,21 @@
 
 #include "hw/usb.h"
 #include "hcd-xhci.h"
+#include "qom/object.h"
 
 #define TYPE_XHCI_PCI "pci-xhci"
+typedef struct XHCIPciState XHCIPciState;
 #define XHCI_PCI(obj) \
     OBJECT_CHECK(XHCIPciState, (obj), TYPE_XHCI_PCI)
 
 
-typedef struct XHCIPciState {
+struct XHCIPciState {
     /*< private >*/
     PCIDevice parent_obj;
     /*< public >*/
     XHCIState xhci;
     OnOffAuto msi;
     OnOffAuto msix;
-} XHCIPciState;
+};
 
 #endif
diff --git a/hw/usb/hcd-xhci-sysbus.h b/hw/usb/hcd-xhci-sysbus.h
index fdfcbbee3bf..7661c811fd1 100644
--- a/hw/usb/hcd-xhci-sysbus.h
+++ b/hw/usb/hcd-xhci-sysbus.h
@@ -14,18 +14,20 @@
 #include "hw/usb.h"
 #include "hcd-xhci.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
+typedef struct XHCISysbusState XHCISysbusState;
 #define XHCI_SYSBUS(obj) \
     OBJECT_CHECK(XHCISysbusState, (obj), TYPE_XHCI_SYSBUS)
 
 
-typedef struct XHCISysbusState {
+struct XHCISysbusState {
     /*< private >*/
     SysBusDevice parent_obj;
     /*< public >*/
     XHCIState xhci;
     qemu_irq *irq;
-} XHCISysbusState;
+};
 
 void xhci_sysbus_reset(DeviceState *dev);
 #endif
diff --git a/hw/usb/u2f.h b/hw/usb/u2f.h
index db30f3586bf..705d5c43ce6 100644
--- a/hw/usb/u2f.h
+++ b/hw/usb/u2f.h
@@ -27,6 +27,7 @@
 #define U2F_H
 
 #include "hw/qdev-core.h"
+#include "qom/object.h"
 
 #define U2FHID_PACKET_SIZE 64
 #define U2FHID_PENDING_IN_NUM 32
@@ -35,6 +36,7 @@ typedef struct U2FKeyState U2FKeyState;
 typedef struct U2FKeyInfo U2FKeyInfo;
 
 #define TYPE_U2F_KEY "u2f-key"
+typedef struct U2FKeyClass U2FKeyClass;
 #define U2F_KEY(obj) \
     OBJECT_CHECK(U2FKeyState, (obj), TYPE_U2F_KEY)
 #define U2F_KEY_CLASS(klass) \
@@ -46,7 +48,7 @@ typedef struct U2FKeyInfo U2FKeyInfo;
  * Callbacks to be used by the U2F key base device (i.e. hw/u2f.c)
  * to interact with its variants (i.e. hw/u2f-*.c)
  */
-typedef struct U2FKeyClass {
+struct U2FKeyClass {
     /*< private >*/
     USBDeviceClass parent_class;
 
@@ -55,7 +57,7 @@ typedef struct U2FKeyClass {
                             const uint8_t packet[U2FHID_PACKET_SIZE]);
     void (*realize)(U2FKeyState *key, Error **errp);
     void (*unrealize)(U2FKeyState *key);
-} U2FKeyClass;
+};
 
 /*
  * State of the U2F key base device (i.e. hw/u2f.c)
diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
index 769ff55c7ee..c9c7c17e043 100644
--- a/include/hw/acpi/acpi_dev_interface.h
+++ b/include/hw/acpi/acpi_dev_interface.h
@@ -21,11 +21,11 @@ typedef enum {
 typedef struct AcpiDeviceIfClass AcpiDeviceIfClass;
 DECLARE_CLASS_CHECKERS(AcpiDeviceIfClass, ACPI_DEVICE_IF,
                        TYPE_ACPI_DEVICE_IF)
+typedef struct AcpiDeviceIf AcpiDeviceIf;
 #define ACPI_DEVICE_IF(obj) \
      INTERFACE_CHECK(AcpiDeviceIf, (obj), \
                      TYPE_ACPI_DEVICE_IF)
 
-typedef struct AcpiDeviceIf AcpiDeviceIf;
 
 void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
 
diff --git a/include/hw/adc/npcm7xx_adc.h b/include/hw/adc/npcm7xx_adc.h
index 8e5a1897b4b..874cfbd6ce3 100644
--- a/include/hw/adc/npcm7xx_adc.h
+++ b/include/hw/adc/npcm7xx_adc.h
@@ -20,6 +20,7 @@
 #include "hw/irq.h"
 #include "hw/sysbus.h"
 #include "qemu/timer.h"
+#include "qom/object.h"
 
 #define NPCM7XX_ADC_NUM_INPUTS      8
 /**
diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
index c85f33b2c51..295e282c36e 100644
--- a/include/hw/arm/linux-boot-if.h
+++ b/include/hw/arm/linux-boot-if.h
@@ -12,10 +12,10 @@
 typedef struct ARMLinuxBootIfClass ARMLinuxBootIfClass;
 DECLARE_CLASS_CHECKERS(ARMLinuxBootIfClass, ARM_LINUX_BOOT_IF,
                        TYPE_ARM_LINUX_BOOT_IF)
+typedef struct ARMLinuxBootIf ARMLinuxBootIf;
 #define ARM_LINUX_BOOT_IF(obj) \
     INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
 
-typedef struct ARMLinuxBootIf ARMLinuxBootIf;
 
 struct ARMLinuxBootIfClass {
     /*< private >*/
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
index 61ecc57ab90..dc802c1645c 100644
--- a/include/hw/arm/npcm7xx.h
+++ b/include/hw/arm/npcm7xx.h
@@ -35,6 +35,7 @@
 #include "hw/usb/hcd-ehci.h"
 #include "hw/usb/hcd-ohci.h"
 #include "target/arm/cpu.h"
+#include "qom/object.h"
 
 #define NPCM7XX_MAX_NUM_CPUS    (2)
 
@@ -62,14 +63,15 @@ typedef struct NPCM7xxMachine {
 } NPCM7xxMachine;
 
 #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
+typedef struct NPCM7xxMachineClass NPCM7xxMachineClass;
 #define NPCM7XX_MACHINE(obj)                                            \
     OBJECT_CHECK(NPCM7xxMachine, (obj), TYPE_NPCM7XX_MACHINE)
 
-typedef struct NPCM7xxMachineClass {
+struct NPCM7xxMachineClass {
     MachineClass        parent;
 
     const char          *soc_type;
-} NPCM7xxMachineClass;
+};
 
 #define NPCM7XX_MACHINE_CLASS(klass)                                    \
     OBJECT_CLASS_CHECK(NPCM7xxMachineClass, (klass), TYPE_NPCM7XX_MACHINE)
@@ -106,19 +108,20 @@ typedef struct NPCM7xxState {
 } NPCM7xxState;
 
 #define TYPE_NPCM7XX    "npcm7xx"
+typedef struct NPCM7xxClass NPCM7xxClass;
 #define NPCM7XX(obj)    OBJECT_CHECK(NPCM7xxState, (obj), TYPE_NPCM7XX)
 
 #define TYPE_NPCM730    "npcm730"
 #define TYPE_NPCM750    "npcm750"
 
-typedef struct NPCM7xxClass {
+struct NPCM7xxClass {
     DeviceClass         parent;
 
     /* Bitmask of modules that are permanently disabled on this chip. */
     uint32_t            disabled_modules;
     /* Number of CPU cores enabled in this SoC class (may be 1 or 2). */
     uint32_t            num_cpus;
-} NPCM7xxClass;
+};
 
 #define NPCM7XX_CLASS(klass)                                            \
     OBJECT_CLASS_CHECK(NPCM7xxClass, (klass), TYPE_NPCM7XX)
diff --git a/include/hw/char/shakti_uart.h b/include/hw/char/shakti_uart.h
index 25f7cbcaa55..be7a93fb14d 100644
--- a/include/hw/char/shakti_uart.h
+++ b/include/hw/char/shakti_uart.h
@@ -27,6 +27,7 @@
 
 #include "hw/sysbus.h"
 #include "chardev/char-fe.h"
+#include "qom/object.h"
 
 #define SHAKTI_UART_BAUD        0x00
 #define SHAKTI_UART_TX          0x04
@@ -48,10 +49,11 @@
 #define SHAKTI_UART_CONTROL_DEFAULT 0x0100
 
 #define TYPE_SHAKTI_UART "shakti-uart"
+typedef struct ShaktiUartState ShaktiUartState;
 #define SHAKTI_UART(obj) \
     OBJECT_CHECK(ShaktiUartState, (obj), TYPE_SHAKTI_UART)
 
-typedef struct ShaktiUartState {
+struct ShaktiUartState {
     /* <private> */
     SysBusDevice parent_obj;
 
@@ -69,6 +71,6 @@ typedef struct ShaktiUartState {
     uint32_t uart_rx_threshold;
 
     CharBackend chr;
-} ShaktiUartState;
+};
 
 #endif /* HW_SHAKTI_UART_H */
diff --git a/include/hw/core/accel-cpu.h b/include/hw/core/accel-cpu.h
index 5dbfd799553..0b7b3f6df3e 100644
--- a/include/hw/core/accel-cpu.h
+++ b/include/hw/core/accel-cpu.h
@@ -10,6 +10,7 @@
 
 #ifndef ACCEL_CPU_H
 #define ACCEL_CPU_H
+#include "qom/object.h"
 
 /*
  * This header is used to define new accelerator-specific target-specific
diff --git a/include/hw/dma/sifive_pdma.h b/include/hw/dma/sifive_pdma.h
index e319bbd6c40..a62908dd0f2 100644
--- a/include/hw/dma/sifive_pdma.h
+++ b/include/hw/dma/sifive_pdma.h
@@ -22,6 +22,7 @@
 
 #ifndef SIFIVE_PDMA_H
 #define SIFIVE_PDMA_H
+#include "qom/object.h"
 
 struct sifive_pdma_chan {
     uint32_t control;
diff --git a/include/hw/dma/xlnx_csu_dma.h b/include/hw/dma/xlnx_csu_dma.h
index 204d94c6737..804ca5958d0 100644
--- a/include/hw/dma/xlnx_csu_dma.h
+++ b/include/hw/dma/xlnx_csu_dma.h
@@ -20,6 +20,7 @@
 
 #ifndef XLNX_CSU_DMA_H
 #define XLNX_CSU_DMA_H
+#include "qom/object.h"
 
 #define TYPE_XLNX_CSU_DMA "xlnx.csu_dma"
 
diff --git a/include/hw/fw-path-provider.h b/include/hw/fw-path-provider.h
index 8e1d45651cf..33d91daed52 100644
--- a/include/hw/fw-path-provider.h
+++ b/include/hw/fw-path-provider.h
@@ -25,10 +25,10 @@
 typedef struct FWPathProviderClass FWPathProviderClass;
 DECLARE_CLASS_CHECKERS(FWPathProviderClass, FW_PATH_PROVIDER,
                        TYPE_FW_PATH_PROVIDER)
+typedef struct FWPathProvider FWPathProvider;
 #define FW_PATH_PROVIDER(obj) \
      INTERFACE_CHECK(FWPathProvider, (obj), TYPE_FW_PATH_PROVIDER)
 
-typedef struct FWPathProvider FWPathProvider;
 
 struct FWPathProviderClass {
     InterfaceClass parent_class;
diff --git a/include/hw/gpio/npcm7xx_gpio.h b/include/hw/gpio/npcm7xx_gpio.h
index b1d771bd776..c4e5b4a353e 100644
--- a/include/hw/gpio/npcm7xx_gpio.h
+++ b/include/hw/gpio/npcm7xx_gpio.h
@@ -17,6 +17,7 @@
 
 #include "exec/memory.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /* Number of pins managed by each controller. */
 #define NPCM7XX_GPIO_NR_PINS (32)
diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h
index e15f59c8b3c..75d32d69e2b 100644
--- a/include/hw/hotplug.h
+++ b/include/hw/hotplug.h
@@ -19,10 +19,10 @@
 typedef struct HotplugHandlerClass HotplugHandlerClass;
 DECLARE_CLASS_CHECKERS(HotplugHandlerClass, HOTPLUG_HANDLER,
                        TYPE_HOTPLUG_HANDLER)
+typedef struct HotplugHandler HotplugHandler;
 #define HOTPLUG_HANDLER(obj) \
      INTERFACE_CHECK(HotplugHandler, (obj), TYPE_HOTPLUG_HANDLER)
 
-typedef struct HotplugHandler HotplugHandler;
 
 /**
  * hotplug_fn:
diff --git a/include/hw/i2c/npcm7xx_smbus.h b/include/hw/i2c/npcm7xx_smbus.h
index 7d59ee917eb..8030d78f69c 100644
--- a/include/hw/i2c/npcm7xx_smbus.h
+++ b/include/hw/i2c/npcm7xx_smbus.h
@@ -20,6 +20,7 @@
 #include "hw/i2c/i2c.h"
 #include "hw/irq.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /*
  * Number of addresses this module contains. Do not change this without
diff --git a/include/hw/intc/intc.h b/include/hw/intc/intc.h
index 7018f608ca5..7c57c3a0379 100644
--- a/include/hw/intc/intc.h
+++ b/include/hw/intc/intc.h
@@ -8,11 +8,11 @@
 typedef struct InterruptStatsProviderClass InterruptStatsProviderClass;
 DECLARE_CLASS_CHECKERS(InterruptStatsProviderClass, INTERRUPT_STATS_PROVIDER,
                        TYPE_INTERRUPT_STATS_PROVIDER)
+typedef struct InterruptStatsProvider InterruptStatsProvider;
 #define INTERRUPT_STATS_PROVIDER(obj) \
     INTERFACE_CHECK(InterruptStatsProvider, (obj), \
                     TYPE_INTERRUPT_STATS_PROVIDER)
 
-typedef struct InterruptStatsProvider InterruptStatsProvider;
 
 struct InterruptStatsProviderClass {
     InterfaceClass parent;
diff --git a/include/hw/intc/m68k_irqc.h b/include/hw/intc/m68k_irqc.h
index dbcfcfc2e00..460d8a5a8d3 100644
--- a/include/hw/intc/m68k_irqc.h
+++ b/include/hw/intc/m68k_irqc.h
@@ -11,8 +11,10 @@
 #define M68K_IRQC_H
 
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 #define TYPE_M68K_IRQC "m68k-irq-controller"
+typedef struct M68KIRQCState M68KIRQCState;
 #define M68K_IRQC(obj) OBJECT_CHECK(M68KIRQCState, (obj), \
                                     TYPE_M68K_IRQC)
 
@@ -29,13 +31,13 @@ enum {
 };
 #define M68K_IRQC_LEVEL_NUM (M68K_IRQC_LEVEL_7 - M68K_IRQC_LEVEL_1 + 1)
 
-typedef struct M68KIRQCState {
+struct M68KIRQCState {
     SysBusDevice parent_obj;
 
     uint8_t ipr;
 
     /* statistics */
     uint64_t stats_irq_count[M68K_IRQC_LEVEL_NUM];
-} M68KIRQCState;
+};
 
 #endif
diff --git a/include/hw/intc/sifive_clint.h b/include/hw/intc/sifive_clint.h
index a30be0f3d6f..8e005e130f1 100644
--- a/include/hw/intc/sifive_clint.h
+++ b/include/hw/intc/sifive_clint.h
@@ -21,13 +21,15 @@
 #define HW_SIFIVE_CLINT_H
 
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 #define TYPE_SIFIVE_CLINT "riscv.sifive.clint"
 
+typedef struct SiFiveCLINTState SiFiveCLINTState;
 #define SIFIVE_CLINT(obj) \
     OBJECT_CHECK(SiFiveCLINTState, (obj), TYPE_SIFIVE_CLINT)
 
-typedef struct SiFiveCLINTState {
+struct SiFiveCLINTState {
     /*< private >*/
     SysBusDevice parent_obj;
 
@@ -40,7 +42,7 @@ typedef struct SiFiveCLINTState {
     uint32_t time_base;
     uint32_t aperture_size;
     uint32_t timebase_freq;
-} SiFiveCLINTState;
+};
 
 DeviceState *sifive_clint_create(hwaddr addr, hwaddr size,
     uint32_t hartid_base, uint32_t num_harts, uint32_t sip_base,
diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h
index 77a7213ed93..d655352fa95 100644
--- a/include/hw/ipmi/ipmi.h
+++ b/include/hw/ipmi/ipmi.h
@@ -109,13 +109,13 @@ uint32_t ipmi_next_uuid(void);
  * and the BMC.
  */
 #define TYPE_IPMI_INTERFACE "ipmi-interface"
+typedef struct IPMIInterface IPMIInterface;
 #define IPMI_INTERFACE(obj) \
      INTERFACE_CHECK(IPMIInterface, (obj), TYPE_IPMI_INTERFACE)
 typedef struct IPMIInterfaceClass IPMIInterfaceClass;
 DECLARE_CLASS_CHECKERS(IPMIInterfaceClass, IPMI_INTERFACE,
                        TYPE_IPMI_INTERFACE)
 
-typedef struct IPMIInterface IPMIInterface;
 
 struct IPMIInterfaceClass {
     InterfaceClass parent;
diff --git a/include/hw/mem/memory-device.h b/include/hw/mem/memory-device.h
index 48d2611fc5e..a83428209b9 100644
--- a/include/hw/mem/memory-device.h
+++ b/include/hw/mem/memory-device.h
@@ -22,10 +22,10 @@
 typedef struct MemoryDeviceClass MemoryDeviceClass;
 DECLARE_CLASS_CHECKERS(MemoryDeviceClass, MEMORY_DEVICE,
                        TYPE_MEMORY_DEVICE)
+typedef struct MemoryDeviceState MemoryDeviceState;
 #define MEMORY_DEVICE(obj) \
      INTERFACE_CHECK(MemoryDeviceState, (obj), TYPE_MEMORY_DEVICE)
 
-typedef struct MemoryDeviceState MemoryDeviceState;
 
 /**
  * MemoryDeviceClass:
diff --git a/include/hw/mem/npcm7xx_mc.h b/include/hw/mem/npcm7xx_mc.h
index 7ed38be2431..83787f6fa57 100644
--- a/include/hw/mem/npcm7xx_mc.h
+++ b/include/hw/mem/npcm7xx_mc.h
@@ -18,6 +18,7 @@
 
 #include "exec/memory.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /**
  * struct NPCM7xxMCState - Device state for the memory controller.
diff --git a/include/hw/misc/aspeed_lpc.h b/include/hw/misc/aspeed_lpc.h
index df418cfcd36..def617b9772 100644
--- a/include/hw/misc/aspeed_lpc.h
+++ b/include/hw/misc/aspeed_lpc.h
@@ -13,8 +13,10 @@
 #include "hw/sysbus.h"
 
 #include <stdint.h>
+#include "qom/object.h"
 
 #define TYPE_ASPEED_LPC "aspeed.lpc"
+typedef struct AspeedLPCState AspeedLPCState;
 #define ASPEED_LPC(obj) OBJECT_CHECK(AspeedLPCState, (obj), TYPE_ASPEED_LPC)
 
 #define ASPEED_LPC_NR_REGS      (0x260 >> 2)
@@ -29,7 +31,7 @@ enum aspeed_lpc_subdevice {
 
 #define ASPEED_LPC_NR_SUBDEVS   5
 
-typedef struct AspeedLPCState {
+struct AspeedLPCState {
     /* <private> */
     SysBusDevice parent;
 
@@ -42,6 +44,6 @@ typedef struct AspeedLPCState {
 
     uint32_t regs[ASPEED_LPC_NR_REGS];
     uint32_t hicr7;
-} AspeedLPCState;
+};
 
 #endif /* _ASPEED_LPC_H_ */
diff --git a/include/hw/misc/bcm2835_cprman.h b/include/hw/misc/bcm2835_cprman.h
index 3df4ceedd2e..ba4b441dce5 100644
--- a/include/hw/misc/bcm2835_cprman.h
+++ b/include/hw/misc/bcm2835_cprman.h
@@ -11,6 +11,7 @@
 
 #include "hw/sysbus.h"
 #include "hw/qdev-clock.h"
+#include "qom/object.h"
 
 #define TYPE_BCM2835_CPRMAN "bcm2835-cprman"
 
diff --git a/include/hw/misc/bcm2835_cprman_internals.h b/include/hw/misc/bcm2835_cprman_internals.h
index 339759b3071..f5410580bff 100644
--- a/include/hw/misc/bcm2835_cprman_internals.h
+++ b/include/hw/misc/bcm2835_cprman_internals.h
@@ -11,6 +11,7 @@
 
 #include "hw/registerfields.h"
 #include "hw/misc/bcm2835_cprman.h"
+#include "qom/object.h"
 
 #define TYPE_CPRMAN_PLL "bcm2835-cprman-pll"
 #define TYPE_CPRMAN_PLL_CHANNEL "bcm2835-cprman-pll-channel"
diff --git a/include/hw/misc/mchp_pfsoc_dmc.h b/include/hw/misc/mchp_pfsoc_dmc.h
index 2baa1413b0c..979527957ea 100644
--- a/include/hw/misc/mchp_pfsoc_dmc.h
+++ b/include/hw/misc/mchp_pfsoc_dmc.h
@@ -22,6 +22,7 @@
 
 #ifndef MCHP_PFSOC_DMC_H
 #define MCHP_PFSOC_DMC_H
+#include "qom/object.h"
 
 /* DDR SGMII PHY module */
 
diff --git a/include/hw/misc/mchp_pfsoc_ioscb.h b/include/hw/misc/mchp_pfsoc_ioscb.h
index 9235523e334..519b897250f 100644
--- a/include/hw/misc/mchp_pfsoc_ioscb.h
+++ b/include/hw/misc/mchp_pfsoc_ioscb.h
@@ -22,6 +22,7 @@
 
 #ifndef MCHP_PFSOC_IOSCB_H
 #define MCHP_PFSOC_IOSCB_H
+#include "qom/object.h"
 
 typedef struct MchpPfSoCIoscbState {
     SysBusDevice parent;
diff --git a/include/hw/misc/mchp_pfsoc_sysreg.h b/include/hw/misc/mchp_pfsoc_sysreg.h
index 546ba68f6a1..d6803be9485 100644
--- a/include/hw/misc/mchp_pfsoc_sysreg.h
+++ b/include/hw/misc/mchp_pfsoc_sysreg.h
@@ -22,6 +22,7 @@
 
 #ifndef MCHP_PFSOC_SYSREG_H
 #define MCHP_PFSOC_SYSREG_H
+#include "qom/object.h"
 
 #define MCHP_PFSOC_SYSREG_REG_SIZE  0x2000
 
diff --git a/include/hw/misc/npcm7xx_clk.h b/include/hw/misc/npcm7xx_clk.h
index d5c8d16ca42..a849345620e 100644
--- a/include/hw/misc/npcm7xx_clk.h
+++ b/include/hw/misc/npcm7xx_clk.h
@@ -19,6 +19,7 @@
 #include "exec/memory.h"
 #include "hw/clock.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /*
  * Number of registers in our device state structure. Don't change this without
diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h
index 13109d9d324..482768c8e76 100644
--- a/include/hw/misc/npcm7xx_gcr.h
+++ b/include/hw/misc/npcm7xx_gcr.h
@@ -18,6 +18,7 @@
 
 #include "exec/memory.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /*
  * Number of registers in our device state structure. Don't change this without
diff --git a/include/hw/misc/npcm7xx_pwm.h b/include/hw/misc/npcm7xx_pwm.h
index 7ad632a93a1..c6643bd04fd 100644
--- a/include/hw/misc/npcm7xx_pwm.h
+++ b/include/hw/misc/npcm7xx_pwm.h
@@ -19,6 +19,7 @@
 #include "hw/clock.h"
 #include "hw/sysbus.h"
 #include "hw/irq.h"
+#include "qom/object.h"
 
 /* Each PWM module holds 4 PWM channels. */
 #define NPCM7XX_PWM_PER_MODULE 4
diff --git a/include/hw/misc/npcm7xx_rng.h b/include/hw/misc/npcm7xx_rng.h
index 5e85fd439d8..1d20293608a 100644
--- a/include/hw/misc/npcm7xx_rng.h
+++ b/include/hw/misc/npcm7xx_rng.h
@@ -17,6 +17,7 @@
 #define NPCM7XX_RNG_H
 
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 typedef struct NPCM7xxRNGState {
     SysBusDevice parent;
diff --git a/include/hw/misc/xlnx-versal-xramc.h b/include/hw/misc/xlnx-versal-xramc.h
index d3d1862676f..ba0d0f3c5af 100644
--- a/include/hw/misc/xlnx-versal-xramc.h
+++ b/include/hw/misc/xlnx-versal-xramc.h
@@ -11,9 +11,11 @@
 
 #include "hw/sysbus.h"
 #include "hw/register.h"
+#include "qom/object.h"
 
 #define TYPE_XLNX_XRAM_CTRL "xlnx.versal-xramc"
 
+typedef struct XlnxXramCtrl XlnxXramCtrl;
 #define XLNX_XRAM_CTRL(obj) \
      OBJECT_CHECK(XlnxXramCtrl, (obj), TYPE_XLNX_XRAM_CTRL)
 
@@ -80,7 +82,7 @@ REG32(XRAM_SAFETY_CHK, 0xff8)
 
 #define XRAM_CTRL_R_MAX (R_XRAM_SAFETY_CHK + 1)
 
-typedef struct XlnxXramCtrl {
+struct XlnxXramCtrl {
     SysBusDevice parent_obj;
     MemoryRegion ram;
     qemu_irq irq;
@@ -93,5 +95,5 @@ typedef struct XlnxXramCtrl {
     RegisterInfoArray *reg_array;
     uint32_t regs[XRAM_CTRL_R_MAX];
     RegisterInfo regs_info[XRAM_CTRL_R_MAX];
-} XlnxXramCtrl;
+};
 #endif
diff --git a/include/hw/net/npcm7xx_emc.h b/include/hw/net/npcm7xx_emc.h
index eac7f298167..5b676f669cd 100644
--- a/include/hw/net/npcm7xx_emc.h
+++ b/include/hw/net/npcm7xx_emc.h
@@ -20,6 +20,7 @@
 #include "hw/irq.h"
 #include "hw/sysbus.h"
 #include "net/net.h"
+#include "qom/object.h"
 
 /* 32-bit register indices. */
 enum NPCM7xxPWMRegister {
diff --git a/include/hw/net/xlnx-zynqmp-can.h b/include/hw/net/xlnx-zynqmp-can.h
index eb1558708bb..3d80c7455db 100644
--- a/include/hw/net/xlnx-zynqmp-can.h
+++ b/include/hw/net/xlnx-zynqmp-can.h
@@ -36,9 +36,11 @@
 #include "qemu/fifo32.h"
 #include "hw/ptimer.h"
 #include "hw/qdev-clock.h"
+#include "qom/object.h"
 
 #define TYPE_XLNX_ZYNQMP_CAN "xlnx.zynqmp-can"
 
+typedef struct XlnxZynqMPCANState XlnxZynqMPCANState;
 #define XLNX_ZYNQMP_CAN(obj) \
      OBJECT_CHECK(XlnxZynqMPCANState, (obj), TYPE_XLNX_ZYNQMP_CAN)
 
@@ -52,7 +54,7 @@
 #define CAN_FRAME_SIZE     4
 #define RXFIFO_SIZE        (MAILBOX_CAPACITY * CAN_FRAME_SIZE)
 
-typedef struct XlnxZynqMPCANState {
+struct XlnxZynqMPCANState {
     SysBusDevice        parent_obj;
     MemoryRegion        iomem;
 
@@ -73,6 +75,6 @@ typedef struct XlnxZynqMPCANState {
     Fifo32              txhpb_fifo;
 
     ptimer_state        *can_timer;
-} XlnxZynqMPCANState;
+};
 
 #endif
diff --git a/include/hw/nmi.h b/include/hw/nmi.h
index fff41bebc69..529ab736f8f 100644
--- a/include/hw/nmi.h
+++ b/include/hw/nmi.h
@@ -29,10 +29,10 @@
 typedef struct NMIClass NMIClass;
 DECLARE_CLASS_CHECKERS(NMIClass, NMI,
                        TYPE_NMI)
+typedef struct NMIState NMIState;
 #define NMI(obj) \
      INTERFACE_CHECK(NMIState, (obj), TYPE_NMI)
 
-typedef struct NMIState NMIState;
 
 struct NMIClass {
     InterfaceClass parent_class;
diff --git a/include/hw/nvram/npcm7xx_otp.h b/include/hw/nvram/npcm7xx_otp.h
index 156bbd151ab..32c73845ff3 100644
--- a/include/hw/nvram/npcm7xx_otp.h
+++ b/include/hw/nvram/npcm7xx_otp.h
@@ -18,6 +18,7 @@
 
 #include "exec/memory.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /* Each OTP module holds 8192 bits of one-time programmable storage */
 #define NPCM7XX_OTP_ARRAY_BITS (8192)
diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h
index 02a63b36666..83019d3f672 100644
--- a/include/hw/ppc/spapr_drc.h
+++ b/include/hw/ppc/spapr_drc.h
@@ -20,6 +20,8 @@
 #include "qapi/error.h"
 
 #define TYPE_SPAPR_DR_CONNECTOR "spapr-dr-connector"
+typedef struct SpaprDrc SpaprDrc;
+typedef struct SpaprDrcClass SpaprDrcClass;
 #define SPAPR_DR_CONNECTOR_GET_CLASS(obj) \
         OBJECT_GET_CLASS(SpaprDrcClass, obj, TYPE_SPAPR_DR_CONNECTOR)
 #define SPAPR_DR_CONNECTOR_CLASS(klass) \
@@ -29,6 +31,7 @@
                                              TYPE_SPAPR_DR_CONNECTOR)
 
 #define TYPE_SPAPR_DRC_PHYSICAL "spapr-drc-physical"
+typedef struct SpaprDrcPhysical SpaprDrcPhysical;
 #define SPAPR_DRC_PHYSICAL(obj) OBJECT_CHECK(SpaprDrcPhysical, (obj), \
                                              TYPE_SPAPR_DRC_PHYSICAL)
 
@@ -168,7 +171,7 @@ typedef enum {
     SPAPR_DRC_STATE_PHYSICAL_CONFIGURED = 8,
 } SpaprDrcState;
 
-typedef struct SpaprDrc {
+struct SpaprDrc {
     /*< private >*/
     DeviceState parent;
 
@@ -187,11 +190,11 @@ typedef struct SpaprDrc {
     bool unplug_requested;
     void *fdt;
     int fdt_start_offset;
-} SpaprDrc;
+};
 
 struct SpaprMachineState;
 
-typedef struct SpaprDrcClass {
+struct SpaprDrcClass {
     /*< private >*/
     DeviceClass parent;
     SpaprDrcState empty_state;
@@ -209,15 +212,15 @@ typedef struct SpaprDrcClass {
 
     int (*dt_populate)(SpaprDrc *drc, struct SpaprMachineState *spapr,
                        void *fdt, int *fdt_start_offset, Error **errp);
-} SpaprDrcClass;
+};
 
-typedef struct SpaprDrcPhysical {
+struct SpaprDrcPhysical {
     /*< private >*/
     SpaprDrc parent;
 
     /* DR-indicator */
     uint32_t dr_indicator;
-} SpaprDrcPhysical;
+};
 
 static inline bool spapr_drc_hotplugged(DeviceState *dev)
 {
diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h
index b282960ad90..d1371b2dbba 100644
--- a/include/hw/ppc/spapr_xive.h
+++ b/include/hw/ppc/spapr_xive.h
@@ -12,15 +12,18 @@
 
 #include "hw/ppc/spapr_irq.h"
 #include "hw/ppc/xive.h"
+#include "qom/object.h"
 
 #define TYPE_SPAPR_XIVE "spapr-xive"
+typedef struct SpaprXive SpaprXive;
+typedef struct SpaprXiveClass SpaprXiveClass;
 #define SPAPR_XIVE(obj) OBJECT_CHECK(SpaprXive, (obj), TYPE_SPAPR_XIVE)
 #define SPAPR_XIVE_CLASS(klass)                                         \
     OBJECT_CLASS_CHECK(SpaprXiveClass, (klass), TYPE_SPAPR_XIVE)
 #define SPAPR_XIVE_GET_CLASS(obj)                               \
     OBJECT_GET_CLASS(SpaprXiveClass, (obj), TYPE_SPAPR_XIVE)
 
-typedef struct SpaprXive {
+struct SpaprXive {
     XiveRouter    parent;
 
     /* Internal interrupt source for IPIs and virtual devices */
@@ -51,13 +54,13 @@ typedef struct SpaprXive {
     VMChangeStateEntry *change;
 
     uint8_t       hv_prio;
-} SpaprXive;
+};
 
-typedef struct SpaprXiveClass {
+struct SpaprXiveClass {
     XiveRouterClass parent;
 
     DeviceRealize parent_realize;
-} SpaprXiveClass;
+};
 
 /*
  * The sPAPR machine has a unique XIVE IC device. Assign a fixed value
diff --git a/include/hw/ppc/vof.h b/include/hw/ppc/vof.h
index 97fdef758bf..dd2b11ed6be 100644
--- a/include/hw/ppc/vof.h
+++ b/include/hw/ppc/vof.h
@@ -5,6 +5,7 @@
  */
 #ifndef HW_VOF_H
 #define HW_VOF_H
+#include "qom/object.h"
 
 typedef struct Vof {
     uint64_t top_addr; /* copied from rma_size */
diff --git a/include/hw/rdma/rdma.h b/include/hw/rdma/rdma.h
index e77e43a1709..e64104d631e 100644
--- a/include/hw/rdma/rdma.h
+++ b/include/hw/rdma/rdma.h
@@ -22,11 +22,11 @@
 typedef struct RdmaProviderClass RdmaProviderClass;
 DECLARE_CLASS_CHECKERS(RdmaProviderClass, RDMA_PROVIDER,
                        INTERFACE_RDMA_PROVIDER)
+typedef struct RdmaProvider RdmaProvider;
 #define RDMA_PROVIDER(obj) \
     INTERFACE_CHECK(RdmaProvider, (obj), \
                     INTERFACE_RDMA_PROVIDER)
 
-typedef struct RdmaProvider RdmaProvider;
 
 struct RdmaProviderClass {
     InterfaceClass parent;
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
index d30916f45d4..3f83f9d98da 100644
--- a/include/hw/riscv/microchip_pfsoc.h
+++ b/include/hw/riscv/microchip_pfsoc.h
@@ -29,6 +29,7 @@
 #include "hw/misc/mchp_pfsoc_sysreg.h"
 #include "hw/net/cadence_gem.h"
 #include "hw/sd/cadence_sdhci.h"
+#include "qom/object.h"
 
 typedef struct MicrochipPFSoCState {
     /*< private >*/
diff --git a/include/hw/riscv/shakti_c.h b/include/hw/riscv/shakti_c.h
index 50a2b790860..e07bca3a357 100644
--- a/include/hw/riscv/shakti_c.h
+++ b/include/hw/riscv/shakti_c.h
@@ -22,12 +22,14 @@
 #include "hw/riscv/riscv_hart.h"
 #include "hw/boards.h"
 #include "hw/char/shakti_uart.h"
+#include "qom/object.h"
 
 #define TYPE_RISCV_SHAKTI_SOC "riscv.shakti.cclass.soc"
+typedef struct ShaktiCSoCState ShaktiCSoCState;
 #define RISCV_SHAKTI_SOC(obj) \
     OBJECT_CHECK(ShaktiCSoCState, (obj), TYPE_RISCV_SHAKTI_SOC)
 
-typedef struct ShaktiCSoCState {
+struct ShaktiCSoCState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -37,18 +39,19 @@ typedef struct ShaktiCSoCState {
     ShaktiUartState uart;
     MemoryRegion rom;
 
-} ShaktiCSoCState;
+};
 
 #define TYPE_RISCV_SHAKTI_MACHINE MACHINE_TYPE_NAME("shakti_c")
+typedef struct ShaktiCMachineState ShaktiCMachineState;
 #define RISCV_SHAKTI_MACHINE(obj) \
     OBJECT_CHECK(ShaktiCMachineState, (obj), TYPE_RISCV_SHAKTI_MACHINE)
-typedef struct ShaktiCMachineState {
+struct ShaktiCMachineState {
     /*< private >*/
     MachineState parent_obj;
 
     /*< public >*/
     ShaktiCSoCState soc;
-} ShaktiCMachineState;
+};
 
 enum {
     SHAKTI_C_ROM,
diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h
index 83604da805c..e654e2dfec6 100644
--- a/include/hw/riscv/sifive_e.h
+++ b/include/hw/riscv/sifive_e.h
@@ -22,12 +22,14 @@
 #include "hw/riscv/riscv_hart.h"
 #include "hw/riscv/sifive_cpu.h"
 #include "hw/gpio/sifive_gpio.h"
+#include "qom/object.h"
 
 #define TYPE_RISCV_E_SOC "riscv.sifive.e.soc"
+typedef struct SiFiveESoCState SiFiveESoCState;
 #define RISCV_E_SOC(obj) \
     OBJECT_CHECK(SiFiveESoCState, (obj), TYPE_RISCV_E_SOC)
 
-typedef struct SiFiveESoCState {
+struct SiFiveESoCState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -37,7 +39,7 @@ typedef struct SiFiveESoCState {
     SIFIVEGPIOState gpio;
     MemoryRegion xip_mem;
     MemoryRegion mask_rom;
-} SiFiveESoCState;
+};
 
 typedef struct SiFiveEState {
     /*< private >*/
diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h
index 2656b39808a..ef050a22dc2 100644
--- a/include/hw/riscv/sifive_u.h
+++ b/include/hw/riscv/sifive_u.h
@@ -27,12 +27,14 @@
 #include "hw/misc/sifive_u_otp.h"
 #include "hw/misc/sifive_u_prci.h"
 #include "hw/ssi/sifive_spi.h"
+#include "qom/object.h"
 
 #define TYPE_RISCV_U_SOC "riscv.sifive.u.soc"
+typedef struct SiFiveUSoCState SiFiveUSoCState;
 #define RISCV_U_SOC(obj) \
     OBJECT_CHECK(SiFiveUSoCState, (obj), TYPE_RISCV_U_SOC)
 
-typedef struct SiFiveUSoCState {
+struct SiFiveUSoCState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -52,13 +54,14 @@ typedef struct SiFiveUSoCState {
 
     uint32_t serial;
     char *cpu_type;
-} SiFiveUSoCState;
+};
 
 #define TYPE_RISCV_U_MACHINE MACHINE_TYPE_NAME("sifive_u")
+typedef struct SiFiveUState SiFiveUState;
 #define RISCV_U_MACHINE(obj) \
     OBJECT_CHECK(SiFiveUState, (obj), TYPE_RISCV_U_MACHINE)
 
-typedef struct SiFiveUState {
+struct SiFiveUState {
     /*< private >*/
     MachineState parent_obj;
 
@@ -71,7 +74,7 @@ typedef struct SiFiveUState {
     bool start_in_flash;
     uint32_t msel;
     uint32_t serial;
-} SiFiveUState;
+};
 
 enum {
     SIFIVE_U_DEV_DEBUG,
diff --git a/include/hw/rtc/m48t59.h b/include/hw/rtc/m48t59.h
index d9b45eb1612..0b5beb9e2d6 100644
--- a/include/hw/rtc/m48t59.h
+++ b/include/hw/rtc/m48t59.h
@@ -34,10 +34,10 @@
 typedef struct NvramClass NvramClass;
 DECLARE_CLASS_CHECKERS(NvramClass, NVRAM,
                        TYPE_NVRAM)
+typedef struct Nvram Nvram;
 #define NVRAM(obj) \
     INTERFACE_CHECK(Nvram, (obj), TYPE_NVRAM)
 
-typedef struct Nvram Nvram;
 
 struct NvramClass {
     InterfaceClass parent;
diff --git a/include/hw/sd/cadence_sdhci.h b/include/hw/sd/cadence_sdhci.h
index cd8288b7d80..c890e285fca 100644
--- a/include/hw/sd/cadence_sdhci.h
+++ b/include/hw/sd/cadence_sdhci.h
@@ -24,6 +24,7 @@
 #define CADENCE_SDHCI_H
 
 #include "hw/sd/sdhci.h"
+#include "qom/object.h"
 
 #define CADENCE_SDHCI_REG_SIZE  0x100
 #define CADENCE_SDHCI_NUM_REGS  (CADENCE_SDHCI_REG_SIZE / sizeof(uint32_t))
diff --git a/include/hw/ssi/npcm7xx_fiu.h b/include/hw/ssi/npcm7xx_fiu.h
index a3a17042896..01597ea8954 100644
--- a/include/hw/ssi/npcm7xx_fiu.h
+++ b/include/hw/ssi/npcm7xx_fiu.h
@@ -18,6 +18,7 @@
 
 #include "hw/ssi/ssi.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /*
  * Number of registers in our device state structure. Don't change this without
diff --git a/include/hw/ssi/sifive_spi.h b/include/hw/ssi/sifive_spi.h
index 47d0d6a47cc..6ed73ccfef0 100644
--- a/include/hw/ssi/sifive_spi.h
+++ b/include/hw/ssi/sifive_spi.h
@@ -21,13 +21,15 @@
 
 #ifndef HW_SIFIVE_SPI_H
 #define HW_SIFIVE_SPI_H
+#include "qom/object.h"
 
 #define SIFIVE_SPI_REG_NUM  (0x78 / 4)
 
 #define TYPE_SIFIVE_SPI "sifive.spi"
+typedef struct SiFiveSPIState SiFiveSPIState;
 #define SIFIVE_SPI(obj) OBJECT_CHECK(SiFiveSPIState, (obj), TYPE_SIFIVE_SPI)
 
-typedef struct SiFiveSPIState {
+struct SiFiveSPIState {
     SysBusDevice parent_obj;
 
     MemoryRegion mmio;
@@ -42,6 +44,6 @@ typedef struct SiFiveSPIState {
     Fifo8 rx_fifo;
 
     uint32_t regs[SIFIVE_SPI_REG_NUM];
-} SiFiveSPIState;
+};
 
 #endif /* HW_SIFIVE_SPI_H */
diff --git a/include/hw/stream.h b/include/hw/stream.h
index f166facb090..3190cc0dc73 100644
--- a/include/hw/stream.h
+++ b/include/hw/stream.h
@@ -8,10 +8,10 @@
 typedef struct StreamSinkClass StreamSinkClass;
 DECLARE_CLASS_CHECKERS(StreamSinkClass, STREAM_SINK,
                        TYPE_STREAM_SINK)
+typedef struct StreamSink StreamSink;
 #define STREAM_SINK(obj) \
      INTERFACE_CHECK(StreamSink, (obj), TYPE_STREAM_SINK)
 
-typedef struct StreamSink StreamSink;
 
 typedef void (*StreamCanPushNotifyFn)(void *opaque);
 
diff --git a/include/hw/timer/npcm7xx_timer.h b/include/hw/timer/npcm7xx_timer.h
index d45c051b56a..d06b14acdc0 100644
--- a/include/hw/timer/npcm7xx_timer.h
+++ b/include/hw/timer/npcm7xx_timer.h
@@ -19,6 +19,7 @@
 #include "exec/memory.h"
 #include "hw/sysbus.h"
 #include "qemu/timer.h"
+#include "qom/object.h"
 
 /* Each Timer Module (TIM) instance holds five 25 MHz timers. */
 #define NPCM7XX_TIMERS_PER_CTRL (5)
diff --git a/include/hw/tricore/tricore_testdevice.h b/include/hw/tricore/tricore_testdevice.h
index e93c883872d..f6a2dd25320 100644
--- a/include/hw/tricore/tricore_testdevice.h
+++ b/include/hw/tricore/tricore_testdevice.h
@@ -21,18 +21,20 @@
 
 #include "hw/sysbus.h"
 #include "hw/hw.h"
+#include "qom/object.h"
 
 #define TYPE_TRICORE_TESTDEVICE "tricore_testdevice"
+typedef struct TriCoreTestDeviceState TriCoreTestDeviceState;
 #define TRICORE_TESTDEVICE(obj) \
     OBJECT_CHECK(TriCoreTestDeviceState, (obj), TYPE_TRICORE_TESTDEVICE)
 
-typedef struct TriCoreTestDeviceState {
+struct TriCoreTestDeviceState {
     /* <private> */
     SysBusDevice parent_obj;
 
     /* <public> */
     MemoryRegion iomem;
 
-} TriCoreTestDeviceState;
+};
 
 #endif
diff --git a/include/hw/usb/hcd-dwc3.h b/include/hw/usb/hcd-dwc3.h
index 7c804d536d5..799a701bae3 100644
--- a/include/hw/usb/hcd-dwc3.h
+++ b/include/hw/usb/hcd-dwc3.h
@@ -28,16 +28,18 @@
 
 #include "hw/usb/hcd-xhci.h"
 #include "hw/usb/hcd-xhci-sysbus.h"
+#include "qom/object.h"
 
 #define TYPE_USB_DWC3 "usb_dwc3"
 
+typedef struct USBDWC3 USBDWC3;
 #define USB_DWC3(obj) \
      OBJECT_CHECK(USBDWC3, (obj), TYPE_USB_DWC3)
 
 #define USB_DWC3_R_MAX ((0x530 / 4) + 1)
 #define DWC3_SIZE 0x10000
 
-typedef struct USBDWC3 {
+struct USBDWC3 {
     SysBusDevice parent_obj;
     MemoryRegion iomem;
     XHCISysbusState sysbus_xhci;
@@ -50,6 +52,6 @@ typedef struct USBDWC3 {
         uint32_t    dwc_usb3_user;
     } cfg;
 
-} USBDWC3;
+};
 
 #endif
diff --git a/include/hw/usb/msd.h b/include/hw/usb/msd.h
index 7538c54569b..82c8b48d561 100644
--- a/include/hw/usb/msd.h
+++ b/include/hw/usb/msd.h
@@ -9,6 +9,7 @@
 
 #include "hw/usb.h"
 #include "hw/scsi/scsi.h"
+#include "qom/object.h"
 
 enum USBMSDMode {
     USB_MSDM_CBW, /* Command Block.  */
diff --git a/include/hw/usb/xlnx-usb-subsystem.h b/include/hw/usb/xlnx-usb-subsystem.h
index 999e423951a..e6175146817 100644
--- a/include/hw/usb/xlnx-usb-subsystem.h
+++ b/include/hw/usb/xlnx-usb-subsystem.h
@@ -27,19 +27,21 @@
 
 #include "hw/usb/xlnx-versal-usb2-ctrl-regs.h"
 #include "hw/usb/hcd-dwc3.h"
+#include "qom/object.h"
 
 #define TYPE_XILINX_VERSAL_USB2 "xlnx.versal-usb2"
 
+typedef struct VersalUsb2 VersalUsb2;
 #define VERSAL_USB2(obj) \
      OBJECT_CHECK(VersalUsb2, (obj), TYPE_XILINX_VERSAL_USB2)
 
-typedef struct VersalUsb2 {
+struct VersalUsb2 {
     SysBusDevice parent_obj;
     MemoryRegion dwc3_mr;
     MemoryRegion usb2Ctrl_mr;
 
     VersalUsb2CtrlRegs usb2Ctrl;
     USBDWC3 dwc3;
-} VersalUsb2;
+};
 
 #endif
diff --git a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
index b76dce04195..7848cac6c1c 100644
--- a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
+++ b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
@@ -25,21 +25,23 @@
 
 #ifndef XLNX_USB2_REGS_H
 #define XLNX_USB2_REGS_H
+#include "qom/object.h"
 
 #define TYPE_XILINX_VERSAL_USB2_CTRL_REGS "xlnx.versal-usb2-ctrl-regs"
 
+typedef struct VersalUsb2CtrlRegs VersalUsb2CtrlRegs;
 #define XILINX_VERSAL_USB2_CTRL_REGS(obj) \
      OBJECT_CHECK(VersalUsb2CtrlRegs, (obj), TYPE_XILINX_VERSAL_USB2_CTRL_REGS)
 
 #define USB2_REGS_R_MAX ((0x78 / 4) + 1)
 
-typedef struct VersalUsb2CtrlRegs {
+struct VersalUsb2CtrlRegs {
     SysBusDevice parent_obj;
     MemoryRegion iomem;
     qemu_irq irq_ir;
 
     uint32_t regs[USB2_REGS_R_MAX];
     RegisterInfo regs_info[USB2_REGS_R_MAX];
-} VersalUsb2CtrlRegs;
+};
 
 #endif
diff --git a/include/hw/vmstate-if.h b/include/hw/vmstate-if.h
index 52df571d17a..0250956967c 100644
--- a/include/hw/vmstate-if.h
+++ b/include/hw/vmstate-if.h
@@ -16,10 +16,10 @@
 typedef struct VMStateIfClass VMStateIfClass;
 DECLARE_CLASS_CHECKERS(VMStateIfClass, VMSTATE_IF,
                        TYPE_VMSTATE_IF)
+typedef struct VMStateIf VMStateIf;
 #define VMSTATE_IF(obj)                             \
     INTERFACE_CHECK(VMStateIf, (obj), TYPE_VMSTATE_IF)
 
-typedef struct VMStateIf VMStateIf;
 
 struct VMStateIfClass {
     InterfaceClass parent_class;
diff --git a/include/hw/watchdog/sbsa_gwdt.h b/include/hw/watchdog/sbsa_gwdt.h
index dcb13bc29dc..babb120f5d3 100644
--- a/include/hw/watchdog/sbsa_gwdt.h
+++ b/include/hw/watchdog/sbsa_gwdt.h
@@ -15,8 +15,10 @@
 #include "qemu/bitops.h"
 #include "hw/sysbus.h"
 #include "hw/irq.h"
+#include "qom/object.h"
 
 #define TYPE_WDT_SBSA "sbsa_gwdt"
+typedef struct SBSA_GWDTState SBSA_GWDTState;
 #define SBSA_GWDT(obj) \
     OBJECT_CHECK(SBSA_GWDTState, (obj), TYPE_WDT_SBSA)
 
@@ -53,7 +55,7 @@
 
 #define SBSA_TIMER_FREQ      62500000 /* Hz */
 
-typedef struct SBSA_GWDTState {
+struct SBSA_GWDTState {
     /* <private> */
     SysBusDevice parent_obj;
 
@@ -70,6 +72,6 @@ typedef struct SBSA_GWDTState {
     uint32_t woru;
     uint32_t wcvl;
     uint32_t wcvu;
-} SBSA_GWDTState;
+};
 
 #endif /* WDT_SBSA_GWDT_H */
diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 81541e20801..57d5f6c0532 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -10,11 +10,11 @@
 typedef struct UserCreatableClass UserCreatableClass;
 DECLARE_CLASS_CHECKERS(UserCreatableClass, USER_CREATABLE,
                        TYPE_USER_CREATABLE)
+typedef struct UserCreatable UserCreatable;
 #define USER_CREATABLE(obj) \
      INTERFACE_CHECK(UserCreatable, (obj), \
                      TYPE_USER_CREATABLE)
 
-typedef struct UserCreatable UserCreatable;
 
 /**
  * UserCreatableClass:
diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
index 68b2206463c..4a02a8e0266 100644
--- a/include/sysemu/tpm.h
+++ b/include/sysemu/tpm.h
@@ -31,10 +31,10 @@ typedef enum TPMVersion {
 typedef struct TPMIfClass TPMIfClass;
 DECLARE_CLASS_CHECKERS(TPMIfClass, TPM_IF,
                        TYPE_TPM_IF)
+typedef struct TPMIf TPMIf;
 #define TPM_IF(obj)                             \
     INTERFACE_CHECK(TPMIf, (obj), TYPE_TPM_IF)
 
-typedef struct TPMIf TPMIf;
 
 struct TPMIfClass {
     InterfaceClass parent_class;
diff --git a/target/arm/idau.h b/target/arm/idau.h
index 0ef5251971d..600ac9066cf 100644
--- a/target/arm/idau.h
+++ b/target/arm/idau.h
@@ -31,13 +31,13 @@
 #include "qom/object.h"
 
 #define TYPE_IDAU_INTERFACE "idau-interface"
+typedef struct IDAUInterface IDAUInterface;
 #define IDAU_INTERFACE(obj) \
     INTERFACE_CHECK(IDAUInterface, (obj), TYPE_IDAU_INTERFACE)
 typedef struct IDAUInterfaceClass IDAUInterfaceClass;
 DECLARE_CLASS_CHECKERS(IDAUInterfaceClass, IDAU_INTERFACE,
                        TYPE_IDAU_INTERFACE)
 
-typedef struct IDAUInterface IDAUInterface;
 
 #define IREGION_NOTVALID -1
 
diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h
index 2855dd38816..20928b9efa5 100644
--- a/target/hexagon/cpu.h
+++ b/target/hexagon/cpu.h
@@ -17,6 +17,7 @@
 
 #ifndef HEXAGON_CPU_H
 #define HEXAGON_CPU_H
+#include "qom/object.h"
 
 /* Forward declaration needed by some of the header files */
 typedef struct CPUHexagonState CPUHexagonState;
@@ -101,6 +102,8 @@ struct CPUHexagonState {
     target_ulong gather_issued;
 };
 
+typedef struct HexagonCPUClass HexagonCPUClass;
+typedef struct HexagonCPU HexagonCPU;
 #define HEXAGON_CPU_CLASS(klass) \
     OBJECT_CLASS_CHECK(HexagonCPUClass, (klass), TYPE_HEXAGON_CPU)
 #define HEXAGON_CPU(obj) \
@@ -108,15 +111,15 @@ struct CPUHexagonState {
 #define HEXAGON_CPU_GET_CLASS(obj) \
     OBJECT_GET_CLASS(HexagonCPUClass, (obj), TYPE_HEXAGON_CPU)
 
-typedef struct HexagonCPUClass {
+struct HexagonCPUClass {
     /*< private >*/
     CPUClass parent_class;
     /*< public >*/
     DeviceRealize parent_realize;
     DeviceReset parent_reset;
-} HexagonCPUClass;
+};
 
-typedef struct HexagonCPU {
+struct HexagonCPU {
     /*< private >*/
     CPUState parent_obj;
     /*< public >*/
@@ -125,7 +128,7 @@ typedef struct HexagonCPU {
 
     bool lldb_compat;
     target_ulong lldb_stack_adjust;
-} HexagonCPU;
+};
 
 #include "cpu_bits.h"
 
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index c0812e5dfd6..3ee6aaff265 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -33,6 +33,7 @@
 #include "qemu/accel.h"
 #include "qapi/qapi-builtin-visit.h"
 #include "qemu/units.h"
+#include "qom/object.h"
 #if !defined(CONFIG_USER_ONLY)
 #include "hw/boards.h"
 #endif
diff --git a/chardev/char-parallel.c b/chardev/char-parallel.c
index acf9fb8afa0..dcbf6177a1e 100644
--- a/chardev/char-parallel.c
+++ b/chardev/char-parallel.c
@@ -28,6 +28,7 @@
 #include "qemu/module.h"
 #include "qemu/option.h"
 #include <sys/ioctl.h>
+#include "qom/object.h"
 
 #ifdef CONFIG_BSD
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
index f894338fc6a..4394c0d67c6 100644
--- a/hw/arm/bcm2836.c
+++ b/hw/arm/bcm2836.c
@@ -15,6 +15,7 @@
 #include "hw/arm/bcm2836.h"
 #include "hw/arm/raspi_platform.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 struct BCM283XClass {
     /*< private >*/
diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c
index 72a815dbbd0..bd7e328435a 100644
--- a/hw/m68k/mcf5206.c
+++ b/hw/m68k/mcf5206.c
@@ -17,6 +17,7 @@
 #include "hw/ptimer.h"
 #include "sysemu/sysemu.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /* General purpose timer module.  */
 typedef struct {
diff --git a/hw/mem/sparse-mem.c b/hw/mem/sparse-mem.c
index e6640eb8e72..0d8c0327258 100644
--- a/hw/mem/sparse-mem.c
+++ b/hw/mem/sparse-mem.c
@@ -18,11 +18,13 @@
 #include "qemu/units.h"
 #include "sysemu/qtest.h"
 #include "hw/mem/sparse-mem.h"
+#include "qom/object.h"
 
+typedef struct SparseMemState SparseMemState;
 #define SPARSE_MEM(obj) OBJECT_CHECK(SparseMemState, (obj), TYPE_SPARSE_MEM)
 #define SPARSE_BLOCK_SIZE 0x1000
 
-typedef struct SparseMemState {
+struct SparseMemState {
     SysBusDevice parent_obj;
     MemoryRegion mmio;
     uint64_t baseaddr;
@@ -30,7 +32,7 @@ typedef struct SparseMemState {
     uint64_t size_used;
     uint64_t maxsize;
     GHashTable *mapped;
-} SparseMemState;
+};
 
 typedef struct sparse_mem_block {
     uint8_t data[SPARSE_BLOCK_SIZE];
diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
index ae192db0c8b..abcc01e4087 100644
--- a/hw/mips/loongson3_virt.c
+++ b/hw/mips/loongson3_virt.c
@@ -52,6 +52,7 @@
 #include "sysemu/reset.h"
 #include "sysemu/runstate.h"
 #include "qemu/error-report.h"
+#include "qom/object.h"
 
 #define PM_CNTL_MODE          0x10
 
diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c
index 0b61070c52f..da6b14c545d 100644
--- a/hw/misc/npcm7xx_clk.c
+++ b/hw/misc/npcm7xx_clk.c
@@ -27,6 +27,7 @@
 #include "qemu/units.h"
 #include "trace.h"
 #include "sysemu/watchdog.h"
+#include "qom/object.h"
 
 /*
  * The reference clock hz, and the SECCNT and CNTR25M registers in this module,
diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c
index 9e3c40a23dc..846b2ff905a 100644
--- a/hw/misc/sbsa_ec.c
+++ b/hw/misc/sbsa_ec.c
@@ -15,6 +15,7 @@
 #include "qemu/log.h"
 #include "hw/sysbus.h"
 #include "sysemu/runstate.h"
+#include "qom/object.h"
 
 typedef struct SECUREECState {
     SysBusDevice parent_obj;
diff --git a/hw/net/can/ctucan_pci.c b/hw/net/can/ctucan_pci.c
index f1c86cd06a7..1f277a7c363 100644
--- a/hw/net/can/ctucan_pci.c
+++ b/hw/net/can/ctucan_pci.c
@@ -40,6 +40,7 @@
 #include "net/can_emu.h"
 
 #include "ctucan_core.h"
+#include "qom/object.h"
 
 #define TYPE_CTUCAN_PCI_DEV "ctucan_pci"
 
diff --git a/hw/nvram/npcm7xx_otp.c b/hw/nvram/npcm7xx_otp.c
index c61f2fc1aa2..52b9482419e 100644
--- a/hw/nvram/npcm7xx_otp.c
+++ b/hw/nvram/npcm7xx_otp.c
@@ -23,6 +23,7 @@
 #include "qemu/log.h"
 #include "qemu/module.h"
 #include "qemu/units.h"
+#include "qom/object.h"
 
 /* Each module has 4 KiB of register space. Only a fraction of it is used. */
 #define NPCM7XX_OTP_REGS_SIZE (4 * KiB)
diff --git a/hw/s390x/vhost-user-fs-ccw.c b/hw/s390x/vhost-user-fs-ccw.c
index 6c6f2692930..7d573156780 100644
--- a/hw/s390x/vhost-user-fs-ccw.c
+++ b/hw/s390x/vhost-user-fs-ccw.c
@@ -12,6 +12,7 @@
 #include "qapi/error.h"
 #include "hw/virtio/vhost-user-fs.h"
 #include "virtio-ccw.h"
+#include "qom/object.h"
 
 typedef struct VHostUserFSCcw {
     VirtioCcwDevice parent_obj;
diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
index 7310c769be2..80365dbd780 100644
--- a/hw/sensor/adm1272.c
+++ b/hw/sensor/adm1272.c
@@ -16,8 +16,10 @@
 #include "qapi/visitor.h"
 #include "qemu/log.h"
 #include "qemu/module.h"
+#include "qom/object.h"
 
 #define TYPE_ADM1272 "adm1272"
+typedef struct ADM1272State ADM1272State;
 #define ADM1272(obj) OBJECT_CHECK(ADM1272State, (obj), TYPE_ADM1272)
 
 #define ADM1272_RESTART_TIME            0xCC
@@ -70,7 +72,7 @@
 #define ADM1272_IOUT_OFFSET             0x5000
 
 
-typedef struct ADM1272State {
+struct ADM1272State {
     PMBusDevice parent;
 
     uint64_t ein_ext;
@@ -96,7 +98,7 @@ typedef struct ADM1272State {
 
     uint16_t strt_up_iout_lim;
 
-} ADM1272State;
+};
 
 static const PMBusCoefficients adm1272_coefficients[] = {
     [0] = { 6770, 0, -2 },        /* voltage, vrange 60V */
diff --git a/hw/sensor/max34451.c b/hw/sensor/max34451.c
index a91d8bd487c..5d50e46b5ba 100644
--- a/hw/sensor/max34451.c
+++ b/hw/sensor/max34451.c
@@ -14,8 +14,10 @@
 #include "qapi/visitor.h"
 #include "qemu/log.h"
 #include "qemu/module.h"
+#include "qom/object.h"
 
 #define TYPE_MAX34451 "max34451"
+typedef struct MAX34451State MAX34451State;
 #define MAX34451(obj) OBJECT_CHECK(MAX34451State, (obj), TYPE_MAX34451)
 
 #define MAX34451_MFR_MODE               0xD1
@@ -134,7 +136,7 @@
  * @vout_scale: scale ADC reading to actual device reading if different
  * @iout_cal_gain: set ratio of the voltage at the ADC input to sensed current
  */
-typedef struct MAX34451State {
+struct MAX34451State {
     PMBusDevice parent;
 
     uint16_t power_good_on[MAX34451_NUM_PWR_DEVICES];
@@ -168,7 +170,7 @@ typedef struct MAX34451State {
     uint16_t temp_sensor_config[MAX34451_NUM_TEMP_DEVICES];
     uint16_t store_single;
     uint16_t crc;
-} MAX34451State;
+};
 
 
 static void max34451_check_limits(MAX34451State *s)
diff --git a/hw/usb/u2f-emulated.c b/hw/usb/u2f-emulated.c
index 9151feb63d4..7c092e7a93f 100644
--- a/hw/usb/u2f-emulated.c
+++ b/hw/usb/u2f-emulated.c
@@ -34,6 +34,7 @@
 #include <u2f-emu/u2f-emu.h>
 
 #include "u2f.h"
+#include "qom/object.h"
 
 /* Counter which sync with a file */
 struct synced_counter {
diff --git a/hw/usb/u2f-passthru.c b/hw/usb/u2f-passthru.c
index fc93429c9c0..954b8aa3c9b 100644
--- a/hw/usb/u2f-passthru.c
+++ b/hw/usb/u2f-passthru.c
@@ -33,6 +33,7 @@
 #include "migration/vmstate.h"
 
 #include "u2f.h"
+#include "qom/object.h"
 
 #ifdef CONFIG_LIBUDEV
 #include <libudev.h>
diff --git a/hw/virtio/vhost-user-i2c-pci.c b/hw/virtio/vhost-user-i2c-pci.c
index 70b7b65fd97..dd25e593545 100644
--- a/hw/virtio/vhost-user-i2c-pci.c
+++ b/hw/virtio/vhost-user-i2c-pci.c
@@ -10,6 +10,7 @@
 #include "hw/qdev-properties.h"
 #include "hw/virtio/vhost-user-i2c.h"
 #include "virtio-pci.h"
+#include "qom/object.h"
 
 struct VHostUserI2CPCI {
     VirtIOPCIProxy parent_obj;
diff --git a/tests/unit/check-qom-interface.c b/tests/unit/check-qom-interface.c
index c99be97ed8b..4f534d09085 100644
--- a/tests/unit/check-qom-interface.c
+++ b/tests/unit/check-qom-interface.c
@@ -19,10 +19,10 @@
 typedef struct TestIfClass TestIfClass;
 DECLARE_CLASS_CHECKERS(TestIfClass, TEST_IF,
                        TYPE_TEST_IF)
+typedef struct TestIf TestIf;
 #define TEST_IF(obj) \
      INTERFACE_CHECK(TestIf, (obj), TYPE_TEST_IF)
 
-typedef struct TestIf TestIf;
 
 struct TestIfClass {
     InterfaceClass parent_class;
diff --git a/ui/vdagent.c b/ui/vdagent.c
index a253a8fe63a..1ca30a97958 100644
--- a/ui/vdagent.c
+++ b/ui/vdagent.c
@@ -15,6 +15,7 @@
 #include "qapi/qapi-types-ui.h"
 
 #include "spice/vd_agent.h"
+#include "qom/object.h"
 
 #define VDAGENT_BUFFER_LIMIT (1 * MiB)
 #define VDAGENT_MOUSE_DEFAULT true
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 05/12] [automated] Move QOM typedefs and add missing includes
@ 2021-08-06 21:11   ` Eduardo Habkost
  0 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrange, Paolo Bonzini, Richard Henderson,
	Marc-André Lureau, Peter Maydell, Andrew Baumann,
	Philippe Mathieu-Daudé,
	Thomas Huth, Michael S. Tsirkin, Igor Mammedov,
	Alexander Bulekov, Bandan Das, Stefan Hajnoczi, Huacai Chen,
	Jiaxun Yang, Aurelien Jarno, Aleksandar Rikalo,
	Havard Skinnemoen, Tyrone Ting, Pavel Pisa, Vikram Garhwal,
	Jason Wang, Keith Busch, Klaus Jensen, Cornelia Huck,
	Halil Pasic, Christian Borntraeger, David Hildenbrand,
	Gerd Hoffmann, Vijai Kumar K, Alistair Francis, Bin Meng,
	Palmer Dabbelt, Edgar E. Iglesias, Laurent Vivier, Corey Minyard,
	Cédric Le Goater, Andrew Jeffery, Joel Stanley,
	Francisco Iglesias, David Gibson, Greg Kurz,
	Alexey Kardashevskiy, Hervé Poussineau, Bastian Koppelmann,
	Juan Quintela, Dr. David Alan Gilbert, Stefan Berger,
	Taylor Simpson, qemu-arm, qemu-block, qemu-s390x, qemu-riscv,
	qemu-ppc

Some typedefs and macros are defined after the type check macros.
This makes it difficult to automatically replace their
definitions with OBJECT_DECLARE_TYPE.

Patch generated using:

 $ ./scripts/codeconverter/converter.py -i --pattern=MoveSymbols \
    $(git grep -l '' -- '*.[ch]')

which will:
- split "typdef struct { ... } TypedefName" declarations
- move the typedefs and #defines above the type check macros
- add missing #include "qom/object.h" lines if necessary

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Thomas Huth <huth@tuxfamily.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Alexander Bulekov <alxndr@bu.edu>
Cc: Bandan Das <bsd@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
Cc: Havard Skinnemoen <hskinnemoen@google.com>
Cc: Tyrone Ting <kfting@nuvoton.com>
Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Klaus Jensen <its@irrelevant.dk>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: Halil Pasic <pasic@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Vijai Kumar K <vijai@behindbytes.com>
Cc: Alistair Francis <Alistair.Francis@wdc.com>
Cc: Bin Meng <bin.meng@windriver.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: Laurent Vivier <laurent@vivier.eu>
Cc: Corey Minyard <minyard@acm.org>
Cc: "Cédric Le Goater" <clg@kaod.org>
Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Greg Kurz <groug@kaod.org>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: "Hervé Poussineau" <hpoussin@reactos.org>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: Juan Quintela <quintela@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>
Cc: Taylor Simpson <tsimpson@quicinc.com>
Cc: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org
Cc: qemu-block@nongnu.org
Cc: qemu-s390x@nongnu.org
Cc: qemu-riscv@nongnu.org
Cc: qemu-ppc@nongnu.org
---
 hw/nvme/nvme.h                              |  6 ++++--
 hw/usb/hcd-uhci.h                           |  1 +
 hw/usb/hcd-xhci-pci.h                       |  6 ++++--
 hw/usb/hcd-xhci-sysbus.h                    |  6 ++++--
 hw/usb/u2f.h                                |  6 ++++--
 include/hw/acpi/acpi_dev_interface.h        |  2 +-
 include/hw/adc/npcm7xx_adc.h                |  1 +
 include/hw/arm/linux-boot-if.h              |  2 +-
 include/hw/arm/npcm7xx.h                    | 11 +++++++----
 include/hw/char/shakti_uart.h               |  6 ++++--
 include/hw/core/accel-cpu.h                 |  1 +
 include/hw/dma/sifive_pdma.h                |  1 +
 include/hw/dma/xlnx_csu_dma.h               |  1 +
 include/hw/fw-path-provider.h               |  2 +-
 include/hw/gpio/npcm7xx_gpio.h              |  1 +
 include/hw/hotplug.h                        |  2 +-
 include/hw/i2c/npcm7xx_smbus.h              |  1 +
 include/hw/intc/intc.h                      |  2 +-
 include/hw/intc/m68k_irqc.h                 |  6 ++++--
 include/hw/intc/sifive_clint.h              |  6 ++++--
 include/hw/ipmi/ipmi.h                      |  2 +-
 include/hw/mem/memory-device.h              |  2 +-
 include/hw/mem/npcm7xx_mc.h                 |  1 +
 include/hw/misc/aspeed_lpc.h                |  6 ++++--
 include/hw/misc/bcm2835_cprman.h            |  1 +
 include/hw/misc/bcm2835_cprman_internals.h  |  1 +
 include/hw/misc/mchp_pfsoc_dmc.h            |  1 +
 include/hw/misc/mchp_pfsoc_ioscb.h          |  1 +
 include/hw/misc/mchp_pfsoc_sysreg.h         |  1 +
 include/hw/misc/npcm7xx_clk.h               |  1 +
 include/hw/misc/npcm7xx_gcr.h               |  1 +
 include/hw/misc/npcm7xx_pwm.h               |  1 +
 include/hw/misc/npcm7xx_rng.h               |  1 +
 include/hw/misc/xlnx-versal-xramc.h         |  6 ++++--
 include/hw/net/npcm7xx_emc.h                |  1 +
 include/hw/net/xlnx-zynqmp-can.h            |  6 ++++--
 include/hw/nmi.h                            |  2 +-
 include/hw/nvram/npcm7xx_otp.h              |  1 +
 include/hw/ppc/spapr_drc.h                  | 15 +++++++++------
 include/hw/ppc/spapr_xive.h                 | 11 +++++++----
 include/hw/ppc/vof.h                        |  1 +
 include/hw/rdma/rdma.h                      |  2 +-
 include/hw/riscv/microchip_pfsoc.h          |  1 +
 include/hw/riscv/shakti_c.h                 | 11 +++++++----
 include/hw/riscv/sifive_e.h                 |  6 ++++--
 include/hw/riscv/sifive_u.h                 | 11 +++++++----
 include/hw/rtc/m48t59.h                     |  2 +-
 include/hw/sd/cadence_sdhci.h               |  1 +
 include/hw/ssi/npcm7xx_fiu.h                |  1 +
 include/hw/ssi/sifive_spi.h                 |  6 ++++--
 include/hw/stream.h                         |  2 +-
 include/hw/timer/npcm7xx_timer.h            |  1 +
 include/hw/tricore/tricore_testdevice.h     |  6 ++++--
 include/hw/usb/hcd-dwc3.h                   |  6 ++++--
 include/hw/usb/msd.h                        |  1 +
 include/hw/usb/xlnx-usb-subsystem.h         |  6 ++++--
 include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  6 ++++--
 include/hw/vmstate-if.h                     |  2 +-
 include/hw/watchdog/sbsa_gwdt.h             |  6 ++++--
 include/qom/object_interfaces.h             |  2 +-
 include/sysemu/tpm.h                        |  2 +-
 target/arm/idau.h                           |  2 +-
 target/hexagon/cpu.h                        | 11 +++++++----
 accel/tcg/tcg-all.c                         |  1 +
 chardev/char-parallel.c                     |  1 +
 hw/arm/bcm2836.c                            |  1 +
 hw/m68k/mcf5206.c                           |  1 +
 hw/mem/sparse-mem.c                         |  6 ++++--
 hw/mips/loongson3_virt.c                    |  1 +
 hw/misc/npcm7xx_clk.c                       |  1 +
 hw/misc/sbsa_ec.c                           |  1 +
 hw/net/can/ctucan_pci.c                     |  1 +
 hw/nvram/npcm7xx_otp.c                      |  1 +
 hw/s390x/vhost-user-fs-ccw.c                |  1 +
 hw/sensor/adm1272.c                         |  6 ++++--
 hw/sensor/max34451.c                        |  6 ++++--
 hw/usb/u2f-emulated.c                       |  1 +
 hw/usb/u2f-passthru.c                       |  1 +
 hw/virtio/vhost-user-i2c-pci.c              |  1 +
 tests/unit/check-qom-interface.c            |  2 +-
 ui/vdagent.c                                |  1 +
 81 files changed, 179 insertions(+), 82 deletions(-)

diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
index 83ffabade4c..5ddcd783055 100644
--- a/hw/nvme/nvme.h
+++ b/hw/nvme/nvme.h
@@ -23,6 +23,7 @@
 #include "hw/block/block.h"
 
 #include "block/nvme.h"
+#include "qom/object.h"
 
 #define NVME_MAX_CONTROLLERS 32
 #define NVME_MAX_NAMESPACES  256
@@ -41,10 +42,11 @@ typedef struct NvmeBus {
 } NvmeBus;
 
 #define TYPE_NVME_SUBSYS "nvme-subsys"
+typedef struct NvmeSubsystem NvmeSubsystem;
 #define NVME_SUBSYS(obj) \
     OBJECT_CHECK(NvmeSubsystem, (obj), TYPE_NVME_SUBSYS)
 
-typedef struct NvmeSubsystem {
+struct NvmeSubsystem {
     DeviceState parent_obj;
     NvmeBus     bus;
     uint8_t     subnqn[256];
@@ -55,7 +57,7 @@ typedef struct NvmeSubsystem {
     struct {
         char *nqn;
     } params;
-} NvmeSubsystem;
+};
 
 int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp);
 void nvme_subsys_unregister_ctrl(NvmeSubsystem *subsys, NvmeCtrl *n);
diff --git a/hw/usb/hcd-uhci.h b/hw/usb/hcd-uhci.h
index e61d8fcb192..57d0d574644 100644
--- a/hw/usb/hcd-uhci.h
+++ b/hw/usb/hcd-uhci.h
@@ -32,6 +32,7 @@
 #include "qemu/timer.h"
 #include "hw/pci/pci.h"
 #include "hw/usb.h"
+#include "qom/object.h"
 
 typedef struct UHCIQueue UHCIQueue;
 
diff --git a/hw/usb/hcd-xhci-pci.h b/hw/usb/hcd-xhci-pci.h
index c193f794439..0cfe630a5ce 100644
--- a/hw/usb/hcd-xhci-pci.h
+++ b/hw/usb/hcd-xhci-pci.h
@@ -26,19 +26,21 @@
 
 #include "hw/usb.h"
 #include "hcd-xhci.h"
+#include "qom/object.h"
 
 #define TYPE_XHCI_PCI "pci-xhci"
+typedef struct XHCIPciState XHCIPciState;
 #define XHCI_PCI(obj) \
     OBJECT_CHECK(XHCIPciState, (obj), TYPE_XHCI_PCI)
 
 
-typedef struct XHCIPciState {
+struct XHCIPciState {
     /*< private >*/
     PCIDevice parent_obj;
     /*< public >*/
     XHCIState xhci;
     OnOffAuto msi;
     OnOffAuto msix;
-} XHCIPciState;
+};
 
 #endif
diff --git a/hw/usb/hcd-xhci-sysbus.h b/hw/usb/hcd-xhci-sysbus.h
index fdfcbbee3bf..7661c811fd1 100644
--- a/hw/usb/hcd-xhci-sysbus.h
+++ b/hw/usb/hcd-xhci-sysbus.h
@@ -14,18 +14,20 @@
 #include "hw/usb.h"
 #include "hcd-xhci.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
+typedef struct XHCISysbusState XHCISysbusState;
 #define XHCI_SYSBUS(obj) \
     OBJECT_CHECK(XHCISysbusState, (obj), TYPE_XHCI_SYSBUS)
 
 
-typedef struct XHCISysbusState {
+struct XHCISysbusState {
     /*< private >*/
     SysBusDevice parent_obj;
     /*< public >*/
     XHCIState xhci;
     qemu_irq *irq;
-} XHCISysbusState;
+};
 
 void xhci_sysbus_reset(DeviceState *dev);
 #endif
diff --git a/hw/usb/u2f.h b/hw/usb/u2f.h
index db30f3586bf..705d5c43ce6 100644
--- a/hw/usb/u2f.h
+++ b/hw/usb/u2f.h
@@ -27,6 +27,7 @@
 #define U2F_H
 
 #include "hw/qdev-core.h"
+#include "qom/object.h"
 
 #define U2FHID_PACKET_SIZE 64
 #define U2FHID_PENDING_IN_NUM 32
@@ -35,6 +36,7 @@ typedef struct U2FKeyState U2FKeyState;
 typedef struct U2FKeyInfo U2FKeyInfo;
 
 #define TYPE_U2F_KEY "u2f-key"
+typedef struct U2FKeyClass U2FKeyClass;
 #define U2F_KEY(obj) \
     OBJECT_CHECK(U2FKeyState, (obj), TYPE_U2F_KEY)
 #define U2F_KEY_CLASS(klass) \
@@ -46,7 +48,7 @@ typedef struct U2FKeyInfo U2FKeyInfo;
  * Callbacks to be used by the U2F key base device (i.e. hw/u2f.c)
  * to interact with its variants (i.e. hw/u2f-*.c)
  */
-typedef struct U2FKeyClass {
+struct U2FKeyClass {
     /*< private >*/
     USBDeviceClass parent_class;
 
@@ -55,7 +57,7 @@ typedef struct U2FKeyClass {
                             const uint8_t packet[U2FHID_PACKET_SIZE]);
     void (*realize)(U2FKeyState *key, Error **errp);
     void (*unrealize)(U2FKeyState *key);
-} U2FKeyClass;
+};
 
 /*
  * State of the U2F key base device (i.e. hw/u2f.c)
diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
index 769ff55c7ee..c9c7c17e043 100644
--- a/include/hw/acpi/acpi_dev_interface.h
+++ b/include/hw/acpi/acpi_dev_interface.h
@@ -21,11 +21,11 @@ typedef enum {
 typedef struct AcpiDeviceIfClass AcpiDeviceIfClass;
 DECLARE_CLASS_CHECKERS(AcpiDeviceIfClass, ACPI_DEVICE_IF,
                        TYPE_ACPI_DEVICE_IF)
+typedef struct AcpiDeviceIf AcpiDeviceIf;
 #define ACPI_DEVICE_IF(obj) \
      INTERFACE_CHECK(AcpiDeviceIf, (obj), \
                      TYPE_ACPI_DEVICE_IF)
 
-typedef struct AcpiDeviceIf AcpiDeviceIf;
 
 void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
 
diff --git a/include/hw/adc/npcm7xx_adc.h b/include/hw/adc/npcm7xx_adc.h
index 8e5a1897b4b..874cfbd6ce3 100644
--- a/include/hw/adc/npcm7xx_adc.h
+++ b/include/hw/adc/npcm7xx_adc.h
@@ -20,6 +20,7 @@
 #include "hw/irq.h"
 #include "hw/sysbus.h"
 #include "qemu/timer.h"
+#include "qom/object.h"
 
 #define NPCM7XX_ADC_NUM_INPUTS      8
 /**
diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
index c85f33b2c51..295e282c36e 100644
--- a/include/hw/arm/linux-boot-if.h
+++ b/include/hw/arm/linux-boot-if.h
@@ -12,10 +12,10 @@
 typedef struct ARMLinuxBootIfClass ARMLinuxBootIfClass;
 DECLARE_CLASS_CHECKERS(ARMLinuxBootIfClass, ARM_LINUX_BOOT_IF,
                        TYPE_ARM_LINUX_BOOT_IF)
+typedef struct ARMLinuxBootIf ARMLinuxBootIf;
 #define ARM_LINUX_BOOT_IF(obj) \
     INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
 
-typedef struct ARMLinuxBootIf ARMLinuxBootIf;
 
 struct ARMLinuxBootIfClass {
     /*< private >*/
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
index 61ecc57ab90..dc802c1645c 100644
--- a/include/hw/arm/npcm7xx.h
+++ b/include/hw/arm/npcm7xx.h
@@ -35,6 +35,7 @@
 #include "hw/usb/hcd-ehci.h"
 #include "hw/usb/hcd-ohci.h"
 #include "target/arm/cpu.h"
+#include "qom/object.h"
 
 #define NPCM7XX_MAX_NUM_CPUS    (2)
 
@@ -62,14 +63,15 @@ typedef struct NPCM7xxMachine {
 } NPCM7xxMachine;
 
 #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
+typedef struct NPCM7xxMachineClass NPCM7xxMachineClass;
 #define NPCM7XX_MACHINE(obj)                                            \
     OBJECT_CHECK(NPCM7xxMachine, (obj), TYPE_NPCM7XX_MACHINE)
 
-typedef struct NPCM7xxMachineClass {
+struct NPCM7xxMachineClass {
     MachineClass        parent;
 
     const char          *soc_type;
-} NPCM7xxMachineClass;
+};
 
 #define NPCM7XX_MACHINE_CLASS(klass)                                    \
     OBJECT_CLASS_CHECK(NPCM7xxMachineClass, (klass), TYPE_NPCM7XX_MACHINE)
@@ -106,19 +108,20 @@ typedef struct NPCM7xxState {
 } NPCM7xxState;
 
 #define TYPE_NPCM7XX    "npcm7xx"
+typedef struct NPCM7xxClass NPCM7xxClass;
 #define NPCM7XX(obj)    OBJECT_CHECK(NPCM7xxState, (obj), TYPE_NPCM7XX)
 
 #define TYPE_NPCM730    "npcm730"
 #define TYPE_NPCM750    "npcm750"
 
-typedef struct NPCM7xxClass {
+struct NPCM7xxClass {
     DeviceClass         parent;
 
     /* Bitmask of modules that are permanently disabled on this chip. */
     uint32_t            disabled_modules;
     /* Number of CPU cores enabled in this SoC class (may be 1 or 2). */
     uint32_t            num_cpus;
-} NPCM7xxClass;
+};
 
 #define NPCM7XX_CLASS(klass)                                            \
     OBJECT_CLASS_CHECK(NPCM7xxClass, (klass), TYPE_NPCM7XX)
diff --git a/include/hw/char/shakti_uart.h b/include/hw/char/shakti_uart.h
index 25f7cbcaa55..be7a93fb14d 100644
--- a/include/hw/char/shakti_uart.h
+++ b/include/hw/char/shakti_uart.h
@@ -27,6 +27,7 @@
 
 #include "hw/sysbus.h"
 #include "chardev/char-fe.h"
+#include "qom/object.h"
 
 #define SHAKTI_UART_BAUD        0x00
 #define SHAKTI_UART_TX          0x04
@@ -48,10 +49,11 @@
 #define SHAKTI_UART_CONTROL_DEFAULT 0x0100
 
 #define TYPE_SHAKTI_UART "shakti-uart"
+typedef struct ShaktiUartState ShaktiUartState;
 #define SHAKTI_UART(obj) \
     OBJECT_CHECK(ShaktiUartState, (obj), TYPE_SHAKTI_UART)
 
-typedef struct ShaktiUartState {
+struct ShaktiUartState {
     /* <private> */
     SysBusDevice parent_obj;
 
@@ -69,6 +71,6 @@ typedef struct ShaktiUartState {
     uint32_t uart_rx_threshold;
 
     CharBackend chr;
-} ShaktiUartState;
+};
 
 #endif /* HW_SHAKTI_UART_H */
diff --git a/include/hw/core/accel-cpu.h b/include/hw/core/accel-cpu.h
index 5dbfd799553..0b7b3f6df3e 100644
--- a/include/hw/core/accel-cpu.h
+++ b/include/hw/core/accel-cpu.h
@@ -10,6 +10,7 @@
 
 #ifndef ACCEL_CPU_H
 #define ACCEL_CPU_H
+#include "qom/object.h"
 
 /*
  * This header is used to define new accelerator-specific target-specific
diff --git a/include/hw/dma/sifive_pdma.h b/include/hw/dma/sifive_pdma.h
index e319bbd6c40..a62908dd0f2 100644
--- a/include/hw/dma/sifive_pdma.h
+++ b/include/hw/dma/sifive_pdma.h
@@ -22,6 +22,7 @@
 
 #ifndef SIFIVE_PDMA_H
 #define SIFIVE_PDMA_H
+#include "qom/object.h"
 
 struct sifive_pdma_chan {
     uint32_t control;
diff --git a/include/hw/dma/xlnx_csu_dma.h b/include/hw/dma/xlnx_csu_dma.h
index 204d94c6737..804ca5958d0 100644
--- a/include/hw/dma/xlnx_csu_dma.h
+++ b/include/hw/dma/xlnx_csu_dma.h
@@ -20,6 +20,7 @@
 
 #ifndef XLNX_CSU_DMA_H
 #define XLNX_CSU_DMA_H
+#include "qom/object.h"
 
 #define TYPE_XLNX_CSU_DMA "xlnx.csu_dma"
 
diff --git a/include/hw/fw-path-provider.h b/include/hw/fw-path-provider.h
index 8e1d45651cf..33d91daed52 100644
--- a/include/hw/fw-path-provider.h
+++ b/include/hw/fw-path-provider.h
@@ -25,10 +25,10 @@
 typedef struct FWPathProviderClass FWPathProviderClass;
 DECLARE_CLASS_CHECKERS(FWPathProviderClass, FW_PATH_PROVIDER,
                        TYPE_FW_PATH_PROVIDER)
+typedef struct FWPathProvider FWPathProvider;
 #define FW_PATH_PROVIDER(obj) \
      INTERFACE_CHECK(FWPathProvider, (obj), TYPE_FW_PATH_PROVIDER)
 
-typedef struct FWPathProvider FWPathProvider;
 
 struct FWPathProviderClass {
     InterfaceClass parent_class;
diff --git a/include/hw/gpio/npcm7xx_gpio.h b/include/hw/gpio/npcm7xx_gpio.h
index b1d771bd776..c4e5b4a353e 100644
--- a/include/hw/gpio/npcm7xx_gpio.h
+++ b/include/hw/gpio/npcm7xx_gpio.h
@@ -17,6 +17,7 @@
 
 #include "exec/memory.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /* Number of pins managed by each controller. */
 #define NPCM7XX_GPIO_NR_PINS (32)
diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h
index e15f59c8b3c..75d32d69e2b 100644
--- a/include/hw/hotplug.h
+++ b/include/hw/hotplug.h
@@ -19,10 +19,10 @@
 typedef struct HotplugHandlerClass HotplugHandlerClass;
 DECLARE_CLASS_CHECKERS(HotplugHandlerClass, HOTPLUG_HANDLER,
                        TYPE_HOTPLUG_HANDLER)
+typedef struct HotplugHandler HotplugHandler;
 #define HOTPLUG_HANDLER(obj) \
      INTERFACE_CHECK(HotplugHandler, (obj), TYPE_HOTPLUG_HANDLER)
 
-typedef struct HotplugHandler HotplugHandler;
 
 /**
  * hotplug_fn:
diff --git a/include/hw/i2c/npcm7xx_smbus.h b/include/hw/i2c/npcm7xx_smbus.h
index 7d59ee917eb..8030d78f69c 100644
--- a/include/hw/i2c/npcm7xx_smbus.h
+++ b/include/hw/i2c/npcm7xx_smbus.h
@@ -20,6 +20,7 @@
 #include "hw/i2c/i2c.h"
 #include "hw/irq.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /*
  * Number of addresses this module contains. Do not change this without
diff --git a/include/hw/intc/intc.h b/include/hw/intc/intc.h
index 7018f608ca5..7c57c3a0379 100644
--- a/include/hw/intc/intc.h
+++ b/include/hw/intc/intc.h
@@ -8,11 +8,11 @@
 typedef struct InterruptStatsProviderClass InterruptStatsProviderClass;
 DECLARE_CLASS_CHECKERS(InterruptStatsProviderClass, INTERRUPT_STATS_PROVIDER,
                        TYPE_INTERRUPT_STATS_PROVIDER)
+typedef struct InterruptStatsProvider InterruptStatsProvider;
 #define INTERRUPT_STATS_PROVIDER(obj) \
     INTERFACE_CHECK(InterruptStatsProvider, (obj), \
                     TYPE_INTERRUPT_STATS_PROVIDER)
 
-typedef struct InterruptStatsProvider InterruptStatsProvider;
 
 struct InterruptStatsProviderClass {
     InterfaceClass parent;
diff --git a/include/hw/intc/m68k_irqc.h b/include/hw/intc/m68k_irqc.h
index dbcfcfc2e00..460d8a5a8d3 100644
--- a/include/hw/intc/m68k_irqc.h
+++ b/include/hw/intc/m68k_irqc.h
@@ -11,8 +11,10 @@
 #define M68K_IRQC_H
 
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 #define TYPE_M68K_IRQC "m68k-irq-controller"
+typedef struct M68KIRQCState M68KIRQCState;
 #define M68K_IRQC(obj) OBJECT_CHECK(M68KIRQCState, (obj), \
                                     TYPE_M68K_IRQC)
 
@@ -29,13 +31,13 @@ enum {
 };
 #define M68K_IRQC_LEVEL_NUM (M68K_IRQC_LEVEL_7 - M68K_IRQC_LEVEL_1 + 1)
 
-typedef struct M68KIRQCState {
+struct M68KIRQCState {
     SysBusDevice parent_obj;
 
     uint8_t ipr;
 
     /* statistics */
     uint64_t stats_irq_count[M68K_IRQC_LEVEL_NUM];
-} M68KIRQCState;
+};
 
 #endif
diff --git a/include/hw/intc/sifive_clint.h b/include/hw/intc/sifive_clint.h
index a30be0f3d6f..8e005e130f1 100644
--- a/include/hw/intc/sifive_clint.h
+++ b/include/hw/intc/sifive_clint.h
@@ -21,13 +21,15 @@
 #define HW_SIFIVE_CLINT_H
 
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 #define TYPE_SIFIVE_CLINT "riscv.sifive.clint"
 
+typedef struct SiFiveCLINTState SiFiveCLINTState;
 #define SIFIVE_CLINT(obj) \
     OBJECT_CHECK(SiFiveCLINTState, (obj), TYPE_SIFIVE_CLINT)
 
-typedef struct SiFiveCLINTState {
+struct SiFiveCLINTState {
     /*< private >*/
     SysBusDevice parent_obj;
 
@@ -40,7 +42,7 @@ typedef struct SiFiveCLINTState {
     uint32_t time_base;
     uint32_t aperture_size;
     uint32_t timebase_freq;
-} SiFiveCLINTState;
+};
 
 DeviceState *sifive_clint_create(hwaddr addr, hwaddr size,
     uint32_t hartid_base, uint32_t num_harts, uint32_t sip_base,
diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h
index 77a7213ed93..d655352fa95 100644
--- a/include/hw/ipmi/ipmi.h
+++ b/include/hw/ipmi/ipmi.h
@@ -109,13 +109,13 @@ uint32_t ipmi_next_uuid(void);
  * and the BMC.
  */
 #define TYPE_IPMI_INTERFACE "ipmi-interface"
+typedef struct IPMIInterface IPMIInterface;
 #define IPMI_INTERFACE(obj) \
      INTERFACE_CHECK(IPMIInterface, (obj), TYPE_IPMI_INTERFACE)
 typedef struct IPMIInterfaceClass IPMIInterfaceClass;
 DECLARE_CLASS_CHECKERS(IPMIInterfaceClass, IPMI_INTERFACE,
                        TYPE_IPMI_INTERFACE)
 
-typedef struct IPMIInterface IPMIInterface;
 
 struct IPMIInterfaceClass {
     InterfaceClass parent;
diff --git a/include/hw/mem/memory-device.h b/include/hw/mem/memory-device.h
index 48d2611fc5e..a83428209b9 100644
--- a/include/hw/mem/memory-device.h
+++ b/include/hw/mem/memory-device.h
@@ -22,10 +22,10 @@
 typedef struct MemoryDeviceClass MemoryDeviceClass;
 DECLARE_CLASS_CHECKERS(MemoryDeviceClass, MEMORY_DEVICE,
                        TYPE_MEMORY_DEVICE)
+typedef struct MemoryDeviceState MemoryDeviceState;
 #define MEMORY_DEVICE(obj) \
      INTERFACE_CHECK(MemoryDeviceState, (obj), TYPE_MEMORY_DEVICE)
 
-typedef struct MemoryDeviceState MemoryDeviceState;
 
 /**
  * MemoryDeviceClass:
diff --git a/include/hw/mem/npcm7xx_mc.h b/include/hw/mem/npcm7xx_mc.h
index 7ed38be2431..83787f6fa57 100644
--- a/include/hw/mem/npcm7xx_mc.h
+++ b/include/hw/mem/npcm7xx_mc.h
@@ -18,6 +18,7 @@
 
 #include "exec/memory.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /**
  * struct NPCM7xxMCState - Device state for the memory controller.
diff --git a/include/hw/misc/aspeed_lpc.h b/include/hw/misc/aspeed_lpc.h
index df418cfcd36..def617b9772 100644
--- a/include/hw/misc/aspeed_lpc.h
+++ b/include/hw/misc/aspeed_lpc.h
@@ -13,8 +13,10 @@
 #include "hw/sysbus.h"
 
 #include <stdint.h>
+#include "qom/object.h"
 
 #define TYPE_ASPEED_LPC "aspeed.lpc"
+typedef struct AspeedLPCState AspeedLPCState;
 #define ASPEED_LPC(obj) OBJECT_CHECK(AspeedLPCState, (obj), TYPE_ASPEED_LPC)
 
 #define ASPEED_LPC_NR_REGS      (0x260 >> 2)
@@ -29,7 +31,7 @@ enum aspeed_lpc_subdevice {
 
 #define ASPEED_LPC_NR_SUBDEVS   5
 
-typedef struct AspeedLPCState {
+struct AspeedLPCState {
     /* <private> */
     SysBusDevice parent;
 
@@ -42,6 +44,6 @@ typedef struct AspeedLPCState {
 
     uint32_t regs[ASPEED_LPC_NR_REGS];
     uint32_t hicr7;
-} AspeedLPCState;
+};
 
 #endif /* _ASPEED_LPC_H_ */
diff --git a/include/hw/misc/bcm2835_cprman.h b/include/hw/misc/bcm2835_cprman.h
index 3df4ceedd2e..ba4b441dce5 100644
--- a/include/hw/misc/bcm2835_cprman.h
+++ b/include/hw/misc/bcm2835_cprman.h
@@ -11,6 +11,7 @@
 
 #include "hw/sysbus.h"
 #include "hw/qdev-clock.h"
+#include "qom/object.h"
 
 #define TYPE_BCM2835_CPRMAN "bcm2835-cprman"
 
diff --git a/include/hw/misc/bcm2835_cprman_internals.h b/include/hw/misc/bcm2835_cprman_internals.h
index 339759b3071..f5410580bff 100644
--- a/include/hw/misc/bcm2835_cprman_internals.h
+++ b/include/hw/misc/bcm2835_cprman_internals.h
@@ -11,6 +11,7 @@
 
 #include "hw/registerfields.h"
 #include "hw/misc/bcm2835_cprman.h"
+#include "qom/object.h"
 
 #define TYPE_CPRMAN_PLL "bcm2835-cprman-pll"
 #define TYPE_CPRMAN_PLL_CHANNEL "bcm2835-cprman-pll-channel"
diff --git a/include/hw/misc/mchp_pfsoc_dmc.h b/include/hw/misc/mchp_pfsoc_dmc.h
index 2baa1413b0c..979527957ea 100644
--- a/include/hw/misc/mchp_pfsoc_dmc.h
+++ b/include/hw/misc/mchp_pfsoc_dmc.h
@@ -22,6 +22,7 @@
 
 #ifndef MCHP_PFSOC_DMC_H
 #define MCHP_PFSOC_DMC_H
+#include "qom/object.h"
 
 /* DDR SGMII PHY module */
 
diff --git a/include/hw/misc/mchp_pfsoc_ioscb.h b/include/hw/misc/mchp_pfsoc_ioscb.h
index 9235523e334..519b897250f 100644
--- a/include/hw/misc/mchp_pfsoc_ioscb.h
+++ b/include/hw/misc/mchp_pfsoc_ioscb.h
@@ -22,6 +22,7 @@
 
 #ifndef MCHP_PFSOC_IOSCB_H
 #define MCHP_PFSOC_IOSCB_H
+#include "qom/object.h"
 
 typedef struct MchpPfSoCIoscbState {
     SysBusDevice parent;
diff --git a/include/hw/misc/mchp_pfsoc_sysreg.h b/include/hw/misc/mchp_pfsoc_sysreg.h
index 546ba68f6a1..d6803be9485 100644
--- a/include/hw/misc/mchp_pfsoc_sysreg.h
+++ b/include/hw/misc/mchp_pfsoc_sysreg.h
@@ -22,6 +22,7 @@
 
 #ifndef MCHP_PFSOC_SYSREG_H
 #define MCHP_PFSOC_SYSREG_H
+#include "qom/object.h"
 
 #define MCHP_PFSOC_SYSREG_REG_SIZE  0x2000
 
diff --git a/include/hw/misc/npcm7xx_clk.h b/include/hw/misc/npcm7xx_clk.h
index d5c8d16ca42..a849345620e 100644
--- a/include/hw/misc/npcm7xx_clk.h
+++ b/include/hw/misc/npcm7xx_clk.h
@@ -19,6 +19,7 @@
 #include "exec/memory.h"
 #include "hw/clock.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /*
  * Number of registers in our device state structure. Don't change this without
diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h
index 13109d9d324..482768c8e76 100644
--- a/include/hw/misc/npcm7xx_gcr.h
+++ b/include/hw/misc/npcm7xx_gcr.h
@@ -18,6 +18,7 @@
 
 #include "exec/memory.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /*
  * Number of registers in our device state structure. Don't change this without
diff --git a/include/hw/misc/npcm7xx_pwm.h b/include/hw/misc/npcm7xx_pwm.h
index 7ad632a93a1..c6643bd04fd 100644
--- a/include/hw/misc/npcm7xx_pwm.h
+++ b/include/hw/misc/npcm7xx_pwm.h
@@ -19,6 +19,7 @@
 #include "hw/clock.h"
 #include "hw/sysbus.h"
 #include "hw/irq.h"
+#include "qom/object.h"
 
 /* Each PWM module holds 4 PWM channels. */
 #define NPCM7XX_PWM_PER_MODULE 4
diff --git a/include/hw/misc/npcm7xx_rng.h b/include/hw/misc/npcm7xx_rng.h
index 5e85fd439d8..1d20293608a 100644
--- a/include/hw/misc/npcm7xx_rng.h
+++ b/include/hw/misc/npcm7xx_rng.h
@@ -17,6 +17,7 @@
 #define NPCM7XX_RNG_H
 
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 typedef struct NPCM7xxRNGState {
     SysBusDevice parent;
diff --git a/include/hw/misc/xlnx-versal-xramc.h b/include/hw/misc/xlnx-versal-xramc.h
index d3d1862676f..ba0d0f3c5af 100644
--- a/include/hw/misc/xlnx-versal-xramc.h
+++ b/include/hw/misc/xlnx-versal-xramc.h
@@ -11,9 +11,11 @@
 
 #include "hw/sysbus.h"
 #include "hw/register.h"
+#include "qom/object.h"
 
 #define TYPE_XLNX_XRAM_CTRL "xlnx.versal-xramc"
 
+typedef struct XlnxXramCtrl XlnxXramCtrl;
 #define XLNX_XRAM_CTRL(obj) \
      OBJECT_CHECK(XlnxXramCtrl, (obj), TYPE_XLNX_XRAM_CTRL)
 
@@ -80,7 +82,7 @@ REG32(XRAM_SAFETY_CHK, 0xff8)
 
 #define XRAM_CTRL_R_MAX (R_XRAM_SAFETY_CHK + 1)
 
-typedef struct XlnxXramCtrl {
+struct XlnxXramCtrl {
     SysBusDevice parent_obj;
     MemoryRegion ram;
     qemu_irq irq;
@@ -93,5 +95,5 @@ typedef struct XlnxXramCtrl {
     RegisterInfoArray *reg_array;
     uint32_t regs[XRAM_CTRL_R_MAX];
     RegisterInfo regs_info[XRAM_CTRL_R_MAX];
-} XlnxXramCtrl;
+};
 #endif
diff --git a/include/hw/net/npcm7xx_emc.h b/include/hw/net/npcm7xx_emc.h
index eac7f298167..5b676f669cd 100644
--- a/include/hw/net/npcm7xx_emc.h
+++ b/include/hw/net/npcm7xx_emc.h
@@ -20,6 +20,7 @@
 #include "hw/irq.h"
 #include "hw/sysbus.h"
 #include "net/net.h"
+#include "qom/object.h"
 
 /* 32-bit register indices. */
 enum NPCM7xxPWMRegister {
diff --git a/include/hw/net/xlnx-zynqmp-can.h b/include/hw/net/xlnx-zynqmp-can.h
index eb1558708bb..3d80c7455db 100644
--- a/include/hw/net/xlnx-zynqmp-can.h
+++ b/include/hw/net/xlnx-zynqmp-can.h
@@ -36,9 +36,11 @@
 #include "qemu/fifo32.h"
 #include "hw/ptimer.h"
 #include "hw/qdev-clock.h"
+#include "qom/object.h"
 
 #define TYPE_XLNX_ZYNQMP_CAN "xlnx.zynqmp-can"
 
+typedef struct XlnxZynqMPCANState XlnxZynqMPCANState;
 #define XLNX_ZYNQMP_CAN(obj) \
      OBJECT_CHECK(XlnxZynqMPCANState, (obj), TYPE_XLNX_ZYNQMP_CAN)
 
@@ -52,7 +54,7 @@
 #define CAN_FRAME_SIZE     4
 #define RXFIFO_SIZE        (MAILBOX_CAPACITY * CAN_FRAME_SIZE)
 
-typedef struct XlnxZynqMPCANState {
+struct XlnxZynqMPCANState {
     SysBusDevice        parent_obj;
     MemoryRegion        iomem;
 
@@ -73,6 +75,6 @@ typedef struct XlnxZynqMPCANState {
     Fifo32              txhpb_fifo;
 
     ptimer_state        *can_timer;
-} XlnxZynqMPCANState;
+};
 
 #endif
diff --git a/include/hw/nmi.h b/include/hw/nmi.h
index fff41bebc69..529ab736f8f 100644
--- a/include/hw/nmi.h
+++ b/include/hw/nmi.h
@@ -29,10 +29,10 @@
 typedef struct NMIClass NMIClass;
 DECLARE_CLASS_CHECKERS(NMIClass, NMI,
                        TYPE_NMI)
+typedef struct NMIState NMIState;
 #define NMI(obj) \
      INTERFACE_CHECK(NMIState, (obj), TYPE_NMI)
 
-typedef struct NMIState NMIState;
 
 struct NMIClass {
     InterfaceClass parent_class;
diff --git a/include/hw/nvram/npcm7xx_otp.h b/include/hw/nvram/npcm7xx_otp.h
index 156bbd151ab..32c73845ff3 100644
--- a/include/hw/nvram/npcm7xx_otp.h
+++ b/include/hw/nvram/npcm7xx_otp.h
@@ -18,6 +18,7 @@
 
 #include "exec/memory.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /* Each OTP module holds 8192 bits of one-time programmable storage */
 #define NPCM7XX_OTP_ARRAY_BITS (8192)
diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h
index 02a63b36666..83019d3f672 100644
--- a/include/hw/ppc/spapr_drc.h
+++ b/include/hw/ppc/spapr_drc.h
@@ -20,6 +20,8 @@
 #include "qapi/error.h"
 
 #define TYPE_SPAPR_DR_CONNECTOR "spapr-dr-connector"
+typedef struct SpaprDrc SpaprDrc;
+typedef struct SpaprDrcClass SpaprDrcClass;
 #define SPAPR_DR_CONNECTOR_GET_CLASS(obj) \
         OBJECT_GET_CLASS(SpaprDrcClass, obj, TYPE_SPAPR_DR_CONNECTOR)
 #define SPAPR_DR_CONNECTOR_CLASS(klass) \
@@ -29,6 +31,7 @@
                                              TYPE_SPAPR_DR_CONNECTOR)
 
 #define TYPE_SPAPR_DRC_PHYSICAL "spapr-drc-physical"
+typedef struct SpaprDrcPhysical SpaprDrcPhysical;
 #define SPAPR_DRC_PHYSICAL(obj) OBJECT_CHECK(SpaprDrcPhysical, (obj), \
                                              TYPE_SPAPR_DRC_PHYSICAL)
 
@@ -168,7 +171,7 @@ typedef enum {
     SPAPR_DRC_STATE_PHYSICAL_CONFIGURED = 8,
 } SpaprDrcState;
 
-typedef struct SpaprDrc {
+struct SpaprDrc {
     /*< private >*/
     DeviceState parent;
 
@@ -187,11 +190,11 @@ typedef struct SpaprDrc {
     bool unplug_requested;
     void *fdt;
     int fdt_start_offset;
-} SpaprDrc;
+};
 
 struct SpaprMachineState;
 
-typedef struct SpaprDrcClass {
+struct SpaprDrcClass {
     /*< private >*/
     DeviceClass parent;
     SpaprDrcState empty_state;
@@ -209,15 +212,15 @@ typedef struct SpaprDrcClass {
 
     int (*dt_populate)(SpaprDrc *drc, struct SpaprMachineState *spapr,
                        void *fdt, int *fdt_start_offset, Error **errp);
-} SpaprDrcClass;
+};
 
-typedef struct SpaprDrcPhysical {
+struct SpaprDrcPhysical {
     /*< private >*/
     SpaprDrc parent;
 
     /* DR-indicator */
     uint32_t dr_indicator;
-} SpaprDrcPhysical;
+};
 
 static inline bool spapr_drc_hotplugged(DeviceState *dev)
 {
diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h
index b282960ad90..d1371b2dbba 100644
--- a/include/hw/ppc/spapr_xive.h
+++ b/include/hw/ppc/spapr_xive.h
@@ -12,15 +12,18 @@
 
 #include "hw/ppc/spapr_irq.h"
 #include "hw/ppc/xive.h"
+#include "qom/object.h"
 
 #define TYPE_SPAPR_XIVE "spapr-xive"
+typedef struct SpaprXive SpaprXive;
+typedef struct SpaprXiveClass SpaprXiveClass;
 #define SPAPR_XIVE(obj) OBJECT_CHECK(SpaprXive, (obj), TYPE_SPAPR_XIVE)
 #define SPAPR_XIVE_CLASS(klass)                                         \
     OBJECT_CLASS_CHECK(SpaprXiveClass, (klass), TYPE_SPAPR_XIVE)
 #define SPAPR_XIVE_GET_CLASS(obj)                               \
     OBJECT_GET_CLASS(SpaprXiveClass, (obj), TYPE_SPAPR_XIVE)
 
-typedef struct SpaprXive {
+struct SpaprXive {
     XiveRouter    parent;
 
     /* Internal interrupt source for IPIs and virtual devices */
@@ -51,13 +54,13 @@ typedef struct SpaprXive {
     VMChangeStateEntry *change;
 
     uint8_t       hv_prio;
-} SpaprXive;
+};
 
-typedef struct SpaprXiveClass {
+struct SpaprXiveClass {
     XiveRouterClass parent;
 
     DeviceRealize parent_realize;
-} SpaprXiveClass;
+};
 
 /*
  * The sPAPR machine has a unique XIVE IC device. Assign a fixed value
diff --git a/include/hw/ppc/vof.h b/include/hw/ppc/vof.h
index 97fdef758bf..dd2b11ed6be 100644
--- a/include/hw/ppc/vof.h
+++ b/include/hw/ppc/vof.h
@@ -5,6 +5,7 @@
  */
 #ifndef HW_VOF_H
 #define HW_VOF_H
+#include "qom/object.h"
 
 typedef struct Vof {
     uint64_t top_addr; /* copied from rma_size */
diff --git a/include/hw/rdma/rdma.h b/include/hw/rdma/rdma.h
index e77e43a1709..e64104d631e 100644
--- a/include/hw/rdma/rdma.h
+++ b/include/hw/rdma/rdma.h
@@ -22,11 +22,11 @@
 typedef struct RdmaProviderClass RdmaProviderClass;
 DECLARE_CLASS_CHECKERS(RdmaProviderClass, RDMA_PROVIDER,
                        INTERFACE_RDMA_PROVIDER)
+typedef struct RdmaProvider RdmaProvider;
 #define RDMA_PROVIDER(obj) \
     INTERFACE_CHECK(RdmaProvider, (obj), \
                     INTERFACE_RDMA_PROVIDER)
 
-typedef struct RdmaProvider RdmaProvider;
 
 struct RdmaProviderClass {
     InterfaceClass parent;
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
index d30916f45d4..3f83f9d98da 100644
--- a/include/hw/riscv/microchip_pfsoc.h
+++ b/include/hw/riscv/microchip_pfsoc.h
@@ -29,6 +29,7 @@
 #include "hw/misc/mchp_pfsoc_sysreg.h"
 #include "hw/net/cadence_gem.h"
 #include "hw/sd/cadence_sdhci.h"
+#include "qom/object.h"
 
 typedef struct MicrochipPFSoCState {
     /*< private >*/
diff --git a/include/hw/riscv/shakti_c.h b/include/hw/riscv/shakti_c.h
index 50a2b790860..e07bca3a357 100644
--- a/include/hw/riscv/shakti_c.h
+++ b/include/hw/riscv/shakti_c.h
@@ -22,12 +22,14 @@
 #include "hw/riscv/riscv_hart.h"
 #include "hw/boards.h"
 #include "hw/char/shakti_uart.h"
+#include "qom/object.h"
 
 #define TYPE_RISCV_SHAKTI_SOC "riscv.shakti.cclass.soc"
+typedef struct ShaktiCSoCState ShaktiCSoCState;
 #define RISCV_SHAKTI_SOC(obj) \
     OBJECT_CHECK(ShaktiCSoCState, (obj), TYPE_RISCV_SHAKTI_SOC)
 
-typedef struct ShaktiCSoCState {
+struct ShaktiCSoCState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -37,18 +39,19 @@ typedef struct ShaktiCSoCState {
     ShaktiUartState uart;
     MemoryRegion rom;
 
-} ShaktiCSoCState;
+};
 
 #define TYPE_RISCV_SHAKTI_MACHINE MACHINE_TYPE_NAME("shakti_c")
+typedef struct ShaktiCMachineState ShaktiCMachineState;
 #define RISCV_SHAKTI_MACHINE(obj) \
     OBJECT_CHECK(ShaktiCMachineState, (obj), TYPE_RISCV_SHAKTI_MACHINE)
-typedef struct ShaktiCMachineState {
+struct ShaktiCMachineState {
     /*< private >*/
     MachineState parent_obj;
 
     /*< public >*/
     ShaktiCSoCState soc;
-} ShaktiCMachineState;
+};
 
 enum {
     SHAKTI_C_ROM,
diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h
index 83604da805c..e654e2dfec6 100644
--- a/include/hw/riscv/sifive_e.h
+++ b/include/hw/riscv/sifive_e.h
@@ -22,12 +22,14 @@
 #include "hw/riscv/riscv_hart.h"
 #include "hw/riscv/sifive_cpu.h"
 #include "hw/gpio/sifive_gpio.h"
+#include "qom/object.h"
 
 #define TYPE_RISCV_E_SOC "riscv.sifive.e.soc"
+typedef struct SiFiveESoCState SiFiveESoCState;
 #define RISCV_E_SOC(obj) \
     OBJECT_CHECK(SiFiveESoCState, (obj), TYPE_RISCV_E_SOC)
 
-typedef struct SiFiveESoCState {
+struct SiFiveESoCState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -37,7 +39,7 @@ typedef struct SiFiveESoCState {
     SIFIVEGPIOState gpio;
     MemoryRegion xip_mem;
     MemoryRegion mask_rom;
-} SiFiveESoCState;
+};
 
 typedef struct SiFiveEState {
     /*< private >*/
diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h
index 2656b39808a..ef050a22dc2 100644
--- a/include/hw/riscv/sifive_u.h
+++ b/include/hw/riscv/sifive_u.h
@@ -27,12 +27,14 @@
 #include "hw/misc/sifive_u_otp.h"
 #include "hw/misc/sifive_u_prci.h"
 #include "hw/ssi/sifive_spi.h"
+#include "qom/object.h"
 
 #define TYPE_RISCV_U_SOC "riscv.sifive.u.soc"
+typedef struct SiFiveUSoCState SiFiveUSoCState;
 #define RISCV_U_SOC(obj) \
     OBJECT_CHECK(SiFiveUSoCState, (obj), TYPE_RISCV_U_SOC)
 
-typedef struct SiFiveUSoCState {
+struct SiFiveUSoCState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -52,13 +54,14 @@ typedef struct SiFiveUSoCState {
 
     uint32_t serial;
     char *cpu_type;
-} SiFiveUSoCState;
+};
 
 #define TYPE_RISCV_U_MACHINE MACHINE_TYPE_NAME("sifive_u")
+typedef struct SiFiveUState SiFiveUState;
 #define RISCV_U_MACHINE(obj) \
     OBJECT_CHECK(SiFiveUState, (obj), TYPE_RISCV_U_MACHINE)
 
-typedef struct SiFiveUState {
+struct SiFiveUState {
     /*< private >*/
     MachineState parent_obj;
 
@@ -71,7 +74,7 @@ typedef struct SiFiveUState {
     bool start_in_flash;
     uint32_t msel;
     uint32_t serial;
-} SiFiveUState;
+};
 
 enum {
     SIFIVE_U_DEV_DEBUG,
diff --git a/include/hw/rtc/m48t59.h b/include/hw/rtc/m48t59.h
index d9b45eb1612..0b5beb9e2d6 100644
--- a/include/hw/rtc/m48t59.h
+++ b/include/hw/rtc/m48t59.h
@@ -34,10 +34,10 @@
 typedef struct NvramClass NvramClass;
 DECLARE_CLASS_CHECKERS(NvramClass, NVRAM,
                        TYPE_NVRAM)
+typedef struct Nvram Nvram;
 #define NVRAM(obj) \
     INTERFACE_CHECK(Nvram, (obj), TYPE_NVRAM)
 
-typedef struct Nvram Nvram;
 
 struct NvramClass {
     InterfaceClass parent;
diff --git a/include/hw/sd/cadence_sdhci.h b/include/hw/sd/cadence_sdhci.h
index cd8288b7d80..c890e285fca 100644
--- a/include/hw/sd/cadence_sdhci.h
+++ b/include/hw/sd/cadence_sdhci.h
@@ -24,6 +24,7 @@
 #define CADENCE_SDHCI_H
 
 #include "hw/sd/sdhci.h"
+#include "qom/object.h"
 
 #define CADENCE_SDHCI_REG_SIZE  0x100
 #define CADENCE_SDHCI_NUM_REGS  (CADENCE_SDHCI_REG_SIZE / sizeof(uint32_t))
diff --git a/include/hw/ssi/npcm7xx_fiu.h b/include/hw/ssi/npcm7xx_fiu.h
index a3a17042896..01597ea8954 100644
--- a/include/hw/ssi/npcm7xx_fiu.h
+++ b/include/hw/ssi/npcm7xx_fiu.h
@@ -18,6 +18,7 @@
 
 #include "hw/ssi/ssi.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /*
  * Number of registers in our device state structure. Don't change this without
diff --git a/include/hw/ssi/sifive_spi.h b/include/hw/ssi/sifive_spi.h
index 47d0d6a47cc..6ed73ccfef0 100644
--- a/include/hw/ssi/sifive_spi.h
+++ b/include/hw/ssi/sifive_spi.h
@@ -21,13 +21,15 @@
 
 #ifndef HW_SIFIVE_SPI_H
 #define HW_SIFIVE_SPI_H
+#include "qom/object.h"
 
 #define SIFIVE_SPI_REG_NUM  (0x78 / 4)
 
 #define TYPE_SIFIVE_SPI "sifive.spi"
+typedef struct SiFiveSPIState SiFiveSPIState;
 #define SIFIVE_SPI(obj) OBJECT_CHECK(SiFiveSPIState, (obj), TYPE_SIFIVE_SPI)
 
-typedef struct SiFiveSPIState {
+struct SiFiveSPIState {
     SysBusDevice parent_obj;
 
     MemoryRegion mmio;
@@ -42,6 +44,6 @@ typedef struct SiFiveSPIState {
     Fifo8 rx_fifo;
 
     uint32_t regs[SIFIVE_SPI_REG_NUM];
-} SiFiveSPIState;
+};
 
 #endif /* HW_SIFIVE_SPI_H */
diff --git a/include/hw/stream.h b/include/hw/stream.h
index f166facb090..3190cc0dc73 100644
--- a/include/hw/stream.h
+++ b/include/hw/stream.h
@@ -8,10 +8,10 @@
 typedef struct StreamSinkClass StreamSinkClass;
 DECLARE_CLASS_CHECKERS(StreamSinkClass, STREAM_SINK,
                        TYPE_STREAM_SINK)
+typedef struct StreamSink StreamSink;
 #define STREAM_SINK(obj) \
      INTERFACE_CHECK(StreamSink, (obj), TYPE_STREAM_SINK)
 
-typedef struct StreamSink StreamSink;
 
 typedef void (*StreamCanPushNotifyFn)(void *opaque);
 
diff --git a/include/hw/timer/npcm7xx_timer.h b/include/hw/timer/npcm7xx_timer.h
index d45c051b56a..d06b14acdc0 100644
--- a/include/hw/timer/npcm7xx_timer.h
+++ b/include/hw/timer/npcm7xx_timer.h
@@ -19,6 +19,7 @@
 #include "exec/memory.h"
 #include "hw/sysbus.h"
 #include "qemu/timer.h"
+#include "qom/object.h"
 
 /* Each Timer Module (TIM) instance holds five 25 MHz timers. */
 #define NPCM7XX_TIMERS_PER_CTRL (5)
diff --git a/include/hw/tricore/tricore_testdevice.h b/include/hw/tricore/tricore_testdevice.h
index e93c883872d..f6a2dd25320 100644
--- a/include/hw/tricore/tricore_testdevice.h
+++ b/include/hw/tricore/tricore_testdevice.h
@@ -21,18 +21,20 @@
 
 #include "hw/sysbus.h"
 #include "hw/hw.h"
+#include "qom/object.h"
 
 #define TYPE_TRICORE_TESTDEVICE "tricore_testdevice"
+typedef struct TriCoreTestDeviceState TriCoreTestDeviceState;
 #define TRICORE_TESTDEVICE(obj) \
     OBJECT_CHECK(TriCoreTestDeviceState, (obj), TYPE_TRICORE_TESTDEVICE)
 
-typedef struct TriCoreTestDeviceState {
+struct TriCoreTestDeviceState {
     /* <private> */
     SysBusDevice parent_obj;
 
     /* <public> */
     MemoryRegion iomem;
 
-} TriCoreTestDeviceState;
+};
 
 #endif
diff --git a/include/hw/usb/hcd-dwc3.h b/include/hw/usb/hcd-dwc3.h
index 7c804d536d5..799a701bae3 100644
--- a/include/hw/usb/hcd-dwc3.h
+++ b/include/hw/usb/hcd-dwc3.h
@@ -28,16 +28,18 @@
 
 #include "hw/usb/hcd-xhci.h"
 #include "hw/usb/hcd-xhci-sysbus.h"
+#include "qom/object.h"
 
 #define TYPE_USB_DWC3 "usb_dwc3"
 
+typedef struct USBDWC3 USBDWC3;
 #define USB_DWC3(obj) \
      OBJECT_CHECK(USBDWC3, (obj), TYPE_USB_DWC3)
 
 #define USB_DWC3_R_MAX ((0x530 / 4) + 1)
 #define DWC3_SIZE 0x10000
 
-typedef struct USBDWC3 {
+struct USBDWC3 {
     SysBusDevice parent_obj;
     MemoryRegion iomem;
     XHCISysbusState sysbus_xhci;
@@ -50,6 +52,6 @@ typedef struct USBDWC3 {
         uint32_t    dwc_usb3_user;
     } cfg;
 
-} USBDWC3;
+};
 
 #endif
diff --git a/include/hw/usb/msd.h b/include/hw/usb/msd.h
index 7538c54569b..82c8b48d561 100644
--- a/include/hw/usb/msd.h
+++ b/include/hw/usb/msd.h
@@ -9,6 +9,7 @@
 
 #include "hw/usb.h"
 #include "hw/scsi/scsi.h"
+#include "qom/object.h"
 
 enum USBMSDMode {
     USB_MSDM_CBW, /* Command Block.  */
diff --git a/include/hw/usb/xlnx-usb-subsystem.h b/include/hw/usb/xlnx-usb-subsystem.h
index 999e423951a..e6175146817 100644
--- a/include/hw/usb/xlnx-usb-subsystem.h
+++ b/include/hw/usb/xlnx-usb-subsystem.h
@@ -27,19 +27,21 @@
 
 #include "hw/usb/xlnx-versal-usb2-ctrl-regs.h"
 #include "hw/usb/hcd-dwc3.h"
+#include "qom/object.h"
 
 #define TYPE_XILINX_VERSAL_USB2 "xlnx.versal-usb2"
 
+typedef struct VersalUsb2 VersalUsb2;
 #define VERSAL_USB2(obj) \
      OBJECT_CHECK(VersalUsb2, (obj), TYPE_XILINX_VERSAL_USB2)
 
-typedef struct VersalUsb2 {
+struct VersalUsb2 {
     SysBusDevice parent_obj;
     MemoryRegion dwc3_mr;
     MemoryRegion usb2Ctrl_mr;
 
     VersalUsb2CtrlRegs usb2Ctrl;
     USBDWC3 dwc3;
-} VersalUsb2;
+};
 
 #endif
diff --git a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
index b76dce04195..7848cac6c1c 100644
--- a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
+++ b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
@@ -25,21 +25,23 @@
 
 #ifndef XLNX_USB2_REGS_H
 #define XLNX_USB2_REGS_H
+#include "qom/object.h"
 
 #define TYPE_XILINX_VERSAL_USB2_CTRL_REGS "xlnx.versal-usb2-ctrl-regs"
 
+typedef struct VersalUsb2CtrlRegs VersalUsb2CtrlRegs;
 #define XILINX_VERSAL_USB2_CTRL_REGS(obj) \
      OBJECT_CHECK(VersalUsb2CtrlRegs, (obj), TYPE_XILINX_VERSAL_USB2_CTRL_REGS)
 
 #define USB2_REGS_R_MAX ((0x78 / 4) + 1)
 
-typedef struct VersalUsb2CtrlRegs {
+struct VersalUsb2CtrlRegs {
     SysBusDevice parent_obj;
     MemoryRegion iomem;
     qemu_irq irq_ir;
 
     uint32_t regs[USB2_REGS_R_MAX];
     RegisterInfo regs_info[USB2_REGS_R_MAX];
-} VersalUsb2CtrlRegs;
+};
 
 #endif
diff --git a/include/hw/vmstate-if.h b/include/hw/vmstate-if.h
index 52df571d17a..0250956967c 100644
--- a/include/hw/vmstate-if.h
+++ b/include/hw/vmstate-if.h
@@ -16,10 +16,10 @@
 typedef struct VMStateIfClass VMStateIfClass;
 DECLARE_CLASS_CHECKERS(VMStateIfClass, VMSTATE_IF,
                        TYPE_VMSTATE_IF)
+typedef struct VMStateIf VMStateIf;
 #define VMSTATE_IF(obj)                             \
     INTERFACE_CHECK(VMStateIf, (obj), TYPE_VMSTATE_IF)
 
-typedef struct VMStateIf VMStateIf;
 
 struct VMStateIfClass {
     InterfaceClass parent_class;
diff --git a/include/hw/watchdog/sbsa_gwdt.h b/include/hw/watchdog/sbsa_gwdt.h
index dcb13bc29dc..babb120f5d3 100644
--- a/include/hw/watchdog/sbsa_gwdt.h
+++ b/include/hw/watchdog/sbsa_gwdt.h
@@ -15,8 +15,10 @@
 #include "qemu/bitops.h"
 #include "hw/sysbus.h"
 #include "hw/irq.h"
+#include "qom/object.h"
 
 #define TYPE_WDT_SBSA "sbsa_gwdt"
+typedef struct SBSA_GWDTState SBSA_GWDTState;
 #define SBSA_GWDT(obj) \
     OBJECT_CHECK(SBSA_GWDTState, (obj), TYPE_WDT_SBSA)
 
@@ -53,7 +55,7 @@
 
 #define SBSA_TIMER_FREQ      62500000 /* Hz */
 
-typedef struct SBSA_GWDTState {
+struct SBSA_GWDTState {
     /* <private> */
     SysBusDevice parent_obj;
 
@@ -70,6 +72,6 @@ typedef struct SBSA_GWDTState {
     uint32_t woru;
     uint32_t wcvl;
     uint32_t wcvu;
-} SBSA_GWDTState;
+};
 
 #endif /* WDT_SBSA_GWDT_H */
diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 81541e20801..57d5f6c0532 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -10,11 +10,11 @@
 typedef struct UserCreatableClass UserCreatableClass;
 DECLARE_CLASS_CHECKERS(UserCreatableClass, USER_CREATABLE,
                        TYPE_USER_CREATABLE)
+typedef struct UserCreatable UserCreatable;
 #define USER_CREATABLE(obj) \
      INTERFACE_CHECK(UserCreatable, (obj), \
                      TYPE_USER_CREATABLE)
 
-typedef struct UserCreatable UserCreatable;
 
 /**
  * UserCreatableClass:
diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
index 68b2206463c..4a02a8e0266 100644
--- a/include/sysemu/tpm.h
+++ b/include/sysemu/tpm.h
@@ -31,10 +31,10 @@ typedef enum TPMVersion {
 typedef struct TPMIfClass TPMIfClass;
 DECLARE_CLASS_CHECKERS(TPMIfClass, TPM_IF,
                        TYPE_TPM_IF)
+typedef struct TPMIf TPMIf;
 #define TPM_IF(obj)                             \
     INTERFACE_CHECK(TPMIf, (obj), TYPE_TPM_IF)
 
-typedef struct TPMIf TPMIf;
 
 struct TPMIfClass {
     InterfaceClass parent_class;
diff --git a/target/arm/idau.h b/target/arm/idau.h
index 0ef5251971d..600ac9066cf 100644
--- a/target/arm/idau.h
+++ b/target/arm/idau.h
@@ -31,13 +31,13 @@
 #include "qom/object.h"
 
 #define TYPE_IDAU_INTERFACE "idau-interface"
+typedef struct IDAUInterface IDAUInterface;
 #define IDAU_INTERFACE(obj) \
     INTERFACE_CHECK(IDAUInterface, (obj), TYPE_IDAU_INTERFACE)
 typedef struct IDAUInterfaceClass IDAUInterfaceClass;
 DECLARE_CLASS_CHECKERS(IDAUInterfaceClass, IDAU_INTERFACE,
                        TYPE_IDAU_INTERFACE)
 
-typedef struct IDAUInterface IDAUInterface;
 
 #define IREGION_NOTVALID -1
 
diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h
index 2855dd38816..20928b9efa5 100644
--- a/target/hexagon/cpu.h
+++ b/target/hexagon/cpu.h
@@ -17,6 +17,7 @@
 
 #ifndef HEXAGON_CPU_H
 #define HEXAGON_CPU_H
+#include "qom/object.h"
 
 /* Forward declaration needed by some of the header files */
 typedef struct CPUHexagonState CPUHexagonState;
@@ -101,6 +102,8 @@ struct CPUHexagonState {
     target_ulong gather_issued;
 };
 
+typedef struct HexagonCPUClass HexagonCPUClass;
+typedef struct HexagonCPU HexagonCPU;
 #define HEXAGON_CPU_CLASS(klass) \
     OBJECT_CLASS_CHECK(HexagonCPUClass, (klass), TYPE_HEXAGON_CPU)
 #define HEXAGON_CPU(obj) \
@@ -108,15 +111,15 @@ struct CPUHexagonState {
 #define HEXAGON_CPU_GET_CLASS(obj) \
     OBJECT_GET_CLASS(HexagonCPUClass, (obj), TYPE_HEXAGON_CPU)
 
-typedef struct HexagonCPUClass {
+struct HexagonCPUClass {
     /*< private >*/
     CPUClass parent_class;
     /*< public >*/
     DeviceRealize parent_realize;
     DeviceReset parent_reset;
-} HexagonCPUClass;
+};
 
-typedef struct HexagonCPU {
+struct HexagonCPU {
     /*< private >*/
     CPUState parent_obj;
     /*< public >*/
@@ -125,7 +128,7 @@ typedef struct HexagonCPU {
 
     bool lldb_compat;
     target_ulong lldb_stack_adjust;
-} HexagonCPU;
+};
 
 #include "cpu_bits.h"
 
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index c0812e5dfd6..3ee6aaff265 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -33,6 +33,7 @@
 #include "qemu/accel.h"
 #include "qapi/qapi-builtin-visit.h"
 #include "qemu/units.h"
+#include "qom/object.h"
 #if !defined(CONFIG_USER_ONLY)
 #include "hw/boards.h"
 #endif
diff --git a/chardev/char-parallel.c b/chardev/char-parallel.c
index acf9fb8afa0..dcbf6177a1e 100644
--- a/chardev/char-parallel.c
+++ b/chardev/char-parallel.c
@@ -28,6 +28,7 @@
 #include "qemu/module.h"
 #include "qemu/option.h"
 #include <sys/ioctl.h>
+#include "qom/object.h"
 
 #ifdef CONFIG_BSD
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
index f894338fc6a..4394c0d67c6 100644
--- a/hw/arm/bcm2836.c
+++ b/hw/arm/bcm2836.c
@@ -15,6 +15,7 @@
 #include "hw/arm/bcm2836.h"
 #include "hw/arm/raspi_platform.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 struct BCM283XClass {
     /*< private >*/
diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c
index 72a815dbbd0..bd7e328435a 100644
--- a/hw/m68k/mcf5206.c
+++ b/hw/m68k/mcf5206.c
@@ -17,6 +17,7 @@
 #include "hw/ptimer.h"
 #include "sysemu/sysemu.h"
 #include "hw/sysbus.h"
+#include "qom/object.h"
 
 /* General purpose timer module.  */
 typedef struct {
diff --git a/hw/mem/sparse-mem.c b/hw/mem/sparse-mem.c
index e6640eb8e72..0d8c0327258 100644
--- a/hw/mem/sparse-mem.c
+++ b/hw/mem/sparse-mem.c
@@ -18,11 +18,13 @@
 #include "qemu/units.h"
 #include "sysemu/qtest.h"
 #include "hw/mem/sparse-mem.h"
+#include "qom/object.h"
 
+typedef struct SparseMemState SparseMemState;
 #define SPARSE_MEM(obj) OBJECT_CHECK(SparseMemState, (obj), TYPE_SPARSE_MEM)
 #define SPARSE_BLOCK_SIZE 0x1000
 
-typedef struct SparseMemState {
+struct SparseMemState {
     SysBusDevice parent_obj;
     MemoryRegion mmio;
     uint64_t baseaddr;
@@ -30,7 +32,7 @@ typedef struct SparseMemState {
     uint64_t size_used;
     uint64_t maxsize;
     GHashTable *mapped;
-} SparseMemState;
+};
 
 typedef struct sparse_mem_block {
     uint8_t data[SPARSE_BLOCK_SIZE];
diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
index ae192db0c8b..abcc01e4087 100644
--- a/hw/mips/loongson3_virt.c
+++ b/hw/mips/loongson3_virt.c
@@ -52,6 +52,7 @@
 #include "sysemu/reset.h"
 #include "sysemu/runstate.h"
 #include "qemu/error-report.h"
+#include "qom/object.h"
 
 #define PM_CNTL_MODE          0x10
 
diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c
index 0b61070c52f..da6b14c545d 100644
--- a/hw/misc/npcm7xx_clk.c
+++ b/hw/misc/npcm7xx_clk.c
@@ -27,6 +27,7 @@
 #include "qemu/units.h"
 #include "trace.h"
 #include "sysemu/watchdog.h"
+#include "qom/object.h"
 
 /*
  * The reference clock hz, and the SECCNT and CNTR25M registers in this module,
diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c
index 9e3c40a23dc..846b2ff905a 100644
--- a/hw/misc/sbsa_ec.c
+++ b/hw/misc/sbsa_ec.c
@@ -15,6 +15,7 @@
 #include "qemu/log.h"
 #include "hw/sysbus.h"
 #include "sysemu/runstate.h"
+#include "qom/object.h"
 
 typedef struct SECUREECState {
     SysBusDevice parent_obj;
diff --git a/hw/net/can/ctucan_pci.c b/hw/net/can/ctucan_pci.c
index f1c86cd06a7..1f277a7c363 100644
--- a/hw/net/can/ctucan_pci.c
+++ b/hw/net/can/ctucan_pci.c
@@ -40,6 +40,7 @@
 #include "net/can_emu.h"
 
 #include "ctucan_core.h"
+#include "qom/object.h"
 
 #define TYPE_CTUCAN_PCI_DEV "ctucan_pci"
 
diff --git a/hw/nvram/npcm7xx_otp.c b/hw/nvram/npcm7xx_otp.c
index c61f2fc1aa2..52b9482419e 100644
--- a/hw/nvram/npcm7xx_otp.c
+++ b/hw/nvram/npcm7xx_otp.c
@@ -23,6 +23,7 @@
 #include "qemu/log.h"
 #include "qemu/module.h"
 #include "qemu/units.h"
+#include "qom/object.h"
 
 /* Each module has 4 KiB of register space. Only a fraction of it is used. */
 #define NPCM7XX_OTP_REGS_SIZE (4 * KiB)
diff --git a/hw/s390x/vhost-user-fs-ccw.c b/hw/s390x/vhost-user-fs-ccw.c
index 6c6f2692930..7d573156780 100644
--- a/hw/s390x/vhost-user-fs-ccw.c
+++ b/hw/s390x/vhost-user-fs-ccw.c
@@ -12,6 +12,7 @@
 #include "qapi/error.h"
 #include "hw/virtio/vhost-user-fs.h"
 #include "virtio-ccw.h"
+#include "qom/object.h"
 
 typedef struct VHostUserFSCcw {
     VirtioCcwDevice parent_obj;
diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
index 7310c769be2..80365dbd780 100644
--- a/hw/sensor/adm1272.c
+++ b/hw/sensor/adm1272.c
@@ -16,8 +16,10 @@
 #include "qapi/visitor.h"
 #include "qemu/log.h"
 #include "qemu/module.h"
+#include "qom/object.h"
 
 #define TYPE_ADM1272 "adm1272"
+typedef struct ADM1272State ADM1272State;
 #define ADM1272(obj) OBJECT_CHECK(ADM1272State, (obj), TYPE_ADM1272)
 
 #define ADM1272_RESTART_TIME            0xCC
@@ -70,7 +72,7 @@
 #define ADM1272_IOUT_OFFSET             0x5000
 
 
-typedef struct ADM1272State {
+struct ADM1272State {
     PMBusDevice parent;
 
     uint64_t ein_ext;
@@ -96,7 +98,7 @@ typedef struct ADM1272State {
 
     uint16_t strt_up_iout_lim;
 
-} ADM1272State;
+};
 
 static const PMBusCoefficients adm1272_coefficients[] = {
     [0] = { 6770, 0, -2 },        /* voltage, vrange 60V */
diff --git a/hw/sensor/max34451.c b/hw/sensor/max34451.c
index a91d8bd487c..5d50e46b5ba 100644
--- a/hw/sensor/max34451.c
+++ b/hw/sensor/max34451.c
@@ -14,8 +14,10 @@
 #include "qapi/visitor.h"
 #include "qemu/log.h"
 #include "qemu/module.h"
+#include "qom/object.h"
 
 #define TYPE_MAX34451 "max34451"
+typedef struct MAX34451State MAX34451State;
 #define MAX34451(obj) OBJECT_CHECK(MAX34451State, (obj), TYPE_MAX34451)
 
 #define MAX34451_MFR_MODE               0xD1
@@ -134,7 +136,7 @@
  * @vout_scale: scale ADC reading to actual device reading if different
  * @iout_cal_gain: set ratio of the voltage at the ADC input to sensed current
  */
-typedef struct MAX34451State {
+struct MAX34451State {
     PMBusDevice parent;
 
     uint16_t power_good_on[MAX34451_NUM_PWR_DEVICES];
@@ -168,7 +170,7 @@ typedef struct MAX34451State {
     uint16_t temp_sensor_config[MAX34451_NUM_TEMP_DEVICES];
     uint16_t store_single;
     uint16_t crc;
-} MAX34451State;
+};
 
 
 static void max34451_check_limits(MAX34451State *s)
diff --git a/hw/usb/u2f-emulated.c b/hw/usb/u2f-emulated.c
index 9151feb63d4..7c092e7a93f 100644
--- a/hw/usb/u2f-emulated.c
+++ b/hw/usb/u2f-emulated.c
@@ -34,6 +34,7 @@
 #include <u2f-emu/u2f-emu.h>
 
 #include "u2f.h"
+#include "qom/object.h"
 
 /* Counter which sync with a file */
 struct synced_counter {
diff --git a/hw/usb/u2f-passthru.c b/hw/usb/u2f-passthru.c
index fc93429c9c0..954b8aa3c9b 100644
--- a/hw/usb/u2f-passthru.c
+++ b/hw/usb/u2f-passthru.c
@@ -33,6 +33,7 @@
 #include "migration/vmstate.h"
 
 #include "u2f.h"
+#include "qom/object.h"
 
 #ifdef CONFIG_LIBUDEV
 #include <libudev.h>
diff --git a/hw/virtio/vhost-user-i2c-pci.c b/hw/virtio/vhost-user-i2c-pci.c
index 70b7b65fd97..dd25e593545 100644
--- a/hw/virtio/vhost-user-i2c-pci.c
+++ b/hw/virtio/vhost-user-i2c-pci.c
@@ -10,6 +10,7 @@
 #include "hw/qdev-properties.h"
 #include "hw/virtio/vhost-user-i2c.h"
 #include "virtio-pci.h"
+#include "qom/object.h"
 
 struct VHostUserI2CPCI {
     VirtIOPCIProxy parent_obj;
diff --git a/tests/unit/check-qom-interface.c b/tests/unit/check-qom-interface.c
index c99be97ed8b..4f534d09085 100644
--- a/tests/unit/check-qom-interface.c
+++ b/tests/unit/check-qom-interface.c
@@ -19,10 +19,10 @@
 typedef struct TestIfClass TestIfClass;
 DECLARE_CLASS_CHECKERS(TestIfClass, TEST_IF,
                        TYPE_TEST_IF)
+typedef struct TestIf TestIf;
 #define TEST_IF(obj) \
      INTERFACE_CHECK(TestIf, (obj), TYPE_TEST_IF)
 
-typedef struct TestIf TestIf;
 
 struct TestIfClass {
     InterfaceClass parent_class;
diff --git a/ui/vdagent.c b/ui/vdagent.c
index a253a8fe63a..1ca30a97958 100644
--- a/ui/vdagent.c
+++ b/ui/vdagent.c
@@ -15,6 +15,7 @@
 #include "qapi/qapi-types-ui.h"
 
 #include "spice/vd_agent.h"
+#include "qom/object.h"
 
 #define VDAGENT_BUFFER_LIMIT (1 * MiB)
 #define VDAGENT_MOUSE_DEFAULT true
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 06/12] [automated] Split QOM "typedef struct T { ... } T" declarations
  2021-08-06 21:11 [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Eduardo Habkost
@ 2021-08-06 21:11   ` Eduardo Habkost
  2021-08-06 21:11 ` [PATCH for-6.2 02/12] qom: Use DEVICE_*CLASS instead of OBJECT_*CLASS Eduardo Habkost
                     ` (11 subsequent siblings)
  12 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Michael S. Tsirkin, Bin Meng, Alistair Francis,
	Gerd Hoffmann, Klaus Jensen, Edgar E. Iglesias, qemu-block,
	qemu-ppc, David Hildenbrand, Havard Skinnemoen, Halil Pasic,
	Christian Borntraeger, Marc-André Lureau, Laurent Vivier,
	Richard Henderson, Greg Kurz, qemu-s390x, qemu-arm,
	Cédric Le Goater, Keith Busch, qemu-riscv, David Gibson,
	Daniel P. Berrange, Thomas Huth, Patrick Venture, Cornelia Huck,
	Philippe Mathieu-Daudé,
	Andrew Baumann, Tyrone Ting, Palmer Dabbelt, Paolo Bonzini

Automatically split struct definition and typedef declaration in
separate declarations, using a codeconverter rule.  The rule will
only touch declarations of structs/typedefs actually used by QOM
types.

This will make automated changes to use OBJECT_DECLARE* macros
easier to implement, because automated removal of typedef lines
will be easier and safer.

Generated using:

  $ ./scripts/codeconverter/converter.py -i \
    --pattern=QOMStructTypedefSplit $(git grep -l '' -- '*.[ch]')

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Patrick Venture <venture@google.com>
Cc: Thomas Huth <huth@tuxfamily.org>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Klaus Jensen <its@irrelevant.dk>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: Halil Pasic <pasic@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Havard Skinnemoen <hskinnemoen@google.com>
Cc: Tyrone Ting <kfting@nuvoton.com>
Cc: Alistair Francis <Alistair.Francis@wdc.com>
Cc: Bin Meng <bin.meng@windriver.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Cédric Le Goater" <clg@kaod.org>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Greg Kurz <groug@kaod.org>
Cc: Laurent Vivier <lvivier@redhat.com>
Cc: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org
Cc: qemu-s390x@nongnu.org
Cc: qemu-arm@nongnu.org
Cc: qemu-riscv@nongnu.org
Cc: qemu-ppc@nongnu.org
---
 hw/nvme/nvme.h                      | 10 ++++++----
 hw/usb/hcd-uhci.h                   |  5 +++--
 hw/usb/u2f.h                        |  5 +++--
 include/hw/adc/npcm7xx_adc.h        |  5 +++--
 include/hw/arm/npcm7xx.h            | 10 ++++++----
 include/hw/core/accel-cpu.h         |  5 +++--
 include/hw/dma/sifive_pdma.h        |  5 +++--
 include/hw/dma/xlnx_csu_dma.h       |  5 +++--
 include/hw/gpio/npcm7xx_gpio.h      |  5 +++--
 include/hw/i2c/npcm7xx_smbus.h      |  5 +++--
 include/hw/mem/npcm7xx_mc.h         |  5 +++--
 include/hw/misc/bcm2835_cprman.h    | 20 ++++++++++++--------
 include/hw/misc/mchp_pfsoc_dmc.h    | 10 ++++++----
 include/hw/misc/mchp_pfsoc_ioscb.h  |  5 +++--
 include/hw/misc/mchp_pfsoc_sysreg.h |  5 +++--
 include/hw/misc/npcm7xx_clk.h       | 15 +++++++++------
 include/hw/misc/npcm7xx_gcr.h       |  5 +++--
 include/hw/misc/npcm7xx_mft.h       |  5 +++--
 include/hw/misc/npcm7xx_rng.h       |  5 +++--
 include/hw/nvram/npcm7xx_otp.h      |  5 +++--
 include/hw/riscv/microchip_pfsoc.h  | 10 ++++++----
 include/hw/riscv/sifive_e.h         |  5 +++--
 include/hw/sd/cadence_sdhci.h       |  5 +++--
 include/qemu/accel.h                | 10 ++++++----
 chardev/char-parallel.c             | 10 ++++++----
 hw/i2c/i2c_mux_pca954x.c            |  5 +++--
 hw/m68k/mcf5206.c                   |  5 +++--
 hw/misc/sbsa_ec.c                   |  5 +++--
 hw/s390x/vhost-user-fs-ccw.c        |  5 +++--
 tests/qtest/pnv-xscom-test.c        |  5 +++--
 30 files changed, 123 insertions(+), 82 deletions(-)

diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
index 5ddcd783055..0840f585d6e 100644
--- a/hw/nvme/nvme.h
+++ b/hw/nvme/nvme.h
@@ -118,7 +118,7 @@ typedef struct NvmeNamespaceParams {
     uint32_t zd_extension_size;
 } NvmeNamespaceParams;
 
-typedef struct NvmeNamespace {
+struct NvmeNamespace {
     DeviceState  parent_obj;
     BlockConf    blkconf;
     int32_t      bootindex;
@@ -153,7 +153,8 @@ typedef struct NvmeNamespace {
     struct {
         uint32_t err_rec;
     } features;
-} NvmeNamespace;
+};
+typedef struct NvmeNamespace NvmeNamespace;
 
 static inline uint32_t nvme_nsid(NvmeNamespace *ns)
 {
@@ -395,7 +396,7 @@ typedef struct NvmeParams {
     bool     legacy_cmb;
 } NvmeParams;
 
-typedef struct NvmeCtrl {
+struct NvmeCtrl {
     PCIDevice    parent_obj;
     MemoryRegion bar0;
     MemoryRegion iomem;
@@ -462,7 +463,8 @@ typedef struct NvmeCtrl {
         };
         uint32_t    async_config;
     } features;
-} NvmeCtrl;
+};
+typedef struct NvmeCtrl NvmeCtrl;
 
 static inline NvmeNamespace *nvme_ns(NvmeCtrl *n, uint32_t nsid)
 {
diff --git a/hw/usb/hcd-uhci.h b/hw/usb/hcd-uhci.h
index 57d0d574644..2597a6d2eb6 100644
--- a/hw/usb/hcd-uhci.h
+++ b/hw/usb/hcd-uhci.h
@@ -43,7 +43,7 @@ typedef struct UHCIPort {
     uint16_t ctrl;
 } UHCIPort;
 
-typedef struct UHCIState {
+struct UHCIState {
     PCIDevice dev;
     MemoryRegion io_bar;
     USBBus bus; /* Note unused when we're a companion controller */
@@ -73,7 +73,8 @@ typedef struct UHCIState {
     char *masterbus;
     uint32_t firstport;
     uint32_t maxframes;
-} UHCIState;
+};
+typedef struct UHCIState UHCIState;
 
 #define TYPE_UHCI "pci-uhci-usb"
 DECLARE_INSTANCE_CHECKER(UHCIState, UHCI, TYPE_UHCI)
diff --git a/hw/usb/u2f.h b/hw/usb/u2f.h
index 705d5c43ce6..7191a23ee1a 100644
--- a/hw/usb/u2f.h
+++ b/hw/usb/u2f.h
@@ -62,7 +62,7 @@ struct U2FKeyClass {
 /*
  * State of the U2F key base device (i.e. hw/u2f.c)
  */
-typedef struct U2FKeyState {
+struct U2FKeyState {
     USBDevice dev;
     USBEndpoint *ep;
     uint8_t idle;
@@ -72,7 +72,8 @@ typedef struct U2FKeyState {
     uint8_t pending_in_start;
     uint8_t pending_in_end;
     uint8_t pending_in_num;
-} U2FKeyState;
+};
+typedef struct U2FKeyState U2FKeyState;
 
 /*
  * API to be used by the U2F key device variants (i.e. hw/u2f-*.c)
diff --git a/include/hw/adc/npcm7xx_adc.h b/include/hw/adc/npcm7xx_adc.h
index 874cfbd6ce3..835d13f5b0d 100644
--- a/include/hw/adc/npcm7xx_adc.h
+++ b/include/hw/adc/npcm7xx_adc.h
@@ -43,7 +43,7 @@
  * @iref: The internal reference voltage, initialized at launch time.
  * @rv: The calibrated output values of 0.5V and 1.5V for the ADC.
  */
-typedef struct NPCM7xxADCState {
+struct NPCM7xxADCState {
     SysBusDevice parent;
 
     MemoryRegion iomem;
@@ -61,7 +61,8 @@ typedef struct NPCM7xxADCState {
     uint32_t     iref;
 
     uint16_t     calibration_r_values[NPCM7XX_ADC_NUM_CALIB];
-} NPCM7xxADCState;
+};
+typedef struct NPCM7xxADCState NPCM7xxADCState;
 
 #define TYPE_NPCM7XX_ADC "npcm7xx-adc"
 #define NPCM7XX_ADC(obj) \
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
index dc802c1645c..697d2957590 100644
--- a/include/hw/arm/npcm7xx.h
+++ b/include/hw/arm/npcm7xx.h
@@ -52,7 +52,7 @@
 
 #define NPCM7XX_NR_PWM_MODULES 2
 
-typedef struct NPCM7xxMachine {
+struct NPCM7xxMachine {
     MachineState        parent;
     /*
      * PWM fan splitter. each splitter connects to one PWM output and
@@ -60,7 +60,8 @@ typedef struct NPCM7xxMachine {
      */
     SplitIRQ            fan_splitter[NPCM7XX_NR_PWM_MODULES *
                                      NPCM7XX_PWM_PER_MODULE];
-} NPCM7xxMachine;
+};
+typedef struct NPCM7xxMachine NPCM7xxMachine;
 
 #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
 typedef struct NPCM7xxMachineClass NPCM7xxMachineClass;
@@ -78,7 +79,7 @@ struct NPCM7xxMachineClass {
 #define NPCM7XX_MACHINE_GET_CLASS(obj)                                  \
     OBJECT_GET_CLASS(NPCM7xxMachineClass, (obj), TYPE_NPCM7XX_MACHINE)
 
-typedef struct NPCM7xxState {
+struct NPCM7xxState {
     DeviceState         parent;
 
     ARMCPU              cpu[NPCM7XX_MAX_NUM_CPUS];
@@ -105,7 +106,8 @@ typedef struct NPCM7xxState {
     OHCISysBusState     ohci;
     NPCM7xxFIUState     fiu[2];
     NPCM7xxEMCState     emc[2];
-} NPCM7xxState;
+};
+typedef struct NPCM7xxState NPCM7xxState;
 
 #define TYPE_NPCM7XX    "npcm7xx"
 typedef struct NPCM7xxClass NPCM7xxClass;
diff --git a/include/hw/core/accel-cpu.h b/include/hw/core/accel-cpu.h
index 0b7b3f6df3e..b1f6fdb756b 100644
--- a/include/hw/core/accel-cpu.h
+++ b/include/hw/core/accel-cpu.h
@@ -26,7 +26,7 @@
 typedef struct AccelCPUClass AccelCPUClass;
 DECLARE_CLASS_CHECKERS(AccelCPUClass, ACCEL_CPU, TYPE_ACCEL_CPU)
 
-typedef struct AccelCPUClass {
+struct AccelCPUClass {
     /*< private >*/
     ObjectClass parent_class;
     /*< public >*/
@@ -34,6 +34,7 @@ typedef struct AccelCPUClass {
     void (*cpu_class_init)(CPUClass *cc);
     void (*cpu_instance_init)(CPUState *cpu);
     bool (*cpu_realizefn)(CPUState *cpu, Error **errp);
-} AccelCPUClass;
+};
+typedef struct AccelCPUClass AccelCPUClass;
 
 #endif /* ACCEL_CPU_H */
diff --git a/include/hw/dma/sifive_pdma.h b/include/hw/dma/sifive_pdma.h
index a62908dd0f2..76b4b45d0a4 100644
--- a/include/hw/dma/sifive_pdma.h
+++ b/include/hw/dma/sifive_pdma.h
@@ -42,13 +42,14 @@ struct sifive_pdma_chan {
 #define SIFIVE_PDMA_REG_SIZE        0x100000
 #define SIFIVE_PDMA_CHAN_NO(reg)    ((reg & (SIFIVE_PDMA_REG_SIZE - 1)) >> 12)
 
-typedef struct SiFivePDMAState {
+struct SiFivePDMAState {
     SysBusDevice parent;
     MemoryRegion iomem;
     qemu_irq irq[SIFIVE_PDMA_IRQS];
 
     struct sifive_pdma_chan chan[SIFIVE_PDMA_CHANS];
-} SiFivePDMAState;
+};
+typedef struct SiFivePDMAState SiFivePDMAState;
 
 #define TYPE_SIFIVE_PDMA    "sifive.pdma"
 
diff --git a/include/hw/dma/xlnx_csu_dma.h b/include/hw/dma/xlnx_csu_dma.h
index 804ca5958d0..f8d88e2ebee 100644
--- a/include/hw/dma/xlnx_csu_dma.h
+++ b/include/hw/dma/xlnx_csu_dma.h
@@ -26,7 +26,7 @@
 
 #define XLNX_CSU_DMA_R_MAX (0x2c / 4)
 
-typedef struct XlnxCSUDMA {
+struct XlnxCSUDMA {
     SysBusDevice busdev;
     MemoryRegion iomem;
     MemTxAttrs attr;
@@ -45,7 +45,8 @@ typedef struct XlnxCSUDMA {
 
     uint32_t regs[XLNX_CSU_DMA_R_MAX];
     RegisterInfo regs_info[XLNX_CSU_DMA_R_MAX];
-} XlnxCSUDMA;
+};
+typedef struct XlnxCSUDMA XlnxCSUDMA;
 
 #define XLNX_CSU_DMA(obj) \
     OBJECT_CHECK(XlnxCSUDMA, (obj), TYPE_XLNX_CSU_DMA)
diff --git a/include/hw/gpio/npcm7xx_gpio.h b/include/hw/gpio/npcm7xx_gpio.h
index c4e5b4a353e..e45cf45e78e 100644
--- a/include/hw/gpio/npcm7xx_gpio.h
+++ b/include/hw/gpio/npcm7xx_gpio.h
@@ -28,7 +28,7 @@
  */
 #define NPCM7XX_GPIO_NR_REGS (0x80 / sizeof(uint32_t))
 
-typedef struct NPCM7xxGPIOState {
+struct NPCM7xxGPIOState {
     SysBusDevice parent;
 
     /* Properties to be defined by the SoC */
@@ -47,7 +47,8 @@ typedef struct NPCM7xxGPIOState {
     uint32_t ext_driven;
 
     uint32_t regs[NPCM7XX_GPIO_NR_REGS];
-} NPCM7xxGPIOState;
+};
+typedef struct NPCM7xxGPIOState NPCM7xxGPIOState;
 
 #define TYPE_NPCM7XX_GPIO "npcm7xx-gpio"
 #define NPCM7XX_GPIO(obj) \
diff --git a/include/hw/i2c/npcm7xx_smbus.h b/include/hw/i2c/npcm7xx_smbus.h
index 8030d78f69c..ef64c6748a7 100644
--- a/include/hw/i2c/npcm7xx_smbus.h
+++ b/include/hw/i2c/npcm7xx_smbus.h
@@ -69,7 +69,7 @@ typedef enum NPCM7xxSMBusStatus {
  * @rx_cur: The current position of rx_fifo.
  * @status: The current status of the SMBus.
  */
-typedef struct NPCM7xxSMBusState {
+struct NPCM7xxSMBusState {
     SysBusDevice parent;
 
     MemoryRegion iomem;
@@ -105,7 +105,8 @@ typedef struct NPCM7xxSMBusState {
     uint8_t      rx_cur;
 
     NPCM7xxSMBusStatus status;
-} NPCM7xxSMBusState;
+};
+typedef struct NPCM7xxSMBusState NPCM7xxSMBusState;
 
 #define TYPE_NPCM7XX_SMBUS "npcm7xx-smbus"
 #define NPCM7XX_SMBUS(obj) OBJECT_CHECK(NPCM7xxSMBusState, (obj), \
diff --git a/include/hw/mem/npcm7xx_mc.h b/include/hw/mem/npcm7xx_mc.h
index 83787f6fa57..e0a9d3b0de9 100644
--- a/include/hw/mem/npcm7xx_mc.h
+++ b/include/hw/mem/npcm7xx_mc.h
@@ -25,11 +25,12 @@
  * @parent: System bus device.
  * @mmio: Memory region through which registers are accessed.
  */
-typedef struct NPCM7xxMCState {
+struct NPCM7xxMCState {
     SysBusDevice parent;
 
     MemoryRegion mmio;
-} NPCM7xxMCState;
+};
+typedef struct NPCM7xxMCState NPCM7xxMCState;
 
 #define TYPE_NPCM7XX_MC "npcm7xx-mc"
 #define NPCM7XX_MC(obj) OBJECT_CHECK(NPCM7xxMCState, (obj), TYPE_NPCM7XX_MC)
diff --git a/include/hw/misc/bcm2835_cprman.h b/include/hw/misc/bcm2835_cprman.h
index ba4b441dce5..966c0b600ed 100644
--- a/include/hw/misc/bcm2835_cprman.h
+++ b/include/hw/misc/bcm2835_cprman.h
@@ -118,7 +118,7 @@ typedef enum CprmanClockMuxSource {
     CPRMAN_NUM_CLOCK_MUX_SRC
 } CprmanClockMuxSource;
 
-typedef struct CprmanPllState {
+struct CprmanPllState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -133,9 +133,10 @@ typedef struct CprmanPllState {
 
     Clock *xosc_in;
     Clock *out;
-} CprmanPllState;
+};
+typedef struct CprmanPllState CprmanPllState;
 
-typedef struct CprmanPllChannelState {
+struct CprmanPllChannelState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -151,9 +152,10 @@ typedef struct CprmanPllChannelState {
 
     Clock *pll_in;
     Clock *out;
-} CprmanPllChannelState;
+};
+typedef struct CprmanPllChannelState CprmanPllChannelState;
 
-typedef struct CprmanClockMuxState {
+struct CprmanClockMuxState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -173,9 +175,10 @@ typedef struct CprmanClockMuxState {
      * source number.
      */
     struct CprmanClockMuxState *backref[CPRMAN_NUM_CLOCK_MUX_SRC];
-} CprmanClockMuxState;
+};
+typedef struct CprmanClockMuxState CprmanClockMuxState;
 
-typedef struct CprmanDsi0HsckMuxState {
+struct CprmanDsi0HsckMuxState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -187,7 +190,8 @@ typedef struct CprmanDsi0HsckMuxState {
     Clock *plla_in;
     Clock *plld_in;
     Clock *out;
-} CprmanDsi0HsckMuxState;
+};
+typedef struct CprmanDsi0HsckMuxState CprmanDsi0HsckMuxState;
 
 struct BCM2835CprmanState {
     /*< private >*/
diff --git a/include/hw/misc/mchp_pfsoc_dmc.h b/include/hw/misc/mchp_pfsoc_dmc.h
index 979527957ea..28cfe3e1e23 100644
--- a/include/hw/misc/mchp_pfsoc_dmc.h
+++ b/include/hw/misc/mchp_pfsoc_dmc.h
@@ -28,10 +28,11 @@
 
 #define MCHP_PFSOC_DDR_SGMII_PHY_REG_SIZE   0x1000
 
-typedef struct MchpPfSoCDdrSgmiiPhyState {
+struct MchpPfSoCDdrSgmiiPhyState {
     SysBusDevice parent;
     MemoryRegion sgmii_phy;
-} MchpPfSoCDdrSgmiiPhyState;
+};
+typedef struct MchpPfSoCDdrSgmiiPhyState MchpPfSoCDdrSgmiiPhyState;
 
 #define TYPE_MCHP_PFSOC_DDR_SGMII_PHY "mchp.pfsoc.ddr_sgmii_phy"
 
@@ -43,10 +44,11 @@ typedef struct MchpPfSoCDdrSgmiiPhyState {
 
 #define MCHP_PFSOC_DDR_CFG_REG_SIZE         0x40000
 
-typedef struct MchpPfSoCDdrCfgState {
+struct MchpPfSoCDdrCfgState {
     SysBusDevice parent;
     MemoryRegion cfg;
-} MchpPfSoCDdrCfgState;
+};
+typedef struct MchpPfSoCDdrCfgState MchpPfSoCDdrCfgState;
 
 #define TYPE_MCHP_PFSOC_DDR_CFG "mchp.pfsoc.ddr_cfg"
 
diff --git a/include/hw/misc/mchp_pfsoc_ioscb.h b/include/hw/misc/mchp_pfsoc_ioscb.h
index 519b897250f..95b0b9069dd 100644
--- a/include/hw/misc/mchp_pfsoc_ioscb.h
+++ b/include/hw/misc/mchp_pfsoc_ioscb.h
@@ -24,7 +24,7 @@
 #define MCHP_PFSOC_IOSCB_H
 #include "qom/object.h"
 
-typedef struct MchpPfSoCIoscbState {
+struct MchpPfSoCIoscbState {
     SysBusDevice parent;
     MemoryRegion container;
     MemoryRegion lane01;
@@ -41,7 +41,8 @@ typedef struct MchpPfSoCIoscbState {
     MemoryRegion cfm_sgmii;
     MemoryRegion bc_sgmii;
     MemoryRegion io_calib_sgmii;
-} MchpPfSoCIoscbState;
+};
+typedef struct MchpPfSoCIoscbState MchpPfSoCIoscbState;
 
 #define TYPE_MCHP_PFSOC_IOSCB "mchp.pfsoc.ioscb"
 
diff --git a/include/hw/misc/mchp_pfsoc_sysreg.h b/include/hw/misc/mchp_pfsoc_sysreg.h
index d6803be9485..adce8d869c4 100644
--- a/include/hw/misc/mchp_pfsoc_sysreg.h
+++ b/include/hw/misc/mchp_pfsoc_sysreg.h
@@ -26,10 +26,11 @@
 
 #define MCHP_PFSOC_SYSREG_REG_SIZE  0x2000
 
-typedef struct MchpPfSoCSysregState {
+struct MchpPfSoCSysregState {
     SysBusDevice parent;
     MemoryRegion sysreg;
-} MchpPfSoCSysregState;
+};
+typedef struct MchpPfSoCSysregState MchpPfSoCSysregState;
 
 #define TYPE_MCHP_PFSOC_SYSREG "mchp.pfsoc.sysreg"
 
diff --git a/include/hw/misc/npcm7xx_clk.h b/include/hw/misc/npcm7xx_clk.h
index a849345620e..80b651c7e44 100644
--- a/include/hw/misc/npcm7xx_clk.h
+++ b/include/hw/misc/npcm7xx_clk.h
@@ -91,7 +91,7 @@ typedef struct NPCM7xxCLKState NPCM7xxCLKState;
  * @clock_out: The output clock of this module.
  * @reg: The control registers for this PLL module.
  */
-typedef struct NPCM7xxClockPLLState {
+struct NPCM7xxClockPLLState {
     DeviceState parent;
 
     const char *name;
@@ -100,7 +100,8 @@ typedef struct NPCM7xxClockPLLState {
     Clock *clock_out;
 
     int reg;
-} NPCM7xxClockPLLState;
+};
+typedef struct NPCM7xxClockPLLState NPCM7xxClockPLLState;
 
 /**
  * struct NPCM7xxClockSELState - A SEL module in CLK module.
@@ -112,7 +113,7 @@ typedef struct NPCM7xxClockPLLState {
  * @offset: The offset of this module in the control register.
  * @len: The length of this module in the control register.
  */
-typedef struct NPCM7xxClockSELState {
+struct NPCM7xxClockSELState {
     DeviceState parent;
 
     const char *name;
@@ -123,7 +124,8 @@ typedef struct NPCM7xxClockSELState {
 
     int offset;
     int len;
-} NPCM7xxClockSELState;
+};
+typedef struct NPCM7xxClockSELState NPCM7xxClockSELState;
 
 /**
  * struct NPCM7xxClockDividerState - A Divider module in CLK module.
@@ -137,7 +139,7 @@ typedef struct NPCM7xxClockSELState {
  * @len: The length of the divisor in the control register.
  * @divisor: The divisor for a constant divisor
  */
-typedef struct NPCM7xxClockDividerState {
+struct NPCM7xxClockDividerState {
     DeviceState parent;
 
     const char *name;
@@ -154,7 +156,8 @@ typedef struct NPCM7xxClockDividerState {
         };
         int divisor;
     };
-} NPCM7xxClockDividerState;
+};
+typedef struct NPCM7xxClockDividerState NPCM7xxClockDividerState;
 
 struct NPCM7xxCLKState {
     SysBusDevice parent;
diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h
index 482768c8e76..b5c573ec8f2 100644
--- a/include/hw/misc/npcm7xx_gcr.h
+++ b/include/hw/misc/npcm7xx_gcr.h
@@ -26,7 +26,7 @@
  */
 #define NPCM7XX_GCR_NR_REGS (0x148 / sizeof(uint32_t))
 
-typedef struct NPCM7xxGCRState {
+struct NPCM7xxGCRState {
     SysBusDevice parent;
 
     MemoryRegion iomem;
@@ -36,7 +36,8 @@ typedef struct NPCM7xxGCRState {
     uint32_t reset_pwron;
     uint32_t reset_mdlr;
     uint32_t reset_intcr3;
-} NPCM7xxGCRState;
+};
+typedef struct NPCM7xxGCRState NPCM7xxGCRState;
 
 #define TYPE_NPCM7XX_GCR "npcm7xx-gcr"
 #define NPCM7XX_GCR(obj) OBJECT_CHECK(NPCM7xxGCRState, (obj), TYPE_NPCM7XX_GCR)
diff --git a/include/hw/misc/npcm7xx_mft.h b/include/hw/misc/npcm7xx_mft.h
index 36785e3ba81..3f7bd2a9c6a 100644
--- a/include/hw/misc/npcm7xx_mft.h
+++ b/include/hw/misc/npcm7xx_mft.h
@@ -49,7 +49,7 @@
  * @max_rpm: The maximum rpm for fans. Order: A0, B0, A1, B1.
  * @duty: The duty cycles for fans, relative to NPCM7XX_PWM_MAX_DUTY.
  */
-typedef struct NPCM7xxMFTState {
+struct NPCM7xxMFTState {
     SysBusDevice parent;
 
     MemoryRegion iomem;
@@ -61,7 +61,8 @@ typedef struct NPCM7xxMFTState {
 
     uint32_t    max_rpm[NPCM7XX_MFT_FANIN_COUNT];
     uint32_t    duty[NPCM7XX_MFT_FANIN_COUNT];
-} NPCM7xxMFTState;
+};
+typedef struct NPCM7xxMFTState NPCM7xxMFTState;
 
 #define TYPE_NPCM7XX_MFT "npcm7xx-mft"
 #define NPCM7XX_MFT(obj) \
diff --git a/include/hw/misc/npcm7xx_rng.h b/include/hw/misc/npcm7xx_rng.h
index 1d20293608a..27122001f4b 100644
--- a/include/hw/misc/npcm7xx_rng.h
+++ b/include/hw/misc/npcm7xx_rng.h
@@ -19,7 +19,7 @@
 #include "hw/sysbus.h"
 #include "qom/object.h"
 
-typedef struct NPCM7xxRNGState {
+struct NPCM7xxRNGState {
     SysBusDevice parent;
 
     MemoryRegion iomem;
@@ -27,7 +27,8 @@ typedef struct NPCM7xxRNGState {
     uint8_t rngcs;
     uint8_t rngd;
     uint8_t rngmode;
-} NPCM7xxRNGState;
+};
+typedef struct NPCM7xxRNGState NPCM7xxRNGState;
 
 #define TYPE_NPCM7XX_RNG "npcm7xx-rng"
 #define NPCM7XX_RNG(obj) OBJECT_CHECK(NPCM7xxRNGState, (obj), TYPE_NPCM7XX_RNG)
diff --git a/include/hw/nvram/npcm7xx_otp.h b/include/hw/nvram/npcm7xx_otp.h
index 32c73845ff3..0ab1d5bae48 100644
--- a/include/hw/nvram/npcm7xx_otp.h
+++ b/include/hw/nvram/npcm7xx_otp.h
@@ -48,13 +48,14 @@
  * @regs: Register contents.
  * @array: OTP storage array.
  */
-typedef struct NPCM7xxOTPState {
+struct NPCM7xxOTPState {
     SysBusDevice parent;
 
     MemoryRegion mmio;
     uint32_t regs[NPCM7XX_OTP_NR_REGS];
     uint8_t array[NPCM7XX_OTP_ARRAY_BYTES];
-} NPCM7xxOTPState;
+};
+typedef struct NPCM7xxOTPState NPCM7xxOTPState;
 
 #define TYPE_NPCM7XX_OTP "npcm7xx-otp"
 #define NPCM7XX_OTP(obj) OBJECT_CHECK(NPCM7xxOTPState, (obj), TYPE_NPCM7XX_OTP)
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
index 3f83f9d98da..b30fb1191d9 100644
--- a/include/hw/riscv/microchip_pfsoc.h
+++ b/include/hw/riscv/microchip_pfsoc.h
@@ -31,7 +31,7 @@
 #include "hw/sd/cadence_sdhci.h"
 #include "qom/object.h"
 
-typedef struct MicrochipPFSoCState {
+struct MicrochipPFSoCState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -54,19 +54,21 @@ typedef struct MicrochipPFSoCState {
     CadenceGEMState gem0;
     CadenceGEMState gem1;
     CadenceSDHCIState sdhci;
-} MicrochipPFSoCState;
+};
+typedef struct MicrochipPFSoCState MicrochipPFSoCState;
 
 #define TYPE_MICROCHIP_PFSOC    "microchip.pfsoc"
 #define MICROCHIP_PFSOC(obj) \
     OBJECT_CHECK(MicrochipPFSoCState, (obj), TYPE_MICROCHIP_PFSOC)
 
-typedef struct MicrochipIcicleKitState {
+struct MicrochipIcicleKitState {
     /*< private >*/
     MachineState parent_obj;
 
     /*< public >*/
     MicrochipPFSoCState soc;
-} MicrochipIcicleKitState;
+};
+typedef struct MicrochipIcicleKitState MicrochipIcicleKitState;
 
 #define TYPE_MICROCHIP_ICICLE_KIT_MACHINE \
     MACHINE_TYPE_NAME("microchip-icicle-kit")
diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h
index e654e2dfec6..9c9ce14a4b4 100644
--- a/include/hw/riscv/sifive_e.h
+++ b/include/hw/riscv/sifive_e.h
@@ -41,14 +41,15 @@ struct SiFiveESoCState {
     MemoryRegion mask_rom;
 };
 
-typedef struct SiFiveEState {
+struct SiFiveEState {
     /*< private >*/
     SysBusDevice parent_obj;
 
     /*< public >*/
     SiFiveESoCState soc;
     bool revb;
-} SiFiveEState;
+};
+typedef struct SiFiveEState SiFiveEState;
 
 #define TYPE_RISCV_E_MACHINE MACHINE_TYPE_NAME("sifive_e")
 #define RISCV_E_MACHINE(obj) \
diff --git a/include/hw/sd/cadence_sdhci.h b/include/hw/sd/cadence_sdhci.h
index c890e285fca..75c174f357a 100644
--- a/include/hw/sd/cadence_sdhci.h
+++ b/include/hw/sd/cadence_sdhci.h
@@ -29,7 +29,7 @@
 #define CADENCE_SDHCI_REG_SIZE  0x100
 #define CADENCE_SDHCI_NUM_REGS  (CADENCE_SDHCI_REG_SIZE / sizeof(uint32_t))
 
-typedef struct CadenceSDHCIState {
+struct CadenceSDHCIState {
     SysBusDevice parent;
 
     MemoryRegion container;
@@ -39,7 +39,8 @@ typedef struct CadenceSDHCIState {
     uint32_t regs[CADENCE_SDHCI_NUM_REGS];
 
     SDHCIState sdhci;
-} CadenceSDHCIState;
+};
+typedef struct CadenceSDHCIState CadenceSDHCIState;
 
 #define TYPE_CADENCE_SDHCI  "cadence.sdhci"
 #define CADENCE_SDHCI(obj)  OBJECT_CHECK(CadenceSDHCIState, (obj), \
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index cc915720494..c18f43a3a8c 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -26,12 +26,13 @@
 #include "qom/object.h"
 #include "exec/hwaddr.h"
 
-typedef struct AccelState {
+struct AccelState {
     /*< private >*/
     Object parent_obj;
-} AccelState;
+};
+typedef struct AccelState AccelState;
 
-typedef struct AccelClass {
+struct AccelClass {
     /*< private >*/
     ObjectClass parent_class;
     /*< public >*/
@@ -52,7 +53,8 @@ typedef struct AccelClass {
      * compat_props or user-provided global properties.
      */
     GPtrArray *compat_props;
-} AccelClass;
+};
+typedef struct AccelClass AccelClass;
 
 #define TYPE_ACCEL_BASE "accel"
 
diff --git a/chardev/char-parallel.c b/chardev/char-parallel.c
index dcbf6177a1e..bebe0507053 100644
--- a/chardev/char-parallel.c
+++ b/chardev/char-parallel.c
@@ -50,11 +50,12 @@
 
 #if defined(__linux__)
 
-typedef struct ParallelChardev {
+struct ParallelChardev {
     Chardev parent;
     int fd;
     int mode;
-} ParallelChardev;
+};
+typedef struct ParallelChardev ParallelChardev;
 
 #define PARALLEL_CHARDEV(obj) \
     OBJECT_CHECK(ParallelChardev, (obj), TYPE_CHARDEV_PARALLEL)
@@ -178,10 +179,11 @@ static void qemu_chr_open_pp_fd(Chardev *chr,
 
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
 
-typedef struct ParallelChardev {
+struct ParallelChardev {
     Chardev parent;
     int fd;
-} ParallelChardev;
+};
+typedef struct ParallelChardev ParallelChardev;
 
 #define PARALLEL_CHARDEV(obj)                                   \
     OBJECT_CHECK(ParallelChardev, (obj), TYPE_CHARDEV_PARALLEL)
diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c
index 847c59921cf..40b4c44a5df 100644
--- a/hw/i2c/i2c_mux_pca954x.c
+++ b/hw/i2c/i2c_mux_pca954x.c
@@ -36,13 +36,14 @@
  * @bus: The owned channel bus.
  * @enabled: Is this channel active?
  */
-typedef struct Pca954xChannel {
+struct Pca954xChannel {
     SysBusDevice parent;
 
     I2CBus       *bus;
 
     bool         enabled;
-} Pca954xChannel;
+};
+typedef struct Pca954xChannel Pca954xChannel;
 
 #define TYPE_PCA954X_CHANNEL "pca954x-channel"
 #define PCA954X_CHANNEL(obj) \
diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c
index bd7e328435a..b8001fdcf5e 100644
--- a/hw/m68k/mcf5206.c
+++ b/hw/m68k/mcf5206.c
@@ -161,7 +161,7 @@ static m5206_timer_state *m5206_timer_init(qemu_irq irq)
 
 /* System Integration Module.  */
 
-typedef struct m5206_mbar_state {
+struct m5206_mbar_state {
     SysBusDevice parent_obj;
 
     M68kCPU *cpu;
@@ -178,7 +178,8 @@ typedef struct m5206_mbar_state {
     uint8_t par;
     /* Include the UART vector registers here.  */
     uint8_t uivr[2];
-} m5206_mbar_state;
+};
+typedef struct m5206_mbar_state m5206_mbar_state;
 
 #define MCF5206_MBAR(obj) OBJECT_CHECK(m5206_mbar_state, (obj), TYPE_MCF5206_MBAR)
 
diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c
index 846b2ff905a..e4b79e98866 100644
--- a/hw/misc/sbsa_ec.c
+++ b/hw/misc/sbsa_ec.c
@@ -17,10 +17,11 @@
 #include "sysemu/runstate.h"
 #include "qom/object.h"
 
-typedef struct SECUREECState {
+struct SECUREECState {
     SysBusDevice parent_obj;
     MemoryRegion iomem;
-} SECUREECState;
+};
+typedef struct SECUREECState SECUREECState;
 
 #define TYPE_SBSA_EC      "sbsa-ec"
 #define SECURE_EC(obj) OBJECT_CHECK(SECUREECState, (obj), TYPE_SBSA_EC)
diff --git a/hw/s390x/vhost-user-fs-ccw.c b/hw/s390x/vhost-user-fs-ccw.c
index 7d573156780..254153860dc 100644
--- a/hw/s390x/vhost-user-fs-ccw.c
+++ b/hw/s390x/vhost-user-fs-ccw.c
@@ -14,10 +14,11 @@
 #include "virtio-ccw.h"
 #include "qom/object.h"
 
-typedef struct VHostUserFSCcw {
+struct VHostUserFSCcw {
     VirtioCcwDevice parent_obj;
     VHostUserFS vdev;
-} VHostUserFSCcw;
+};
+typedef struct VHostUserFSCcw VHostUserFSCcw;
 
 #define TYPE_VHOST_USER_FS_CCW "vhost-user-fs-ccw"
 #define VHOST_USER_FS_CCW(obj) \
diff --git a/tests/qtest/pnv-xscom-test.c b/tests/qtest/pnv-xscom-test.c
index c8d40433620..1b13c046a9f 100644
--- a/tests/qtest/pnv-xscom-test.c
+++ b/tests/qtest/pnv-xscom-test.c
@@ -17,13 +17,14 @@ typedef enum PnvChipType {
     PNV_CHIP_POWER9,      /* AKA Nimbus */
 } PnvChipType;
 
-typedef struct PnvChip {
+struct PnvChip {
     PnvChipType chip_type;
     const char *cpu_model;
     uint64_t    xscom_base;
     uint64_t    cfam_id;
     uint32_t    first_core;
-} PnvChip;
+};
+typedef struct PnvChip PnvChip;
 
 static const PnvChip pnv_chips[] = {
     {
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 06/12] [automated] Split QOM "typedef struct T { ... } T" declarations
@ 2021-08-06 21:11   ` Eduardo Habkost
  0 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrange, Paolo Bonzini, Marc-André Lureau,
	Patrick Venture, Thomas Huth, Keith Busch, Klaus Jensen,
	Michael S. Tsirkin, Cornelia Huck, Halil Pasic,
	Christian Borntraeger, Richard Henderson, David Hildenbrand,
	Gerd Hoffmann, Havard Skinnemoen, Tyrone Ting, Alistair Francis,
	Bin Meng, Palmer Dabbelt, Edgar E. Iglesias, Peter Maydell,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Cédric Le Goater, David Gibson, Greg Kurz, Laurent Vivier,
	qemu-block, qemu-s390x, qemu-arm, qemu-riscv, qemu-ppc

Automatically split struct definition and typedef declaration in
separate declarations, using a codeconverter rule.  The rule will
only touch declarations of structs/typedefs actually used by QOM
types.

This will make automated changes to use OBJECT_DECLARE* macros
easier to implement, because automated removal of typedef lines
will be easier and safer.

Generated using:

  $ ./scripts/codeconverter/converter.py -i \
    --pattern=QOMStructTypedefSplit $(git grep -l '' -- '*.[ch]')

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Patrick Venture <venture@google.com>
Cc: Thomas Huth <huth@tuxfamily.org>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Klaus Jensen <its@irrelevant.dk>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: Halil Pasic <pasic@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Havard Skinnemoen <hskinnemoen@google.com>
Cc: Tyrone Ting <kfting@nuvoton.com>
Cc: Alistair Francis <Alistair.Francis@wdc.com>
Cc: Bin Meng <bin.meng@windriver.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Cédric Le Goater" <clg@kaod.org>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Greg Kurz <groug@kaod.org>
Cc: Laurent Vivier <lvivier@redhat.com>
Cc: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org
Cc: qemu-s390x@nongnu.org
Cc: qemu-arm@nongnu.org
Cc: qemu-riscv@nongnu.org
Cc: qemu-ppc@nongnu.org
---
 hw/nvme/nvme.h                      | 10 ++++++----
 hw/usb/hcd-uhci.h                   |  5 +++--
 hw/usb/u2f.h                        |  5 +++--
 include/hw/adc/npcm7xx_adc.h        |  5 +++--
 include/hw/arm/npcm7xx.h            | 10 ++++++----
 include/hw/core/accel-cpu.h         |  5 +++--
 include/hw/dma/sifive_pdma.h        |  5 +++--
 include/hw/dma/xlnx_csu_dma.h       |  5 +++--
 include/hw/gpio/npcm7xx_gpio.h      |  5 +++--
 include/hw/i2c/npcm7xx_smbus.h      |  5 +++--
 include/hw/mem/npcm7xx_mc.h         |  5 +++--
 include/hw/misc/bcm2835_cprman.h    | 20 ++++++++++++--------
 include/hw/misc/mchp_pfsoc_dmc.h    | 10 ++++++----
 include/hw/misc/mchp_pfsoc_ioscb.h  |  5 +++--
 include/hw/misc/mchp_pfsoc_sysreg.h |  5 +++--
 include/hw/misc/npcm7xx_clk.h       | 15 +++++++++------
 include/hw/misc/npcm7xx_gcr.h       |  5 +++--
 include/hw/misc/npcm7xx_mft.h       |  5 +++--
 include/hw/misc/npcm7xx_rng.h       |  5 +++--
 include/hw/nvram/npcm7xx_otp.h      |  5 +++--
 include/hw/riscv/microchip_pfsoc.h  | 10 ++++++----
 include/hw/riscv/sifive_e.h         |  5 +++--
 include/hw/sd/cadence_sdhci.h       |  5 +++--
 include/qemu/accel.h                | 10 ++++++----
 chardev/char-parallel.c             | 10 ++++++----
 hw/i2c/i2c_mux_pca954x.c            |  5 +++--
 hw/m68k/mcf5206.c                   |  5 +++--
 hw/misc/sbsa_ec.c                   |  5 +++--
 hw/s390x/vhost-user-fs-ccw.c        |  5 +++--
 tests/qtest/pnv-xscom-test.c        |  5 +++--
 30 files changed, 123 insertions(+), 82 deletions(-)

diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
index 5ddcd783055..0840f585d6e 100644
--- a/hw/nvme/nvme.h
+++ b/hw/nvme/nvme.h
@@ -118,7 +118,7 @@ typedef struct NvmeNamespaceParams {
     uint32_t zd_extension_size;
 } NvmeNamespaceParams;
 
-typedef struct NvmeNamespace {
+struct NvmeNamespace {
     DeviceState  parent_obj;
     BlockConf    blkconf;
     int32_t      bootindex;
@@ -153,7 +153,8 @@ typedef struct NvmeNamespace {
     struct {
         uint32_t err_rec;
     } features;
-} NvmeNamespace;
+};
+typedef struct NvmeNamespace NvmeNamespace;
 
 static inline uint32_t nvme_nsid(NvmeNamespace *ns)
 {
@@ -395,7 +396,7 @@ typedef struct NvmeParams {
     bool     legacy_cmb;
 } NvmeParams;
 
-typedef struct NvmeCtrl {
+struct NvmeCtrl {
     PCIDevice    parent_obj;
     MemoryRegion bar0;
     MemoryRegion iomem;
@@ -462,7 +463,8 @@ typedef struct NvmeCtrl {
         };
         uint32_t    async_config;
     } features;
-} NvmeCtrl;
+};
+typedef struct NvmeCtrl NvmeCtrl;
 
 static inline NvmeNamespace *nvme_ns(NvmeCtrl *n, uint32_t nsid)
 {
diff --git a/hw/usb/hcd-uhci.h b/hw/usb/hcd-uhci.h
index 57d0d574644..2597a6d2eb6 100644
--- a/hw/usb/hcd-uhci.h
+++ b/hw/usb/hcd-uhci.h
@@ -43,7 +43,7 @@ typedef struct UHCIPort {
     uint16_t ctrl;
 } UHCIPort;
 
-typedef struct UHCIState {
+struct UHCIState {
     PCIDevice dev;
     MemoryRegion io_bar;
     USBBus bus; /* Note unused when we're a companion controller */
@@ -73,7 +73,8 @@ typedef struct UHCIState {
     char *masterbus;
     uint32_t firstport;
     uint32_t maxframes;
-} UHCIState;
+};
+typedef struct UHCIState UHCIState;
 
 #define TYPE_UHCI "pci-uhci-usb"
 DECLARE_INSTANCE_CHECKER(UHCIState, UHCI, TYPE_UHCI)
diff --git a/hw/usb/u2f.h b/hw/usb/u2f.h
index 705d5c43ce6..7191a23ee1a 100644
--- a/hw/usb/u2f.h
+++ b/hw/usb/u2f.h
@@ -62,7 +62,7 @@ struct U2FKeyClass {
 /*
  * State of the U2F key base device (i.e. hw/u2f.c)
  */
-typedef struct U2FKeyState {
+struct U2FKeyState {
     USBDevice dev;
     USBEndpoint *ep;
     uint8_t idle;
@@ -72,7 +72,8 @@ typedef struct U2FKeyState {
     uint8_t pending_in_start;
     uint8_t pending_in_end;
     uint8_t pending_in_num;
-} U2FKeyState;
+};
+typedef struct U2FKeyState U2FKeyState;
 
 /*
  * API to be used by the U2F key device variants (i.e. hw/u2f-*.c)
diff --git a/include/hw/adc/npcm7xx_adc.h b/include/hw/adc/npcm7xx_adc.h
index 874cfbd6ce3..835d13f5b0d 100644
--- a/include/hw/adc/npcm7xx_adc.h
+++ b/include/hw/adc/npcm7xx_adc.h
@@ -43,7 +43,7 @@
  * @iref: The internal reference voltage, initialized at launch time.
  * @rv: The calibrated output values of 0.5V and 1.5V for the ADC.
  */
-typedef struct NPCM7xxADCState {
+struct NPCM7xxADCState {
     SysBusDevice parent;
 
     MemoryRegion iomem;
@@ -61,7 +61,8 @@ typedef struct NPCM7xxADCState {
     uint32_t     iref;
 
     uint16_t     calibration_r_values[NPCM7XX_ADC_NUM_CALIB];
-} NPCM7xxADCState;
+};
+typedef struct NPCM7xxADCState NPCM7xxADCState;
 
 #define TYPE_NPCM7XX_ADC "npcm7xx-adc"
 #define NPCM7XX_ADC(obj) \
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
index dc802c1645c..697d2957590 100644
--- a/include/hw/arm/npcm7xx.h
+++ b/include/hw/arm/npcm7xx.h
@@ -52,7 +52,7 @@
 
 #define NPCM7XX_NR_PWM_MODULES 2
 
-typedef struct NPCM7xxMachine {
+struct NPCM7xxMachine {
     MachineState        parent;
     /*
      * PWM fan splitter. each splitter connects to one PWM output and
@@ -60,7 +60,8 @@ typedef struct NPCM7xxMachine {
      */
     SplitIRQ            fan_splitter[NPCM7XX_NR_PWM_MODULES *
                                      NPCM7XX_PWM_PER_MODULE];
-} NPCM7xxMachine;
+};
+typedef struct NPCM7xxMachine NPCM7xxMachine;
 
 #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
 typedef struct NPCM7xxMachineClass NPCM7xxMachineClass;
@@ -78,7 +79,7 @@ struct NPCM7xxMachineClass {
 #define NPCM7XX_MACHINE_GET_CLASS(obj)                                  \
     OBJECT_GET_CLASS(NPCM7xxMachineClass, (obj), TYPE_NPCM7XX_MACHINE)
 
-typedef struct NPCM7xxState {
+struct NPCM7xxState {
     DeviceState         parent;
 
     ARMCPU              cpu[NPCM7XX_MAX_NUM_CPUS];
@@ -105,7 +106,8 @@ typedef struct NPCM7xxState {
     OHCISysBusState     ohci;
     NPCM7xxFIUState     fiu[2];
     NPCM7xxEMCState     emc[2];
-} NPCM7xxState;
+};
+typedef struct NPCM7xxState NPCM7xxState;
 
 #define TYPE_NPCM7XX    "npcm7xx"
 typedef struct NPCM7xxClass NPCM7xxClass;
diff --git a/include/hw/core/accel-cpu.h b/include/hw/core/accel-cpu.h
index 0b7b3f6df3e..b1f6fdb756b 100644
--- a/include/hw/core/accel-cpu.h
+++ b/include/hw/core/accel-cpu.h
@@ -26,7 +26,7 @@
 typedef struct AccelCPUClass AccelCPUClass;
 DECLARE_CLASS_CHECKERS(AccelCPUClass, ACCEL_CPU, TYPE_ACCEL_CPU)
 
-typedef struct AccelCPUClass {
+struct AccelCPUClass {
     /*< private >*/
     ObjectClass parent_class;
     /*< public >*/
@@ -34,6 +34,7 @@ typedef struct AccelCPUClass {
     void (*cpu_class_init)(CPUClass *cc);
     void (*cpu_instance_init)(CPUState *cpu);
     bool (*cpu_realizefn)(CPUState *cpu, Error **errp);
-} AccelCPUClass;
+};
+typedef struct AccelCPUClass AccelCPUClass;
 
 #endif /* ACCEL_CPU_H */
diff --git a/include/hw/dma/sifive_pdma.h b/include/hw/dma/sifive_pdma.h
index a62908dd0f2..76b4b45d0a4 100644
--- a/include/hw/dma/sifive_pdma.h
+++ b/include/hw/dma/sifive_pdma.h
@@ -42,13 +42,14 @@ struct sifive_pdma_chan {
 #define SIFIVE_PDMA_REG_SIZE        0x100000
 #define SIFIVE_PDMA_CHAN_NO(reg)    ((reg & (SIFIVE_PDMA_REG_SIZE - 1)) >> 12)
 
-typedef struct SiFivePDMAState {
+struct SiFivePDMAState {
     SysBusDevice parent;
     MemoryRegion iomem;
     qemu_irq irq[SIFIVE_PDMA_IRQS];
 
     struct sifive_pdma_chan chan[SIFIVE_PDMA_CHANS];
-} SiFivePDMAState;
+};
+typedef struct SiFivePDMAState SiFivePDMAState;
 
 #define TYPE_SIFIVE_PDMA    "sifive.pdma"
 
diff --git a/include/hw/dma/xlnx_csu_dma.h b/include/hw/dma/xlnx_csu_dma.h
index 804ca5958d0..f8d88e2ebee 100644
--- a/include/hw/dma/xlnx_csu_dma.h
+++ b/include/hw/dma/xlnx_csu_dma.h
@@ -26,7 +26,7 @@
 
 #define XLNX_CSU_DMA_R_MAX (0x2c / 4)
 
-typedef struct XlnxCSUDMA {
+struct XlnxCSUDMA {
     SysBusDevice busdev;
     MemoryRegion iomem;
     MemTxAttrs attr;
@@ -45,7 +45,8 @@ typedef struct XlnxCSUDMA {
 
     uint32_t regs[XLNX_CSU_DMA_R_MAX];
     RegisterInfo regs_info[XLNX_CSU_DMA_R_MAX];
-} XlnxCSUDMA;
+};
+typedef struct XlnxCSUDMA XlnxCSUDMA;
 
 #define XLNX_CSU_DMA(obj) \
     OBJECT_CHECK(XlnxCSUDMA, (obj), TYPE_XLNX_CSU_DMA)
diff --git a/include/hw/gpio/npcm7xx_gpio.h b/include/hw/gpio/npcm7xx_gpio.h
index c4e5b4a353e..e45cf45e78e 100644
--- a/include/hw/gpio/npcm7xx_gpio.h
+++ b/include/hw/gpio/npcm7xx_gpio.h
@@ -28,7 +28,7 @@
  */
 #define NPCM7XX_GPIO_NR_REGS (0x80 / sizeof(uint32_t))
 
-typedef struct NPCM7xxGPIOState {
+struct NPCM7xxGPIOState {
     SysBusDevice parent;
 
     /* Properties to be defined by the SoC */
@@ -47,7 +47,8 @@ typedef struct NPCM7xxGPIOState {
     uint32_t ext_driven;
 
     uint32_t regs[NPCM7XX_GPIO_NR_REGS];
-} NPCM7xxGPIOState;
+};
+typedef struct NPCM7xxGPIOState NPCM7xxGPIOState;
 
 #define TYPE_NPCM7XX_GPIO "npcm7xx-gpio"
 #define NPCM7XX_GPIO(obj) \
diff --git a/include/hw/i2c/npcm7xx_smbus.h b/include/hw/i2c/npcm7xx_smbus.h
index 8030d78f69c..ef64c6748a7 100644
--- a/include/hw/i2c/npcm7xx_smbus.h
+++ b/include/hw/i2c/npcm7xx_smbus.h
@@ -69,7 +69,7 @@ typedef enum NPCM7xxSMBusStatus {
  * @rx_cur: The current position of rx_fifo.
  * @status: The current status of the SMBus.
  */
-typedef struct NPCM7xxSMBusState {
+struct NPCM7xxSMBusState {
     SysBusDevice parent;
 
     MemoryRegion iomem;
@@ -105,7 +105,8 @@ typedef struct NPCM7xxSMBusState {
     uint8_t      rx_cur;
 
     NPCM7xxSMBusStatus status;
-} NPCM7xxSMBusState;
+};
+typedef struct NPCM7xxSMBusState NPCM7xxSMBusState;
 
 #define TYPE_NPCM7XX_SMBUS "npcm7xx-smbus"
 #define NPCM7XX_SMBUS(obj) OBJECT_CHECK(NPCM7xxSMBusState, (obj), \
diff --git a/include/hw/mem/npcm7xx_mc.h b/include/hw/mem/npcm7xx_mc.h
index 83787f6fa57..e0a9d3b0de9 100644
--- a/include/hw/mem/npcm7xx_mc.h
+++ b/include/hw/mem/npcm7xx_mc.h
@@ -25,11 +25,12 @@
  * @parent: System bus device.
  * @mmio: Memory region through which registers are accessed.
  */
-typedef struct NPCM7xxMCState {
+struct NPCM7xxMCState {
     SysBusDevice parent;
 
     MemoryRegion mmio;
-} NPCM7xxMCState;
+};
+typedef struct NPCM7xxMCState NPCM7xxMCState;
 
 #define TYPE_NPCM7XX_MC "npcm7xx-mc"
 #define NPCM7XX_MC(obj) OBJECT_CHECK(NPCM7xxMCState, (obj), TYPE_NPCM7XX_MC)
diff --git a/include/hw/misc/bcm2835_cprman.h b/include/hw/misc/bcm2835_cprman.h
index ba4b441dce5..966c0b600ed 100644
--- a/include/hw/misc/bcm2835_cprman.h
+++ b/include/hw/misc/bcm2835_cprman.h
@@ -118,7 +118,7 @@ typedef enum CprmanClockMuxSource {
     CPRMAN_NUM_CLOCK_MUX_SRC
 } CprmanClockMuxSource;
 
-typedef struct CprmanPllState {
+struct CprmanPllState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -133,9 +133,10 @@ typedef struct CprmanPllState {
 
     Clock *xosc_in;
     Clock *out;
-} CprmanPllState;
+};
+typedef struct CprmanPllState CprmanPllState;
 
-typedef struct CprmanPllChannelState {
+struct CprmanPllChannelState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -151,9 +152,10 @@ typedef struct CprmanPllChannelState {
 
     Clock *pll_in;
     Clock *out;
-} CprmanPllChannelState;
+};
+typedef struct CprmanPllChannelState CprmanPllChannelState;
 
-typedef struct CprmanClockMuxState {
+struct CprmanClockMuxState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -173,9 +175,10 @@ typedef struct CprmanClockMuxState {
      * source number.
      */
     struct CprmanClockMuxState *backref[CPRMAN_NUM_CLOCK_MUX_SRC];
-} CprmanClockMuxState;
+};
+typedef struct CprmanClockMuxState CprmanClockMuxState;
 
-typedef struct CprmanDsi0HsckMuxState {
+struct CprmanDsi0HsckMuxState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -187,7 +190,8 @@ typedef struct CprmanDsi0HsckMuxState {
     Clock *plla_in;
     Clock *plld_in;
     Clock *out;
-} CprmanDsi0HsckMuxState;
+};
+typedef struct CprmanDsi0HsckMuxState CprmanDsi0HsckMuxState;
 
 struct BCM2835CprmanState {
     /*< private >*/
diff --git a/include/hw/misc/mchp_pfsoc_dmc.h b/include/hw/misc/mchp_pfsoc_dmc.h
index 979527957ea..28cfe3e1e23 100644
--- a/include/hw/misc/mchp_pfsoc_dmc.h
+++ b/include/hw/misc/mchp_pfsoc_dmc.h
@@ -28,10 +28,11 @@
 
 #define MCHP_PFSOC_DDR_SGMII_PHY_REG_SIZE   0x1000
 
-typedef struct MchpPfSoCDdrSgmiiPhyState {
+struct MchpPfSoCDdrSgmiiPhyState {
     SysBusDevice parent;
     MemoryRegion sgmii_phy;
-} MchpPfSoCDdrSgmiiPhyState;
+};
+typedef struct MchpPfSoCDdrSgmiiPhyState MchpPfSoCDdrSgmiiPhyState;
 
 #define TYPE_MCHP_PFSOC_DDR_SGMII_PHY "mchp.pfsoc.ddr_sgmii_phy"
 
@@ -43,10 +44,11 @@ typedef struct MchpPfSoCDdrSgmiiPhyState {
 
 #define MCHP_PFSOC_DDR_CFG_REG_SIZE         0x40000
 
-typedef struct MchpPfSoCDdrCfgState {
+struct MchpPfSoCDdrCfgState {
     SysBusDevice parent;
     MemoryRegion cfg;
-} MchpPfSoCDdrCfgState;
+};
+typedef struct MchpPfSoCDdrCfgState MchpPfSoCDdrCfgState;
 
 #define TYPE_MCHP_PFSOC_DDR_CFG "mchp.pfsoc.ddr_cfg"
 
diff --git a/include/hw/misc/mchp_pfsoc_ioscb.h b/include/hw/misc/mchp_pfsoc_ioscb.h
index 519b897250f..95b0b9069dd 100644
--- a/include/hw/misc/mchp_pfsoc_ioscb.h
+++ b/include/hw/misc/mchp_pfsoc_ioscb.h
@@ -24,7 +24,7 @@
 #define MCHP_PFSOC_IOSCB_H
 #include "qom/object.h"
 
-typedef struct MchpPfSoCIoscbState {
+struct MchpPfSoCIoscbState {
     SysBusDevice parent;
     MemoryRegion container;
     MemoryRegion lane01;
@@ -41,7 +41,8 @@ typedef struct MchpPfSoCIoscbState {
     MemoryRegion cfm_sgmii;
     MemoryRegion bc_sgmii;
     MemoryRegion io_calib_sgmii;
-} MchpPfSoCIoscbState;
+};
+typedef struct MchpPfSoCIoscbState MchpPfSoCIoscbState;
 
 #define TYPE_MCHP_PFSOC_IOSCB "mchp.pfsoc.ioscb"
 
diff --git a/include/hw/misc/mchp_pfsoc_sysreg.h b/include/hw/misc/mchp_pfsoc_sysreg.h
index d6803be9485..adce8d869c4 100644
--- a/include/hw/misc/mchp_pfsoc_sysreg.h
+++ b/include/hw/misc/mchp_pfsoc_sysreg.h
@@ -26,10 +26,11 @@
 
 #define MCHP_PFSOC_SYSREG_REG_SIZE  0x2000
 
-typedef struct MchpPfSoCSysregState {
+struct MchpPfSoCSysregState {
     SysBusDevice parent;
     MemoryRegion sysreg;
-} MchpPfSoCSysregState;
+};
+typedef struct MchpPfSoCSysregState MchpPfSoCSysregState;
 
 #define TYPE_MCHP_PFSOC_SYSREG "mchp.pfsoc.sysreg"
 
diff --git a/include/hw/misc/npcm7xx_clk.h b/include/hw/misc/npcm7xx_clk.h
index a849345620e..80b651c7e44 100644
--- a/include/hw/misc/npcm7xx_clk.h
+++ b/include/hw/misc/npcm7xx_clk.h
@@ -91,7 +91,7 @@ typedef struct NPCM7xxCLKState NPCM7xxCLKState;
  * @clock_out: The output clock of this module.
  * @reg: The control registers for this PLL module.
  */
-typedef struct NPCM7xxClockPLLState {
+struct NPCM7xxClockPLLState {
     DeviceState parent;
 
     const char *name;
@@ -100,7 +100,8 @@ typedef struct NPCM7xxClockPLLState {
     Clock *clock_out;
 
     int reg;
-} NPCM7xxClockPLLState;
+};
+typedef struct NPCM7xxClockPLLState NPCM7xxClockPLLState;
 
 /**
  * struct NPCM7xxClockSELState - A SEL module in CLK module.
@@ -112,7 +113,7 @@ typedef struct NPCM7xxClockPLLState {
  * @offset: The offset of this module in the control register.
  * @len: The length of this module in the control register.
  */
-typedef struct NPCM7xxClockSELState {
+struct NPCM7xxClockSELState {
     DeviceState parent;
 
     const char *name;
@@ -123,7 +124,8 @@ typedef struct NPCM7xxClockSELState {
 
     int offset;
     int len;
-} NPCM7xxClockSELState;
+};
+typedef struct NPCM7xxClockSELState NPCM7xxClockSELState;
 
 /**
  * struct NPCM7xxClockDividerState - A Divider module in CLK module.
@@ -137,7 +139,7 @@ typedef struct NPCM7xxClockSELState {
  * @len: The length of the divisor in the control register.
  * @divisor: The divisor for a constant divisor
  */
-typedef struct NPCM7xxClockDividerState {
+struct NPCM7xxClockDividerState {
     DeviceState parent;
 
     const char *name;
@@ -154,7 +156,8 @@ typedef struct NPCM7xxClockDividerState {
         };
         int divisor;
     };
-} NPCM7xxClockDividerState;
+};
+typedef struct NPCM7xxClockDividerState NPCM7xxClockDividerState;
 
 struct NPCM7xxCLKState {
     SysBusDevice parent;
diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h
index 482768c8e76..b5c573ec8f2 100644
--- a/include/hw/misc/npcm7xx_gcr.h
+++ b/include/hw/misc/npcm7xx_gcr.h
@@ -26,7 +26,7 @@
  */
 #define NPCM7XX_GCR_NR_REGS (0x148 / sizeof(uint32_t))
 
-typedef struct NPCM7xxGCRState {
+struct NPCM7xxGCRState {
     SysBusDevice parent;
 
     MemoryRegion iomem;
@@ -36,7 +36,8 @@ typedef struct NPCM7xxGCRState {
     uint32_t reset_pwron;
     uint32_t reset_mdlr;
     uint32_t reset_intcr3;
-} NPCM7xxGCRState;
+};
+typedef struct NPCM7xxGCRState NPCM7xxGCRState;
 
 #define TYPE_NPCM7XX_GCR "npcm7xx-gcr"
 #define NPCM7XX_GCR(obj) OBJECT_CHECK(NPCM7xxGCRState, (obj), TYPE_NPCM7XX_GCR)
diff --git a/include/hw/misc/npcm7xx_mft.h b/include/hw/misc/npcm7xx_mft.h
index 36785e3ba81..3f7bd2a9c6a 100644
--- a/include/hw/misc/npcm7xx_mft.h
+++ b/include/hw/misc/npcm7xx_mft.h
@@ -49,7 +49,7 @@
  * @max_rpm: The maximum rpm for fans. Order: A0, B0, A1, B1.
  * @duty: The duty cycles for fans, relative to NPCM7XX_PWM_MAX_DUTY.
  */
-typedef struct NPCM7xxMFTState {
+struct NPCM7xxMFTState {
     SysBusDevice parent;
 
     MemoryRegion iomem;
@@ -61,7 +61,8 @@ typedef struct NPCM7xxMFTState {
 
     uint32_t    max_rpm[NPCM7XX_MFT_FANIN_COUNT];
     uint32_t    duty[NPCM7XX_MFT_FANIN_COUNT];
-} NPCM7xxMFTState;
+};
+typedef struct NPCM7xxMFTState NPCM7xxMFTState;
 
 #define TYPE_NPCM7XX_MFT "npcm7xx-mft"
 #define NPCM7XX_MFT(obj) \
diff --git a/include/hw/misc/npcm7xx_rng.h b/include/hw/misc/npcm7xx_rng.h
index 1d20293608a..27122001f4b 100644
--- a/include/hw/misc/npcm7xx_rng.h
+++ b/include/hw/misc/npcm7xx_rng.h
@@ -19,7 +19,7 @@
 #include "hw/sysbus.h"
 #include "qom/object.h"
 
-typedef struct NPCM7xxRNGState {
+struct NPCM7xxRNGState {
     SysBusDevice parent;
 
     MemoryRegion iomem;
@@ -27,7 +27,8 @@ typedef struct NPCM7xxRNGState {
     uint8_t rngcs;
     uint8_t rngd;
     uint8_t rngmode;
-} NPCM7xxRNGState;
+};
+typedef struct NPCM7xxRNGState NPCM7xxRNGState;
 
 #define TYPE_NPCM7XX_RNG "npcm7xx-rng"
 #define NPCM7XX_RNG(obj) OBJECT_CHECK(NPCM7xxRNGState, (obj), TYPE_NPCM7XX_RNG)
diff --git a/include/hw/nvram/npcm7xx_otp.h b/include/hw/nvram/npcm7xx_otp.h
index 32c73845ff3..0ab1d5bae48 100644
--- a/include/hw/nvram/npcm7xx_otp.h
+++ b/include/hw/nvram/npcm7xx_otp.h
@@ -48,13 +48,14 @@
  * @regs: Register contents.
  * @array: OTP storage array.
  */
-typedef struct NPCM7xxOTPState {
+struct NPCM7xxOTPState {
     SysBusDevice parent;
 
     MemoryRegion mmio;
     uint32_t regs[NPCM7XX_OTP_NR_REGS];
     uint8_t array[NPCM7XX_OTP_ARRAY_BYTES];
-} NPCM7xxOTPState;
+};
+typedef struct NPCM7xxOTPState NPCM7xxOTPState;
 
 #define TYPE_NPCM7XX_OTP "npcm7xx-otp"
 #define NPCM7XX_OTP(obj) OBJECT_CHECK(NPCM7xxOTPState, (obj), TYPE_NPCM7XX_OTP)
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
index 3f83f9d98da..b30fb1191d9 100644
--- a/include/hw/riscv/microchip_pfsoc.h
+++ b/include/hw/riscv/microchip_pfsoc.h
@@ -31,7 +31,7 @@
 #include "hw/sd/cadence_sdhci.h"
 #include "qom/object.h"
 
-typedef struct MicrochipPFSoCState {
+struct MicrochipPFSoCState {
     /*< private >*/
     DeviceState parent_obj;
 
@@ -54,19 +54,21 @@ typedef struct MicrochipPFSoCState {
     CadenceGEMState gem0;
     CadenceGEMState gem1;
     CadenceSDHCIState sdhci;
-} MicrochipPFSoCState;
+};
+typedef struct MicrochipPFSoCState MicrochipPFSoCState;
 
 #define TYPE_MICROCHIP_PFSOC    "microchip.pfsoc"
 #define MICROCHIP_PFSOC(obj) \
     OBJECT_CHECK(MicrochipPFSoCState, (obj), TYPE_MICROCHIP_PFSOC)
 
-typedef struct MicrochipIcicleKitState {
+struct MicrochipIcicleKitState {
     /*< private >*/
     MachineState parent_obj;
 
     /*< public >*/
     MicrochipPFSoCState soc;
-} MicrochipIcicleKitState;
+};
+typedef struct MicrochipIcicleKitState MicrochipIcicleKitState;
 
 #define TYPE_MICROCHIP_ICICLE_KIT_MACHINE \
     MACHINE_TYPE_NAME("microchip-icicle-kit")
diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h
index e654e2dfec6..9c9ce14a4b4 100644
--- a/include/hw/riscv/sifive_e.h
+++ b/include/hw/riscv/sifive_e.h
@@ -41,14 +41,15 @@ struct SiFiveESoCState {
     MemoryRegion mask_rom;
 };
 
-typedef struct SiFiveEState {
+struct SiFiveEState {
     /*< private >*/
     SysBusDevice parent_obj;
 
     /*< public >*/
     SiFiveESoCState soc;
     bool revb;
-} SiFiveEState;
+};
+typedef struct SiFiveEState SiFiveEState;
 
 #define TYPE_RISCV_E_MACHINE MACHINE_TYPE_NAME("sifive_e")
 #define RISCV_E_MACHINE(obj) \
diff --git a/include/hw/sd/cadence_sdhci.h b/include/hw/sd/cadence_sdhci.h
index c890e285fca..75c174f357a 100644
--- a/include/hw/sd/cadence_sdhci.h
+++ b/include/hw/sd/cadence_sdhci.h
@@ -29,7 +29,7 @@
 #define CADENCE_SDHCI_REG_SIZE  0x100
 #define CADENCE_SDHCI_NUM_REGS  (CADENCE_SDHCI_REG_SIZE / sizeof(uint32_t))
 
-typedef struct CadenceSDHCIState {
+struct CadenceSDHCIState {
     SysBusDevice parent;
 
     MemoryRegion container;
@@ -39,7 +39,8 @@ typedef struct CadenceSDHCIState {
     uint32_t regs[CADENCE_SDHCI_NUM_REGS];
 
     SDHCIState sdhci;
-} CadenceSDHCIState;
+};
+typedef struct CadenceSDHCIState CadenceSDHCIState;
 
 #define TYPE_CADENCE_SDHCI  "cadence.sdhci"
 #define CADENCE_SDHCI(obj)  OBJECT_CHECK(CadenceSDHCIState, (obj), \
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index cc915720494..c18f43a3a8c 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -26,12 +26,13 @@
 #include "qom/object.h"
 #include "exec/hwaddr.h"
 
-typedef struct AccelState {
+struct AccelState {
     /*< private >*/
     Object parent_obj;
-} AccelState;
+};
+typedef struct AccelState AccelState;
 
-typedef struct AccelClass {
+struct AccelClass {
     /*< private >*/
     ObjectClass parent_class;
     /*< public >*/
@@ -52,7 +53,8 @@ typedef struct AccelClass {
      * compat_props or user-provided global properties.
      */
     GPtrArray *compat_props;
-} AccelClass;
+};
+typedef struct AccelClass AccelClass;
 
 #define TYPE_ACCEL_BASE "accel"
 
diff --git a/chardev/char-parallel.c b/chardev/char-parallel.c
index dcbf6177a1e..bebe0507053 100644
--- a/chardev/char-parallel.c
+++ b/chardev/char-parallel.c
@@ -50,11 +50,12 @@
 
 #if defined(__linux__)
 
-typedef struct ParallelChardev {
+struct ParallelChardev {
     Chardev parent;
     int fd;
     int mode;
-} ParallelChardev;
+};
+typedef struct ParallelChardev ParallelChardev;
 
 #define PARALLEL_CHARDEV(obj) \
     OBJECT_CHECK(ParallelChardev, (obj), TYPE_CHARDEV_PARALLEL)
@@ -178,10 +179,11 @@ static void qemu_chr_open_pp_fd(Chardev *chr,
 
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
 
-typedef struct ParallelChardev {
+struct ParallelChardev {
     Chardev parent;
     int fd;
-} ParallelChardev;
+};
+typedef struct ParallelChardev ParallelChardev;
 
 #define PARALLEL_CHARDEV(obj)                                   \
     OBJECT_CHECK(ParallelChardev, (obj), TYPE_CHARDEV_PARALLEL)
diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c
index 847c59921cf..40b4c44a5df 100644
--- a/hw/i2c/i2c_mux_pca954x.c
+++ b/hw/i2c/i2c_mux_pca954x.c
@@ -36,13 +36,14 @@
  * @bus: The owned channel bus.
  * @enabled: Is this channel active?
  */
-typedef struct Pca954xChannel {
+struct Pca954xChannel {
     SysBusDevice parent;
 
     I2CBus       *bus;
 
     bool         enabled;
-} Pca954xChannel;
+};
+typedef struct Pca954xChannel Pca954xChannel;
 
 #define TYPE_PCA954X_CHANNEL "pca954x-channel"
 #define PCA954X_CHANNEL(obj) \
diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c
index bd7e328435a..b8001fdcf5e 100644
--- a/hw/m68k/mcf5206.c
+++ b/hw/m68k/mcf5206.c
@@ -161,7 +161,7 @@ static m5206_timer_state *m5206_timer_init(qemu_irq irq)
 
 /* System Integration Module.  */
 
-typedef struct m5206_mbar_state {
+struct m5206_mbar_state {
     SysBusDevice parent_obj;
 
     M68kCPU *cpu;
@@ -178,7 +178,8 @@ typedef struct m5206_mbar_state {
     uint8_t par;
     /* Include the UART vector registers here.  */
     uint8_t uivr[2];
-} m5206_mbar_state;
+};
+typedef struct m5206_mbar_state m5206_mbar_state;
 
 #define MCF5206_MBAR(obj) OBJECT_CHECK(m5206_mbar_state, (obj), TYPE_MCF5206_MBAR)
 
diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c
index 846b2ff905a..e4b79e98866 100644
--- a/hw/misc/sbsa_ec.c
+++ b/hw/misc/sbsa_ec.c
@@ -17,10 +17,11 @@
 #include "sysemu/runstate.h"
 #include "qom/object.h"
 
-typedef struct SECUREECState {
+struct SECUREECState {
     SysBusDevice parent_obj;
     MemoryRegion iomem;
-} SECUREECState;
+};
+typedef struct SECUREECState SECUREECState;
 
 #define TYPE_SBSA_EC      "sbsa-ec"
 #define SECURE_EC(obj) OBJECT_CHECK(SECUREECState, (obj), TYPE_SBSA_EC)
diff --git a/hw/s390x/vhost-user-fs-ccw.c b/hw/s390x/vhost-user-fs-ccw.c
index 7d573156780..254153860dc 100644
--- a/hw/s390x/vhost-user-fs-ccw.c
+++ b/hw/s390x/vhost-user-fs-ccw.c
@@ -14,10 +14,11 @@
 #include "virtio-ccw.h"
 #include "qom/object.h"
 
-typedef struct VHostUserFSCcw {
+struct VHostUserFSCcw {
     VirtioCcwDevice parent_obj;
     VHostUserFS vdev;
-} VHostUserFSCcw;
+};
+typedef struct VHostUserFSCcw VHostUserFSCcw;
 
 #define TYPE_VHOST_USER_FS_CCW "vhost-user-fs-ccw"
 #define VHOST_USER_FS_CCW(obj) \
diff --git a/tests/qtest/pnv-xscom-test.c b/tests/qtest/pnv-xscom-test.c
index c8d40433620..1b13c046a9f 100644
--- a/tests/qtest/pnv-xscom-test.c
+++ b/tests/qtest/pnv-xscom-test.c
@@ -17,13 +17,14 @@ typedef enum PnvChipType {
     PNV_CHIP_POWER9,      /* AKA Nimbus */
 } PnvChipType;
 
-typedef struct PnvChip {
+struct PnvChip {
     PnvChipType chip_type;
     const char *cpu_model;
     uint64_t    xscom_base;
     uint64_t    cfam_id;
     uint32_t    first_core;
-} PnvChip;
+};
+typedef struct PnvChip PnvChip;
 
 static const PnvChip pnv_chips[] = {
     {
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 07/12] [automated] Use DECLARE_*CHECKER* macros when possible
  2021-08-06 21:11 [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Eduardo Habkost
@ 2021-08-06 21:11   ` Eduardo Habkost
  2021-08-06 21:11 ` [PATCH for-6.2 02/12] qom: Use DEVICE_*CLASS instead of OBJECT_*CLASS Eduardo Habkost
                     ` (11 subsequent siblings)
  12 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Michael S. Tsirkin, Andrew Jeffery, Jason Wang,
	Bin Meng, Vijai Kumar K, Taylor Simpson, Alistair Francis,
	Gerd Hoffmann, Klaus Jensen, Edgar E. Iglesias, Vikram Garhwal,
	qemu-block, qemu-ppc, David Hildenbrand, Havard Skinnemoen,
	Halil Pasic, Christian Borntraeger, Joel Stanley,
	Marc-André Lureau, qemu-s390x, Richard Henderson, Greg Kurz,
	Alexander Bulekov, Bandan Das, qemu-arm, Cédric Le Goater,
	Stefan Hajnoczi, Paolo Bonzini, Keith Busch, qemu-riscv,
	David Gibson, Daniel P. Berrange, Francisco Iglesias,
	Thomas Huth, Patrick Venture, Cornelia Huck, Laurent Vivier,
	Tyrone Ting, Palmer Dabbelt, Bastian Koppelmann, Igor Mammedov

Converting existing QOM types to OBJECT_DECLARE_TYPE is not
always trivial (due to inconsistent type/macro naming schemes),
but at least converting existing manual QOM type checking macros
to use DECLARE_*CHECKER* is a simpler process, and should at
least discourage people from defining new QOM type checker macros
manually.

Generated using:

  $ ./scripts/codeconverter/converter.py -i \
    --pattern=TypeCheckMacro $(git grep -l '' -- '*.[ch]')

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Patrick Venture <venture@google.com>
Cc: Thomas Huth <huth@tuxfamily.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Alexander Bulekov <alxndr@bu.edu>
Cc: Bandan Das <bsd@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Klaus Jensen <its@irrelevant.dk>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: Halil Pasic <pasic@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Havard Skinnemoen <hskinnemoen@google.com>
Cc: Tyrone Ting <kfting@nuvoton.com>
Cc: Vijai Kumar K <vijai@behindbytes.com>
Cc: Alistair Francis <Alistair.Francis@wdc.com>
Cc: Bin Meng <bin.meng@windriver.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Laurent Vivier <laurent@vivier.eu>
Cc: "Cédric Le Goater" <clg@kaod.org>
Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Greg Kurz <groug@kaod.org>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: Taylor Simpson <tsimpson@quicinc.com>
Cc: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org
Cc: qemu-s390x@nongnu.org
Cc: qemu-arm@nongnu.org
Cc: qemu-riscv@nongnu.org
Cc: qemu-ppc@nongnu.org
---
 hw/nvme/nvme.h                              | 12 ++++++------
 hw/usb/hcd-xhci-pci.h                       |  4 ++--
 hw/usb/hcd-xhci-sysbus.h                    |  4 ++--
 hw/usb/u2f.h                                |  8 ++------
 include/hw/adc/npcm7xx_adc.h                |  4 ++--
 include/hw/arm/npcm7xx.h                    | 15 ++++-----------
 include/hw/char/shakti_uart.h               |  4 ++--
 include/hw/dma/sifive_pdma.h                |  4 ++--
 include/hw/dma/xlnx_csu_dma.h               |  4 ++--
 include/hw/gpio/npcm7xx_gpio.h              |  4 ++--
 include/hw/i2c/npcm7xx_smbus.h              |  4 ++--
 include/hw/intc/m68k_irqc.h                 |  4 ++--
 include/hw/intc/sifive_clint.h              |  4 ++--
 include/hw/mem/npcm7xx_mc.h                 |  3 ++-
 include/hw/misc/aspeed_lpc.h                |  3 ++-
 include/hw/misc/mchp_pfsoc_dmc.h            | 10 ++++------
 include/hw/misc/mchp_pfsoc_ioscb.h          |  4 ++--
 include/hw/misc/mchp_pfsoc_sysreg.h         |  5 ++---
 include/hw/misc/npcm7xx_clk.h               |  3 ++-
 include/hw/misc/npcm7xx_gcr.h               |  3 ++-
 include/hw/misc/npcm7xx_mft.h               |  4 ++--
 include/hw/misc/npcm7xx_pwm.h               |  4 ++--
 include/hw/misc/npcm7xx_rng.h               |  3 ++-
 include/hw/misc/xlnx-versal-xramc.h         |  4 ++--
 include/hw/net/npcm7xx_emc.h                |  4 ++--
 include/hw/net/xlnx-zynqmp-can.h            |  4 ++--
 include/hw/nvram/npcm7xx_otp.h              |  3 ++-
 include/hw/ppc/spapr_drc.h                  | 13 ++++---------
 include/hw/ppc/spapr_xive.h                 |  7 ++-----
 include/hw/riscv/microchip_pfsoc.h          |  9 ++++-----
 include/hw/riscv/shakti_c.h                 |  8 ++++----
 include/hw/riscv/sifive_e.h                 |  8 ++++----
 include/hw/riscv/sifive_u.h                 |  8 ++++----
 include/hw/sd/cadence_sdhci.h               |  4 ++--
 include/hw/ssi/npcm7xx_fiu.h                |  3 ++-
 include/hw/ssi/sifive_spi.h                 |  3 ++-
 include/hw/timer/npcm7xx_timer.h            |  4 ++--
 include/hw/tricore/tricore_testdevice.h     |  4 ++--
 include/hw/usb/hcd-dwc3.h                   |  4 ++--
 include/hw/usb/xlnx-usb-subsystem.h         |  4 ++--
 include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  4 ++--
 include/hw/watchdog/sbsa_gwdt.h             |  4 ++--
 include/qemu/accel.h                        |  8 ++------
 target/hexagon/cpu.h                        |  8 ++------
 chardev/char-parallel.c                     |  6 ++----
 hw/i2c/i2c_mux_pca954x.c                    |  4 ++--
 hw/m68k/mcf5206.c                           |  3 ++-
 hw/mem/sparse-mem.c                         |  3 ++-
 hw/misc/sbsa_ec.c                           |  3 ++-
 hw/s390x/vhost-user-fs-ccw.c                |  4 ++--
 hw/sensor/adm1272.c                         |  3 ++-
 hw/sensor/max34451.c                        |  3 ++-
 hw/usb/u2f-emulated.c                       |  4 ++--
 hw/usb/u2f-passthru.c                       |  4 ++--
 54 files changed, 126 insertions(+), 146 deletions(-)

diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
index 0840f585d6e..c4c43da5c17 100644
--- a/hw/nvme/nvme.h
+++ b/hw/nvme/nvme.h
@@ -43,8 +43,8 @@ typedef struct NvmeBus {
 
 #define TYPE_NVME_SUBSYS "nvme-subsys"
 typedef struct NvmeSubsystem NvmeSubsystem;
-#define NVME_SUBSYS(obj) \
-    OBJECT_CHECK(NvmeSubsystem, (obj), TYPE_NVME_SUBSYS)
+DECLARE_INSTANCE_CHECKER(NvmeSubsystem, NVME_SUBSYS,
+                         TYPE_NVME_SUBSYS)
 
 struct NvmeSubsystem {
     DeviceState parent_obj;
@@ -83,8 +83,8 @@ static inline NvmeNamespace *nvme_subsys_ns(NvmeSubsystem *subsys,
 }
 
 #define TYPE_NVME_NS "nvme-ns"
-#define NVME_NS(obj) \
-    OBJECT_CHECK(NvmeNamespace, (obj), TYPE_NVME_NS)
+DECLARE_INSTANCE_CHECKER(NvmeNamespace, NVME_NS,
+                         TYPE_NVME_NS)
 
 typedef struct NvmeZone {
     NvmeZoneDescr   d;
@@ -377,8 +377,8 @@ typedef struct NvmeCQueue {
 } NvmeCQueue;
 
 #define TYPE_NVME "nvme"
-#define NVME(obj) \
-        OBJECT_CHECK(NvmeCtrl, (obj), TYPE_NVME)
+DECLARE_INSTANCE_CHECKER(NvmeCtrl, NVME,
+                         TYPE_NVME)
 
 typedef struct NvmeParams {
     char     *serial;
diff --git a/hw/usb/hcd-xhci-pci.h b/hw/usb/hcd-xhci-pci.h
index 0cfe630a5ce..d83aad82e04 100644
--- a/hw/usb/hcd-xhci-pci.h
+++ b/hw/usb/hcd-xhci-pci.h
@@ -30,8 +30,8 @@
 
 #define TYPE_XHCI_PCI "pci-xhci"
 typedef struct XHCIPciState XHCIPciState;
-#define XHCI_PCI(obj) \
-    OBJECT_CHECK(XHCIPciState, (obj), TYPE_XHCI_PCI)
+DECLARE_INSTANCE_CHECKER(XHCIPciState, XHCI_PCI,
+                         TYPE_XHCI_PCI)
 
 
 struct XHCIPciState {
diff --git a/hw/usb/hcd-xhci-sysbus.h b/hw/usb/hcd-xhci-sysbus.h
index 7661c811fd1..561e5144e05 100644
--- a/hw/usb/hcd-xhci-sysbus.h
+++ b/hw/usb/hcd-xhci-sysbus.h
@@ -17,8 +17,8 @@
 #include "qom/object.h"
 
 typedef struct XHCISysbusState XHCISysbusState;
-#define XHCI_SYSBUS(obj) \
-    OBJECT_CHECK(XHCISysbusState, (obj), TYPE_XHCI_SYSBUS)
+DECLARE_INSTANCE_CHECKER(XHCISysbusState, XHCI_SYSBUS,
+                         TYPE_XHCI_SYSBUS)
 
 
 struct XHCISysbusState {
diff --git a/hw/usb/u2f.h b/hw/usb/u2f.h
index 7191a23ee1a..5767ca8fac9 100644
--- a/hw/usb/u2f.h
+++ b/hw/usb/u2f.h
@@ -37,12 +37,8 @@ typedef struct U2FKeyInfo U2FKeyInfo;
 
 #define TYPE_U2F_KEY "u2f-key"
 typedef struct U2FKeyClass U2FKeyClass;
-#define U2F_KEY(obj) \
-    OBJECT_CHECK(U2FKeyState, (obj), TYPE_U2F_KEY)
-#define U2F_KEY_CLASS(klass) \
-    OBJECT_CLASS_CHECK(U2FKeyClass, (klass), TYPE_U2F_KEY)
-#define U2F_KEY_GET_CLASS(obj) \
-    OBJECT_GET_CLASS(U2FKeyClass, (obj), TYPE_U2F_KEY)
+DECLARE_OBJ_CHECKERS(U2FKeyState, U2FKeyClass,
+                     U2F_KEY, TYPE_U2F_KEY)
 
 /*
  * Callbacks to be used by the U2F key base device (i.e. hw/u2f.c)
diff --git a/include/hw/adc/npcm7xx_adc.h b/include/hw/adc/npcm7xx_adc.h
index 835d13f5b0d..b694adece6a 100644
--- a/include/hw/adc/npcm7xx_adc.h
+++ b/include/hw/adc/npcm7xx_adc.h
@@ -65,7 +65,7 @@ struct NPCM7xxADCState {
 typedef struct NPCM7xxADCState NPCM7xxADCState;
 
 #define TYPE_NPCM7XX_ADC "npcm7xx-adc"
-#define NPCM7XX_ADC(obj) \
-    OBJECT_CHECK(NPCM7xxADCState, (obj), TYPE_NPCM7XX_ADC)
+DECLARE_INSTANCE_CHECKER(NPCM7xxADCState, NPCM7XX_ADC,
+                         TYPE_NPCM7XX_ADC)
 
 #endif /* NPCM7XX_ADC_H */
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
index 697d2957590..310b3d89ed8 100644
--- a/include/hw/arm/npcm7xx.h
+++ b/include/hw/arm/npcm7xx.h
@@ -65,8 +65,8 @@ typedef struct NPCM7xxMachine NPCM7xxMachine;
 
 #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
 typedef struct NPCM7xxMachineClass NPCM7xxMachineClass;
-#define NPCM7XX_MACHINE(obj)                                            \
-    OBJECT_CHECK(NPCM7xxMachine, (obj), TYPE_NPCM7XX_MACHINE)
+DECLARE_OBJ_CHECKERS(NPCM7xxMachine, NPCM7xxMachineClass,
+                     NPCM7XX_MACHINE, TYPE_NPCM7XX_MACHINE)
 
 struct NPCM7xxMachineClass {
     MachineClass        parent;
@@ -74,10 +74,6 @@ struct NPCM7xxMachineClass {
     const char          *soc_type;
 };
 
-#define NPCM7XX_MACHINE_CLASS(klass)                                    \
-    OBJECT_CLASS_CHECK(NPCM7xxMachineClass, (klass), TYPE_NPCM7XX_MACHINE)
-#define NPCM7XX_MACHINE_GET_CLASS(obj)                                  \
-    OBJECT_GET_CLASS(NPCM7xxMachineClass, (obj), TYPE_NPCM7XX_MACHINE)
 
 struct NPCM7xxState {
     DeviceState         parent;
@@ -111,7 +107,8 @@ typedef struct NPCM7xxState NPCM7xxState;
 
 #define TYPE_NPCM7XX    "npcm7xx"
 typedef struct NPCM7xxClass NPCM7xxClass;
-#define NPCM7XX(obj)    OBJECT_CHECK(NPCM7xxState, (obj), TYPE_NPCM7XX)
+DECLARE_OBJ_CHECKERS(NPCM7xxState, NPCM7xxClass,
+                     NPCM7XX, TYPE_NPCM7XX)
 
 #define TYPE_NPCM730    "npcm730"
 #define TYPE_NPCM750    "npcm750"
@@ -125,10 +122,6 @@ struct NPCM7xxClass {
     uint32_t            num_cpus;
 };
 
-#define NPCM7XX_CLASS(klass)                                            \
-    OBJECT_CLASS_CHECK(NPCM7xxClass, (klass), TYPE_NPCM7XX)
-#define NPCM7XX_GET_CLASS(obj)                                          \
-    OBJECT_GET_CLASS(NPCM7xxClass, (obj), TYPE_NPCM7XX)
 
 /**
  * npcm7xx_load_kernel - Loads memory with everything needed to boot
diff --git a/include/hw/char/shakti_uart.h b/include/hw/char/shakti_uart.h
index be7a93fb14d..9bec3062af0 100644
--- a/include/hw/char/shakti_uart.h
+++ b/include/hw/char/shakti_uart.h
@@ -50,8 +50,8 @@
 
 #define TYPE_SHAKTI_UART "shakti-uart"
 typedef struct ShaktiUartState ShaktiUartState;
-#define SHAKTI_UART(obj) \
-    OBJECT_CHECK(ShaktiUartState, (obj), TYPE_SHAKTI_UART)
+DECLARE_INSTANCE_CHECKER(ShaktiUartState, SHAKTI_UART,
+                         TYPE_SHAKTI_UART)
 
 struct ShaktiUartState {
     /* <private> */
diff --git a/include/hw/dma/sifive_pdma.h b/include/hw/dma/sifive_pdma.h
index 76b4b45d0a4..d81526cfc2f 100644
--- a/include/hw/dma/sifive_pdma.h
+++ b/include/hw/dma/sifive_pdma.h
@@ -53,7 +53,7 @@ typedef struct SiFivePDMAState SiFivePDMAState;
 
 #define TYPE_SIFIVE_PDMA    "sifive.pdma"
 
-#define SIFIVE_PDMA(obj)    \
-    OBJECT_CHECK(SiFivePDMAState, (obj), TYPE_SIFIVE_PDMA)
+DECLARE_INSTANCE_CHECKER(SiFivePDMAState, SIFIVE_PDMA,
+                         TYPE_SIFIVE_PDMA)
 
 #endif /* SIFIVE_PDMA_H */
diff --git a/include/hw/dma/xlnx_csu_dma.h b/include/hw/dma/xlnx_csu_dma.h
index f8d88e2ebee..36433d189ac 100644
--- a/include/hw/dma/xlnx_csu_dma.h
+++ b/include/hw/dma/xlnx_csu_dma.h
@@ -48,7 +48,7 @@ struct XlnxCSUDMA {
 };
 typedef struct XlnxCSUDMA XlnxCSUDMA;
 
-#define XLNX_CSU_DMA(obj) \
-    OBJECT_CHECK(XlnxCSUDMA, (obj), TYPE_XLNX_CSU_DMA)
+DECLARE_INSTANCE_CHECKER(XlnxCSUDMA, XLNX_CSU_DMA,
+                         TYPE_XLNX_CSU_DMA)
 
 #endif
diff --git a/include/hw/gpio/npcm7xx_gpio.h b/include/hw/gpio/npcm7xx_gpio.h
index e45cf45e78e..cfc9baefce5 100644
--- a/include/hw/gpio/npcm7xx_gpio.h
+++ b/include/hw/gpio/npcm7xx_gpio.h
@@ -51,7 +51,7 @@ struct NPCM7xxGPIOState {
 typedef struct NPCM7xxGPIOState NPCM7xxGPIOState;
 
 #define TYPE_NPCM7XX_GPIO "npcm7xx-gpio"
-#define NPCM7XX_GPIO(obj) \
-    OBJECT_CHECK(NPCM7xxGPIOState, (obj), TYPE_NPCM7XX_GPIO)
+DECLARE_INSTANCE_CHECKER(NPCM7xxGPIOState, NPCM7XX_GPIO,
+                         TYPE_NPCM7XX_GPIO)
 
 #endif /* NPCM7XX_GPIO_H */
diff --git a/include/hw/i2c/npcm7xx_smbus.h b/include/hw/i2c/npcm7xx_smbus.h
index ef64c6748a7..aa5e1d84b41 100644
--- a/include/hw/i2c/npcm7xx_smbus.h
+++ b/include/hw/i2c/npcm7xx_smbus.h
@@ -109,7 +109,7 @@ struct NPCM7xxSMBusState {
 typedef struct NPCM7xxSMBusState NPCM7xxSMBusState;
 
 #define TYPE_NPCM7XX_SMBUS "npcm7xx-smbus"
-#define NPCM7XX_SMBUS(obj) OBJECT_CHECK(NPCM7xxSMBusState, (obj), \
-                                        TYPE_NPCM7XX_SMBUS)
+DECLARE_INSTANCE_CHECKER(NPCM7xxSMBusState, NPCM7XX_SMBUS,
+                         TYPE_NPCM7XX_SMBUS)
 
 #endif /* NPCM7XX_SMBUS_H */
diff --git a/include/hw/intc/m68k_irqc.h b/include/hw/intc/m68k_irqc.h
index 460d8a5a8d3..843cec3c666 100644
--- a/include/hw/intc/m68k_irqc.h
+++ b/include/hw/intc/m68k_irqc.h
@@ -15,8 +15,8 @@
 
 #define TYPE_M68K_IRQC "m68k-irq-controller"
 typedef struct M68KIRQCState M68KIRQCState;
-#define M68K_IRQC(obj) OBJECT_CHECK(M68KIRQCState, (obj), \
-                                    TYPE_M68K_IRQC)
+DECLARE_INSTANCE_CHECKER(M68KIRQCState, M68K_IRQC,
+                         TYPE_M68K_IRQC)
 
 #define M68K_IRQC_AUTOVECTOR_BASE 25
 
diff --git a/include/hw/intc/sifive_clint.h b/include/hw/intc/sifive_clint.h
index 8e005e130f1..c7df3f7f2b3 100644
--- a/include/hw/intc/sifive_clint.h
+++ b/include/hw/intc/sifive_clint.h
@@ -26,8 +26,8 @@
 #define TYPE_SIFIVE_CLINT "riscv.sifive.clint"
 
 typedef struct SiFiveCLINTState SiFiveCLINTState;
-#define SIFIVE_CLINT(obj) \
-    OBJECT_CHECK(SiFiveCLINTState, (obj), TYPE_SIFIVE_CLINT)
+DECLARE_INSTANCE_CHECKER(SiFiveCLINTState, SIFIVE_CLINT,
+                         TYPE_SIFIVE_CLINT)
 
 struct SiFiveCLINTState {
     /*< private >*/
diff --git a/include/hw/mem/npcm7xx_mc.h b/include/hw/mem/npcm7xx_mc.h
index e0a9d3b0de9..bec8ebc45ef 100644
--- a/include/hw/mem/npcm7xx_mc.h
+++ b/include/hw/mem/npcm7xx_mc.h
@@ -33,6 +33,7 @@ struct NPCM7xxMCState {
 typedef struct NPCM7xxMCState NPCM7xxMCState;
 
 #define TYPE_NPCM7XX_MC "npcm7xx-mc"
-#define NPCM7XX_MC(obj) OBJECT_CHECK(NPCM7xxMCState, (obj), TYPE_NPCM7XX_MC)
+DECLARE_INSTANCE_CHECKER(NPCM7xxMCState, NPCM7XX_MC,
+                         TYPE_NPCM7XX_MC)
 
 #endif /* NPCM7XX_MC_H */
diff --git a/include/hw/misc/aspeed_lpc.h b/include/hw/misc/aspeed_lpc.h
index def617b9772..d8e5af6296b 100644
--- a/include/hw/misc/aspeed_lpc.h
+++ b/include/hw/misc/aspeed_lpc.h
@@ -17,7 +17,8 @@
 
 #define TYPE_ASPEED_LPC "aspeed.lpc"
 typedef struct AspeedLPCState AspeedLPCState;
-#define ASPEED_LPC(obj) OBJECT_CHECK(AspeedLPCState, (obj), TYPE_ASPEED_LPC)
+DECLARE_INSTANCE_CHECKER(AspeedLPCState, ASPEED_LPC,
+                         TYPE_ASPEED_LPC)
 
 #define ASPEED_LPC_NR_REGS      (0x260 >> 2)
 
diff --git a/include/hw/misc/mchp_pfsoc_dmc.h b/include/hw/misc/mchp_pfsoc_dmc.h
index 28cfe3e1e23..3a0e3bbba76 100644
--- a/include/hw/misc/mchp_pfsoc_dmc.h
+++ b/include/hw/misc/mchp_pfsoc_dmc.h
@@ -36,9 +36,8 @@ typedef struct MchpPfSoCDdrSgmiiPhyState MchpPfSoCDdrSgmiiPhyState;
 
 #define TYPE_MCHP_PFSOC_DDR_SGMII_PHY "mchp.pfsoc.ddr_sgmii_phy"
 
-#define MCHP_PFSOC_DDR_SGMII_PHY(obj) \
-    OBJECT_CHECK(MchpPfSoCDdrSgmiiPhyState, (obj), \
-                 TYPE_MCHP_PFSOC_DDR_SGMII_PHY)
+DECLARE_INSTANCE_CHECKER(MchpPfSoCDdrSgmiiPhyState, MCHP_PFSOC_DDR_SGMII_PHY,
+                         TYPE_MCHP_PFSOC_DDR_SGMII_PHY)
 
 /* DDR CFG module */
 
@@ -52,8 +51,7 @@ typedef struct MchpPfSoCDdrCfgState MchpPfSoCDdrCfgState;
 
 #define TYPE_MCHP_PFSOC_DDR_CFG "mchp.pfsoc.ddr_cfg"
 
-#define MCHP_PFSOC_DDR_CFG(obj) \
-    OBJECT_CHECK(MchpPfSoCDdrCfgState, (obj), \
-                 TYPE_MCHP_PFSOC_DDR_CFG)
+DECLARE_INSTANCE_CHECKER(MchpPfSoCDdrCfgState, MCHP_PFSOC_DDR_CFG,
+                         TYPE_MCHP_PFSOC_DDR_CFG)
 
 #endif /* MCHP_PFSOC_DMC_H */
diff --git a/include/hw/misc/mchp_pfsoc_ioscb.h b/include/hw/misc/mchp_pfsoc_ioscb.h
index 95b0b9069dd..18ef5ff1739 100644
--- a/include/hw/misc/mchp_pfsoc_ioscb.h
+++ b/include/hw/misc/mchp_pfsoc_ioscb.h
@@ -46,7 +46,7 @@ typedef struct MchpPfSoCIoscbState MchpPfSoCIoscbState;
 
 #define TYPE_MCHP_PFSOC_IOSCB "mchp.pfsoc.ioscb"
 
-#define MCHP_PFSOC_IOSCB(obj) \
-    OBJECT_CHECK(MchpPfSoCIoscbState, (obj), TYPE_MCHP_PFSOC_IOSCB)
+DECLARE_INSTANCE_CHECKER(MchpPfSoCIoscbState, MCHP_PFSOC_IOSCB,
+                         TYPE_MCHP_PFSOC_IOSCB)
 
 #endif /* MCHP_PFSOC_IOSCB_H */
diff --git a/include/hw/misc/mchp_pfsoc_sysreg.h b/include/hw/misc/mchp_pfsoc_sysreg.h
index adce8d869c4..c842cf7e716 100644
--- a/include/hw/misc/mchp_pfsoc_sysreg.h
+++ b/include/hw/misc/mchp_pfsoc_sysreg.h
@@ -34,8 +34,7 @@ typedef struct MchpPfSoCSysregState MchpPfSoCSysregState;
 
 #define TYPE_MCHP_PFSOC_SYSREG "mchp.pfsoc.sysreg"
 
-#define MCHP_PFSOC_SYSREG(obj) \
-    OBJECT_CHECK(MchpPfSoCSysregState, (obj), \
-                 TYPE_MCHP_PFSOC_SYSREG)
+DECLARE_INSTANCE_CHECKER(MchpPfSoCSysregState, MCHP_PFSOC_SYSREG,
+                         TYPE_MCHP_PFSOC_SYSREG)
 
 #endif /* MCHP_PFSOC_SYSREG_H */
diff --git a/include/hw/misc/npcm7xx_clk.h b/include/hw/misc/npcm7xx_clk.h
index 80b651c7e44..023a1aed7a9 100644
--- a/include/hw/misc/npcm7xx_clk.h
+++ b/include/hw/misc/npcm7xx_clk.h
@@ -179,6 +179,7 @@ struct NPCM7xxCLKState {
 };
 
 #define TYPE_NPCM7XX_CLK "npcm7xx-clk"
-#define NPCM7XX_CLK(obj) OBJECT_CHECK(NPCM7xxCLKState, (obj), TYPE_NPCM7XX_CLK)
+DECLARE_INSTANCE_CHECKER(NPCM7xxCLKState, NPCM7XX_CLK,
+                         TYPE_NPCM7XX_CLK)
 
 #endif /* NPCM7XX_CLK_H */
diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h
index b5c573ec8f2..eed59f94f91 100644
--- a/include/hw/misc/npcm7xx_gcr.h
+++ b/include/hw/misc/npcm7xx_gcr.h
@@ -40,6 +40,7 @@ struct NPCM7xxGCRState {
 typedef struct NPCM7xxGCRState NPCM7xxGCRState;
 
 #define TYPE_NPCM7XX_GCR "npcm7xx-gcr"
-#define NPCM7XX_GCR(obj) OBJECT_CHECK(NPCM7xxGCRState, (obj), TYPE_NPCM7XX_GCR)
+DECLARE_INSTANCE_CHECKER(NPCM7xxGCRState, NPCM7XX_GCR,
+                         TYPE_NPCM7XX_GCR)
 
 #endif /* NPCM7XX_GCR_H */
diff --git a/include/hw/misc/npcm7xx_mft.h b/include/hw/misc/npcm7xx_mft.h
index 3f7bd2a9c6a..a351cf9b2be 100644
--- a/include/hw/misc/npcm7xx_mft.h
+++ b/include/hw/misc/npcm7xx_mft.h
@@ -65,7 +65,7 @@ struct NPCM7xxMFTState {
 typedef struct NPCM7xxMFTState NPCM7xxMFTState;
 
 #define TYPE_NPCM7XX_MFT "npcm7xx-mft"
-#define NPCM7XX_MFT(obj) \
-    OBJECT_CHECK(NPCM7xxMFTState, (obj), TYPE_NPCM7XX_MFT)
+DECLARE_INSTANCE_CHECKER(NPCM7xxMFTState, NPCM7XX_MFT,
+                         TYPE_NPCM7XX_MFT)
 
 #endif /* NPCM7XX_MFT_H */
diff --git a/include/hw/misc/npcm7xx_pwm.h b/include/hw/misc/npcm7xx_pwm.h
index c6643bd04fd..3be975e1ee4 100644
--- a/include/hw/misc/npcm7xx_pwm.h
+++ b/include/hw/misc/npcm7xx_pwm.h
@@ -102,7 +102,7 @@ struct NPCM7xxPWMState {
 };
 
 #define TYPE_NPCM7XX_PWM "npcm7xx-pwm"
-#define NPCM7XX_PWM(obj) \
-    OBJECT_CHECK(NPCM7xxPWMState, (obj), TYPE_NPCM7XX_PWM)
+DECLARE_INSTANCE_CHECKER(NPCM7xxPWMState, NPCM7XX_PWM,
+                         TYPE_NPCM7XX_PWM)
 
 #endif /* NPCM7XX_PWM_H */
diff --git a/include/hw/misc/npcm7xx_rng.h b/include/hw/misc/npcm7xx_rng.h
index 27122001f4b..e1f798a4bed 100644
--- a/include/hw/misc/npcm7xx_rng.h
+++ b/include/hw/misc/npcm7xx_rng.h
@@ -31,6 +31,7 @@ struct NPCM7xxRNGState {
 typedef struct NPCM7xxRNGState NPCM7xxRNGState;
 
 #define TYPE_NPCM7XX_RNG "npcm7xx-rng"
-#define NPCM7XX_RNG(obj) OBJECT_CHECK(NPCM7xxRNGState, (obj), TYPE_NPCM7XX_RNG)
+DECLARE_INSTANCE_CHECKER(NPCM7xxRNGState, NPCM7XX_RNG,
+                         TYPE_NPCM7XX_RNG)
 
 #endif /* NPCM7XX_RNG_H */
diff --git a/include/hw/misc/xlnx-versal-xramc.h b/include/hw/misc/xlnx-versal-xramc.h
index ba0d0f3c5af..fc5a12165cf 100644
--- a/include/hw/misc/xlnx-versal-xramc.h
+++ b/include/hw/misc/xlnx-versal-xramc.h
@@ -16,8 +16,8 @@
 #define TYPE_XLNX_XRAM_CTRL "xlnx.versal-xramc"
 
 typedef struct XlnxXramCtrl XlnxXramCtrl;
-#define XLNX_XRAM_CTRL(obj) \
-     OBJECT_CHECK(XlnxXramCtrl, (obj), TYPE_XLNX_XRAM_CTRL)
+DECLARE_INSTANCE_CHECKER(XlnxXramCtrl, XLNX_XRAM_CTRL,
+                         TYPE_XLNX_XRAM_CTRL)
 
 REG32(XRAM_ERR_CTRL, 0x0)
     FIELD(XRAM_ERR_CTRL, UE_RES, 3, 1)
diff --git a/include/hw/net/npcm7xx_emc.h b/include/hw/net/npcm7xx_emc.h
index 5b676f669cd..bdf06c69dde 100644
--- a/include/hw/net/npcm7xx_emc.h
+++ b/include/hw/net/npcm7xx_emc.h
@@ -281,7 +281,7 @@ struct NPCM7xxEMCState {
 typedef struct NPCM7xxEMCState NPCM7xxEMCState;
 
 #define TYPE_NPCM7XX_EMC "npcm7xx-emc"
-#define NPCM7XX_EMC(obj) \
-    OBJECT_CHECK(NPCM7xxEMCState, (obj), TYPE_NPCM7XX_EMC)
+DECLARE_INSTANCE_CHECKER(NPCM7xxEMCState, NPCM7XX_EMC,
+                         TYPE_NPCM7XX_EMC)
 
 #endif /* NPCM7XX_EMC_H */
diff --git a/include/hw/net/xlnx-zynqmp-can.h b/include/hw/net/xlnx-zynqmp-can.h
index 3d80c7455db..4a1fa166571 100644
--- a/include/hw/net/xlnx-zynqmp-can.h
+++ b/include/hw/net/xlnx-zynqmp-can.h
@@ -41,8 +41,8 @@
 #define TYPE_XLNX_ZYNQMP_CAN "xlnx.zynqmp-can"
 
 typedef struct XlnxZynqMPCANState XlnxZynqMPCANState;
-#define XLNX_ZYNQMP_CAN(obj) \
-     OBJECT_CHECK(XlnxZynqMPCANState, (obj), TYPE_XLNX_ZYNQMP_CAN)
+DECLARE_INSTANCE_CHECKER(XlnxZynqMPCANState, XLNX_ZYNQMP_CAN,
+                         TYPE_XLNX_ZYNQMP_CAN)
 
 #define MAX_CAN_CTRLS      2
 #define XLNX_ZYNQMP_CAN_R_MAX     (0x84 / 4)
diff --git a/include/hw/nvram/npcm7xx_otp.h b/include/hw/nvram/npcm7xx_otp.h
index 0ab1d5bae48..4cfc6577e87 100644
--- a/include/hw/nvram/npcm7xx_otp.h
+++ b/include/hw/nvram/npcm7xx_otp.h
@@ -58,7 +58,8 @@ struct NPCM7xxOTPState {
 typedef struct NPCM7xxOTPState NPCM7xxOTPState;
 
 #define TYPE_NPCM7XX_OTP "npcm7xx-otp"
-#define NPCM7XX_OTP(obj) OBJECT_CHECK(NPCM7xxOTPState, (obj), TYPE_NPCM7XX_OTP)
+DECLARE_INSTANCE_CHECKER(NPCM7xxOTPState, NPCM7XX_OTP,
+                         TYPE_NPCM7XX_OTP)
 
 #define TYPE_NPCM7XX_KEY_STORAGE "npcm7xx-key-storage"
 #define TYPE_NPCM7XX_FUSE_ARRAY "npcm7xx-fuse-array"
diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h
index 83019d3f672..540439812f0 100644
--- a/include/hw/ppc/spapr_drc.h
+++ b/include/hw/ppc/spapr_drc.h
@@ -22,18 +22,13 @@
 #define TYPE_SPAPR_DR_CONNECTOR "spapr-dr-connector"
 typedef struct SpaprDrc SpaprDrc;
 typedef struct SpaprDrcClass SpaprDrcClass;
-#define SPAPR_DR_CONNECTOR_GET_CLASS(obj) \
-        OBJECT_GET_CLASS(SpaprDrcClass, obj, TYPE_SPAPR_DR_CONNECTOR)
-#define SPAPR_DR_CONNECTOR_CLASS(klass) \
-        OBJECT_CLASS_CHECK(SpaprDrcClass, klass, \
-                           TYPE_SPAPR_DR_CONNECTOR)
-#define SPAPR_DR_CONNECTOR(obj) OBJECT_CHECK(SpaprDrc, (obj), \
-                                             TYPE_SPAPR_DR_CONNECTOR)
+DECLARE_OBJ_CHECKERS(SpaprDrc, SpaprDrcClass,
+                     SPAPR_DR_CONNECTOR, TYPE_SPAPR_DR_CONNECTOR)
 
 #define TYPE_SPAPR_DRC_PHYSICAL "spapr-drc-physical"
 typedef struct SpaprDrcPhysical SpaprDrcPhysical;
-#define SPAPR_DRC_PHYSICAL(obj) OBJECT_CHECK(SpaprDrcPhysical, (obj), \
-                                             TYPE_SPAPR_DRC_PHYSICAL)
+DECLARE_INSTANCE_CHECKER(SpaprDrcPhysical, SPAPR_DRC_PHYSICAL,
+                         TYPE_SPAPR_DRC_PHYSICAL)
 
 #define TYPE_SPAPR_DRC_LOGICAL "spapr-drc-logical"
 
diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h
index d1371b2dbba..333095c3fd9 100644
--- a/include/hw/ppc/spapr_xive.h
+++ b/include/hw/ppc/spapr_xive.h
@@ -17,11 +17,8 @@
 #define TYPE_SPAPR_XIVE "spapr-xive"
 typedef struct SpaprXive SpaprXive;
 typedef struct SpaprXiveClass SpaprXiveClass;
-#define SPAPR_XIVE(obj) OBJECT_CHECK(SpaprXive, (obj), TYPE_SPAPR_XIVE)
-#define SPAPR_XIVE_CLASS(klass)                                         \
-    OBJECT_CLASS_CHECK(SpaprXiveClass, (klass), TYPE_SPAPR_XIVE)
-#define SPAPR_XIVE_GET_CLASS(obj)                               \
-    OBJECT_GET_CLASS(SpaprXiveClass, (obj), TYPE_SPAPR_XIVE)
+DECLARE_OBJ_CHECKERS(SpaprXive, SpaprXiveClass,
+                     SPAPR_XIVE, TYPE_SPAPR_XIVE)
 
 struct SpaprXive {
     XiveRouter    parent;
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
index b30fb1191d9..3a29a48019e 100644
--- a/include/hw/riscv/microchip_pfsoc.h
+++ b/include/hw/riscv/microchip_pfsoc.h
@@ -58,8 +58,8 @@ struct MicrochipPFSoCState {
 typedef struct MicrochipPFSoCState MicrochipPFSoCState;
 
 #define TYPE_MICROCHIP_PFSOC    "microchip.pfsoc"
-#define MICROCHIP_PFSOC(obj) \
-    OBJECT_CHECK(MicrochipPFSoCState, (obj), TYPE_MICROCHIP_PFSOC)
+DECLARE_INSTANCE_CHECKER(MicrochipPFSoCState, MICROCHIP_PFSOC,
+                         TYPE_MICROCHIP_PFSOC)
 
 struct MicrochipIcicleKitState {
     /*< private >*/
@@ -72,9 +72,8 @@ typedef struct MicrochipIcicleKitState MicrochipIcicleKitState;
 
 #define TYPE_MICROCHIP_ICICLE_KIT_MACHINE \
     MACHINE_TYPE_NAME("microchip-icicle-kit")
-#define MICROCHIP_ICICLE_KIT_MACHINE(obj) \
-    OBJECT_CHECK(MicrochipIcicleKitState, (obj), \
-                 TYPE_MICROCHIP_ICICLE_KIT_MACHINE)
+DECLARE_INSTANCE_CHECKER(MicrochipIcicleKitState, MICROCHIP_ICICLE_KIT_MACHINE,
+                         TYPE_MICROCHIP_ICICLE_KIT_MACHINE)
 
 enum {
     MICROCHIP_PFSOC_RSVD0,
diff --git a/include/hw/riscv/shakti_c.h b/include/hw/riscv/shakti_c.h
index e07bca3a357..6733eca2303 100644
--- a/include/hw/riscv/shakti_c.h
+++ b/include/hw/riscv/shakti_c.h
@@ -26,8 +26,8 @@
 
 #define TYPE_RISCV_SHAKTI_SOC "riscv.shakti.cclass.soc"
 typedef struct ShaktiCSoCState ShaktiCSoCState;
-#define RISCV_SHAKTI_SOC(obj) \
-    OBJECT_CHECK(ShaktiCSoCState, (obj), TYPE_RISCV_SHAKTI_SOC)
+DECLARE_INSTANCE_CHECKER(ShaktiCSoCState, RISCV_SHAKTI_SOC,
+                         TYPE_RISCV_SHAKTI_SOC)
 
 struct ShaktiCSoCState {
     /*< private >*/
@@ -43,8 +43,8 @@ struct ShaktiCSoCState {
 
 #define TYPE_RISCV_SHAKTI_MACHINE MACHINE_TYPE_NAME("shakti_c")
 typedef struct ShaktiCMachineState ShaktiCMachineState;
-#define RISCV_SHAKTI_MACHINE(obj) \
-    OBJECT_CHECK(ShaktiCMachineState, (obj), TYPE_RISCV_SHAKTI_MACHINE)
+DECLARE_INSTANCE_CHECKER(ShaktiCMachineState, RISCV_SHAKTI_MACHINE,
+                         TYPE_RISCV_SHAKTI_MACHINE)
 struct ShaktiCMachineState {
     /*< private >*/
     MachineState parent_obj;
diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h
index 9c9ce14a4b4..22abd643753 100644
--- a/include/hw/riscv/sifive_e.h
+++ b/include/hw/riscv/sifive_e.h
@@ -26,8 +26,8 @@
 
 #define TYPE_RISCV_E_SOC "riscv.sifive.e.soc"
 typedef struct SiFiveESoCState SiFiveESoCState;
-#define RISCV_E_SOC(obj) \
-    OBJECT_CHECK(SiFiveESoCState, (obj), TYPE_RISCV_E_SOC)
+DECLARE_INSTANCE_CHECKER(SiFiveESoCState, RISCV_E_SOC,
+                         TYPE_RISCV_E_SOC)
 
 struct SiFiveESoCState {
     /*< private >*/
@@ -52,8 +52,8 @@ struct SiFiveEState {
 typedef struct SiFiveEState SiFiveEState;
 
 #define TYPE_RISCV_E_MACHINE MACHINE_TYPE_NAME("sifive_e")
-#define RISCV_E_MACHINE(obj) \
-    OBJECT_CHECK(SiFiveEState, (obj), TYPE_RISCV_E_MACHINE)
+DECLARE_INSTANCE_CHECKER(SiFiveEState, RISCV_E_MACHINE,
+                         TYPE_RISCV_E_MACHINE)
 
 enum {
     SIFIVE_E_DEV_DEBUG,
diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h
index ef050a22dc2..d974043a36d 100644
--- a/include/hw/riscv/sifive_u.h
+++ b/include/hw/riscv/sifive_u.h
@@ -31,8 +31,8 @@
 
 #define TYPE_RISCV_U_SOC "riscv.sifive.u.soc"
 typedef struct SiFiveUSoCState SiFiveUSoCState;
-#define RISCV_U_SOC(obj) \
-    OBJECT_CHECK(SiFiveUSoCState, (obj), TYPE_RISCV_U_SOC)
+DECLARE_INSTANCE_CHECKER(SiFiveUSoCState, RISCV_U_SOC,
+                         TYPE_RISCV_U_SOC)
 
 struct SiFiveUSoCState {
     /*< private >*/
@@ -58,8 +58,8 @@ struct SiFiveUSoCState {
 
 #define TYPE_RISCV_U_MACHINE MACHINE_TYPE_NAME("sifive_u")
 typedef struct SiFiveUState SiFiveUState;
-#define RISCV_U_MACHINE(obj) \
-    OBJECT_CHECK(SiFiveUState, (obj), TYPE_RISCV_U_MACHINE)
+DECLARE_INSTANCE_CHECKER(SiFiveUState, RISCV_U_MACHINE,
+                         TYPE_RISCV_U_MACHINE)
 
 struct SiFiveUState {
     /*< private >*/
diff --git a/include/hw/sd/cadence_sdhci.h b/include/hw/sd/cadence_sdhci.h
index 75c174f357a..6d6a2d9c0da 100644
--- a/include/hw/sd/cadence_sdhci.h
+++ b/include/hw/sd/cadence_sdhci.h
@@ -43,7 +43,7 @@ struct CadenceSDHCIState {
 typedef struct CadenceSDHCIState CadenceSDHCIState;
 
 #define TYPE_CADENCE_SDHCI  "cadence.sdhci"
-#define CADENCE_SDHCI(obj)  OBJECT_CHECK(CadenceSDHCIState, (obj), \
-                                         TYPE_CADENCE_SDHCI)
+DECLARE_INSTANCE_CHECKER(CadenceSDHCIState, CADENCE_SDHCI,
+                         TYPE_CADENCE_SDHCI)
 
 #endif /* CADENCE_SDHCI_H */
diff --git a/include/hw/ssi/npcm7xx_fiu.h b/include/hw/ssi/npcm7xx_fiu.h
index 01597ea8954..6503da5b37a 100644
--- a/include/hw/ssi/npcm7xx_fiu.h
+++ b/include/hw/ssi/npcm7xx_fiu.h
@@ -69,6 +69,7 @@ struct NPCM7xxFIUState {
 };
 
 #define TYPE_NPCM7XX_FIU "npcm7xx-fiu"
-#define NPCM7XX_FIU(obj) OBJECT_CHECK(NPCM7xxFIUState, (obj), TYPE_NPCM7XX_FIU)
+DECLARE_INSTANCE_CHECKER(NPCM7xxFIUState, NPCM7XX_FIU,
+                         TYPE_NPCM7XX_FIU)
 
 #endif /* NPCM7XX_FIU_H */
diff --git a/include/hw/ssi/sifive_spi.h b/include/hw/ssi/sifive_spi.h
index 6ed73ccfef0..d32deaea0ec 100644
--- a/include/hw/ssi/sifive_spi.h
+++ b/include/hw/ssi/sifive_spi.h
@@ -27,7 +27,8 @@
 
 #define TYPE_SIFIVE_SPI "sifive.spi"
 typedef struct SiFiveSPIState SiFiveSPIState;
-#define SIFIVE_SPI(obj) OBJECT_CHECK(SiFiveSPIState, (obj), TYPE_SIFIVE_SPI)
+DECLARE_INSTANCE_CHECKER(SiFiveSPIState, SIFIVE_SPI,
+                         TYPE_SIFIVE_SPI)
 
 struct SiFiveSPIState {
     SysBusDevice parent_obj;
diff --git a/include/hw/timer/npcm7xx_timer.h b/include/hw/timer/npcm7xx_timer.h
index d06b14acdc0..ff1985f5ca5 100644
--- a/include/hw/timer/npcm7xx_timer.h
+++ b/include/hw/timer/npcm7xx_timer.h
@@ -108,7 +108,7 @@ struct NPCM7xxTimerCtrlState {
 };
 
 #define TYPE_NPCM7XX_TIMER "npcm7xx-timer"
-#define NPCM7XX_TIMER(obj)                                              \
-    OBJECT_CHECK(NPCM7xxTimerCtrlState, (obj), TYPE_NPCM7XX_TIMER)
+DECLARE_INSTANCE_CHECKER(NPCM7xxTimerCtrlState, NPCM7XX_TIMER,
+                         TYPE_NPCM7XX_TIMER)
 
 #endif /* NPCM7XX_TIMER_H */
diff --git a/include/hw/tricore/tricore_testdevice.h b/include/hw/tricore/tricore_testdevice.h
index f6a2dd25320..4d68f129cc1 100644
--- a/include/hw/tricore/tricore_testdevice.h
+++ b/include/hw/tricore/tricore_testdevice.h
@@ -25,8 +25,8 @@
 
 #define TYPE_TRICORE_TESTDEVICE "tricore_testdevice"
 typedef struct TriCoreTestDeviceState TriCoreTestDeviceState;
-#define TRICORE_TESTDEVICE(obj) \
-    OBJECT_CHECK(TriCoreTestDeviceState, (obj), TYPE_TRICORE_TESTDEVICE)
+DECLARE_INSTANCE_CHECKER(TriCoreTestDeviceState, TRICORE_TESTDEVICE,
+                         TYPE_TRICORE_TESTDEVICE)
 
 struct TriCoreTestDeviceState {
     /* <private> */
diff --git a/include/hw/usb/hcd-dwc3.h b/include/hw/usb/hcd-dwc3.h
index 799a701bae3..20402a9ad0b 100644
--- a/include/hw/usb/hcd-dwc3.h
+++ b/include/hw/usb/hcd-dwc3.h
@@ -33,8 +33,8 @@
 #define TYPE_USB_DWC3 "usb_dwc3"
 
 typedef struct USBDWC3 USBDWC3;
-#define USB_DWC3(obj) \
-     OBJECT_CHECK(USBDWC3, (obj), TYPE_USB_DWC3)
+DECLARE_INSTANCE_CHECKER(USBDWC3, USB_DWC3,
+                         TYPE_USB_DWC3)
 
 #define USB_DWC3_R_MAX ((0x530 / 4) + 1)
 #define DWC3_SIZE 0x10000
diff --git a/include/hw/usb/xlnx-usb-subsystem.h b/include/hw/usb/xlnx-usb-subsystem.h
index e6175146817..8278f6e052a 100644
--- a/include/hw/usb/xlnx-usb-subsystem.h
+++ b/include/hw/usb/xlnx-usb-subsystem.h
@@ -32,8 +32,8 @@
 #define TYPE_XILINX_VERSAL_USB2 "xlnx.versal-usb2"
 
 typedef struct VersalUsb2 VersalUsb2;
-#define VERSAL_USB2(obj) \
-     OBJECT_CHECK(VersalUsb2, (obj), TYPE_XILINX_VERSAL_USB2)
+DECLARE_INSTANCE_CHECKER(VersalUsb2, VERSAL_USB2,
+                         TYPE_XILINX_VERSAL_USB2)
 
 struct VersalUsb2 {
     SysBusDevice parent_obj;
diff --git a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
index 7848cac6c1c..701302ad044 100644
--- a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
+++ b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
@@ -30,8 +30,8 @@
 #define TYPE_XILINX_VERSAL_USB2_CTRL_REGS "xlnx.versal-usb2-ctrl-regs"
 
 typedef struct VersalUsb2CtrlRegs VersalUsb2CtrlRegs;
-#define XILINX_VERSAL_USB2_CTRL_REGS(obj) \
-     OBJECT_CHECK(VersalUsb2CtrlRegs, (obj), TYPE_XILINX_VERSAL_USB2_CTRL_REGS)
+DECLARE_INSTANCE_CHECKER(VersalUsb2CtrlRegs, XILINX_VERSAL_USB2_CTRL_REGS,
+                         TYPE_XILINX_VERSAL_USB2_CTRL_REGS)
 
 #define USB2_REGS_R_MAX ((0x78 / 4) + 1)
 
diff --git a/include/hw/watchdog/sbsa_gwdt.h b/include/hw/watchdog/sbsa_gwdt.h
index babb120f5d3..d41da751cf7 100644
--- a/include/hw/watchdog/sbsa_gwdt.h
+++ b/include/hw/watchdog/sbsa_gwdt.h
@@ -19,8 +19,8 @@
 
 #define TYPE_WDT_SBSA "sbsa_gwdt"
 typedef struct SBSA_GWDTState SBSA_GWDTState;
-#define SBSA_GWDT(obj) \
-    OBJECT_CHECK(SBSA_GWDTState, (obj), TYPE_WDT_SBSA)
+DECLARE_INSTANCE_CHECKER(SBSA_GWDTState, SBSA_GWDT,
+                         TYPE_WDT_SBSA)
 
 /* SBSA Generic Watchdog register definitions */
 /* refresh frame */
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index c18f43a3a8c..8dc4ccc39ef 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -61,12 +61,8 @@ typedef struct AccelClass AccelClass;
 #define ACCEL_CLASS_SUFFIX  "-" TYPE_ACCEL_BASE
 #define ACCEL_CLASS_NAME(a) (a ACCEL_CLASS_SUFFIX)
 
-#define ACCEL_BASE_CLASS(klass) \
-    OBJECT_CLASS_CHECK(AccelClass, (klass), TYPE_ACCEL_BASE)
-#define ACCEL_BASE(obj) \
-    OBJECT_CHECK(AccelState, (obj), TYPE_ACCEL_BASE)
-#define ACCEL_BASE_GET_CLASS(obj) \
-    OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL_BASE)
+DECLARE_OBJ_CHECKERS(AccelState, AccelClass,
+                     ACCEL_BASE, TYPE_ACCEL_BASE)
 
 AccelClass *accel_find(const char *opt_name);
 AccelState *current_accel(void);
diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h
index 20928b9efa5..30462497c6e 100644
--- a/target/hexagon/cpu.h
+++ b/target/hexagon/cpu.h
@@ -104,12 +104,8 @@ struct CPUHexagonState {
 
 typedef struct HexagonCPUClass HexagonCPUClass;
 typedef struct HexagonCPU HexagonCPU;
-#define HEXAGON_CPU_CLASS(klass) \
-    OBJECT_CLASS_CHECK(HexagonCPUClass, (klass), TYPE_HEXAGON_CPU)
-#define HEXAGON_CPU(obj) \
-    OBJECT_CHECK(HexagonCPU, (obj), TYPE_HEXAGON_CPU)
-#define HEXAGON_CPU_GET_CLASS(obj) \
-    OBJECT_GET_CLASS(HexagonCPUClass, (obj), TYPE_HEXAGON_CPU)
+DECLARE_OBJ_CHECKERS(HexagonCPU, HexagonCPUClass,
+                     HEXAGON_CPU, TYPE_HEXAGON_CPU)
 
 struct HexagonCPUClass {
     /*< private >*/
diff --git a/chardev/char-parallel.c b/chardev/char-parallel.c
index bebe0507053..66e4589b2b2 100644
--- a/chardev/char-parallel.c
+++ b/chardev/char-parallel.c
@@ -57,8 +57,8 @@ struct ParallelChardev {
 };
 typedef struct ParallelChardev ParallelChardev;
 
-#define PARALLEL_CHARDEV(obj) \
-    OBJECT_CHECK(ParallelChardev, (obj), TYPE_CHARDEV_PARALLEL)
+DECLARE_INSTANCE_CHECKER(ParallelChardev, PARALLEL_CHARDEV,
+                         TYPE_CHARDEV_PARALLEL)
 
 static int pp_hw_mode(ParallelChardev *s, uint16_t mode)
 {
@@ -185,8 +185,6 @@ struct ParallelChardev {
 };
 typedef struct ParallelChardev ParallelChardev;
 
-#define PARALLEL_CHARDEV(obj)                                   \
-    OBJECT_CHECK(ParallelChardev, (obj), TYPE_CHARDEV_PARALLEL)
 
 static int pp_ioctl(Chardev *chr, int cmd, void *arg)
 {
diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c
index 40b4c44a5df..f95c5127643 100644
--- a/hw/i2c/i2c_mux_pca954x.c
+++ b/hw/i2c/i2c_mux_pca954x.c
@@ -46,8 +46,8 @@ struct Pca954xChannel {
 typedef struct Pca954xChannel Pca954xChannel;
 
 #define TYPE_PCA954X_CHANNEL "pca954x-channel"
-#define PCA954X_CHANNEL(obj) \
-    OBJECT_CHECK(Pca954xChannel, (obj), TYPE_PCA954X_CHANNEL)
+DECLARE_INSTANCE_CHECKER(Pca954xChannel, PCA954X_CHANNEL,
+                         TYPE_PCA954X_CHANNEL)
 
 /*
  * struct Pca954xState - The pca954x state object.
diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c
index b8001fdcf5e..165ab56eeaa 100644
--- a/hw/m68k/mcf5206.c
+++ b/hw/m68k/mcf5206.c
@@ -181,7 +181,8 @@ struct m5206_mbar_state {
 };
 typedef struct m5206_mbar_state m5206_mbar_state;
 
-#define MCF5206_MBAR(obj) OBJECT_CHECK(m5206_mbar_state, (obj), TYPE_MCF5206_MBAR)
+DECLARE_INSTANCE_CHECKER(m5206_mbar_state, MCF5206_MBAR,
+                         TYPE_MCF5206_MBAR)
 
 /* Interrupt controller.  */
 
diff --git a/hw/mem/sparse-mem.c b/hw/mem/sparse-mem.c
index 0d8c0327258..2cc34cc91cf 100644
--- a/hw/mem/sparse-mem.c
+++ b/hw/mem/sparse-mem.c
@@ -21,7 +21,8 @@
 #include "qom/object.h"
 
 typedef struct SparseMemState SparseMemState;
-#define SPARSE_MEM(obj) OBJECT_CHECK(SparseMemState, (obj), TYPE_SPARSE_MEM)
+DECLARE_INSTANCE_CHECKER(SparseMemState, SPARSE_MEM,
+                         TYPE_SPARSE_MEM)
 #define SPARSE_BLOCK_SIZE 0x1000
 
 struct SparseMemState {
diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c
index e4b79e98866..f60273a6e27 100644
--- a/hw/misc/sbsa_ec.c
+++ b/hw/misc/sbsa_ec.c
@@ -24,7 +24,8 @@ struct SECUREECState {
 typedef struct SECUREECState SECUREECState;
 
 #define TYPE_SBSA_EC      "sbsa-ec"
-#define SECURE_EC(obj) OBJECT_CHECK(SECUREECState, (obj), TYPE_SBSA_EC)
+DECLARE_INSTANCE_CHECKER(SECUREECState, SECURE_EC,
+                         TYPE_SBSA_EC)
 
 enum sbsa_ec_powerstates {
     SBSA_EC_CMD_POWEROFF = 0x01,
diff --git a/hw/s390x/vhost-user-fs-ccw.c b/hw/s390x/vhost-user-fs-ccw.c
index 254153860dc..5a72a22d48f 100644
--- a/hw/s390x/vhost-user-fs-ccw.c
+++ b/hw/s390x/vhost-user-fs-ccw.c
@@ -21,8 +21,8 @@ struct VHostUserFSCcw {
 typedef struct VHostUserFSCcw VHostUserFSCcw;
 
 #define TYPE_VHOST_USER_FS_CCW "vhost-user-fs-ccw"
-#define VHOST_USER_FS_CCW(obj) \
-        OBJECT_CHECK(VHostUserFSCcw, (obj), TYPE_VHOST_USER_FS_CCW)
+DECLARE_INSTANCE_CHECKER(VHostUserFSCcw, VHOST_USER_FS_CCW,
+                         TYPE_VHOST_USER_FS_CCW)
 
 
 static Property vhost_user_fs_ccw_properties[] = {
diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
index 80365dbd780..a678174b18c 100644
--- a/hw/sensor/adm1272.c
+++ b/hw/sensor/adm1272.c
@@ -20,7 +20,8 @@
 
 #define TYPE_ADM1272 "adm1272"
 typedef struct ADM1272State ADM1272State;
-#define ADM1272(obj) OBJECT_CHECK(ADM1272State, (obj), TYPE_ADM1272)
+DECLARE_INSTANCE_CHECKER(ADM1272State, ADM1272,
+                         TYPE_ADM1272)
 
 #define ADM1272_RESTART_TIME            0xCC
 #define ADM1272_MFR_PEAK_IOUT           0xD0
diff --git a/hw/sensor/max34451.c b/hw/sensor/max34451.c
index 5d50e46b5ba..864f0bfc736 100644
--- a/hw/sensor/max34451.c
+++ b/hw/sensor/max34451.c
@@ -18,7 +18,8 @@
 
 #define TYPE_MAX34451 "max34451"
 typedef struct MAX34451State MAX34451State;
-#define MAX34451(obj) OBJECT_CHECK(MAX34451State, (obj), TYPE_MAX34451)
+DECLARE_INSTANCE_CHECKER(MAX34451State, MAX34451,
+                         TYPE_MAX34451)
 
 #define MAX34451_MFR_MODE               0xD1
 #define MAX34451_MFR_PSEN_CONFIG        0xD2
diff --git a/hw/usb/u2f-emulated.c b/hw/usb/u2f-emulated.c
index 7c092e7a93f..f35865d42dd 100644
--- a/hw/usb/u2f-emulated.c
+++ b/hw/usb/u2f-emulated.c
@@ -99,8 +99,8 @@ struct U2FEmulatedState {
 };
 
 #define TYPE_U2F_EMULATED "u2f-emulated"
-#define EMULATED_U2F_KEY(obj) \
-    OBJECT_CHECK(U2FEmulatedState, (obj), TYPE_U2F_EMULATED)
+DECLARE_INSTANCE_CHECKER(U2FEmulatedState, EMULATED_U2F_KEY,
+                         TYPE_U2F_EMULATED)
 
 static void u2f_emulated_reset(U2FEmulatedState *key)
 {
diff --git a/hw/usb/u2f-passthru.c b/hw/usb/u2f-passthru.c
index 954b8aa3c9b..7daaac19844 100644
--- a/hw/usb/u2f-passthru.c
+++ b/hw/usb/u2f-passthru.c
@@ -77,8 +77,8 @@ struct U2FPassthruState {
 };
 
 #define TYPE_U2F_PASSTHRU "u2f-passthru"
-#define PASSTHRU_U2F_KEY(obj) \
-    OBJECT_CHECK(U2FPassthruState, (obj), TYPE_U2F_PASSTHRU)
+DECLARE_INSTANCE_CHECKER(U2FPassthruState, PASSTHRU_U2F_KEY,
+                         TYPE_U2F_PASSTHRU)
 
 /* Init packet sizes */
 #define PACKET_INIT_HEADER_SIZE 7
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 07/12] [automated] Use DECLARE_*CHECKER* macros when possible
@ 2021-08-06 21:11   ` Eduardo Habkost
  0 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrange, Paolo Bonzini, Marc-André Lureau,
	Patrick Venture, Thomas Huth, Michael S. Tsirkin, Igor Mammedov,
	Alexander Bulekov, Bandan Das, Stefan Hajnoczi, Keith Busch,
	Klaus Jensen, Cornelia Huck, Halil Pasic, Christian Borntraeger,
	Richard Henderson, David Hildenbrand, Gerd Hoffmann,
	Havard Skinnemoen, Tyrone Ting, Vijai Kumar K, Alistair Francis,
	Bin Meng, Palmer Dabbelt, Edgar E. Iglesias, Peter Maydell,
	Laurent Vivier, Cédric Le Goater, Andrew Jeffery,
	Joel Stanley, Jason Wang, Vikram Garhwal, Francisco Iglesias,
	David Gibson, Greg Kurz, Bastian Koppelmann, Taylor Simpson,
	qemu-block, qemu-s390x, qemu-arm, qemu-riscv, qemu-ppc

Converting existing QOM types to OBJECT_DECLARE_TYPE is not
always trivial (due to inconsistent type/macro naming schemes),
but at least converting existing manual QOM type checking macros
to use DECLARE_*CHECKER* is a simpler process, and should at
least discourage people from defining new QOM type checker macros
manually.

Generated using:

  $ ./scripts/codeconverter/converter.py -i \
    --pattern=TypeCheckMacro $(git grep -l '' -- '*.[ch]')

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Patrick Venture <venture@google.com>
Cc: Thomas Huth <huth@tuxfamily.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Alexander Bulekov <alxndr@bu.edu>
Cc: Bandan Das <bsd@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Klaus Jensen <its@irrelevant.dk>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: Halil Pasic <pasic@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Havard Skinnemoen <hskinnemoen@google.com>
Cc: Tyrone Ting <kfting@nuvoton.com>
Cc: Vijai Kumar K <vijai@behindbytes.com>
Cc: Alistair Francis <Alistair.Francis@wdc.com>
Cc: Bin Meng <bin.meng@windriver.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Laurent Vivier <laurent@vivier.eu>
Cc: "Cédric Le Goater" <clg@kaod.org>
Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Greg Kurz <groug@kaod.org>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: Taylor Simpson <tsimpson@quicinc.com>
Cc: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org
Cc: qemu-s390x@nongnu.org
Cc: qemu-arm@nongnu.org
Cc: qemu-riscv@nongnu.org
Cc: qemu-ppc@nongnu.org
---
 hw/nvme/nvme.h                              | 12 ++++++------
 hw/usb/hcd-xhci-pci.h                       |  4 ++--
 hw/usb/hcd-xhci-sysbus.h                    |  4 ++--
 hw/usb/u2f.h                                |  8 ++------
 include/hw/adc/npcm7xx_adc.h                |  4 ++--
 include/hw/arm/npcm7xx.h                    | 15 ++++-----------
 include/hw/char/shakti_uart.h               |  4 ++--
 include/hw/dma/sifive_pdma.h                |  4 ++--
 include/hw/dma/xlnx_csu_dma.h               |  4 ++--
 include/hw/gpio/npcm7xx_gpio.h              |  4 ++--
 include/hw/i2c/npcm7xx_smbus.h              |  4 ++--
 include/hw/intc/m68k_irqc.h                 |  4 ++--
 include/hw/intc/sifive_clint.h              |  4 ++--
 include/hw/mem/npcm7xx_mc.h                 |  3 ++-
 include/hw/misc/aspeed_lpc.h                |  3 ++-
 include/hw/misc/mchp_pfsoc_dmc.h            | 10 ++++------
 include/hw/misc/mchp_pfsoc_ioscb.h          |  4 ++--
 include/hw/misc/mchp_pfsoc_sysreg.h         |  5 ++---
 include/hw/misc/npcm7xx_clk.h               |  3 ++-
 include/hw/misc/npcm7xx_gcr.h               |  3 ++-
 include/hw/misc/npcm7xx_mft.h               |  4 ++--
 include/hw/misc/npcm7xx_pwm.h               |  4 ++--
 include/hw/misc/npcm7xx_rng.h               |  3 ++-
 include/hw/misc/xlnx-versal-xramc.h         |  4 ++--
 include/hw/net/npcm7xx_emc.h                |  4 ++--
 include/hw/net/xlnx-zynqmp-can.h            |  4 ++--
 include/hw/nvram/npcm7xx_otp.h              |  3 ++-
 include/hw/ppc/spapr_drc.h                  | 13 ++++---------
 include/hw/ppc/spapr_xive.h                 |  7 ++-----
 include/hw/riscv/microchip_pfsoc.h          |  9 ++++-----
 include/hw/riscv/shakti_c.h                 |  8 ++++----
 include/hw/riscv/sifive_e.h                 |  8 ++++----
 include/hw/riscv/sifive_u.h                 |  8 ++++----
 include/hw/sd/cadence_sdhci.h               |  4 ++--
 include/hw/ssi/npcm7xx_fiu.h                |  3 ++-
 include/hw/ssi/sifive_spi.h                 |  3 ++-
 include/hw/timer/npcm7xx_timer.h            |  4 ++--
 include/hw/tricore/tricore_testdevice.h     |  4 ++--
 include/hw/usb/hcd-dwc3.h                   |  4 ++--
 include/hw/usb/xlnx-usb-subsystem.h         |  4 ++--
 include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  4 ++--
 include/hw/watchdog/sbsa_gwdt.h             |  4 ++--
 include/qemu/accel.h                        |  8 ++------
 target/hexagon/cpu.h                        |  8 ++------
 chardev/char-parallel.c                     |  6 ++----
 hw/i2c/i2c_mux_pca954x.c                    |  4 ++--
 hw/m68k/mcf5206.c                           |  3 ++-
 hw/mem/sparse-mem.c                         |  3 ++-
 hw/misc/sbsa_ec.c                           |  3 ++-
 hw/s390x/vhost-user-fs-ccw.c                |  4 ++--
 hw/sensor/adm1272.c                         |  3 ++-
 hw/sensor/max34451.c                        |  3 ++-
 hw/usb/u2f-emulated.c                       |  4 ++--
 hw/usb/u2f-passthru.c                       |  4 ++--
 54 files changed, 126 insertions(+), 146 deletions(-)

diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
index 0840f585d6e..c4c43da5c17 100644
--- a/hw/nvme/nvme.h
+++ b/hw/nvme/nvme.h
@@ -43,8 +43,8 @@ typedef struct NvmeBus {
 
 #define TYPE_NVME_SUBSYS "nvme-subsys"
 typedef struct NvmeSubsystem NvmeSubsystem;
-#define NVME_SUBSYS(obj) \
-    OBJECT_CHECK(NvmeSubsystem, (obj), TYPE_NVME_SUBSYS)
+DECLARE_INSTANCE_CHECKER(NvmeSubsystem, NVME_SUBSYS,
+                         TYPE_NVME_SUBSYS)
 
 struct NvmeSubsystem {
     DeviceState parent_obj;
@@ -83,8 +83,8 @@ static inline NvmeNamespace *nvme_subsys_ns(NvmeSubsystem *subsys,
 }
 
 #define TYPE_NVME_NS "nvme-ns"
-#define NVME_NS(obj) \
-    OBJECT_CHECK(NvmeNamespace, (obj), TYPE_NVME_NS)
+DECLARE_INSTANCE_CHECKER(NvmeNamespace, NVME_NS,
+                         TYPE_NVME_NS)
 
 typedef struct NvmeZone {
     NvmeZoneDescr   d;
@@ -377,8 +377,8 @@ typedef struct NvmeCQueue {
 } NvmeCQueue;
 
 #define TYPE_NVME "nvme"
-#define NVME(obj) \
-        OBJECT_CHECK(NvmeCtrl, (obj), TYPE_NVME)
+DECLARE_INSTANCE_CHECKER(NvmeCtrl, NVME,
+                         TYPE_NVME)
 
 typedef struct NvmeParams {
     char     *serial;
diff --git a/hw/usb/hcd-xhci-pci.h b/hw/usb/hcd-xhci-pci.h
index 0cfe630a5ce..d83aad82e04 100644
--- a/hw/usb/hcd-xhci-pci.h
+++ b/hw/usb/hcd-xhci-pci.h
@@ -30,8 +30,8 @@
 
 #define TYPE_XHCI_PCI "pci-xhci"
 typedef struct XHCIPciState XHCIPciState;
-#define XHCI_PCI(obj) \
-    OBJECT_CHECK(XHCIPciState, (obj), TYPE_XHCI_PCI)
+DECLARE_INSTANCE_CHECKER(XHCIPciState, XHCI_PCI,
+                         TYPE_XHCI_PCI)
 
 
 struct XHCIPciState {
diff --git a/hw/usb/hcd-xhci-sysbus.h b/hw/usb/hcd-xhci-sysbus.h
index 7661c811fd1..561e5144e05 100644
--- a/hw/usb/hcd-xhci-sysbus.h
+++ b/hw/usb/hcd-xhci-sysbus.h
@@ -17,8 +17,8 @@
 #include "qom/object.h"
 
 typedef struct XHCISysbusState XHCISysbusState;
-#define XHCI_SYSBUS(obj) \
-    OBJECT_CHECK(XHCISysbusState, (obj), TYPE_XHCI_SYSBUS)
+DECLARE_INSTANCE_CHECKER(XHCISysbusState, XHCI_SYSBUS,
+                         TYPE_XHCI_SYSBUS)
 
 
 struct XHCISysbusState {
diff --git a/hw/usb/u2f.h b/hw/usb/u2f.h
index 7191a23ee1a..5767ca8fac9 100644
--- a/hw/usb/u2f.h
+++ b/hw/usb/u2f.h
@@ -37,12 +37,8 @@ typedef struct U2FKeyInfo U2FKeyInfo;
 
 #define TYPE_U2F_KEY "u2f-key"
 typedef struct U2FKeyClass U2FKeyClass;
-#define U2F_KEY(obj) \
-    OBJECT_CHECK(U2FKeyState, (obj), TYPE_U2F_KEY)
-#define U2F_KEY_CLASS(klass) \
-    OBJECT_CLASS_CHECK(U2FKeyClass, (klass), TYPE_U2F_KEY)
-#define U2F_KEY_GET_CLASS(obj) \
-    OBJECT_GET_CLASS(U2FKeyClass, (obj), TYPE_U2F_KEY)
+DECLARE_OBJ_CHECKERS(U2FKeyState, U2FKeyClass,
+                     U2F_KEY, TYPE_U2F_KEY)
 
 /*
  * Callbacks to be used by the U2F key base device (i.e. hw/u2f.c)
diff --git a/include/hw/adc/npcm7xx_adc.h b/include/hw/adc/npcm7xx_adc.h
index 835d13f5b0d..b694adece6a 100644
--- a/include/hw/adc/npcm7xx_adc.h
+++ b/include/hw/adc/npcm7xx_adc.h
@@ -65,7 +65,7 @@ struct NPCM7xxADCState {
 typedef struct NPCM7xxADCState NPCM7xxADCState;
 
 #define TYPE_NPCM7XX_ADC "npcm7xx-adc"
-#define NPCM7XX_ADC(obj) \
-    OBJECT_CHECK(NPCM7xxADCState, (obj), TYPE_NPCM7XX_ADC)
+DECLARE_INSTANCE_CHECKER(NPCM7xxADCState, NPCM7XX_ADC,
+                         TYPE_NPCM7XX_ADC)
 
 #endif /* NPCM7XX_ADC_H */
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
index 697d2957590..310b3d89ed8 100644
--- a/include/hw/arm/npcm7xx.h
+++ b/include/hw/arm/npcm7xx.h
@@ -65,8 +65,8 @@ typedef struct NPCM7xxMachine NPCM7xxMachine;
 
 #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
 typedef struct NPCM7xxMachineClass NPCM7xxMachineClass;
-#define NPCM7XX_MACHINE(obj)                                            \
-    OBJECT_CHECK(NPCM7xxMachine, (obj), TYPE_NPCM7XX_MACHINE)
+DECLARE_OBJ_CHECKERS(NPCM7xxMachine, NPCM7xxMachineClass,
+                     NPCM7XX_MACHINE, TYPE_NPCM7XX_MACHINE)
 
 struct NPCM7xxMachineClass {
     MachineClass        parent;
@@ -74,10 +74,6 @@ struct NPCM7xxMachineClass {
     const char          *soc_type;
 };
 
-#define NPCM7XX_MACHINE_CLASS(klass)                                    \
-    OBJECT_CLASS_CHECK(NPCM7xxMachineClass, (klass), TYPE_NPCM7XX_MACHINE)
-#define NPCM7XX_MACHINE_GET_CLASS(obj)                                  \
-    OBJECT_GET_CLASS(NPCM7xxMachineClass, (obj), TYPE_NPCM7XX_MACHINE)
 
 struct NPCM7xxState {
     DeviceState         parent;
@@ -111,7 +107,8 @@ typedef struct NPCM7xxState NPCM7xxState;
 
 #define TYPE_NPCM7XX    "npcm7xx"
 typedef struct NPCM7xxClass NPCM7xxClass;
-#define NPCM7XX(obj)    OBJECT_CHECK(NPCM7xxState, (obj), TYPE_NPCM7XX)
+DECLARE_OBJ_CHECKERS(NPCM7xxState, NPCM7xxClass,
+                     NPCM7XX, TYPE_NPCM7XX)
 
 #define TYPE_NPCM730    "npcm730"
 #define TYPE_NPCM750    "npcm750"
@@ -125,10 +122,6 @@ struct NPCM7xxClass {
     uint32_t            num_cpus;
 };
 
-#define NPCM7XX_CLASS(klass)                                            \
-    OBJECT_CLASS_CHECK(NPCM7xxClass, (klass), TYPE_NPCM7XX)
-#define NPCM7XX_GET_CLASS(obj)                                          \
-    OBJECT_GET_CLASS(NPCM7xxClass, (obj), TYPE_NPCM7XX)
 
 /**
  * npcm7xx_load_kernel - Loads memory with everything needed to boot
diff --git a/include/hw/char/shakti_uart.h b/include/hw/char/shakti_uart.h
index be7a93fb14d..9bec3062af0 100644
--- a/include/hw/char/shakti_uart.h
+++ b/include/hw/char/shakti_uart.h
@@ -50,8 +50,8 @@
 
 #define TYPE_SHAKTI_UART "shakti-uart"
 typedef struct ShaktiUartState ShaktiUartState;
-#define SHAKTI_UART(obj) \
-    OBJECT_CHECK(ShaktiUartState, (obj), TYPE_SHAKTI_UART)
+DECLARE_INSTANCE_CHECKER(ShaktiUartState, SHAKTI_UART,
+                         TYPE_SHAKTI_UART)
 
 struct ShaktiUartState {
     /* <private> */
diff --git a/include/hw/dma/sifive_pdma.h b/include/hw/dma/sifive_pdma.h
index 76b4b45d0a4..d81526cfc2f 100644
--- a/include/hw/dma/sifive_pdma.h
+++ b/include/hw/dma/sifive_pdma.h
@@ -53,7 +53,7 @@ typedef struct SiFivePDMAState SiFivePDMAState;
 
 #define TYPE_SIFIVE_PDMA    "sifive.pdma"
 
-#define SIFIVE_PDMA(obj)    \
-    OBJECT_CHECK(SiFivePDMAState, (obj), TYPE_SIFIVE_PDMA)
+DECLARE_INSTANCE_CHECKER(SiFivePDMAState, SIFIVE_PDMA,
+                         TYPE_SIFIVE_PDMA)
 
 #endif /* SIFIVE_PDMA_H */
diff --git a/include/hw/dma/xlnx_csu_dma.h b/include/hw/dma/xlnx_csu_dma.h
index f8d88e2ebee..36433d189ac 100644
--- a/include/hw/dma/xlnx_csu_dma.h
+++ b/include/hw/dma/xlnx_csu_dma.h
@@ -48,7 +48,7 @@ struct XlnxCSUDMA {
 };
 typedef struct XlnxCSUDMA XlnxCSUDMA;
 
-#define XLNX_CSU_DMA(obj) \
-    OBJECT_CHECK(XlnxCSUDMA, (obj), TYPE_XLNX_CSU_DMA)
+DECLARE_INSTANCE_CHECKER(XlnxCSUDMA, XLNX_CSU_DMA,
+                         TYPE_XLNX_CSU_DMA)
 
 #endif
diff --git a/include/hw/gpio/npcm7xx_gpio.h b/include/hw/gpio/npcm7xx_gpio.h
index e45cf45e78e..cfc9baefce5 100644
--- a/include/hw/gpio/npcm7xx_gpio.h
+++ b/include/hw/gpio/npcm7xx_gpio.h
@@ -51,7 +51,7 @@ struct NPCM7xxGPIOState {
 typedef struct NPCM7xxGPIOState NPCM7xxGPIOState;
 
 #define TYPE_NPCM7XX_GPIO "npcm7xx-gpio"
-#define NPCM7XX_GPIO(obj) \
-    OBJECT_CHECK(NPCM7xxGPIOState, (obj), TYPE_NPCM7XX_GPIO)
+DECLARE_INSTANCE_CHECKER(NPCM7xxGPIOState, NPCM7XX_GPIO,
+                         TYPE_NPCM7XX_GPIO)
 
 #endif /* NPCM7XX_GPIO_H */
diff --git a/include/hw/i2c/npcm7xx_smbus.h b/include/hw/i2c/npcm7xx_smbus.h
index ef64c6748a7..aa5e1d84b41 100644
--- a/include/hw/i2c/npcm7xx_smbus.h
+++ b/include/hw/i2c/npcm7xx_smbus.h
@@ -109,7 +109,7 @@ struct NPCM7xxSMBusState {
 typedef struct NPCM7xxSMBusState NPCM7xxSMBusState;
 
 #define TYPE_NPCM7XX_SMBUS "npcm7xx-smbus"
-#define NPCM7XX_SMBUS(obj) OBJECT_CHECK(NPCM7xxSMBusState, (obj), \
-                                        TYPE_NPCM7XX_SMBUS)
+DECLARE_INSTANCE_CHECKER(NPCM7xxSMBusState, NPCM7XX_SMBUS,
+                         TYPE_NPCM7XX_SMBUS)
 
 #endif /* NPCM7XX_SMBUS_H */
diff --git a/include/hw/intc/m68k_irqc.h b/include/hw/intc/m68k_irqc.h
index 460d8a5a8d3..843cec3c666 100644
--- a/include/hw/intc/m68k_irqc.h
+++ b/include/hw/intc/m68k_irqc.h
@@ -15,8 +15,8 @@
 
 #define TYPE_M68K_IRQC "m68k-irq-controller"
 typedef struct M68KIRQCState M68KIRQCState;
-#define M68K_IRQC(obj) OBJECT_CHECK(M68KIRQCState, (obj), \
-                                    TYPE_M68K_IRQC)
+DECLARE_INSTANCE_CHECKER(M68KIRQCState, M68K_IRQC,
+                         TYPE_M68K_IRQC)
 
 #define M68K_IRQC_AUTOVECTOR_BASE 25
 
diff --git a/include/hw/intc/sifive_clint.h b/include/hw/intc/sifive_clint.h
index 8e005e130f1..c7df3f7f2b3 100644
--- a/include/hw/intc/sifive_clint.h
+++ b/include/hw/intc/sifive_clint.h
@@ -26,8 +26,8 @@
 #define TYPE_SIFIVE_CLINT "riscv.sifive.clint"
 
 typedef struct SiFiveCLINTState SiFiveCLINTState;
-#define SIFIVE_CLINT(obj) \
-    OBJECT_CHECK(SiFiveCLINTState, (obj), TYPE_SIFIVE_CLINT)
+DECLARE_INSTANCE_CHECKER(SiFiveCLINTState, SIFIVE_CLINT,
+                         TYPE_SIFIVE_CLINT)
 
 struct SiFiveCLINTState {
     /*< private >*/
diff --git a/include/hw/mem/npcm7xx_mc.h b/include/hw/mem/npcm7xx_mc.h
index e0a9d3b0de9..bec8ebc45ef 100644
--- a/include/hw/mem/npcm7xx_mc.h
+++ b/include/hw/mem/npcm7xx_mc.h
@@ -33,6 +33,7 @@ struct NPCM7xxMCState {
 typedef struct NPCM7xxMCState NPCM7xxMCState;
 
 #define TYPE_NPCM7XX_MC "npcm7xx-mc"
-#define NPCM7XX_MC(obj) OBJECT_CHECK(NPCM7xxMCState, (obj), TYPE_NPCM7XX_MC)
+DECLARE_INSTANCE_CHECKER(NPCM7xxMCState, NPCM7XX_MC,
+                         TYPE_NPCM7XX_MC)
 
 #endif /* NPCM7XX_MC_H */
diff --git a/include/hw/misc/aspeed_lpc.h b/include/hw/misc/aspeed_lpc.h
index def617b9772..d8e5af6296b 100644
--- a/include/hw/misc/aspeed_lpc.h
+++ b/include/hw/misc/aspeed_lpc.h
@@ -17,7 +17,8 @@
 
 #define TYPE_ASPEED_LPC "aspeed.lpc"
 typedef struct AspeedLPCState AspeedLPCState;
-#define ASPEED_LPC(obj) OBJECT_CHECK(AspeedLPCState, (obj), TYPE_ASPEED_LPC)
+DECLARE_INSTANCE_CHECKER(AspeedLPCState, ASPEED_LPC,
+                         TYPE_ASPEED_LPC)
 
 #define ASPEED_LPC_NR_REGS      (0x260 >> 2)
 
diff --git a/include/hw/misc/mchp_pfsoc_dmc.h b/include/hw/misc/mchp_pfsoc_dmc.h
index 28cfe3e1e23..3a0e3bbba76 100644
--- a/include/hw/misc/mchp_pfsoc_dmc.h
+++ b/include/hw/misc/mchp_pfsoc_dmc.h
@@ -36,9 +36,8 @@ typedef struct MchpPfSoCDdrSgmiiPhyState MchpPfSoCDdrSgmiiPhyState;
 
 #define TYPE_MCHP_PFSOC_DDR_SGMII_PHY "mchp.pfsoc.ddr_sgmii_phy"
 
-#define MCHP_PFSOC_DDR_SGMII_PHY(obj) \
-    OBJECT_CHECK(MchpPfSoCDdrSgmiiPhyState, (obj), \
-                 TYPE_MCHP_PFSOC_DDR_SGMII_PHY)
+DECLARE_INSTANCE_CHECKER(MchpPfSoCDdrSgmiiPhyState, MCHP_PFSOC_DDR_SGMII_PHY,
+                         TYPE_MCHP_PFSOC_DDR_SGMII_PHY)
 
 /* DDR CFG module */
 
@@ -52,8 +51,7 @@ typedef struct MchpPfSoCDdrCfgState MchpPfSoCDdrCfgState;
 
 #define TYPE_MCHP_PFSOC_DDR_CFG "mchp.pfsoc.ddr_cfg"
 
-#define MCHP_PFSOC_DDR_CFG(obj) \
-    OBJECT_CHECK(MchpPfSoCDdrCfgState, (obj), \
-                 TYPE_MCHP_PFSOC_DDR_CFG)
+DECLARE_INSTANCE_CHECKER(MchpPfSoCDdrCfgState, MCHP_PFSOC_DDR_CFG,
+                         TYPE_MCHP_PFSOC_DDR_CFG)
 
 #endif /* MCHP_PFSOC_DMC_H */
diff --git a/include/hw/misc/mchp_pfsoc_ioscb.h b/include/hw/misc/mchp_pfsoc_ioscb.h
index 95b0b9069dd..18ef5ff1739 100644
--- a/include/hw/misc/mchp_pfsoc_ioscb.h
+++ b/include/hw/misc/mchp_pfsoc_ioscb.h
@@ -46,7 +46,7 @@ typedef struct MchpPfSoCIoscbState MchpPfSoCIoscbState;
 
 #define TYPE_MCHP_PFSOC_IOSCB "mchp.pfsoc.ioscb"
 
-#define MCHP_PFSOC_IOSCB(obj) \
-    OBJECT_CHECK(MchpPfSoCIoscbState, (obj), TYPE_MCHP_PFSOC_IOSCB)
+DECLARE_INSTANCE_CHECKER(MchpPfSoCIoscbState, MCHP_PFSOC_IOSCB,
+                         TYPE_MCHP_PFSOC_IOSCB)
 
 #endif /* MCHP_PFSOC_IOSCB_H */
diff --git a/include/hw/misc/mchp_pfsoc_sysreg.h b/include/hw/misc/mchp_pfsoc_sysreg.h
index adce8d869c4..c842cf7e716 100644
--- a/include/hw/misc/mchp_pfsoc_sysreg.h
+++ b/include/hw/misc/mchp_pfsoc_sysreg.h
@@ -34,8 +34,7 @@ typedef struct MchpPfSoCSysregState MchpPfSoCSysregState;
 
 #define TYPE_MCHP_PFSOC_SYSREG "mchp.pfsoc.sysreg"
 
-#define MCHP_PFSOC_SYSREG(obj) \
-    OBJECT_CHECK(MchpPfSoCSysregState, (obj), \
-                 TYPE_MCHP_PFSOC_SYSREG)
+DECLARE_INSTANCE_CHECKER(MchpPfSoCSysregState, MCHP_PFSOC_SYSREG,
+                         TYPE_MCHP_PFSOC_SYSREG)
 
 #endif /* MCHP_PFSOC_SYSREG_H */
diff --git a/include/hw/misc/npcm7xx_clk.h b/include/hw/misc/npcm7xx_clk.h
index 80b651c7e44..023a1aed7a9 100644
--- a/include/hw/misc/npcm7xx_clk.h
+++ b/include/hw/misc/npcm7xx_clk.h
@@ -179,6 +179,7 @@ struct NPCM7xxCLKState {
 };
 
 #define TYPE_NPCM7XX_CLK "npcm7xx-clk"
-#define NPCM7XX_CLK(obj) OBJECT_CHECK(NPCM7xxCLKState, (obj), TYPE_NPCM7XX_CLK)
+DECLARE_INSTANCE_CHECKER(NPCM7xxCLKState, NPCM7XX_CLK,
+                         TYPE_NPCM7XX_CLK)
 
 #endif /* NPCM7XX_CLK_H */
diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h
index b5c573ec8f2..eed59f94f91 100644
--- a/include/hw/misc/npcm7xx_gcr.h
+++ b/include/hw/misc/npcm7xx_gcr.h
@@ -40,6 +40,7 @@ struct NPCM7xxGCRState {
 typedef struct NPCM7xxGCRState NPCM7xxGCRState;
 
 #define TYPE_NPCM7XX_GCR "npcm7xx-gcr"
-#define NPCM7XX_GCR(obj) OBJECT_CHECK(NPCM7xxGCRState, (obj), TYPE_NPCM7XX_GCR)
+DECLARE_INSTANCE_CHECKER(NPCM7xxGCRState, NPCM7XX_GCR,
+                         TYPE_NPCM7XX_GCR)
 
 #endif /* NPCM7XX_GCR_H */
diff --git a/include/hw/misc/npcm7xx_mft.h b/include/hw/misc/npcm7xx_mft.h
index 3f7bd2a9c6a..a351cf9b2be 100644
--- a/include/hw/misc/npcm7xx_mft.h
+++ b/include/hw/misc/npcm7xx_mft.h
@@ -65,7 +65,7 @@ struct NPCM7xxMFTState {
 typedef struct NPCM7xxMFTState NPCM7xxMFTState;
 
 #define TYPE_NPCM7XX_MFT "npcm7xx-mft"
-#define NPCM7XX_MFT(obj) \
-    OBJECT_CHECK(NPCM7xxMFTState, (obj), TYPE_NPCM7XX_MFT)
+DECLARE_INSTANCE_CHECKER(NPCM7xxMFTState, NPCM7XX_MFT,
+                         TYPE_NPCM7XX_MFT)
 
 #endif /* NPCM7XX_MFT_H */
diff --git a/include/hw/misc/npcm7xx_pwm.h b/include/hw/misc/npcm7xx_pwm.h
index c6643bd04fd..3be975e1ee4 100644
--- a/include/hw/misc/npcm7xx_pwm.h
+++ b/include/hw/misc/npcm7xx_pwm.h
@@ -102,7 +102,7 @@ struct NPCM7xxPWMState {
 };
 
 #define TYPE_NPCM7XX_PWM "npcm7xx-pwm"
-#define NPCM7XX_PWM(obj) \
-    OBJECT_CHECK(NPCM7xxPWMState, (obj), TYPE_NPCM7XX_PWM)
+DECLARE_INSTANCE_CHECKER(NPCM7xxPWMState, NPCM7XX_PWM,
+                         TYPE_NPCM7XX_PWM)
 
 #endif /* NPCM7XX_PWM_H */
diff --git a/include/hw/misc/npcm7xx_rng.h b/include/hw/misc/npcm7xx_rng.h
index 27122001f4b..e1f798a4bed 100644
--- a/include/hw/misc/npcm7xx_rng.h
+++ b/include/hw/misc/npcm7xx_rng.h
@@ -31,6 +31,7 @@ struct NPCM7xxRNGState {
 typedef struct NPCM7xxRNGState NPCM7xxRNGState;
 
 #define TYPE_NPCM7XX_RNG "npcm7xx-rng"
-#define NPCM7XX_RNG(obj) OBJECT_CHECK(NPCM7xxRNGState, (obj), TYPE_NPCM7XX_RNG)
+DECLARE_INSTANCE_CHECKER(NPCM7xxRNGState, NPCM7XX_RNG,
+                         TYPE_NPCM7XX_RNG)
 
 #endif /* NPCM7XX_RNG_H */
diff --git a/include/hw/misc/xlnx-versal-xramc.h b/include/hw/misc/xlnx-versal-xramc.h
index ba0d0f3c5af..fc5a12165cf 100644
--- a/include/hw/misc/xlnx-versal-xramc.h
+++ b/include/hw/misc/xlnx-versal-xramc.h
@@ -16,8 +16,8 @@
 #define TYPE_XLNX_XRAM_CTRL "xlnx.versal-xramc"
 
 typedef struct XlnxXramCtrl XlnxXramCtrl;
-#define XLNX_XRAM_CTRL(obj) \
-     OBJECT_CHECK(XlnxXramCtrl, (obj), TYPE_XLNX_XRAM_CTRL)
+DECLARE_INSTANCE_CHECKER(XlnxXramCtrl, XLNX_XRAM_CTRL,
+                         TYPE_XLNX_XRAM_CTRL)
 
 REG32(XRAM_ERR_CTRL, 0x0)
     FIELD(XRAM_ERR_CTRL, UE_RES, 3, 1)
diff --git a/include/hw/net/npcm7xx_emc.h b/include/hw/net/npcm7xx_emc.h
index 5b676f669cd..bdf06c69dde 100644
--- a/include/hw/net/npcm7xx_emc.h
+++ b/include/hw/net/npcm7xx_emc.h
@@ -281,7 +281,7 @@ struct NPCM7xxEMCState {
 typedef struct NPCM7xxEMCState NPCM7xxEMCState;
 
 #define TYPE_NPCM7XX_EMC "npcm7xx-emc"
-#define NPCM7XX_EMC(obj) \
-    OBJECT_CHECK(NPCM7xxEMCState, (obj), TYPE_NPCM7XX_EMC)
+DECLARE_INSTANCE_CHECKER(NPCM7xxEMCState, NPCM7XX_EMC,
+                         TYPE_NPCM7XX_EMC)
 
 #endif /* NPCM7XX_EMC_H */
diff --git a/include/hw/net/xlnx-zynqmp-can.h b/include/hw/net/xlnx-zynqmp-can.h
index 3d80c7455db..4a1fa166571 100644
--- a/include/hw/net/xlnx-zynqmp-can.h
+++ b/include/hw/net/xlnx-zynqmp-can.h
@@ -41,8 +41,8 @@
 #define TYPE_XLNX_ZYNQMP_CAN "xlnx.zynqmp-can"
 
 typedef struct XlnxZynqMPCANState XlnxZynqMPCANState;
-#define XLNX_ZYNQMP_CAN(obj) \
-     OBJECT_CHECK(XlnxZynqMPCANState, (obj), TYPE_XLNX_ZYNQMP_CAN)
+DECLARE_INSTANCE_CHECKER(XlnxZynqMPCANState, XLNX_ZYNQMP_CAN,
+                         TYPE_XLNX_ZYNQMP_CAN)
 
 #define MAX_CAN_CTRLS      2
 #define XLNX_ZYNQMP_CAN_R_MAX     (0x84 / 4)
diff --git a/include/hw/nvram/npcm7xx_otp.h b/include/hw/nvram/npcm7xx_otp.h
index 0ab1d5bae48..4cfc6577e87 100644
--- a/include/hw/nvram/npcm7xx_otp.h
+++ b/include/hw/nvram/npcm7xx_otp.h
@@ -58,7 +58,8 @@ struct NPCM7xxOTPState {
 typedef struct NPCM7xxOTPState NPCM7xxOTPState;
 
 #define TYPE_NPCM7XX_OTP "npcm7xx-otp"
-#define NPCM7XX_OTP(obj) OBJECT_CHECK(NPCM7xxOTPState, (obj), TYPE_NPCM7XX_OTP)
+DECLARE_INSTANCE_CHECKER(NPCM7xxOTPState, NPCM7XX_OTP,
+                         TYPE_NPCM7XX_OTP)
 
 #define TYPE_NPCM7XX_KEY_STORAGE "npcm7xx-key-storage"
 #define TYPE_NPCM7XX_FUSE_ARRAY "npcm7xx-fuse-array"
diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h
index 83019d3f672..540439812f0 100644
--- a/include/hw/ppc/spapr_drc.h
+++ b/include/hw/ppc/spapr_drc.h
@@ -22,18 +22,13 @@
 #define TYPE_SPAPR_DR_CONNECTOR "spapr-dr-connector"
 typedef struct SpaprDrc SpaprDrc;
 typedef struct SpaprDrcClass SpaprDrcClass;
-#define SPAPR_DR_CONNECTOR_GET_CLASS(obj) \
-        OBJECT_GET_CLASS(SpaprDrcClass, obj, TYPE_SPAPR_DR_CONNECTOR)
-#define SPAPR_DR_CONNECTOR_CLASS(klass) \
-        OBJECT_CLASS_CHECK(SpaprDrcClass, klass, \
-                           TYPE_SPAPR_DR_CONNECTOR)
-#define SPAPR_DR_CONNECTOR(obj) OBJECT_CHECK(SpaprDrc, (obj), \
-                                             TYPE_SPAPR_DR_CONNECTOR)
+DECLARE_OBJ_CHECKERS(SpaprDrc, SpaprDrcClass,
+                     SPAPR_DR_CONNECTOR, TYPE_SPAPR_DR_CONNECTOR)
 
 #define TYPE_SPAPR_DRC_PHYSICAL "spapr-drc-physical"
 typedef struct SpaprDrcPhysical SpaprDrcPhysical;
-#define SPAPR_DRC_PHYSICAL(obj) OBJECT_CHECK(SpaprDrcPhysical, (obj), \
-                                             TYPE_SPAPR_DRC_PHYSICAL)
+DECLARE_INSTANCE_CHECKER(SpaprDrcPhysical, SPAPR_DRC_PHYSICAL,
+                         TYPE_SPAPR_DRC_PHYSICAL)
 
 #define TYPE_SPAPR_DRC_LOGICAL "spapr-drc-logical"
 
diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h
index d1371b2dbba..333095c3fd9 100644
--- a/include/hw/ppc/spapr_xive.h
+++ b/include/hw/ppc/spapr_xive.h
@@ -17,11 +17,8 @@
 #define TYPE_SPAPR_XIVE "spapr-xive"
 typedef struct SpaprXive SpaprXive;
 typedef struct SpaprXiveClass SpaprXiveClass;
-#define SPAPR_XIVE(obj) OBJECT_CHECK(SpaprXive, (obj), TYPE_SPAPR_XIVE)
-#define SPAPR_XIVE_CLASS(klass)                                         \
-    OBJECT_CLASS_CHECK(SpaprXiveClass, (klass), TYPE_SPAPR_XIVE)
-#define SPAPR_XIVE_GET_CLASS(obj)                               \
-    OBJECT_GET_CLASS(SpaprXiveClass, (obj), TYPE_SPAPR_XIVE)
+DECLARE_OBJ_CHECKERS(SpaprXive, SpaprXiveClass,
+                     SPAPR_XIVE, TYPE_SPAPR_XIVE)
 
 struct SpaprXive {
     XiveRouter    parent;
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
index b30fb1191d9..3a29a48019e 100644
--- a/include/hw/riscv/microchip_pfsoc.h
+++ b/include/hw/riscv/microchip_pfsoc.h
@@ -58,8 +58,8 @@ struct MicrochipPFSoCState {
 typedef struct MicrochipPFSoCState MicrochipPFSoCState;
 
 #define TYPE_MICROCHIP_PFSOC    "microchip.pfsoc"
-#define MICROCHIP_PFSOC(obj) \
-    OBJECT_CHECK(MicrochipPFSoCState, (obj), TYPE_MICROCHIP_PFSOC)
+DECLARE_INSTANCE_CHECKER(MicrochipPFSoCState, MICROCHIP_PFSOC,
+                         TYPE_MICROCHIP_PFSOC)
 
 struct MicrochipIcicleKitState {
     /*< private >*/
@@ -72,9 +72,8 @@ typedef struct MicrochipIcicleKitState MicrochipIcicleKitState;
 
 #define TYPE_MICROCHIP_ICICLE_KIT_MACHINE \
     MACHINE_TYPE_NAME("microchip-icicle-kit")
-#define MICROCHIP_ICICLE_KIT_MACHINE(obj) \
-    OBJECT_CHECK(MicrochipIcicleKitState, (obj), \
-                 TYPE_MICROCHIP_ICICLE_KIT_MACHINE)
+DECLARE_INSTANCE_CHECKER(MicrochipIcicleKitState, MICROCHIP_ICICLE_KIT_MACHINE,
+                         TYPE_MICROCHIP_ICICLE_KIT_MACHINE)
 
 enum {
     MICROCHIP_PFSOC_RSVD0,
diff --git a/include/hw/riscv/shakti_c.h b/include/hw/riscv/shakti_c.h
index e07bca3a357..6733eca2303 100644
--- a/include/hw/riscv/shakti_c.h
+++ b/include/hw/riscv/shakti_c.h
@@ -26,8 +26,8 @@
 
 #define TYPE_RISCV_SHAKTI_SOC "riscv.shakti.cclass.soc"
 typedef struct ShaktiCSoCState ShaktiCSoCState;
-#define RISCV_SHAKTI_SOC(obj) \
-    OBJECT_CHECK(ShaktiCSoCState, (obj), TYPE_RISCV_SHAKTI_SOC)
+DECLARE_INSTANCE_CHECKER(ShaktiCSoCState, RISCV_SHAKTI_SOC,
+                         TYPE_RISCV_SHAKTI_SOC)
 
 struct ShaktiCSoCState {
     /*< private >*/
@@ -43,8 +43,8 @@ struct ShaktiCSoCState {
 
 #define TYPE_RISCV_SHAKTI_MACHINE MACHINE_TYPE_NAME("shakti_c")
 typedef struct ShaktiCMachineState ShaktiCMachineState;
-#define RISCV_SHAKTI_MACHINE(obj) \
-    OBJECT_CHECK(ShaktiCMachineState, (obj), TYPE_RISCV_SHAKTI_MACHINE)
+DECLARE_INSTANCE_CHECKER(ShaktiCMachineState, RISCV_SHAKTI_MACHINE,
+                         TYPE_RISCV_SHAKTI_MACHINE)
 struct ShaktiCMachineState {
     /*< private >*/
     MachineState parent_obj;
diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h
index 9c9ce14a4b4..22abd643753 100644
--- a/include/hw/riscv/sifive_e.h
+++ b/include/hw/riscv/sifive_e.h
@@ -26,8 +26,8 @@
 
 #define TYPE_RISCV_E_SOC "riscv.sifive.e.soc"
 typedef struct SiFiveESoCState SiFiveESoCState;
-#define RISCV_E_SOC(obj) \
-    OBJECT_CHECK(SiFiveESoCState, (obj), TYPE_RISCV_E_SOC)
+DECLARE_INSTANCE_CHECKER(SiFiveESoCState, RISCV_E_SOC,
+                         TYPE_RISCV_E_SOC)
 
 struct SiFiveESoCState {
     /*< private >*/
@@ -52,8 +52,8 @@ struct SiFiveEState {
 typedef struct SiFiveEState SiFiveEState;
 
 #define TYPE_RISCV_E_MACHINE MACHINE_TYPE_NAME("sifive_e")
-#define RISCV_E_MACHINE(obj) \
-    OBJECT_CHECK(SiFiveEState, (obj), TYPE_RISCV_E_MACHINE)
+DECLARE_INSTANCE_CHECKER(SiFiveEState, RISCV_E_MACHINE,
+                         TYPE_RISCV_E_MACHINE)
 
 enum {
     SIFIVE_E_DEV_DEBUG,
diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h
index ef050a22dc2..d974043a36d 100644
--- a/include/hw/riscv/sifive_u.h
+++ b/include/hw/riscv/sifive_u.h
@@ -31,8 +31,8 @@
 
 #define TYPE_RISCV_U_SOC "riscv.sifive.u.soc"
 typedef struct SiFiveUSoCState SiFiveUSoCState;
-#define RISCV_U_SOC(obj) \
-    OBJECT_CHECK(SiFiveUSoCState, (obj), TYPE_RISCV_U_SOC)
+DECLARE_INSTANCE_CHECKER(SiFiveUSoCState, RISCV_U_SOC,
+                         TYPE_RISCV_U_SOC)
 
 struct SiFiveUSoCState {
     /*< private >*/
@@ -58,8 +58,8 @@ struct SiFiveUSoCState {
 
 #define TYPE_RISCV_U_MACHINE MACHINE_TYPE_NAME("sifive_u")
 typedef struct SiFiveUState SiFiveUState;
-#define RISCV_U_MACHINE(obj) \
-    OBJECT_CHECK(SiFiveUState, (obj), TYPE_RISCV_U_MACHINE)
+DECLARE_INSTANCE_CHECKER(SiFiveUState, RISCV_U_MACHINE,
+                         TYPE_RISCV_U_MACHINE)
 
 struct SiFiveUState {
     /*< private >*/
diff --git a/include/hw/sd/cadence_sdhci.h b/include/hw/sd/cadence_sdhci.h
index 75c174f357a..6d6a2d9c0da 100644
--- a/include/hw/sd/cadence_sdhci.h
+++ b/include/hw/sd/cadence_sdhci.h
@@ -43,7 +43,7 @@ struct CadenceSDHCIState {
 typedef struct CadenceSDHCIState CadenceSDHCIState;
 
 #define TYPE_CADENCE_SDHCI  "cadence.sdhci"
-#define CADENCE_SDHCI(obj)  OBJECT_CHECK(CadenceSDHCIState, (obj), \
-                                         TYPE_CADENCE_SDHCI)
+DECLARE_INSTANCE_CHECKER(CadenceSDHCIState, CADENCE_SDHCI,
+                         TYPE_CADENCE_SDHCI)
 
 #endif /* CADENCE_SDHCI_H */
diff --git a/include/hw/ssi/npcm7xx_fiu.h b/include/hw/ssi/npcm7xx_fiu.h
index 01597ea8954..6503da5b37a 100644
--- a/include/hw/ssi/npcm7xx_fiu.h
+++ b/include/hw/ssi/npcm7xx_fiu.h
@@ -69,6 +69,7 @@ struct NPCM7xxFIUState {
 };
 
 #define TYPE_NPCM7XX_FIU "npcm7xx-fiu"
-#define NPCM7XX_FIU(obj) OBJECT_CHECK(NPCM7xxFIUState, (obj), TYPE_NPCM7XX_FIU)
+DECLARE_INSTANCE_CHECKER(NPCM7xxFIUState, NPCM7XX_FIU,
+                         TYPE_NPCM7XX_FIU)
 
 #endif /* NPCM7XX_FIU_H */
diff --git a/include/hw/ssi/sifive_spi.h b/include/hw/ssi/sifive_spi.h
index 6ed73ccfef0..d32deaea0ec 100644
--- a/include/hw/ssi/sifive_spi.h
+++ b/include/hw/ssi/sifive_spi.h
@@ -27,7 +27,8 @@
 
 #define TYPE_SIFIVE_SPI "sifive.spi"
 typedef struct SiFiveSPIState SiFiveSPIState;
-#define SIFIVE_SPI(obj) OBJECT_CHECK(SiFiveSPIState, (obj), TYPE_SIFIVE_SPI)
+DECLARE_INSTANCE_CHECKER(SiFiveSPIState, SIFIVE_SPI,
+                         TYPE_SIFIVE_SPI)
 
 struct SiFiveSPIState {
     SysBusDevice parent_obj;
diff --git a/include/hw/timer/npcm7xx_timer.h b/include/hw/timer/npcm7xx_timer.h
index d06b14acdc0..ff1985f5ca5 100644
--- a/include/hw/timer/npcm7xx_timer.h
+++ b/include/hw/timer/npcm7xx_timer.h
@@ -108,7 +108,7 @@ struct NPCM7xxTimerCtrlState {
 };
 
 #define TYPE_NPCM7XX_TIMER "npcm7xx-timer"
-#define NPCM7XX_TIMER(obj)                                              \
-    OBJECT_CHECK(NPCM7xxTimerCtrlState, (obj), TYPE_NPCM7XX_TIMER)
+DECLARE_INSTANCE_CHECKER(NPCM7xxTimerCtrlState, NPCM7XX_TIMER,
+                         TYPE_NPCM7XX_TIMER)
 
 #endif /* NPCM7XX_TIMER_H */
diff --git a/include/hw/tricore/tricore_testdevice.h b/include/hw/tricore/tricore_testdevice.h
index f6a2dd25320..4d68f129cc1 100644
--- a/include/hw/tricore/tricore_testdevice.h
+++ b/include/hw/tricore/tricore_testdevice.h
@@ -25,8 +25,8 @@
 
 #define TYPE_TRICORE_TESTDEVICE "tricore_testdevice"
 typedef struct TriCoreTestDeviceState TriCoreTestDeviceState;
-#define TRICORE_TESTDEVICE(obj) \
-    OBJECT_CHECK(TriCoreTestDeviceState, (obj), TYPE_TRICORE_TESTDEVICE)
+DECLARE_INSTANCE_CHECKER(TriCoreTestDeviceState, TRICORE_TESTDEVICE,
+                         TYPE_TRICORE_TESTDEVICE)
 
 struct TriCoreTestDeviceState {
     /* <private> */
diff --git a/include/hw/usb/hcd-dwc3.h b/include/hw/usb/hcd-dwc3.h
index 799a701bae3..20402a9ad0b 100644
--- a/include/hw/usb/hcd-dwc3.h
+++ b/include/hw/usb/hcd-dwc3.h
@@ -33,8 +33,8 @@
 #define TYPE_USB_DWC3 "usb_dwc3"
 
 typedef struct USBDWC3 USBDWC3;
-#define USB_DWC3(obj) \
-     OBJECT_CHECK(USBDWC3, (obj), TYPE_USB_DWC3)
+DECLARE_INSTANCE_CHECKER(USBDWC3, USB_DWC3,
+                         TYPE_USB_DWC3)
 
 #define USB_DWC3_R_MAX ((0x530 / 4) + 1)
 #define DWC3_SIZE 0x10000
diff --git a/include/hw/usb/xlnx-usb-subsystem.h b/include/hw/usb/xlnx-usb-subsystem.h
index e6175146817..8278f6e052a 100644
--- a/include/hw/usb/xlnx-usb-subsystem.h
+++ b/include/hw/usb/xlnx-usb-subsystem.h
@@ -32,8 +32,8 @@
 #define TYPE_XILINX_VERSAL_USB2 "xlnx.versal-usb2"
 
 typedef struct VersalUsb2 VersalUsb2;
-#define VERSAL_USB2(obj) \
-     OBJECT_CHECK(VersalUsb2, (obj), TYPE_XILINX_VERSAL_USB2)
+DECLARE_INSTANCE_CHECKER(VersalUsb2, VERSAL_USB2,
+                         TYPE_XILINX_VERSAL_USB2)
 
 struct VersalUsb2 {
     SysBusDevice parent_obj;
diff --git a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
index 7848cac6c1c..701302ad044 100644
--- a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
+++ b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
@@ -30,8 +30,8 @@
 #define TYPE_XILINX_VERSAL_USB2_CTRL_REGS "xlnx.versal-usb2-ctrl-regs"
 
 typedef struct VersalUsb2CtrlRegs VersalUsb2CtrlRegs;
-#define XILINX_VERSAL_USB2_CTRL_REGS(obj) \
-     OBJECT_CHECK(VersalUsb2CtrlRegs, (obj), TYPE_XILINX_VERSAL_USB2_CTRL_REGS)
+DECLARE_INSTANCE_CHECKER(VersalUsb2CtrlRegs, XILINX_VERSAL_USB2_CTRL_REGS,
+                         TYPE_XILINX_VERSAL_USB2_CTRL_REGS)
 
 #define USB2_REGS_R_MAX ((0x78 / 4) + 1)
 
diff --git a/include/hw/watchdog/sbsa_gwdt.h b/include/hw/watchdog/sbsa_gwdt.h
index babb120f5d3..d41da751cf7 100644
--- a/include/hw/watchdog/sbsa_gwdt.h
+++ b/include/hw/watchdog/sbsa_gwdt.h
@@ -19,8 +19,8 @@
 
 #define TYPE_WDT_SBSA "sbsa_gwdt"
 typedef struct SBSA_GWDTState SBSA_GWDTState;
-#define SBSA_GWDT(obj) \
-    OBJECT_CHECK(SBSA_GWDTState, (obj), TYPE_WDT_SBSA)
+DECLARE_INSTANCE_CHECKER(SBSA_GWDTState, SBSA_GWDT,
+                         TYPE_WDT_SBSA)
 
 /* SBSA Generic Watchdog register definitions */
 /* refresh frame */
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index c18f43a3a8c..8dc4ccc39ef 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -61,12 +61,8 @@ typedef struct AccelClass AccelClass;
 #define ACCEL_CLASS_SUFFIX  "-" TYPE_ACCEL_BASE
 #define ACCEL_CLASS_NAME(a) (a ACCEL_CLASS_SUFFIX)
 
-#define ACCEL_BASE_CLASS(klass) \
-    OBJECT_CLASS_CHECK(AccelClass, (klass), TYPE_ACCEL_BASE)
-#define ACCEL_BASE(obj) \
-    OBJECT_CHECK(AccelState, (obj), TYPE_ACCEL_BASE)
-#define ACCEL_BASE_GET_CLASS(obj) \
-    OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL_BASE)
+DECLARE_OBJ_CHECKERS(AccelState, AccelClass,
+                     ACCEL_BASE, TYPE_ACCEL_BASE)
 
 AccelClass *accel_find(const char *opt_name);
 AccelState *current_accel(void);
diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h
index 20928b9efa5..30462497c6e 100644
--- a/target/hexagon/cpu.h
+++ b/target/hexagon/cpu.h
@@ -104,12 +104,8 @@ struct CPUHexagonState {
 
 typedef struct HexagonCPUClass HexagonCPUClass;
 typedef struct HexagonCPU HexagonCPU;
-#define HEXAGON_CPU_CLASS(klass) \
-    OBJECT_CLASS_CHECK(HexagonCPUClass, (klass), TYPE_HEXAGON_CPU)
-#define HEXAGON_CPU(obj) \
-    OBJECT_CHECK(HexagonCPU, (obj), TYPE_HEXAGON_CPU)
-#define HEXAGON_CPU_GET_CLASS(obj) \
-    OBJECT_GET_CLASS(HexagonCPUClass, (obj), TYPE_HEXAGON_CPU)
+DECLARE_OBJ_CHECKERS(HexagonCPU, HexagonCPUClass,
+                     HEXAGON_CPU, TYPE_HEXAGON_CPU)
 
 struct HexagonCPUClass {
     /*< private >*/
diff --git a/chardev/char-parallel.c b/chardev/char-parallel.c
index bebe0507053..66e4589b2b2 100644
--- a/chardev/char-parallel.c
+++ b/chardev/char-parallel.c
@@ -57,8 +57,8 @@ struct ParallelChardev {
 };
 typedef struct ParallelChardev ParallelChardev;
 
-#define PARALLEL_CHARDEV(obj) \
-    OBJECT_CHECK(ParallelChardev, (obj), TYPE_CHARDEV_PARALLEL)
+DECLARE_INSTANCE_CHECKER(ParallelChardev, PARALLEL_CHARDEV,
+                         TYPE_CHARDEV_PARALLEL)
 
 static int pp_hw_mode(ParallelChardev *s, uint16_t mode)
 {
@@ -185,8 +185,6 @@ struct ParallelChardev {
 };
 typedef struct ParallelChardev ParallelChardev;
 
-#define PARALLEL_CHARDEV(obj)                                   \
-    OBJECT_CHECK(ParallelChardev, (obj), TYPE_CHARDEV_PARALLEL)
 
 static int pp_ioctl(Chardev *chr, int cmd, void *arg)
 {
diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c
index 40b4c44a5df..f95c5127643 100644
--- a/hw/i2c/i2c_mux_pca954x.c
+++ b/hw/i2c/i2c_mux_pca954x.c
@@ -46,8 +46,8 @@ struct Pca954xChannel {
 typedef struct Pca954xChannel Pca954xChannel;
 
 #define TYPE_PCA954X_CHANNEL "pca954x-channel"
-#define PCA954X_CHANNEL(obj) \
-    OBJECT_CHECK(Pca954xChannel, (obj), TYPE_PCA954X_CHANNEL)
+DECLARE_INSTANCE_CHECKER(Pca954xChannel, PCA954X_CHANNEL,
+                         TYPE_PCA954X_CHANNEL)
 
 /*
  * struct Pca954xState - The pca954x state object.
diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c
index b8001fdcf5e..165ab56eeaa 100644
--- a/hw/m68k/mcf5206.c
+++ b/hw/m68k/mcf5206.c
@@ -181,7 +181,8 @@ struct m5206_mbar_state {
 };
 typedef struct m5206_mbar_state m5206_mbar_state;
 
-#define MCF5206_MBAR(obj) OBJECT_CHECK(m5206_mbar_state, (obj), TYPE_MCF5206_MBAR)
+DECLARE_INSTANCE_CHECKER(m5206_mbar_state, MCF5206_MBAR,
+                         TYPE_MCF5206_MBAR)
 
 /* Interrupt controller.  */
 
diff --git a/hw/mem/sparse-mem.c b/hw/mem/sparse-mem.c
index 0d8c0327258..2cc34cc91cf 100644
--- a/hw/mem/sparse-mem.c
+++ b/hw/mem/sparse-mem.c
@@ -21,7 +21,8 @@
 #include "qom/object.h"
 
 typedef struct SparseMemState SparseMemState;
-#define SPARSE_MEM(obj) OBJECT_CHECK(SparseMemState, (obj), TYPE_SPARSE_MEM)
+DECLARE_INSTANCE_CHECKER(SparseMemState, SPARSE_MEM,
+                         TYPE_SPARSE_MEM)
 #define SPARSE_BLOCK_SIZE 0x1000
 
 struct SparseMemState {
diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c
index e4b79e98866..f60273a6e27 100644
--- a/hw/misc/sbsa_ec.c
+++ b/hw/misc/sbsa_ec.c
@@ -24,7 +24,8 @@ struct SECUREECState {
 typedef struct SECUREECState SECUREECState;
 
 #define TYPE_SBSA_EC      "sbsa-ec"
-#define SECURE_EC(obj) OBJECT_CHECK(SECUREECState, (obj), TYPE_SBSA_EC)
+DECLARE_INSTANCE_CHECKER(SECUREECState, SECURE_EC,
+                         TYPE_SBSA_EC)
 
 enum sbsa_ec_powerstates {
     SBSA_EC_CMD_POWEROFF = 0x01,
diff --git a/hw/s390x/vhost-user-fs-ccw.c b/hw/s390x/vhost-user-fs-ccw.c
index 254153860dc..5a72a22d48f 100644
--- a/hw/s390x/vhost-user-fs-ccw.c
+++ b/hw/s390x/vhost-user-fs-ccw.c
@@ -21,8 +21,8 @@ struct VHostUserFSCcw {
 typedef struct VHostUserFSCcw VHostUserFSCcw;
 
 #define TYPE_VHOST_USER_FS_CCW "vhost-user-fs-ccw"
-#define VHOST_USER_FS_CCW(obj) \
-        OBJECT_CHECK(VHostUserFSCcw, (obj), TYPE_VHOST_USER_FS_CCW)
+DECLARE_INSTANCE_CHECKER(VHostUserFSCcw, VHOST_USER_FS_CCW,
+                         TYPE_VHOST_USER_FS_CCW)
 
 
 static Property vhost_user_fs_ccw_properties[] = {
diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
index 80365dbd780..a678174b18c 100644
--- a/hw/sensor/adm1272.c
+++ b/hw/sensor/adm1272.c
@@ -20,7 +20,8 @@
 
 #define TYPE_ADM1272 "adm1272"
 typedef struct ADM1272State ADM1272State;
-#define ADM1272(obj) OBJECT_CHECK(ADM1272State, (obj), TYPE_ADM1272)
+DECLARE_INSTANCE_CHECKER(ADM1272State, ADM1272,
+                         TYPE_ADM1272)
 
 #define ADM1272_RESTART_TIME            0xCC
 #define ADM1272_MFR_PEAK_IOUT           0xD0
diff --git a/hw/sensor/max34451.c b/hw/sensor/max34451.c
index 5d50e46b5ba..864f0bfc736 100644
--- a/hw/sensor/max34451.c
+++ b/hw/sensor/max34451.c
@@ -18,7 +18,8 @@
 
 #define TYPE_MAX34451 "max34451"
 typedef struct MAX34451State MAX34451State;
-#define MAX34451(obj) OBJECT_CHECK(MAX34451State, (obj), TYPE_MAX34451)
+DECLARE_INSTANCE_CHECKER(MAX34451State, MAX34451,
+                         TYPE_MAX34451)
 
 #define MAX34451_MFR_MODE               0xD1
 #define MAX34451_MFR_PSEN_CONFIG        0xD2
diff --git a/hw/usb/u2f-emulated.c b/hw/usb/u2f-emulated.c
index 7c092e7a93f..f35865d42dd 100644
--- a/hw/usb/u2f-emulated.c
+++ b/hw/usb/u2f-emulated.c
@@ -99,8 +99,8 @@ struct U2FEmulatedState {
 };
 
 #define TYPE_U2F_EMULATED "u2f-emulated"
-#define EMULATED_U2F_KEY(obj) \
-    OBJECT_CHECK(U2FEmulatedState, (obj), TYPE_U2F_EMULATED)
+DECLARE_INSTANCE_CHECKER(U2FEmulatedState, EMULATED_U2F_KEY,
+                         TYPE_U2F_EMULATED)
 
 static void u2f_emulated_reset(U2FEmulatedState *key)
 {
diff --git a/hw/usb/u2f-passthru.c b/hw/usb/u2f-passthru.c
index 954b8aa3c9b..7daaac19844 100644
--- a/hw/usb/u2f-passthru.c
+++ b/hw/usb/u2f-passthru.c
@@ -77,8 +77,8 @@ struct U2FPassthruState {
 };
 
 #define TYPE_U2F_PASSTHRU "u2f-passthru"
-#define PASSTHRU_U2F_KEY(obj) \
-    OBJECT_CHECK(U2FPassthruState, (obj), TYPE_U2F_PASSTHRU)
+DECLARE_INSTANCE_CHECKER(U2FPassthruState, PASSTHRU_U2F_KEY,
+                         TYPE_U2F_PASSTHRU)
 
 /* Init packet sizes */
 #define PACKET_INIT_HEADER_SIZE 7
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 08/12] npcm7xx_clk: Use DECLARE_INSTANCE_CHECKER
  2021-08-06 21:11 [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Eduardo Habkost
                   ` (6 preceding siblings ...)
  2021-08-06 21:11   ` Eduardo Habkost
@ 2021-08-06 21:11 ` Eduardo Habkost
  2021-08-07  7:59   ` Philippe Mathieu-Daudé
  2021-08-06 21:11 ` [PATCH for-6.2 09/12] npcm7xx_otp: Use DECLARE_CLASS_CHECKERS Eduardo Habkost
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, qemu-arm, Daniel P. Berrange, Havard Skinnemoen,
	Tyrone Ting

Use DECLARE_INSTANCE_CHECKER instead of defining the
NPCM7XX_CLOCK_PLL, NPCM7XX_CLOCK_SEL, and NPCM7XX_CLOCK_DIVIDER
macros manually.

These changes had to be done manually because the codeconverter
script isn't smart enough to figure out that the typedefs exist
in a separate header.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Havard Skinnemoen <hskinnemoen@google.com>
Cc: Tyrone Ting <kfting@nuvoton.com>
Cc: qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org
---
 hw/misc/npcm7xx_clk.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c
index da6b14c545d..5247acfeb5a 100644
--- a/hw/misc/npcm7xx_clk.c
+++ b/hw/misc/npcm7xx_clk.c
@@ -110,14 +110,14 @@ static const uint32_t cold_reset_values[NPCM7XX_CLK_NR_REGS] = {
 /* Clock converter functions */
 
 #define TYPE_NPCM7XX_CLOCK_PLL "npcm7xx-clock-pll"
-#define NPCM7XX_CLOCK_PLL(obj) OBJECT_CHECK(NPCM7xxClockPLLState, \
-        (obj), TYPE_NPCM7XX_CLOCK_PLL)
+DECLARE_INSTANCE_CHECKER(NPCM7xxClockPLLState, NPCM7XX_CLOCK_PLL,
+                         TYPE_NPCM7XX_CLOCK_PLL)
 #define TYPE_NPCM7XX_CLOCK_SEL "npcm7xx-clock-sel"
-#define NPCM7XX_CLOCK_SEL(obj) OBJECT_CHECK(NPCM7xxClockSELState, \
-        (obj), TYPE_NPCM7XX_CLOCK_SEL)
+DECLARE_INSTANCE_CHECKER(NPCM7xxClockSELState, NPCM7XX_CLOCK_SEL,
+                         TYPE_NPCM7XX_CLOCK_SEL)
 #define TYPE_NPCM7XX_CLOCK_DIVIDER "npcm7xx-clock-divider"
-#define NPCM7XX_CLOCK_DIVIDER(obj) OBJECT_CHECK(NPCM7xxClockDividerState, \
-        (obj), TYPE_NPCM7XX_CLOCK_DIVIDER)
+DECLARE_INSTANCE_CHECKER(NPCM7xxClockDividerState, NPCM7XX_CLOCK_DIVIDER,
+                         TYPE_NPCM7XX_CLOCK_DIVIDER)
 
 static void npcm7xx_clk_update_pll(void *opaque)
 {
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 09/12] npcm7xx_otp: Use DECLARE_CLASS_CHECKERS
  2021-08-06 21:11 [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Eduardo Habkost
                   ` (7 preceding siblings ...)
  2021-08-06 21:11 ` [PATCH for-6.2 08/12] npcm7xx_clk: Use DECLARE_INSTANCE_CHECKER Eduardo Habkost
@ 2021-08-06 21:11 ` Eduardo Habkost
  2021-08-07  8:00   ` Philippe Mathieu-Daudé
  2021-08-06 21:11 ` [PATCH for-6.2 10/12] [automated] Use DECLARE_OBJ_CHECKERS when possible Eduardo Habkost
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, qemu-arm, Daniel P. Berrange, Havard Skinnemoen,
	Tyrone Ting

Use DECLARE_CLASS_CHECKERS instead of defining the
NPCM7XX_OTP_CLASS and NPCM7XX_OTP_GET_CLASS macros manually.

These changes had to be done manually because the typedef and the
existing macro definitions were in different files.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Havard Skinnemoen <hskinnemoen@google.com>
Cc: Tyrone Ting <kfting@nuvoton.com>
Cc: qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org
---
 include/hw/nvram/npcm7xx_otp.h | 5 +++--
 hw/nvram/npcm7xx_otp.c         | 5 -----
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/include/hw/nvram/npcm7xx_otp.h b/include/hw/nvram/npcm7xx_otp.h
index 4cfc6577e87..0a3ebb091d5 100644
--- a/include/hw/nvram/npcm7xx_otp.h
+++ b/include/hw/nvram/npcm7xx_otp.h
@@ -60,12 +60,13 @@ typedef struct NPCM7xxOTPState NPCM7xxOTPState;
 #define TYPE_NPCM7XX_OTP "npcm7xx-otp"
 DECLARE_INSTANCE_CHECKER(NPCM7xxOTPState, NPCM7XX_OTP,
                          TYPE_NPCM7XX_OTP)
+typedef struct NPCM7xxOTPClass NPCM7xxOTPClass;
+DECLARE_CLASS_CHECKERS(NPCM7xxOTPClass, NPCM7XX_OTP,
+                       TYPE_NPCM7XX_OTP)
 
 #define TYPE_NPCM7XX_KEY_STORAGE "npcm7xx-key-storage"
 #define TYPE_NPCM7XX_FUSE_ARRAY "npcm7xx-fuse-array"
 
-typedef struct NPCM7xxOTPClass NPCM7xxOTPClass;
-
 /**
  * npcm7xx_otp_array_write - ECC encode and write data to OTP array.
  * @s: OTP module.
diff --git a/hw/nvram/npcm7xx_otp.c b/hw/nvram/npcm7xx_otp.c
index 52b9482419e..61085c5228b 100644
--- a/hw/nvram/npcm7xx_otp.c
+++ b/hw/nvram/npcm7xx_otp.c
@@ -73,11 +73,6 @@ struct NPCM7xxOTPClass {
     const MemoryRegionOps *mmio_ops;
 };
 
-#define NPCM7XX_OTP_CLASS(klass) \
-    OBJECT_CLASS_CHECK(NPCM7xxOTPClass, (klass), TYPE_NPCM7XX_OTP)
-#define NPCM7XX_OTP_GET_CLASS(obj) \
-    OBJECT_GET_CLASS(NPCM7xxOTPClass, (obj), TYPE_NPCM7XX_OTP)
-
 static uint8_t ecc_encode_nibble(uint8_t n)
 {
     uint8_t result = n;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 10/12] [automated] Use DECLARE_OBJ_CHECKERS when possible
  2021-08-06 21:11 [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Eduardo Habkost
                   ` (8 preceding siblings ...)
  2021-08-06 21:11 ` [PATCH for-6.2 09/12] npcm7xx_otp: Use DECLARE_CLASS_CHECKERS Eduardo Habkost
@ 2021-08-06 21:11 ` Eduardo Habkost
  2021-08-06 21:11 ` [PATCH for-6.2 11/12] [automated] Use OBJECT_DECLARE_TYPE " Eduardo Habkost
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, qemu-arm, Daniel P. Berrange, Havard Skinnemoen,
	Tyrone Ting

This automatically convert
DECLARE_INSTANCE_CHECKER/DECLARE_CLASS_CHECKER pairs to
DECLARE_OBJ_CHECKERS.

Generated using:

  $ ./scripts/codeconverter/converter.py -i \
    --pattern=AddDeclareObjCheckers $(git grep -l '' -- '*.[ch]')

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Havard Skinnemoen <hskinnemoen@google.com>
Cc: Tyrone Ting <kfting@nuvoton.com>
Cc: qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org
---
 include/hw/nvram/npcm7xx_otp.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/include/hw/nvram/npcm7xx_otp.h b/include/hw/nvram/npcm7xx_otp.h
index 0a3ebb091d5..377cf462090 100644
--- a/include/hw/nvram/npcm7xx_otp.h
+++ b/include/hw/nvram/npcm7xx_otp.h
@@ -58,11 +58,9 @@ struct NPCM7xxOTPState {
 typedef struct NPCM7xxOTPState NPCM7xxOTPState;
 
 #define TYPE_NPCM7XX_OTP "npcm7xx-otp"
-DECLARE_INSTANCE_CHECKER(NPCM7xxOTPState, NPCM7XX_OTP,
-                         TYPE_NPCM7XX_OTP)
 typedef struct NPCM7xxOTPClass NPCM7xxOTPClass;
-DECLARE_CLASS_CHECKERS(NPCM7xxOTPClass, NPCM7XX_OTP,
-                       TYPE_NPCM7XX_OTP)
+DECLARE_OBJ_CHECKERS(NPCM7xxOTPState, NPCM7xxOTPClass,
+                     NPCM7XX_OTP, TYPE_NPCM7XX_OTP)
 
 #define TYPE_NPCM7XX_KEY_STORAGE "npcm7xx-key-storage"
 #define TYPE_NPCM7XX_FUSE_ARRAY "npcm7xx-fuse-array"
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 11/12] [automated] Use OBJECT_DECLARE_TYPE when possible
  2021-08-06 21:11 [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Eduardo Habkost
                   ` (9 preceding siblings ...)
  2021-08-06 21:11 ` [PATCH for-6.2 10/12] [automated] Use DECLARE_OBJ_CHECKERS when possible Eduardo Habkost
@ 2021-08-06 21:11 ` Eduardo Habkost
  2021-08-07  8:02   ` Philippe Mathieu-Daudé
  2021-08-06 21:11   ` Eduardo Habkost
  2021-08-07  8:15 ` [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Philippe Mathieu-Daudé
  12 siblings, 1 reply; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Daniel P. Berrange, qemu-block, Richard Henderson,
	Greg Kurz, Max Reitz, Cédric Le Goater, qemu-ppc,
	Gerd Hoffmann, Paolo Bonzini, John Snow, David Gibson

Replace typedefs + DECLARE_OBJ_CHECKERS with equivalent
OBJECT_DECLARE_TYPE macro.

Generated using:

$ ./scripts/codeconverter/converter.py -i \
  --pattern=AddObjectDeclareType $(git grep -l '' -- '*.[ch]')

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: John Snow <jsnow@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Greg Kurz <groug@kaod.org>
Cc: "Cédric Le Goater" <clg@kaod.org>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org
---
 hw/usb/u2f.h                | 6 +-----
 include/crypto/tlscreds.h   | 5 +----
 include/hw/ppc/spapr_drc.h  | 5 +----
 include/hw/ppc/spapr_xive.h | 5 +----
 include/qemu/accel.h        | 4 +---
 hw/block/fdc-sysbus.c       | 5 +----
 6 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/hw/usb/u2f.h b/hw/usb/u2f.h
index 5767ca8fac9..e6e3ead40f1 100644
--- a/hw/usb/u2f.h
+++ b/hw/usb/u2f.h
@@ -32,13 +32,10 @@
 #define U2FHID_PACKET_SIZE 64
 #define U2FHID_PENDING_IN_NUM 32
 
-typedef struct U2FKeyState U2FKeyState;
 typedef struct U2FKeyInfo U2FKeyInfo;
 
 #define TYPE_U2F_KEY "u2f-key"
-typedef struct U2FKeyClass U2FKeyClass;
-DECLARE_OBJ_CHECKERS(U2FKeyState, U2FKeyClass,
-                     U2F_KEY, TYPE_U2F_KEY)
+OBJECT_DECLARE_TYPE(U2FKeyState, U2FKeyClass, U2F_KEY)
 
 /*
  * Callbacks to be used by the U2F key base device (i.e. hw/u2f.c)
@@ -69,7 +66,6 @@ struct U2FKeyState {
     uint8_t pending_in_end;
     uint8_t pending_in_num;
 };
-typedef struct U2FKeyState U2FKeyState;
 
 /*
  * API to be used by the U2F key device variants (i.e. hw/u2f-*.c)
diff --git a/include/crypto/tlscreds.h b/include/crypto/tlscreds.h
index 2a8a8570109..617979a3986 100644
--- a/include/crypto/tlscreds.h
+++ b/include/crypto/tlscreds.h
@@ -25,10 +25,7 @@
 #include "qom/object.h"
 
 #define TYPE_QCRYPTO_TLS_CREDS "tls-creds"
-typedef struct QCryptoTLSCreds QCryptoTLSCreds;
-typedef struct QCryptoTLSCredsClass QCryptoTLSCredsClass;
-DECLARE_OBJ_CHECKERS(QCryptoTLSCreds, QCryptoTLSCredsClass, QCRYPTO_TLS_CREDS,
-                     TYPE_QCRYPTO_TLS_CREDS)
+OBJECT_DECLARE_TYPE(QCryptoTLSCreds, QCryptoTLSCredsClass, QCRYPTO_TLS_CREDS)
 
 
 #define QCRYPTO_TLS_CREDS_DH_PARAMS "dh-params.pem"
diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h
index 540439812f0..ff876fd74ca 100644
--- a/include/hw/ppc/spapr_drc.h
+++ b/include/hw/ppc/spapr_drc.h
@@ -20,10 +20,7 @@
 #include "qapi/error.h"
 
 #define TYPE_SPAPR_DR_CONNECTOR "spapr-dr-connector"
-typedef struct SpaprDrc SpaprDrc;
-typedef struct SpaprDrcClass SpaprDrcClass;
-DECLARE_OBJ_CHECKERS(SpaprDrc, SpaprDrcClass,
-                     SPAPR_DR_CONNECTOR, TYPE_SPAPR_DR_CONNECTOR)
+OBJECT_DECLARE_TYPE(SpaprDrc, SpaprDrcClass, SPAPR_DR_CONNECTOR)
 
 #define TYPE_SPAPR_DRC_PHYSICAL "spapr-drc-physical"
 typedef struct SpaprDrcPhysical SpaprDrcPhysical;
diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h
index 333095c3fd9..9e7c46c801f 100644
--- a/include/hw/ppc/spapr_xive.h
+++ b/include/hw/ppc/spapr_xive.h
@@ -15,10 +15,7 @@
 #include "qom/object.h"
 
 #define TYPE_SPAPR_XIVE "spapr-xive"
-typedef struct SpaprXive SpaprXive;
-typedef struct SpaprXiveClass SpaprXiveClass;
-DECLARE_OBJ_CHECKERS(SpaprXive, SpaprXiveClass,
-                     SPAPR_XIVE, TYPE_SPAPR_XIVE)
+OBJECT_DECLARE_TYPE(SpaprXive, SpaprXiveClass, SPAPR_XIVE)
 
 struct SpaprXive {
     XiveRouter    parent;
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 8dc4ccc39ef..1b7696f9fbc 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -54,15 +54,13 @@ struct AccelClass {
      */
     GPtrArray *compat_props;
 };
-typedef struct AccelClass AccelClass;
 
 #define TYPE_ACCEL_BASE "accel"
 
 #define ACCEL_CLASS_SUFFIX  "-" TYPE_ACCEL_BASE
 #define ACCEL_CLASS_NAME(a) (a ACCEL_CLASS_SUFFIX)
 
-DECLARE_OBJ_CHECKERS(AccelState, AccelClass,
-                     ACCEL_BASE, TYPE_ACCEL_BASE)
+OBJECT_DECLARE_TYPE(AccelState, AccelClass, ACCEL_BASE)
 
 AccelClass *accel_find(const char *opt_name);
 AccelState *current_accel(void);
diff --git a/hw/block/fdc-sysbus.c b/hw/block/fdc-sysbus.c
index 57fc8773f12..ecce27db34e 100644
--- a/hw/block/fdc-sysbus.c
+++ b/hw/block/fdc-sysbus.c
@@ -33,10 +33,7 @@
 #include "trace.h"
 
 #define TYPE_SYSBUS_FDC "base-sysbus-fdc"
-typedef struct FDCtrlSysBusClass FDCtrlSysBusClass;
-typedef struct FDCtrlSysBus FDCtrlSysBus;
-DECLARE_OBJ_CHECKERS(FDCtrlSysBus, FDCtrlSysBusClass,
-                     SYSBUS_FDC, TYPE_SYSBUS_FDC)
+OBJECT_DECLARE_TYPE(FDCtrlSysBus, FDCtrlSysBusClass, SYSBUS_FDC)
 
 struct FDCtrlSysBusClass {
     /*< private >*/
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 12/12] [automated] Use OBJECT_DECLARE_SIMPLE_TYPE when possible
  2021-08-06 21:11 [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Eduardo Habkost
@ 2021-08-06 21:11   ` Eduardo Habkost
  2021-08-06 21:11 ` [PATCH for-6.2 02/12] qom: Use DEVICE_*CLASS instead of OBJECT_*CLASS Eduardo Habkost
                     ` (11 subsequent siblings)
  12 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Michael S. Tsirkin, Andrew Jeffery, Jason Wang,
	Bin Meng, Laurent Vivier, Vijai Kumar K, Alistair Francis,
	Gerd Hoffmann, Klaus Jensen, Edgar E. Iglesias, Vikram Garhwal,
	Paul Burton, David Hildenbrand, Havard Skinnemoen, Halil Pasic,
	Christian Borntraeger, Joel Stanley, qemu-ppc, Pavel Pisa,
	Aleksandar Rikalo, Richard Henderson, Greg Kurz, qemu-s390x,
	qemu-arm, Cédric Le Goater, Keith Busch, qemu-riscv,
	David Gibson, Daniel P. Berrange, qemu-block, Francisco Iglesias,
	Thomas Huth, Bastian Koppelmann, Cornelia Huck,
	Philippe Mathieu-Daudé,
	Andrew Baumann, Tyrone Ting, Palmer Dabbelt, Paolo Bonzini,
	Aurelien Jarno

Replace typedef + DECLARE_INSTANCE_CHECKER with
equivalent OBJECT_DECLARE_SIMPLE_TYPE macro.

Generated using:

$ ./scripts/codeconverter/converter.py -i \
  --pattern=AddObjectDeclareSimpleType $(git grep -l '' -- '*.[ch]')

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Thomas Huth <huth@tuxfamily.org>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Havard Skinnemoen <hskinnemoen@google.com>
Cc: Tyrone Ting <kfting@nuvoton.com>
Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Klaus Jensen <its@irrelevant.dk>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: Halil Pasic <pasic@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Vijai Kumar K <vijai@behindbytes.com>
Cc: Alistair Francis <Alistair.Francis@wdc.com>
Cc: Bin Meng <bin.meng@windriver.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Laurent Vivier <laurent@vivier.eu>
Cc: "Cédric Le Goater" <clg@kaod.org>
Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Greg Kurz <groug@kaod.org>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org
Cc: qemu-block@nongnu.org
Cc: qemu-s390x@nongnu.org
Cc: qemu-riscv@nongnu.org
Cc: qemu-ppc@nongnu.org
---
 hw/nvme/nvme.h                              | 10 +++-------
 hw/usb/hcd-xhci-pci.h                       |  4 +---
 hw/usb/hcd-xhci-sysbus.h                    |  4 +---
 include/hw/adc/npcm7xx_adc.h                |  4 +---
 include/hw/char/shakti_uart.h               |  4 +---
 include/hw/dma/sifive_pdma.h                |  4 +---
 include/hw/dma/xlnx_csu_dma.h               |  4 +---
 include/hw/gpio/sifive_gpio.h               |  4 +---
 include/hw/intc/m68k_irqc.h                 |  4 +---
 include/hw/intc/sifive_clint.h              |  4 +---
 include/hw/intc/sifive_plic.h               |  4 +---
 include/hw/misc/aspeed_lpc.h                |  4 +---
 include/hw/misc/bcm2835_cprman_internals.h  | 12 ++++--------
 include/hw/misc/led.h                       |  3 +--
 include/hw/misc/mchp_pfsoc_dmc.h            |  8 ++------
 include/hw/misc/mchp_pfsoc_ioscb.h          |  4 +---
 include/hw/misc/mchp_pfsoc_sysreg.h         |  4 +---
 include/hw/misc/npcm7xx_clk.h               |  3 +--
 include/hw/misc/npcm7xx_gcr.h               |  4 +---
 include/hw/misc/npcm7xx_mft.h               |  4 +---
 include/hw/misc/npcm7xx_pwm.h               |  3 +--
 include/hw/misc/sifive_e_prci.h             |  4 +---
 include/hw/misc/sifive_test.h               |  4 +---
 include/hw/misc/sifive_u_otp.h              |  4 +---
 include/hw/misc/sifive_u_prci.h             |  4 +---
 include/hw/misc/xlnx-versal-xramc.h         |  4 +---
 include/hw/net/npcm7xx_emc.h                |  4 +---
 include/hw/net/xlnx-zynqmp-can.h            |  4 +---
 include/hw/ppc/spapr_drc.h                  |  4 +---
 include/hw/register.h                       |  3 +--
 include/hw/riscv/microchip_pfsoc.h          |  4 +---
 include/hw/riscv/shakti_c.h                 |  8 ++------
 include/hw/riscv/sifive_e.h                 |  4 +---
 include/hw/riscv/sifive_u.h                 |  4 +---
 include/hw/sd/cadence_sdhci.h               |  4 +---
 include/hw/ssi/sifive_spi.h                 |  4 +---
 include/hw/timer/npcm7xx_timer.h            |  3 +--
 include/hw/tricore/tricore_testdevice.h     |  4 +---
 include/hw/usb/hcd-dwc3.h                   |  4 +---
 include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  4 +---
 hw/m68k/mcf5206.c                           |  4 +---
 hw/mips/boston.c                            |  4 +---
 hw/misc/npcm7xx_clk.c                       |  9 +++------
 hw/net/can/ctucan_pci.c                     |  4 +---
 hw/s390x/vhost-user-fs-ccw.c                |  4 +---
 hw/sensor/adm1272.c                         |  4 +---
 hw/sensor/max34451.c                        |  4 +---
 47 files changed, 56 insertions(+), 154 deletions(-)

diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
index c4c43da5c17..a9ee5c4f1de 100644
--- a/hw/nvme/nvme.h
+++ b/hw/nvme/nvme.h
@@ -42,9 +42,7 @@ typedef struct NvmeBus {
 } NvmeBus;
 
 #define TYPE_NVME_SUBSYS "nvme-subsys"
-typedef struct NvmeSubsystem NvmeSubsystem;
-DECLARE_INSTANCE_CHECKER(NvmeSubsystem, NVME_SUBSYS,
-                         TYPE_NVME_SUBSYS)
+OBJECT_DECLARE_SIMPLE_TYPE(NvmeSubsystem, NVME_SUBSYS)
 
 struct NvmeSubsystem {
     DeviceState parent_obj;
@@ -83,8 +81,7 @@ static inline NvmeNamespace *nvme_subsys_ns(NvmeSubsystem *subsys,
 }
 
 #define TYPE_NVME_NS "nvme-ns"
-DECLARE_INSTANCE_CHECKER(NvmeNamespace, NVME_NS,
-                         TYPE_NVME_NS)
+OBJECT_DECLARE_SIMPLE_TYPE(NvmeNamespace, NVME_NS)
 
 typedef struct NvmeZone {
     NvmeZoneDescr   d;
@@ -377,8 +374,7 @@ typedef struct NvmeCQueue {
 } NvmeCQueue;
 
 #define TYPE_NVME "nvme"
-DECLARE_INSTANCE_CHECKER(NvmeCtrl, NVME,
-                         TYPE_NVME)
+OBJECT_DECLARE_SIMPLE_TYPE(NvmeCtrl, NVME)
 
 typedef struct NvmeParams {
     char     *serial;
diff --git a/hw/usb/hcd-xhci-pci.h b/hw/usb/hcd-xhci-pci.h
index d83aad82e04..2ad2eeefb7f 100644
--- a/hw/usb/hcd-xhci-pci.h
+++ b/hw/usb/hcd-xhci-pci.h
@@ -29,9 +29,7 @@
 #include "qom/object.h"
 
 #define TYPE_XHCI_PCI "pci-xhci"
-typedef struct XHCIPciState XHCIPciState;
-DECLARE_INSTANCE_CHECKER(XHCIPciState, XHCI_PCI,
-                         TYPE_XHCI_PCI)
+OBJECT_DECLARE_SIMPLE_TYPE(XHCIPciState, XHCI_PCI)
 
 
 struct XHCIPciState {
diff --git a/hw/usb/hcd-xhci-sysbus.h b/hw/usb/hcd-xhci-sysbus.h
index 561e5144e05..512d4a40e19 100644
--- a/hw/usb/hcd-xhci-sysbus.h
+++ b/hw/usb/hcd-xhci-sysbus.h
@@ -16,9 +16,7 @@
 #include "hw/sysbus.h"
 #include "qom/object.h"
 
-typedef struct XHCISysbusState XHCISysbusState;
-DECLARE_INSTANCE_CHECKER(XHCISysbusState, XHCI_SYSBUS,
-                         TYPE_XHCI_SYSBUS)
+OBJECT_DECLARE_SIMPLE_TYPE(XHCISysbusState, XHCI_SYSBUS)
 
 
 struct XHCISysbusState {
diff --git a/include/hw/adc/npcm7xx_adc.h b/include/hw/adc/npcm7xx_adc.h
index b694adece6a..08992229f09 100644
--- a/include/hw/adc/npcm7xx_adc.h
+++ b/include/hw/adc/npcm7xx_adc.h
@@ -62,10 +62,8 @@ struct NPCM7xxADCState {
 
     uint16_t     calibration_r_values[NPCM7XX_ADC_NUM_CALIB];
 };
-typedef struct NPCM7xxADCState NPCM7xxADCState;
 
 #define TYPE_NPCM7XX_ADC "npcm7xx-adc"
-DECLARE_INSTANCE_CHECKER(NPCM7xxADCState, NPCM7XX_ADC,
-                         TYPE_NPCM7XX_ADC)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxADCState, NPCM7XX_ADC)
 
 #endif /* NPCM7XX_ADC_H */
diff --git a/include/hw/char/shakti_uart.h b/include/hw/char/shakti_uart.h
index 9bec3062af0..2c305562e78 100644
--- a/include/hw/char/shakti_uart.h
+++ b/include/hw/char/shakti_uart.h
@@ -49,9 +49,7 @@
 #define SHAKTI_UART_CONTROL_DEFAULT 0x0100
 
 #define TYPE_SHAKTI_UART "shakti-uart"
-typedef struct ShaktiUartState ShaktiUartState;
-DECLARE_INSTANCE_CHECKER(ShaktiUartState, SHAKTI_UART,
-                         TYPE_SHAKTI_UART)
+OBJECT_DECLARE_SIMPLE_TYPE(ShaktiUartState, SHAKTI_UART)
 
 struct ShaktiUartState {
     /* <private> */
diff --git a/include/hw/dma/sifive_pdma.h b/include/hw/dma/sifive_pdma.h
index d81526cfc2f..f1fb9093358 100644
--- a/include/hw/dma/sifive_pdma.h
+++ b/include/hw/dma/sifive_pdma.h
@@ -49,11 +49,9 @@ struct SiFivePDMAState {
 
     struct sifive_pdma_chan chan[SIFIVE_PDMA_CHANS];
 };
-typedef struct SiFivePDMAState SiFivePDMAState;
 
 #define TYPE_SIFIVE_PDMA    "sifive.pdma"
 
-DECLARE_INSTANCE_CHECKER(SiFivePDMAState, SIFIVE_PDMA,
-                         TYPE_SIFIVE_PDMA)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFivePDMAState, SIFIVE_PDMA)
 
 #endif /* SIFIVE_PDMA_H */
diff --git a/include/hw/dma/xlnx_csu_dma.h b/include/hw/dma/xlnx_csu_dma.h
index 36433d189ac..1ef9f36f89d 100644
--- a/include/hw/dma/xlnx_csu_dma.h
+++ b/include/hw/dma/xlnx_csu_dma.h
@@ -46,9 +46,7 @@ struct XlnxCSUDMA {
     uint32_t regs[XLNX_CSU_DMA_R_MAX];
     RegisterInfo regs_info[XLNX_CSU_DMA_R_MAX];
 };
-typedef struct XlnxCSUDMA XlnxCSUDMA;
 
-DECLARE_INSTANCE_CHECKER(XlnxCSUDMA, XLNX_CSU_DMA,
-                         TYPE_XLNX_CSU_DMA)
+OBJECT_DECLARE_SIMPLE_TYPE(XlnxCSUDMA, XLNX_CSU_DMA)
 
 #endif
diff --git a/include/hw/gpio/sifive_gpio.h b/include/hw/gpio/sifive_gpio.h
index fc53785c9d0..6c44e33fbe3 100644
--- a/include/hw/gpio/sifive_gpio.h
+++ b/include/hw/gpio/sifive_gpio.h
@@ -18,9 +18,7 @@
 #include "qom/object.h"
 
 #define TYPE_SIFIVE_GPIO "sifive_soc.gpio"
-typedef struct SIFIVEGPIOState SIFIVEGPIOState;
-DECLARE_INSTANCE_CHECKER(SIFIVEGPIOState, SIFIVE_GPIO,
-                         TYPE_SIFIVE_GPIO)
+OBJECT_DECLARE_SIMPLE_TYPE(SIFIVEGPIOState, SIFIVE_GPIO)
 
 #define SIFIVE_GPIO_PINS 32
 
diff --git a/include/hw/intc/m68k_irqc.h b/include/hw/intc/m68k_irqc.h
index 843cec3c666..4cb19918134 100644
--- a/include/hw/intc/m68k_irqc.h
+++ b/include/hw/intc/m68k_irqc.h
@@ -14,9 +14,7 @@
 #include "qom/object.h"
 
 #define TYPE_M68K_IRQC "m68k-irq-controller"
-typedef struct M68KIRQCState M68KIRQCState;
-DECLARE_INSTANCE_CHECKER(M68KIRQCState, M68K_IRQC,
-                         TYPE_M68K_IRQC)
+OBJECT_DECLARE_SIMPLE_TYPE(M68KIRQCState, M68K_IRQC)
 
 #define M68K_IRQC_AUTOVECTOR_BASE 25
 
diff --git a/include/hw/intc/sifive_clint.h b/include/hw/intc/sifive_clint.h
index c7df3f7f2b3..349f5ad14dd 100644
--- a/include/hw/intc/sifive_clint.h
+++ b/include/hw/intc/sifive_clint.h
@@ -25,9 +25,7 @@
 
 #define TYPE_SIFIVE_CLINT "riscv.sifive.clint"
 
-typedef struct SiFiveCLINTState SiFiveCLINTState;
-DECLARE_INSTANCE_CHECKER(SiFiveCLINTState, SIFIVE_CLINT,
-                         TYPE_SIFIVE_CLINT)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveCLINTState, SIFIVE_CLINT)
 
 struct SiFiveCLINTState {
     /*< private >*/
diff --git a/include/hw/intc/sifive_plic.h b/include/hw/intc/sifive_plic.h
index 1e451a270c7..0cdb7d584c9 100644
--- a/include/hw/intc/sifive_plic.h
+++ b/include/hw/intc/sifive_plic.h
@@ -26,9 +26,7 @@
 
 #define TYPE_SIFIVE_PLIC "riscv.sifive.plic"
 
-typedef struct SiFivePLICState SiFivePLICState;
-DECLARE_INSTANCE_CHECKER(SiFivePLICState, SIFIVE_PLIC,
-                         TYPE_SIFIVE_PLIC)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFivePLICState, SIFIVE_PLIC)
 
 typedef enum PLICMode {
     PLICMode_U,
diff --git a/include/hw/misc/aspeed_lpc.h b/include/hw/misc/aspeed_lpc.h
index d8e5af6296b..dd6a63e6a53 100644
--- a/include/hw/misc/aspeed_lpc.h
+++ b/include/hw/misc/aspeed_lpc.h
@@ -16,9 +16,7 @@
 #include "qom/object.h"
 
 #define TYPE_ASPEED_LPC "aspeed.lpc"
-typedef struct AspeedLPCState AspeedLPCState;
-DECLARE_INSTANCE_CHECKER(AspeedLPCState, ASPEED_LPC,
-                         TYPE_ASPEED_LPC)
+OBJECT_DECLARE_SIMPLE_TYPE(AspeedLPCState, ASPEED_LPC)
 
 #define ASPEED_LPC_NR_REGS      (0x260 >> 2)
 
diff --git a/include/hw/misc/bcm2835_cprman_internals.h b/include/hw/misc/bcm2835_cprman_internals.h
index f5410580bff..db297e5b18c 100644
--- a/include/hw/misc/bcm2835_cprman_internals.h
+++ b/include/hw/misc/bcm2835_cprman_internals.h
@@ -18,14 +18,10 @@
 #define TYPE_CPRMAN_CLOCK_MUX "bcm2835-cprman-clock-mux"
 #define TYPE_CPRMAN_DSI0HSCK_MUX "bcm2835-cprman-dsi0hsck-mux"
 
-DECLARE_INSTANCE_CHECKER(CprmanPllState, CPRMAN_PLL,
-                         TYPE_CPRMAN_PLL)
-DECLARE_INSTANCE_CHECKER(CprmanPllChannelState, CPRMAN_PLL_CHANNEL,
-                         TYPE_CPRMAN_PLL_CHANNEL)
-DECLARE_INSTANCE_CHECKER(CprmanClockMuxState, CPRMAN_CLOCK_MUX,
-                         TYPE_CPRMAN_CLOCK_MUX)
-DECLARE_INSTANCE_CHECKER(CprmanDsi0HsckMuxState, CPRMAN_DSI0HSCK_MUX,
-                         TYPE_CPRMAN_DSI0HSCK_MUX)
+OBJECT_DECLARE_SIMPLE_TYPE(CprmanPllState, CPRMAN_PLL)
+OBJECT_DECLARE_SIMPLE_TYPE(CprmanPllChannelState, CPRMAN_PLL_CHANNEL)
+OBJECT_DECLARE_SIMPLE_TYPE(CprmanClockMuxState, CPRMAN_CLOCK_MUX)
+OBJECT_DECLARE_SIMPLE_TYPE(CprmanDsi0HsckMuxState, CPRMAN_DSI0HSCK_MUX)
 
 /* Register map */
 
diff --git a/include/hw/misc/led.h b/include/hw/misc/led.h
index 29c08795708..b4a090db3bf 100644
--- a/include/hw/misc/led.h
+++ b/include/hw/misc/led.h
@@ -51,8 +51,7 @@ struct LEDState {
      */
     bool gpio_active_high;
 };
-typedef struct LEDState LEDState;
-DECLARE_INSTANCE_CHECKER(LEDState, LED, TYPE_LED)
+OBJECT_DECLARE_SIMPLE_TYPE(LEDState, LED)
 
 /**
  * led_set_intensity: Set the intensity of a LED device
diff --git a/include/hw/misc/mchp_pfsoc_dmc.h b/include/hw/misc/mchp_pfsoc_dmc.h
index 3a0e3bbba76..ece1dfe6954 100644
--- a/include/hw/misc/mchp_pfsoc_dmc.h
+++ b/include/hw/misc/mchp_pfsoc_dmc.h
@@ -32,12 +32,10 @@ struct MchpPfSoCDdrSgmiiPhyState {
     SysBusDevice parent;
     MemoryRegion sgmii_phy;
 };
-typedef struct MchpPfSoCDdrSgmiiPhyState MchpPfSoCDdrSgmiiPhyState;
 
 #define TYPE_MCHP_PFSOC_DDR_SGMII_PHY "mchp.pfsoc.ddr_sgmii_phy"
 
-DECLARE_INSTANCE_CHECKER(MchpPfSoCDdrSgmiiPhyState, MCHP_PFSOC_DDR_SGMII_PHY,
-                         TYPE_MCHP_PFSOC_DDR_SGMII_PHY)
+OBJECT_DECLARE_SIMPLE_TYPE(MchpPfSoCDdrSgmiiPhyState, MCHP_PFSOC_DDR_SGMII_PHY)
 
 /* DDR CFG module */
 
@@ -47,11 +45,9 @@ struct MchpPfSoCDdrCfgState {
     SysBusDevice parent;
     MemoryRegion cfg;
 };
-typedef struct MchpPfSoCDdrCfgState MchpPfSoCDdrCfgState;
 
 #define TYPE_MCHP_PFSOC_DDR_CFG "mchp.pfsoc.ddr_cfg"
 
-DECLARE_INSTANCE_CHECKER(MchpPfSoCDdrCfgState, MCHP_PFSOC_DDR_CFG,
-                         TYPE_MCHP_PFSOC_DDR_CFG)
+OBJECT_DECLARE_SIMPLE_TYPE(MchpPfSoCDdrCfgState, MCHP_PFSOC_DDR_CFG)
 
 #endif /* MCHP_PFSOC_DMC_H */
diff --git a/include/hw/misc/mchp_pfsoc_ioscb.h b/include/hw/misc/mchp_pfsoc_ioscb.h
index 18ef5ff1739..d6d8e18b2c5 100644
--- a/include/hw/misc/mchp_pfsoc_ioscb.h
+++ b/include/hw/misc/mchp_pfsoc_ioscb.h
@@ -42,11 +42,9 @@ struct MchpPfSoCIoscbState {
     MemoryRegion bc_sgmii;
     MemoryRegion io_calib_sgmii;
 };
-typedef struct MchpPfSoCIoscbState MchpPfSoCIoscbState;
 
 #define TYPE_MCHP_PFSOC_IOSCB "mchp.pfsoc.ioscb"
 
-DECLARE_INSTANCE_CHECKER(MchpPfSoCIoscbState, MCHP_PFSOC_IOSCB,
-                         TYPE_MCHP_PFSOC_IOSCB)
+OBJECT_DECLARE_SIMPLE_TYPE(MchpPfSoCIoscbState, MCHP_PFSOC_IOSCB)
 
 #endif /* MCHP_PFSOC_IOSCB_H */
diff --git a/include/hw/misc/mchp_pfsoc_sysreg.h b/include/hw/misc/mchp_pfsoc_sysreg.h
index c842cf7e716..b17b6f8831c 100644
--- a/include/hw/misc/mchp_pfsoc_sysreg.h
+++ b/include/hw/misc/mchp_pfsoc_sysreg.h
@@ -30,11 +30,9 @@ struct MchpPfSoCSysregState {
     SysBusDevice parent;
     MemoryRegion sysreg;
 };
-typedef struct MchpPfSoCSysregState MchpPfSoCSysregState;
 
 #define TYPE_MCHP_PFSOC_SYSREG "mchp.pfsoc.sysreg"
 
-DECLARE_INSTANCE_CHECKER(MchpPfSoCSysregState, MCHP_PFSOC_SYSREG,
-                         TYPE_MCHP_PFSOC_SYSREG)
+OBJECT_DECLARE_SIMPLE_TYPE(MchpPfSoCSysregState, MCHP_PFSOC_SYSREG)
 
 #endif /* MCHP_PFSOC_SYSREG_H */
diff --git a/include/hw/misc/npcm7xx_clk.h b/include/hw/misc/npcm7xx_clk.h
index 023a1aed7a9..93b441c42e3 100644
--- a/include/hw/misc/npcm7xx_clk.h
+++ b/include/hw/misc/npcm7xx_clk.h
@@ -179,7 +179,6 @@ struct NPCM7xxCLKState {
 };
 
 #define TYPE_NPCM7XX_CLK "npcm7xx-clk"
-DECLARE_INSTANCE_CHECKER(NPCM7xxCLKState, NPCM7XX_CLK,
-                         TYPE_NPCM7XX_CLK)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxCLKState, NPCM7XX_CLK)
 
 #endif /* NPCM7XX_CLK_H */
diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h
index eed59f94f91..b20fa2618a1 100644
--- a/include/hw/misc/npcm7xx_gcr.h
+++ b/include/hw/misc/npcm7xx_gcr.h
@@ -37,10 +37,8 @@ struct NPCM7xxGCRState {
     uint32_t reset_mdlr;
     uint32_t reset_intcr3;
 };
-typedef struct NPCM7xxGCRState NPCM7xxGCRState;
 
 #define TYPE_NPCM7XX_GCR "npcm7xx-gcr"
-DECLARE_INSTANCE_CHECKER(NPCM7xxGCRState, NPCM7XX_GCR,
-                         TYPE_NPCM7XX_GCR)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxGCRState, NPCM7XX_GCR)
 
 #endif /* NPCM7XX_GCR_H */
diff --git a/include/hw/misc/npcm7xx_mft.h b/include/hw/misc/npcm7xx_mft.h
index a351cf9b2be..d6384382cea 100644
--- a/include/hw/misc/npcm7xx_mft.h
+++ b/include/hw/misc/npcm7xx_mft.h
@@ -62,10 +62,8 @@ struct NPCM7xxMFTState {
     uint32_t    max_rpm[NPCM7XX_MFT_FANIN_COUNT];
     uint32_t    duty[NPCM7XX_MFT_FANIN_COUNT];
 };
-typedef struct NPCM7xxMFTState NPCM7xxMFTState;
 
 #define TYPE_NPCM7XX_MFT "npcm7xx-mft"
-DECLARE_INSTANCE_CHECKER(NPCM7xxMFTState, NPCM7XX_MFT,
-                         TYPE_NPCM7XX_MFT)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxMFTState, NPCM7XX_MFT)
 
 #endif /* NPCM7XX_MFT_H */
diff --git a/include/hw/misc/npcm7xx_pwm.h b/include/hw/misc/npcm7xx_pwm.h
index 3be975e1ee4..e4a2336dc9a 100644
--- a/include/hw/misc/npcm7xx_pwm.h
+++ b/include/hw/misc/npcm7xx_pwm.h
@@ -102,7 +102,6 @@ struct NPCM7xxPWMState {
 };
 
 #define TYPE_NPCM7XX_PWM "npcm7xx-pwm"
-DECLARE_INSTANCE_CHECKER(NPCM7xxPWMState, NPCM7XX_PWM,
-                         TYPE_NPCM7XX_PWM)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxPWMState, NPCM7XX_PWM)
 
 #endif /* NPCM7XX_PWM_H */
diff --git a/include/hw/misc/sifive_e_prci.h b/include/hw/misc/sifive_e_prci.h
index 262ca16181b..a29cb259179 100644
--- a/include/hw/misc/sifive_e_prci.h
+++ b/include/hw/misc/sifive_e_prci.h
@@ -52,9 +52,7 @@ enum {
 
 #define TYPE_SIFIVE_E_PRCI      "riscv.sifive.e.prci"
 
-typedef struct SiFiveEPRCIState SiFiveEPRCIState;
-DECLARE_INSTANCE_CHECKER(SiFiveEPRCIState, SIFIVE_E_PRCI,
-                         TYPE_SIFIVE_E_PRCI)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveEPRCIState, SIFIVE_E_PRCI)
 
 struct SiFiveEPRCIState {
     /*< private >*/
diff --git a/include/hw/misc/sifive_test.h b/include/hw/misc/sifive_test.h
index 88a38d00c59..0e5e760f290 100644
--- a/include/hw/misc/sifive_test.h
+++ b/include/hw/misc/sifive_test.h
@@ -24,9 +24,7 @@
 
 #define TYPE_SIFIVE_TEST "riscv.sifive.test"
 
-typedef struct SiFiveTestState SiFiveTestState;
-DECLARE_INSTANCE_CHECKER(SiFiveTestState, SIFIVE_TEST,
-                         TYPE_SIFIVE_TEST)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveTestState, SIFIVE_TEST)
 
 struct SiFiveTestState {
     /*< private >*/
diff --git a/include/hw/misc/sifive_u_otp.h b/include/hw/misc/sifive_u_otp.h
index 5d0d7df455f..a80fd858f94 100644
--- a/include/hw/misc/sifive_u_otp.h
+++ b/include/hw/misc/sifive_u_otp.h
@@ -53,9 +53,7 @@
 
 #define TYPE_SIFIVE_U_OTP           "riscv.sifive.u.otp"
 
-typedef struct SiFiveUOTPState SiFiveUOTPState;
-DECLARE_INSTANCE_CHECKER(SiFiveUOTPState, SIFIVE_U_OTP,
-                         TYPE_SIFIVE_U_OTP)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveUOTPState, SIFIVE_U_OTP)
 
 struct SiFiveUOTPState {
     /*< private >*/
diff --git a/include/hw/misc/sifive_u_prci.h b/include/hw/misc/sifive_u_prci.h
index d9ebf40b7fa..5ea9a7325ca 100644
--- a/include/hw/misc/sifive_u_prci.h
+++ b/include/hw/misc/sifive_u_prci.h
@@ -59,9 +59,7 @@
 
 #define TYPE_SIFIVE_U_PRCI      "riscv.sifive.u.prci"
 
-typedef struct SiFiveUPRCIState SiFiveUPRCIState;
-DECLARE_INSTANCE_CHECKER(SiFiveUPRCIState, SIFIVE_U_PRCI,
-                         TYPE_SIFIVE_U_PRCI)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveUPRCIState, SIFIVE_U_PRCI)
 
 struct SiFiveUPRCIState {
     /*< private >*/
diff --git a/include/hw/misc/xlnx-versal-xramc.h b/include/hw/misc/xlnx-versal-xramc.h
index fc5a12165cf..7d58656a586 100644
--- a/include/hw/misc/xlnx-versal-xramc.h
+++ b/include/hw/misc/xlnx-versal-xramc.h
@@ -15,9 +15,7 @@
 
 #define TYPE_XLNX_XRAM_CTRL "xlnx.versal-xramc"
 
-typedef struct XlnxXramCtrl XlnxXramCtrl;
-DECLARE_INSTANCE_CHECKER(XlnxXramCtrl, XLNX_XRAM_CTRL,
-                         TYPE_XLNX_XRAM_CTRL)
+OBJECT_DECLARE_SIMPLE_TYPE(XlnxXramCtrl, XLNX_XRAM_CTRL)
 
 REG32(XRAM_ERR_CTRL, 0x0)
     FIELD(XRAM_ERR_CTRL, UE_RES, 3, 1)
diff --git a/include/hw/net/npcm7xx_emc.h b/include/hw/net/npcm7xx_emc.h
index bdf06c69dde..94f1cd159d8 100644
--- a/include/hw/net/npcm7xx_emc.h
+++ b/include/hw/net/npcm7xx_emc.h
@@ -278,10 +278,8 @@ struct NPCM7xxEMCState {
     bool rx_active;
 };
 
-typedef struct NPCM7xxEMCState NPCM7xxEMCState;
 
 #define TYPE_NPCM7XX_EMC "npcm7xx-emc"
-DECLARE_INSTANCE_CHECKER(NPCM7xxEMCState, NPCM7XX_EMC,
-                         TYPE_NPCM7XX_EMC)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxEMCState, NPCM7XX_EMC)
 
 #endif /* NPCM7XX_EMC_H */
diff --git a/include/hw/net/xlnx-zynqmp-can.h b/include/hw/net/xlnx-zynqmp-can.h
index 4a1fa166571..6283e865148 100644
--- a/include/hw/net/xlnx-zynqmp-can.h
+++ b/include/hw/net/xlnx-zynqmp-can.h
@@ -40,9 +40,7 @@
 
 #define TYPE_XLNX_ZYNQMP_CAN "xlnx.zynqmp-can"
 
-typedef struct XlnxZynqMPCANState XlnxZynqMPCANState;
-DECLARE_INSTANCE_CHECKER(XlnxZynqMPCANState, XLNX_ZYNQMP_CAN,
-                         TYPE_XLNX_ZYNQMP_CAN)
+OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPCANState, XLNX_ZYNQMP_CAN)
 
 #define MAX_CAN_CTRLS      2
 #define XLNX_ZYNQMP_CAN_R_MAX     (0x84 / 4)
diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h
index ff876fd74ca..700abe0874c 100644
--- a/include/hw/ppc/spapr_drc.h
+++ b/include/hw/ppc/spapr_drc.h
@@ -23,9 +23,7 @@
 OBJECT_DECLARE_TYPE(SpaprDrc, SpaprDrcClass, SPAPR_DR_CONNECTOR)
 
 #define TYPE_SPAPR_DRC_PHYSICAL "spapr-drc-physical"
-typedef struct SpaprDrcPhysical SpaprDrcPhysical;
-DECLARE_INSTANCE_CHECKER(SpaprDrcPhysical, SPAPR_DRC_PHYSICAL,
-                         TYPE_SPAPR_DRC_PHYSICAL)
+OBJECT_DECLARE_SIMPLE_TYPE(SpaprDrcPhysical, SPAPR_DRC_PHYSICAL)
 
 #define TYPE_SPAPR_DRC_LOGICAL "spapr-drc-logical"
 
diff --git a/include/hw/register.h b/include/hw/register.h
index b480e3882cd..1af762682b7 100644
--- a/include/hw/register.h
+++ b/include/hw/register.h
@@ -88,8 +88,7 @@ struct RegisterInfo {
 };
 
 #define TYPE_REGISTER "qemu-register"
-DECLARE_INSTANCE_CHECKER(RegisterInfo, REGISTER,
-                         TYPE_REGISTER)
+OBJECT_DECLARE_SIMPLE_TYPE(RegisterInfo, REGISTER)
 
 /**
  * This structure is used to group all of the individual registers which are
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
index 3a29a48019e..7996fceade4 100644
--- a/include/hw/riscv/microchip_pfsoc.h
+++ b/include/hw/riscv/microchip_pfsoc.h
@@ -55,11 +55,9 @@ struct MicrochipPFSoCState {
     CadenceGEMState gem1;
     CadenceSDHCIState sdhci;
 };
-typedef struct MicrochipPFSoCState MicrochipPFSoCState;
 
 #define TYPE_MICROCHIP_PFSOC    "microchip.pfsoc"
-DECLARE_INSTANCE_CHECKER(MicrochipPFSoCState, MICROCHIP_PFSOC,
-                         TYPE_MICROCHIP_PFSOC)
+OBJECT_DECLARE_SIMPLE_TYPE(MicrochipPFSoCState, MICROCHIP_PFSOC)
 
 struct MicrochipIcicleKitState {
     /*< private >*/
diff --git a/include/hw/riscv/shakti_c.h b/include/hw/riscv/shakti_c.h
index 6733eca2303..e8e051ee7e9 100644
--- a/include/hw/riscv/shakti_c.h
+++ b/include/hw/riscv/shakti_c.h
@@ -25,9 +25,7 @@
 #include "qom/object.h"
 
 #define TYPE_RISCV_SHAKTI_SOC "riscv.shakti.cclass.soc"
-typedef struct ShaktiCSoCState ShaktiCSoCState;
-DECLARE_INSTANCE_CHECKER(ShaktiCSoCState, RISCV_SHAKTI_SOC,
-                         TYPE_RISCV_SHAKTI_SOC)
+OBJECT_DECLARE_SIMPLE_TYPE(ShaktiCSoCState, RISCV_SHAKTI_SOC)
 
 struct ShaktiCSoCState {
     /*< private >*/
@@ -42,9 +40,7 @@ struct ShaktiCSoCState {
 };
 
 #define TYPE_RISCV_SHAKTI_MACHINE MACHINE_TYPE_NAME("shakti_c")
-typedef struct ShaktiCMachineState ShaktiCMachineState;
-DECLARE_INSTANCE_CHECKER(ShaktiCMachineState, RISCV_SHAKTI_MACHINE,
-                         TYPE_RISCV_SHAKTI_MACHINE)
+OBJECT_DECLARE_SIMPLE_TYPE(ShaktiCMachineState, RISCV_SHAKTI_MACHINE)
 struct ShaktiCMachineState {
     /*< private >*/
     MachineState parent_obj;
diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h
index 22abd643753..44744d16fbd 100644
--- a/include/hw/riscv/sifive_e.h
+++ b/include/hw/riscv/sifive_e.h
@@ -25,9 +25,7 @@
 #include "qom/object.h"
 
 #define TYPE_RISCV_E_SOC "riscv.sifive.e.soc"
-typedef struct SiFiveESoCState SiFiveESoCState;
-DECLARE_INSTANCE_CHECKER(SiFiveESoCState, RISCV_E_SOC,
-                         TYPE_RISCV_E_SOC)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveESoCState, RISCV_E_SOC)
 
 struct SiFiveESoCState {
     /*< private >*/
diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h
index d974043a36d..fff7d61ef5b 100644
--- a/include/hw/riscv/sifive_u.h
+++ b/include/hw/riscv/sifive_u.h
@@ -30,9 +30,7 @@
 #include "qom/object.h"
 
 #define TYPE_RISCV_U_SOC "riscv.sifive.u.soc"
-typedef struct SiFiveUSoCState SiFiveUSoCState;
-DECLARE_INSTANCE_CHECKER(SiFiveUSoCState, RISCV_U_SOC,
-                         TYPE_RISCV_U_SOC)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveUSoCState, RISCV_U_SOC)
 
 struct SiFiveUSoCState {
     /*< private >*/
diff --git a/include/hw/sd/cadence_sdhci.h b/include/hw/sd/cadence_sdhci.h
index 6d6a2d9c0da..22cffb854ea 100644
--- a/include/hw/sd/cadence_sdhci.h
+++ b/include/hw/sd/cadence_sdhci.h
@@ -40,10 +40,8 @@ struct CadenceSDHCIState {
 
     SDHCIState sdhci;
 };
-typedef struct CadenceSDHCIState CadenceSDHCIState;
 
 #define TYPE_CADENCE_SDHCI  "cadence.sdhci"
-DECLARE_INSTANCE_CHECKER(CadenceSDHCIState, CADENCE_SDHCI,
-                         TYPE_CADENCE_SDHCI)
+OBJECT_DECLARE_SIMPLE_TYPE(CadenceSDHCIState, CADENCE_SDHCI)
 
 #endif /* CADENCE_SDHCI_H */
diff --git a/include/hw/ssi/sifive_spi.h b/include/hw/ssi/sifive_spi.h
index d32deaea0ec..c4f744230f2 100644
--- a/include/hw/ssi/sifive_spi.h
+++ b/include/hw/ssi/sifive_spi.h
@@ -26,9 +26,7 @@
 #define SIFIVE_SPI_REG_NUM  (0x78 / 4)
 
 #define TYPE_SIFIVE_SPI "sifive.spi"
-typedef struct SiFiveSPIState SiFiveSPIState;
-DECLARE_INSTANCE_CHECKER(SiFiveSPIState, SIFIVE_SPI,
-                         TYPE_SIFIVE_SPI)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveSPIState, SIFIVE_SPI)
 
 struct SiFiveSPIState {
     SysBusDevice parent_obj;
diff --git a/include/hw/timer/npcm7xx_timer.h b/include/hw/timer/npcm7xx_timer.h
index ff1985f5ca5..8d41b66e966 100644
--- a/include/hw/timer/npcm7xx_timer.h
+++ b/include/hw/timer/npcm7xx_timer.h
@@ -108,7 +108,6 @@ struct NPCM7xxTimerCtrlState {
 };
 
 #define TYPE_NPCM7XX_TIMER "npcm7xx-timer"
-DECLARE_INSTANCE_CHECKER(NPCM7xxTimerCtrlState, NPCM7XX_TIMER,
-                         TYPE_NPCM7XX_TIMER)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxTimerCtrlState, NPCM7XX_TIMER)
 
 #endif /* NPCM7XX_TIMER_H */
diff --git a/include/hw/tricore/tricore_testdevice.h b/include/hw/tricore/tricore_testdevice.h
index 4d68f129cc1..f1266c85401 100644
--- a/include/hw/tricore/tricore_testdevice.h
+++ b/include/hw/tricore/tricore_testdevice.h
@@ -24,9 +24,7 @@
 #include "qom/object.h"
 
 #define TYPE_TRICORE_TESTDEVICE "tricore_testdevice"
-typedef struct TriCoreTestDeviceState TriCoreTestDeviceState;
-DECLARE_INSTANCE_CHECKER(TriCoreTestDeviceState, TRICORE_TESTDEVICE,
-                         TYPE_TRICORE_TESTDEVICE)
+OBJECT_DECLARE_SIMPLE_TYPE(TriCoreTestDeviceState, TRICORE_TESTDEVICE)
 
 struct TriCoreTestDeviceState {
     /* <private> */
diff --git a/include/hw/usb/hcd-dwc3.h b/include/hw/usb/hcd-dwc3.h
index 20402a9ad0b..9f2e64ee498 100644
--- a/include/hw/usb/hcd-dwc3.h
+++ b/include/hw/usb/hcd-dwc3.h
@@ -32,9 +32,7 @@
 
 #define TYPE_USB_DWC3 "usb_dwc3"
 
-typedef struct USBDWC3 USBDWC3;
-DECLARE_INSTANCE_CHECKER(USBDWC3, USB_DWC3,
-                         TYPE_USB_DWC3)
+OBJECT_DECLARE_SIMPLE_TYPE(USBDWC3, USB_DWC3)
 
 #define USB_DWC3_R_MAX ((0x530 / 4) + 1)
 #define DWC3_SIZE 0x10000
diff --git a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
index 701302ad044..2576193e673 100644
--- a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
+++ b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
@@ -29,9 +29,7 @@
 
 #define TYPE_XILINX_VERSAL_USB2_CTRL_REGS "xlnx.versal-usb2-ctrl-regs"
 
-typedef struct VersalUsb2CtrlRegs VersalUsb2CtrlRegs;
-DECLARE_INSTANCE_CHECKER(VersalUsb2CtrlRegs, XILINX_VERSAL_USB2_CTRL_REGS,
-                         TYPE_XILINX_VERSAL_USB2_CTRL_REGS)
+OBJECT_DECLARE_SIMPLE_TYPE(VersalUsb2CtrlRegs, XILINX_VERSAL_USB2_CTRL_REGS)
 
 #define USB2_REGS_R_MAX ((0x78 / 4) + 1)
 
diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c
index 165ab56eeaa..ee064e185c5 100644
--- a/hw/m68k/mcf5206.c
+++ b/hw/m68k/mcf5206.c
@@ -179,10 +179,8 @@ struct m5206_mbar_state {
     /* Include the UART vector registers here.  */
     uint8_t uivr[2];
 };
-typedef struct m5206_mbar_state m5206_mbar_state;
 
-DECLARE_INSTANCE_CHECKER(m5206_mbar_state, MCF5206_MBAR,
-                         TYPE_MCF5206_MBAR)
+OBJECT_DECLARE_SIMPLE_TYPE(m5206_mbar_state, MCF5206_MBAR)
 
 /* Interrupt controller.  */
 
diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index 20b06865b2b..fa8b23d2694 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -44,9 +44,7 @@
 #include "qom/object.h"
 
 #define TYPE_BOSTON "mips-boston"
-typedef struct BostonState BostonState;
-DECLARE_INSTANCE_CHECKER(BostonState, BOSTON,
-                         TYPE_BOSTON)
+OBJECT_DECLARE_SIMPLE_TYPE(BostonState, BOSTON)
 
 struct BostonState {
     SysBusDevice parent_obj;
diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c
index 5247acfeb5a..4dd60fff03f 100644
--- a/hw/misc/npcm7xx_clk.c
+++ b/hw/misc/npcm7xx_clk.c
@@ -110,14 +110,11 @@ static const uint32_t cold_reset_values[NPCM7XX_CLK_NR_REGS] = {
 /* Clock converter functions */
 
 #define TYPE_NPCM7XX_CLOCK_PLL "npcm7xx-clock-pll"
-DECLARE_INSTANCE_CHECKER(NPCM7xxClockPLLState, NPCM7XX_CLOCK_PLL,
-                         TYPE_NPCM7XX_CLOCK_PLL)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxClockPLLState, NPCM7XX_CLOCK_PLL)
 #define TYPE_NPCM7XX_CLOCK_SEL "npcm7xx-clock-sel"
-DECLARE_INSTANCE_CHECKER(NPCM7xxClockSELState, NPCM7XX_CLOCK_SEL,
-                         TYPE_NPCM7XX_CLOCK_SEL)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxClockSELState, NPCM7XX_CLOCK_SEL)
 #define TYPE_NPCM7XX_CLOCK_DIVIDER "npcm7xx-clock-divider"
-DECLARE_INSTANCE_CHECKER(NPCM7xxClockDividerState, NPCM7XX_CLOCK_DIVIDER,
-                         TYPE_NPCM7XX_CLOCK_DIVIDER)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxClockDividerState, NPCM7XX_CLOCK_DIVIDER)
 
 static void npcm7xx_clk_update_pll(void *opaque)
 {
diff --git a/hw/net/can/ctucan_pci.c b/hw/net/can/ctucan_pci.c
index 1f277a7c363..4ce36dfa976 100644
--- a/hw/net/can/ctucan_pci.c
+++ b/hw/net/can/ctucan_pci.c
@@ -44,9 +44,7 @@
 
 #define TYPE_CTUCAN_PCI_DEV "ctucan_pci"
 
-typedef struct CtuCanPCIState CtuCanPCIState;
-DECLARE_INSTANCE_CHECKER(CtuCanPCIState, CTUCAN_PCI_DEV,
-                         TYPE_CTUCAN_PCI_DEV)
+OBJECT_DECLARE_SIMPLE_TYPE(CtuCanPCIState, CTUCAN_PCI_DEV)
 
 #define CTUCAN_PCI_CORE_COUNT     2
 #define CTUCAN_PCI_CORE_RANGE     0x10000
diff --git a/hw/s390x/vhost-user-fs-ccw.c b/hw/s390x/vhost-user-fs-ccw.c
index 5a72a22d48f..e905849a580 100644
--- a/hw/s390x/vhost-user-fs-ccw.c
+++ b/hw/s390x/vhost-user-fs-ccw.c
@@ -18,11 +18,9 @@ struct VHostUserFSCcw {
     VirtioCcwDevice parent_obj;
     VHostUserFS vdev;
 };
-typedef struct VHostUserFSCcw VHostUserFSCcw;
 
 #define TYPE_VHOST_USER_FS_CCW "vhost-user-fs-ccw"
-DECLARE_INSTANCE_CHECKER(VHostUserFSCcw, VHOST_USER_FS_CCW,
-                         TYPE_VHOST_USER_FS_CCW)
+OBJECT_DECLARE_SIMPLE_TYPE(VHostUserFSCcw, VHOST_USER_FS_CCW)
 
 
 static Property vhost_user_fs_ccw_properties[] = {
diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
index a678174b18c..cbed43adb64 100644
--- a/hw/sensor/adm1272.c
+++ b/hw/sensor/adm1272.c
@@ -19,9 +19,7 @@
 #include "qom/object.h"
 
 #define TYPE_ADM1272 "adm1272"
-typedef struct ADM1272State ADM1272State;
-DECLARE_INSTANCE_CHECKER(ADM1272State, ADM1272,
-                         TYPE_ADM1272)
+OBJECT_DECLARE_SIMPLE_TYPE(ADM1272State, ADM1272)
 
 #define ADM1272_RESTART_TIME            0xCC
 #define ADM1272_MFR_PEAK_IOUT           0xD0
diff --git a/hw/sensor/max34451.c b/hw/sensor/max34451.c
index 864f0bfc736..918c78b0f21 100644
--- a/hw/sensor/max34451.c
+++ b/hw/sensor/max34451.c
@@ -17,9 +17,7 @@
 #include "qom/object.h"
 
 #define TYPE_MAX34451 "max34451"
-typedef struct MAX34451State MAX34451State;
-DECLARE_INSTANCE_CHECKER(MAX34451State, MAX34451,
-                         TYPE_MAX34451)
+OBJECT_DECLARE_SIMPLE_TYPE(MAX34451State, MAX34451)
 
 #define MAX34451_MFR_MODE               0xD1
 #define MAX34451_MFR_PSEN_CONFIG        0xD2
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH for-6.2 12/12] [automated] Use OBJECT_DECLARE_SIMPLE_TYPE when possible
@ 2021-08-06 21:11   ` Eduardo Habkost
  0 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-06 21:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrange, Paolo Bonzini, Thomas Huth, Paul Burton,
	Aleksandar Rikalo, Philippe Mathieu-Daudé,
	Aurelien Jarno, Jiaxun Yang, Havard Skinnemoen, Tyrone Ting,
	Pavel Pisa, Vikram Garhwal, Jason Wang, Keith Busch,
	Klaus Jensen, Michael S. Tsirkin, Richard Henderson,
	David Hildenbrand, Cornelia Huck, Halil Pasic,
	Christian Borntraeger, Gerd Hoffmann, Vijai Kumar K,
	Alistair Francis, Bin Meng, Palmer Dabbelt, Edgar E. Iglesias,
	Peter Maydell, Laurent Vivier, Cédric Le Goater,
	Andrew Jeffery, Joel Stanley, Andrew Baumann, Francisco Iglesias,
	David Gibson, Greg Kurz, Bastian Koppelmann, qemu-arm,
	qemu-block, qemu-s390x, qemu-riscv, qemu-ppc

Replace typedef + DECLARE_INSTANCE_CHECKER with
equivalent OBJECT_DECLARE_SIMPLE_TYPE macro.

Generated using:

$ ./scripts/codeconverter/converter.py -i \
  --pattern=AddObjectDeclareSimpleType $(git grep -l '' -- '*.[ch]')

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Thomas Huth <huth@tuxfamily.org>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Havard Skinnemoen <hskinnemoen@google.com>
Cc: Tyrone Ting <kfting@nuvoton.com>
Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Klaus Jensen <its@irrelevant.dk>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: Halil Pasic <pasic@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Vijai Kumar K <vijai@behindbytes.com>
Cc: Alistair Francis <Alistair.Francis@wdc.com>
Cc: Bin Meng <bin.meng@windriver.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Laurent Vivier <laurent@vivier.eu>
Cc: "Cédric Le Goater" <clg@kaod.org>
Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Greg Kurz <groug@kaod.org>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org
Cc: qemu-block@nongnu.org
Cc: qemu-s390x@nongnu.org
Cc: qemu-riscv@nongnu.org
Cc: qemu-ppc@nongnu.org
---
 hw/nvme/nvme.h                              | 10 +++-------
 hw/usb/hcd-xhci-pci.h                       |  4 +---
 hw/usb/hcd-xhci-sysbus.h                    |  4 +---
 include/hw/adc/npcm7xx_adc.h                |  4 +---
 include/hw/char/shakti_uart.h               |  4 +---
 include/hw/dma/sifive_pdma.h                |  4 +---
 include/hw/dma/xlnx_csu_dma.h               |  4 +---
 include/hw/gpio/sifive_gpio.h               |  4 +---
 include/hw/intc/m68k_irqc.h                 |  4 +---
 include/hw/intc/sifive_clint.h              |  4 +---
 include/hw/intc/sifive_plic.h               |  4 +---
 include/hw/misc/aspeed_lpc.h                |  4 +---
 include/hw/misc/bcm2835_cprman_internals.h  | 12 ++++--------
 include/hw/misc/led.h                       |  3 +--
 include/hw/misc/mchp_pfsoc_dmc.h            |  8 ++------
 include/hw/misc/mchp_pfsoc_ioscb.h          |  4 +---
 include/hw/misc/mchp_pfsoc_sysreg.h         |  4 +---
 include/hw/misc/npcm7xx_clk.h               |  3 +--
 include/hw/misc/npcm7xx_gcr.h               |  4 +---
 include/hw/misc/npcm7xx_mft.h               |  4 +---
 include/hw/misc/npcm7xx_pwm.h               |  3 +--
 include/hw/misc/sifive_e_prci.h             |  4 +---
 include/hw/misc/sifive_test.h               |  4 +---
 include/hw/misc/sifive_u_otp.h              |  4 +---
 include/hw/misc/sifive_u_prci.h             |  4 +---
 include/hw/misc/xlnx-versal-xramc.h         |  4 +---
 include/hw/net/npcm7xx_emc.h                |  4 +---
 include/hw/net/xlnx-zynqmp-can.h            |  4 +---
 include/hw/ppc/spapr_drc.h                  |  4 +---
 include/hw/register.h                       |  3 +--
 include/hw/riscv/microchip_pfsoc.h          |  4 +---
 include/hw/riscv/shakti_c.h                 |  8 ++------
 include/hw/riscv/sifive_e.h                 |  4 +---
 include/hw/riscv/sifive_u.h                 |  4 +---
 include/hw/sd/cadence_sdhci.h               |  4 +---
 include/hw/ssi/sifive_spi.h                 |  4 +---
 include/hw/timer/npcm7xx_timer.h            |  3 +--
 include/hw/tricore/tricore_testdevice.h     |  4 +---
 include/hw/usb/hcd-dwc3.h                   |  4 +---
 include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  4 +---
 hw/m68k/mcf5206.c                           |  4 +---
 hw/mips/boston.c                            |  4 +---
 hw/misc/npcm7xx_clk.c                       |  9 +++------
 hw/net/can/ctucan_pci.c                     |  4 +---
 hw/s390x/vhost-user-fs-ccw.c                |  4 +---
 hw/sensor/adm1272.c                         |  4 +---
 hw/sensor/max34451.c                        |  4 +---
 47 files changed, 56 insertions(+), 154 deletions(-)

diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
index c4c43da5c17..a9ee5c4f1de 100644
--- a/hw/nvme/nvme.h
+++ b/hw/nvme/nvme.h
@@ -42,9 +42,7 @@ typedef struct NvmeBus {
 } NvmeBus;
 
 #define TYPE_NVME_SUBSYS "nvme-subsys"
-typedef struct NvmeSubsystem NvmeSubsystem;
-DECLARE_INSTANCE_CHECKER(NvmeSubsystem, NVME_SUBSYS,
-                         TYPE_NVME_SUBSYS)
+OBJECT_DECLARE_SIMPLE_TYPE(NvmeSubsystem, NVME_SUBSYS)
 
 struct NvmeSubsystem {
     DeviceState parent_obj;
@@ -83,8 +81,7 @@ static inline NvmeNamespace *nvme_subsys_ns(NvmeSubsystem *subsys,
 }
 
 #define TYPE_NVME_NS "nvme-ns"
-DECLARE_INSTANCE_CHECKER(NvmeNamespace, NVME_NS,
-                         TYPE_NVME_NS)
+OBJECT_DECLARE_SIMPLE_TYPE(NvmeNamespace, NVME_NS)
 
 typedef struct NvmeZone {
     NvmeZoneDescr   d;
@@ -377,8 +374,7 @@ typedef struct NvmeCQueue {
 } NvmeCQueue;
 
 #define TYPE_NVME "nvme"
-DECLARE_INSTANCE_CHECKER(NvmeCtrl, NVME,
-                         TYPE_NVME)
+OBJECT_DECLARE_SIMPLE_TYPE(NvmeCtrl, NVME)
 
 typedef struct NvmeParams {
     char     *serial;
diff --git a/hw/usb/hcd-xhci-pci.h b/hw/usb/hcd-xhci-pci.h
index d83aad82e04..2ad2eeefb7f 100644
--- a/hw/usb/hcd-xhci-pci.h
+++ b/hw/usb/hcd-xhci-pci.h
@@ -29,9 +29,7 @@
 #include "qom/object.h"
 
 #define TYPE_XHCI_PCI "pci-xhci"
-typedef struct XHCIPciState XHCIPciState;
-DECLARE_INSTANCE_CHECKER(XHCIPciState, XHCI_PCI,
-                         TYPE_XHCI_PCI)
+OBJECT_DECLARE_SIMPLE_TYPE(XHCIPciState, XHCI_PCI)
 
 
 struct XHCIPciState {
diff --git a/hw/usb/hcd-xhci-sysbus.h b/hw/usb/hcd-xhci-sysbus.h
index 561e5144e05..512d4a40e19 100644
--- a/hw/usb/hcd-xhci-sysbus.h
+++ b/hw/usb/hcd-xhci-sysbus.h
@@ -16,9 +16,7 @@
 #include "hw/sysbus.h"
 #include "qom/object.h"
 
-typedef struct XHCISysbusState XHCISysbusState;
-DECLARE_INSTANCE_CHECKER(XHCISysbusState, XHCI_SYSBUS,
-                         TYPE_XHCI_SYSBUS)
+OBJECT_DECLARE_SIMPLE_TYPE(XHCISysbusState, XHCI_SYSBUS)
 
 
 struct XHCISysbusState {
diff --git a/include/hw/adc/npcm7xx_adc.h b/include/hw/adc/npcm7xx_adc.h
index b694adece6a..08992229f09 100644
--- a/include/hw/adc/npcm7xx_adc.h
+++ b/include/hw/adc/npcm7xx_adc.h
@@ -62,10 +62,8 @@ struct NPCM7xxADCState {
 
     uint16_t     calibration_r_values[NPCM7XX_ADC_NUM_CALIB];
 };
-typedef struct NPCM7xxADCState NPCM7xxADCState;
 
 #define TYPE_NPCM7XX_ADC "npcm7xx-adc"
-DECLARE_INSTANCE_CHECKER(NPCM7xxADCState, NPCM7XX_ADC,
-                         TYPE_NPCM7XX_ADC)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxADCState, NPCM7XX_ADC)
 
 #endif /* NPCM7XX_ADC_H */
diff --git a/include/hw/char/shakti_uart.h b/include/hw/char/shakti_uart.h
index 9bec3062af0..2c305562e78 100644
--- a/include/hw/char/shakti_uart.h
+++ b/include/hw/char/shakti_uart.h
@@ -49,9 +49,7 @@
 #define SHAKTI_UART_CONTROL_DEFAULT 0x0100
 
 #define TYPE_SHAKTI_UART "shakti-uart"
-typedef struct ShaktiUartState ShaktiUartState;
-DECLARE_INSTANCE_CHECKER(ShaktiUartState, SHAKTI_UART,
-                         TYPE_SHAKTI_UART)
+OBJECT_DECLARE_SIMPLE_TYPE(ShaktiUartState, SHAKTI_UART)
 
 struct ShaktiUartState {
     /* <private> */
diff --git a/include/hw/dma/sifive_pdma.h b/include/hw/dma/sifive_pdma.h
index d81526cfc2f..f1fb9093358 100644
--- a/include/hw/dma/sifive_pdma.h
+++ b/include/hw/dma/sifive_pdma.h
@@ -49,11 +49,9 @@ struct SiFivePDMAState {
 
     struct sifive_pdma_chan chan[SIFIVE_PDMA_CHANS];
 };
-typedef struct SiFivePDMAState SiFivePDMAState;
 
 #define TYPE_SIFIVE_PDMA    "sifive.pdma"
 
-DECLARE_INSTANCE_CHECKER(SiFivePDMAState, SIFIVE_PDMA,
-                         TYPE_SIFIVE_PDMA)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFivePDMAState, SIFIVE_PDMA)
 
 #endif /* SIFIVE_PDMA_H */
diff --git a/include/hw/dma/xlnx_csu_dma.h b/include/hw/dma/xlnx_csu_dma.h
index 36433d189ac..1ef9f36f89d 100644
--- a/include/hw/dma/xlnx_csu_dma.h
+++ b/include/hw/dma/xlnx_csu_dma.h
@@ -46,9 +46,7 @@ struct XlnxCSUDMA {
     uint32_t regs[XLNX_CSU_DMA_R_MAX];
     RegisterInfo regs_info[XLNX_CSU_DMA_R_MAX];
 };
-typedef struct XlnxCSUDMA XlnxCSUDMA;
 
-DECLARE_INSTANCE_CHECKER(XlnxCSUDMA, XLNX_CSU_DMA,
-                         TYPE_XLNX_CSU_DMA)
+OBJECT_DECLARE_SIMPLE_TYPE(XlnxCSUDMA, XLNX_CSU_DMA)
 
 #endif
diff --git a/include/hw/gpio/sifive_gpio.h b/include/hw/gpio/sifive_gpio.h
index fc53785c9d0..6c44e33fbe3 100644
--- a/include/hw/gpio/sifive_gpio.h
+++ b/include/hw/gpio/sifive_gpio.h
@@ -18,9 +18,7 @@
 #include "qom/object.h"
 
 #define TYPE_SIFIVE_GPIO "sifive_soc.gpio"
-typedef struct SIFIVEGPIOState SIFIVEGPIOState;
-DECLARE_INSTANCE_CHECKER(SIFIVEGPIOState, SIFIVE_GPIO,
-                         TYPE_SIFIVE_GPIO)
+OBJECT_DECLARE_SIMPLE_TYPE(SIFIVEGPIOState, SIFIVE_GPIO)
 
 #define SIFIVE_GPIO_PINS 32
 
diff --git a/include/hw/intc/m68k_irqc.h b/include/hw/intc/m68k_irqc.h
index 843cec3c666..4cb19918134 100644
--- a/include/hw/intc/m68k_irqc.h
+++ b/include/hw/intc/m68k_irqc.h
@@ -14,9 +14,7 @@
 #include "qom/object.h"
 
 #define TYPE_M68K_IRQC "m68k-irq-controller"
-typedef struct M68KIRQCState M68KIRQCState;
-DECLARE_INSTANCE_CHECKER(M68KIRQCState, M68K_IRQC,
-                         TYPE_M68K_IRQC)
+OBJECT_DECLARE_SIMPLE_TYPE(M68KIRQCState, M68K_IRQC)
 
 #define M68K_IRQC_AUTOVECTOR_BASE 25
 
diff --git a/include/hw/intc/sifive_clint.h b/include/hw/intc/sifive_clint.h
index c7df3f7f2b3..349f5ad14dd 100644
--- a/include/hw/intc/sifive_clint.h
+++ b/include/hw/intc/sifive_clint.h
@@ -25,9 +25,7 @@
 
 #define TYPE_SIFIVE_CLINT "riscv.sifive.clint"
 
-typedef struct SiFiveCLINTState SiFiveCLINTState;
-DECLARE_INSTANCE_CHECKER(SiFiveCLINTState, SIFIVE_CLINT,
-                         TYPE_SIFIVE_CLINT)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveCLINTState, SIFIVE_CLINT)
 
 struct SiFiveCLINTState {
     /*< private >*/
diff --git a/include/hw/intc/sifive_plic.h b/include/hw/intc/sifive_plic.h
index 1e451a270c7..0cdb7d584c9 100644
--- a/include/hw/intc/sifive_plic.h
+++ b/include/hw/intc/sifive_plic.h
@@ -26,9 +26,7 @@
 
 #define TYPE_SIFIVE_PLIC "riscv.sifive.plic"
 
-typedef struct SiFivePLICState SiFivePLICState;
-DECLARE_INSTANCE_CHECKER(SiFivePLICState, SIFIVE_PLIC,
-                         TYPE_SIFIVE_PLIC)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFivePLICState, SIFIVE_PLIC)
 
 typedef enum PLICMode {
     PLICMode_U,
diff --git a/include/hw/misc/aspeed_lpc.h b/include/hw/misc/aspeed_lpc.h
index d8e5af6296b..dd6a63e6a53 100644
--- a/include/hw/misc/aspeed_lpc.h
+++ b/include/hw/misc/aspeed_lpc.h
@@ -16,9 +16,7 @@
 #include "qom/object.h"
 
 #define TYPE_ASPEED_LPC "aspeed.lpc"
-typedef struct AspeedLPCState AspeedLPCState;
-DECLARE_INSTANCE_CHECKER(AspeedLPCState, ASPEED_LPC,
-                         TYPE_ASPEED_LPC)
+OBJECT_DECLARE_SIMPLE_TYPE(AspeedLPCState, ASPEED_LPC)
 
 #define ASPEED_LPC_NR_REGS      (0x260 >> 2)
 
diff --git a/include/hw/misc/bcm2835_cprman_internals.h b/include/hw/misc/bcm2835_cprman_internals.h
index f5410580bff..db297e5b18c 100644
--- a/include/hw/misc/bcm2835_cprman_internals.h
+++ b/include/hw/misc/bcm2835_cprman_internals.h
@@ -18,14 +18,10 @@
 #define TYPE_CPRMAN_CLOCK_MUX "bcm2835-cprman-clock-mux"
 #define TYPE_CPRMAN_DSI0HSCK_MUX "bcm2835-cprman-dsi0hsck-mux"
 
-DECLARE_INSTANCE_CHECKER(CprmanPllState, CPRMAN_PLL,
-                         TYPE_CPRMAN_PLL)
-DECLARE_INSTANCE_CHECKER(CprmanPllChannelState, CPRMAN_PLL_CHANNEL,
-                         TYPE_CPRMAN_PLL_CHANNEL)
-DECLARE_INSTANCE_CHECKER(CprmanClockMuxState, CPRMAN_CLOCK_MUX,
-                         TYPE_CPRMAN_CLOCK_MUX)
-DECLARE_INSTANCE_CHECKER(CprmanDsi0HsckMuxState, CPRMAN_DSI0HSCK_MUX,
-                         TYPE_CPRMAN_DSI0HSCK_MUX)
+OBJECT_DECLARE_SIMPLE_TYPE(CprmanPllState, CPRMAN_PLL)
+OBJECT_DECLARE_SIMPLE_TYPE(CprmanPllChannelState, CPRMAN_PLL_CHANNEL)
+OBJECT_DECLARE_SIMPLE_TYPE(CprmanClockMuxState, CPRMAN_CLOCK_MUX)
+OBJECT_DECLARE_SIMPLE_TYPE(CprmanDsi0HsckMuxState, CPRMAN_DSI0HSCK_MUX)
 
 /* Register map */
 
diff --git a/include/hw/misc/led.h b/include/hw/misc/led.h
index 29c08795708..b4a090db3bf 100644
--- a/include/hw/misc/led.h
+++ b/include/hw/misc/led.h
@@ -51,8 +51,7 @@ struct LEDState {
      */
     bool gpio_active_high;
 };
-typedef struct LEDState LEDState;
-DECLARE_INSTANCE_CHECKER(LEDState, LED, TYPE_LED)
+OBJECT_DECLARE_SIMPLE_TYPE(LEDState, LED)
 
 /**
  * led_set_intensity: Set the intensity of a LED device
diff --git a/include/hw/misc/mchp_pfsoc_dmc.h b/include/hw/misc/mchp_pfsoc_dmc.h
index 3a0e3bbba76..ece1dfe6954 100644
--- a/include/hw/misc/mchp_pfsoc_dmc.h
+++ b/include/hw/misc/mchp_pfsoc_dmc.h
@@ -32,12 +32,10 @@ struct MchpPfSoCDdrSgmiiPhyState {
     SysBusDevice parent;
     MemoryRegion sgmii_phy;
 };
-typedef struct MchpPfSoCDdrSgmiiPhyState MchpPfSoCDdrSgmiiPhyState;
 
 #define TYPE_MCHP_PFSOC_DDR_SGMII_PHY "mchp.pfsoc.ddr_sgmii_phy"
 
-DECLARE_INSTANCE_CHECKER(MchpPfSoCDdrSgmiiPhyState, MCHP_PFSOC_DDR_SGMII_PHY,
-                         TYPE_MCHP_PFSOC_DDR_SGMII_PHY)
+OBJECT_DECLARE_SIMPLE_TYPE(MchpPfSoCDdrSgmiiPhyState, MCHP_PFSOC_DDR_SGMII_PHY)
 
 /* DDR CFG module */
 
@@ -47,11 +45,9 @@ struct MchpPfSoCDdrCfgState {
     SysBusDevice parent;
     MemoryRegion cfg;
 };
-typedef struct MchpPfSoCDdrCfgState MchpPfSoCDdrCfgState;
 
 #define TYPE_MCHP_PFSOC_DDR_CFG "mchp.pfsoc.ddr_cfg"
 
-DECLARE_INSTANCE_CHECKER(MchpPfSoCDdrCfgState, MCHP_PFSOC_DDR_CFG,
-                         TYPE_MCHP_PFSOC_DDR_CFG)
+OBJECT_DECLARE_SIMPLE_TYPE(MchpPfSoCDdrCfgState, MCHP_PFSOC_DDR_CFG)
 
 #endif /* MCHP_PFSOC_DMC_H */
diff --git a/include/hw/misc/mchp_pfsoc_ioscb.h b/include/hw/misc/mchp_pfsoc_ioscb.h
index 18ef5ff1739..d6d8e18b2c5 100644
--- a/include/hw/misc/mchp_pfsoc_ioscb.h
+++ b/include/hw/misc/mchp_pfsoc_ioscb.h
@@ -42,11 +42,9 @@ struct MchpPfSoCIoscbState {
     MemoryRegion bc_sgmii;
     MemoryRegion io_calib_sgmii;
 };
-typedef struct MchpPfSoCIoscbState MchpPfSoCIoscbState;
 
 #define TYPE_MCHP_PFSOC_IOSCB "mchp.pfsoc.ioscb"
 
-DECLARE_INSTANCE_CHECKER(MchpPfSoCIoscbState, MCHP_PFSOC_IOSCB,
-                         TYPE_MCHP_PFSOC_IOSCB)
+OBJECT_DECLARE_SIMPLE_TYPE(MchpPfSoCIoscbState, MCHP_PFSOC_IOSCB)
 
 #endif /* MCHP_PFSOC_IOSCB_H */
diff --git a/include/hw/misc/mchp_pfsoc_sysreg.h b/include/hw/misc/mchp_pfsoc_sysreg.h
index c842cf7e716..b17b6f8831c 100644
--- a/include/hw/misc/mchp_pfsoc_sysreg.h
+++ b/include/hw/misc/mchp_pfsoc_sysreg.h
@@ -30,11 +30,9 @@ struct MchpPfSoCSysregState {
     SysBusDevice parent;
     MemoryRegion sysreg;
 };
-typedef struct MchpPfSoCSysregState MchpPfSoCSysregState;
 
 #define TYPE_MCHP_PFSOC_SYSREG "mchp.pfsoc.sysreg"
 
-DECLARE_INSTANCE_CHECKER(MchpPfSoCSysregState, MCHP_PFSOC_SYSREG,
-                         TYPE_MCHP_PFSOC_SYSREG)
+OBJECT_DECLARE_SIMPLE_TYPE(MchpPfSoCSysregState, MCHP_PFSOC_SYSREG)
 
 #endif /* MCHP_PFSOC_SYSREG_H */
diff --git a/include/hw/misc/npcm7xx_clk.h b/include/hw/misc/npcm7xx_clk.h
index 023a1aed7a9..93b441c42e3 100644
--- a/include/hw/misc/npcm7xx_clk.h
+++ b/include/hw/misc/npcm7xx_clk.h
@@ -179,7 +179,6 @@ struct NPCM7xxCLKState {
 };
 
 #define TYPE_NPCM7XX_CLK "npcm7xx-clk"
-DECLARE_INSTANCE_CHECKER(NPCM7xxCLKState, NPCM7XX_CLK,
-                         TYPE_NPCM7XX_CLK)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxCLKState, NPCM7XX_CLK)
 
 #endif /* NPCM7XX_CLK_H */
diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h
index eed59f94f91..b20fa2618a1 100644
--- a/include/hw/misc/npcm7xx_gcr.h
+++ b/include/hw/misc/npcm7xx_gcr.h
@@ -37,10 +37,8 @@ struct NPCM7xxGCRState {
     uint32_t reset_mdlr;
     uint32_t reset_intcr3;
 };
-typedef struct NPCM7xxGCRState NPCM7xxGCRState;
 
 #define TYPE_NPCM7XX_GCR "npcm7xx-gcr"
-DECLARE_INSTANCE_CHECKER(NPCM7xxGCRState, NPCM7XX_GCR,
-                         TYPE_NPCM7XX_GCR)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxGCRState, NPCM7XX_GCR)
 
 #endif /* NPCM7XX_GCR_H */
diff --git a/include/hw/misc/npcm7xx_mft.h b/include/hw/misc/npcm7xx_mft.h
index a351cf9b2be..d6384382cea 100644
--- a/include/hw/misc/npcm7xx_mft.h
+++ b/include/hw/misc/npcm7xx_mft.h
@@ -62,10 +62,8 @@ struct NPCM7xxMFTState {
     uint32_t    max_rpm[NPCM7XX_MFT_FANIN_COUNT];
     uint32_t    duty[NPCM7XX_MFT_FANIN_COUNT];
 };
-typedef struct NPCM7xxMFTState NPCM7xxMFTState;
 
 #define TYPE_NPCM7XX_MFT "npcm7xx-mft"
-DECLARE_INSTANCE_CHECKER(NPCM7xxMFTState, NPCM7XX_MFT,
-                         TYPE_NPCM7XX_MFT)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxMFTState, NPCM7XX_MFT)
 
 #endif /* NPCM7XX_MFT_H */
diff --git a/include/hw/misc/npcm7xx_pwm.h b/include/hw/misc/npcm7xx_pwm.h
index 3be975e1ee4..e4a2336dc9a 100644
--- a/include/hw/misc/npcm7xx_pwm.h
+++ b/include/hw/misc/npcm7xx_pwm.h
@@ -102,7 +102,6 @@ struct NPCM7xxPWMState {
 };
 
 #define TYPE_NPCM7XX_PWM "npcm7xx-pwm"
-DECLARE_INSTANCE_CHECKER(NPCM7xxPWMState, NPCM7XX_PWM,
-                         TYPE_NPCM7XX_PWM)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxPWMState, NPCM7XX_PWM)
 
 #endif /* NPCM7XX_PWM_H */
diff --git a/include/hw/misc/sifive_e_prci.h b/include/hw/misc/sifive_e_prci.h
index 262ca16181b..a29cb259179 100644
--- a/include/hw/misc/sifive_e_prci.h
+++ b/include/hw/misc/sifive_e_prci.h
@@ -52,9 +52,7 @@ enum {
 
 #define TYPE_SIFIVE_E_PRCI      "riscv.sifive.e.prci"
 
-typedef struct SiFiveEPRCIState SiFiveEPRCIState;
-DECLARE_INSTANCE_CHECKER(SiFiveEPRCIState, SIFIVE_E_PRCI,
-                         TYPE_SIFIVE_E_PRCI)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveEPRCIState, SIFIVE_E_PRCI)
 
 struct SiFiveEPRCIState {
     /*< private >*/
diff --git a/include/hw/misc/sifive_test.h b/include/hw/misc/sifive_test.h
index 88a38d00c59..0e5e760f290 100644
--- a/include/hw/misc/sifive_test.h
+++ b/include/hw/misc/sifive_test.h
@@ -24,9 +24,7 @@
 
 #define TYPE_SIFIVE_TEST "riscv.sifive.test"
 
-typedef struct SiFiveTestState SiFiveTestState;
-DECLARE_INSTANCE_CHECKER(SiFiveTestState, SIFIVE_TEST,
-                         TYPE_SIFIVE_TEST)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveTestState, SIFIVE_TEST)
 
 struct SiFiveTestState {
     /*< private >*/
diff --git a/include/hw/misc/sifive_u_otp.h b/include/hw/misc/sifive_u_otp.h
index 5d0d7df455f..a80fd858f94 100644
--- a/include/hw/misc/sifive_u_otp.h
+++ b/include/hw/misc/sifive_u_otp.h
@@ -53,9 +53,7 @@
 
 #define TYPE_SIFIVE_U_OTP           "riscv.sifive.u.otp"
 
-typedef struct SiFiveUOTPState SiFiveUOTPState;
-DECLARE_INSTANCE_CHECKER(SiFiveUOTPState, SIFIVE_U_OTP,
-                         TYPE_SIFIVE_U_OTP)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveUOTPState, SIFIVE_U_OTP)
 
 struct SiFiveUOTPState {
     /*< private >*/
diff --git a/include/hw/misc/sifive_u_prci.h b/include/hw/misc/sifive_u_prci.h
index d9ebf40b7fa..5ea9a7325ca 100644
--- a/include/hw/misc/sifive_u_prci.h
+++ b/include/hw/misc/sifive_u_prci.h
@@ -59,9 +59,7 @@
 
 #define TYPE_SIFIVE_U_PRCI      "riscv.sifive.u.prci"
 
-typedef struct SiFiveUPRCIState SiFiveUPRCIState;
-DECLARE_INSTANCE_CHECKER(SiFiveUPRCIState, SIFIVE_U_PRCI,
-                         TYPE_SIFIVE_U_PRCI)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveUPRCIState, SIFIVE_U_PRCI)
 
 struct SiFiveUPRCIState {
     /*< private >*/
diff --git a/include/hw/misc/xlnx-versal-xramc.h b/include/hw/misc/xlnx-versal-xramc.h
index fc5a12165cf..7d58656a586 100644
--- a/include/hw/misc/xlnx-versal-xramc.h
+++ b/include/hw/misc/xlnx-versal-xramc.h
@@ -15,9 +15,7 @@
 
 #define TYPE_XLNX_XRAM_CTRL "xlnx.versal-xramc"
 
-typedef struct XlnxXramCtrl XlnxXramCtrl;
-DECLARE_INSTANCE_CHECKER(XlnxXramCtrl, XLNX_XRAM_CTRL,
-                         TYPE_XLNX_XRAM_CTRL)
+OBJECT_DECLARE_SIMPLE_TYPE(XlnxXramCtrl, XLNX_XRAM_CTRL)
 
 REG32(XRAM_ERR_CTRL, 0x0)
     FIELD(XRAM_ERR_CTRL, UE_RES, 3, 1)
diff --git a/include/hw/net/npcm7xx_emc.h b/include/hw/net/npcm7xx_emc.h
index bdf06c69dde..94f1cd159d8 100644
--- a/include/hw/net/npcm7xx_emc.h
+++ b/include/hw/net/npcm7xx_emc.h
@@ -278,10 +278,8 @@ struct NPCM7xxEMCState {
     bool rx_active;
 };
 
-typedef struct NPCM7xxEMCState NPCM7xxEMCState;
 
 #define TYPE_NPCM7XX_EMC "npcm7xx-emc"
-DECLARE_INSTANCE_CHECKER(NPCM7xxEMCState, NPCM7XX_EMC,
-                         TYPE_NPCM7XX_EMC)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxEMCState, NPCM7XX_EMC)
 
 #endif /* NPCM7XX_EMC_H */
diff --git a/include/hw/net/xlnx-zynqmp-can.h b/include/hw/net/xlnx-zynqmp-can.h
index 4a1fa166571..6283e865148 100644
--- a/include/hw/net/xlnx-zynqmp-can.h
+++ b/include/hw/net/xlnx-zynqmp-can.h
@@ -40,9 +40,7 @@
 
 #define TYPE_XLNX_ZYNQMP_CAN "xlnx.zynqmp-can"
 
-typedef struct XlnxZynqMPCANState XlnxZynqMPCANState;
-DECLARE_INSTANCE_CHECKER(XlnxZynqMPCANState, XLNX_ZYNQMP_CAN,
-                         TYPE_XLNX_ZYNQMP_CAN)
+OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPCANState, XLNX_ZYNQMP_CAN)
 
 #define MAX_CAN_CTRLS      2
 #define XLNX_ZYNQMP_CAN_R_MAX     (0x84 / 4)
diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h
index ff876fd74ca..700abe0874c 100644
--- a/include/hw/ppc/spapr_drc.h
+++ b/include/hw/ppc/spapr_drc.h
@@ -23,9 +23,7 @@
 OBJECT_DECLARE_TYPE(SpaprDrc, SpaprDrcClass, SPAPR_DR_CONNECTOR)
 
 #define TYPE_SPAPR_DRC_PHYSICAL "spapr-drc-physical"
-typedef struct SpaprDrcPhysical SpaprDrcPhysical;
-DECLARE_INSTANCE_CHECKER(SpaprDrcPhysical, SPAPR_DRC_PHYSICAL,
-                         TYPE_SPAPR_DRC_PHYSICAL)
+OBJECT_DECLARE_SIMPLE_TYPE(SpaprDrcPhysical, SPAPR_DRC_PHYSICAL)
 
 #define TYPE_SPAPR_DRC_LOGICAL "spapr-drc-logical"
 
diff --git a/include/hw/register.h b/include/hw/register.h
index b480e3882cd..1af762682b7 100644
--- a/include/hw/register.h
+++ b/include/hw/register.h
@@ -88,8 +88,7 @@ struct RegisterInfo {
 };
 
 #define TYPE_REGISTER "qemu-register"
-DECLARE_INSTANCE_CHECKER(RegisterInfo, REGISTER,
-                         TYPE_REGISTER)
+OBJECT_DECLARE_SIMPLE_TYPE(RegisterInfo, REGISTER)
 
 /**
  * This structure is used to group all of the individual registers which are
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
index 3a29a48019e..7996fceade4 100644
--- a/include/hw/riscv/microchip_pfsoc.h
+++ b/include/hw/riscv/microchip_pfsoc.h
@@ -55,11 +55,9 @@ struct MicrochipPFSoCState {
     CadenceGEMState gem1;
     CadenceSDHCIState sdhci;
 };
-typedef struct MicrochipPFSoCState MicrochipPFSoCState;
 
 #define TYPE_MICROCHIP_PFSOC    "microchip.pfsoc"
-DECLARE_INSTANCE_CHECKER(MicrochipPFSoCState, MICROCHIP_PFSOC,
-                         TYPE_MICROCHIP_PFSOC)
+OBJECT_DECLARE_SIMPLE_TYPE(MicrochipPFSoCState, MICROCHIP_PFSOC)
 
 struct MicrochipIcicleKitState {
     /*< private >*/
diff --git a/include/hw/riscv/shakti_c.h b/include/hw/riscv/shakti_c.h
index 6733eca2303..e8e051ee7e9 100644
--- a/include/hw/riscv/shakti_c.h
+++ b/include/hw/riscv/shakti_c.h
@@ -25,9 +25,7 @@
 #include "qom/object.h"
 
 #define TYPE_RISCV_SHAKTI_SOC "riscv.shakti.cclass.soc"
-typedef struct ShaktiCSoCState ShaktiCSoCState;
-DECLARE_INSTANCE_CHECKER(ShaktiCSoCState, RISCV_SHAKTI_SOC,
-                         TYPE_RISCV_SHAKTI_SOC)
+OBJECT_DECLARE_SIMPLE_TYPE(ShaktiCSoCState, RISCV_SHAKTI_SOC)
 
 struct ShaktiCSoCState {
     /*< private >*/
@@ -42,9 +40,7 @@ struct ShaktiCSoCState {
 };
 
 #define TYPE_RISCV_SHAKTI_MACHINE MACHINE_TYPE_NAME("shakti_c")
-typedef struct ShaktiCMachineState ShaktiCMachineState;
-DECLARE_INSTANCE_CHECKER(ShaktiCMachineState, RISCV_SHAKTI_MACHINE,
-                         TYPE_RISCV_SHAKTI_MACHINE)
+OBJECT_DECLARE_SIMPLE_TYPE(ShaktiCMachineState, RISCV_SHAKTI_MACHINE)
 struct ShaktiCMachineState {
     /*< private >*/
     MachineState parent_obj;
diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h
index 22abd643753..44744d16fbd 100644
--- a/include/hw/riscv/sifive_e.h
+++ b/include/hw/riscv/sifive_e.h
@@ -25,9 +25,7 @@
 #include "qom/object.h"
 
 #define TYPE_RISCV_E_SOC "riscv.sifive.e.soc"
-typedef struct SiFiveESoCState SiFiveESoCState;
-DECLARE_INSTANCE_CHECKER(SiFiveESoCState, RISCV_E_SOC,
-                         TYPE_RISCV_E_SOC)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveESoCState, RISCV_E_SOC)
 
 struct SiFiveESoCState {
     /*< private >*/
diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h
index d974043a36d..fff7d61ef5b 100644
--- a/include/hw/riscv/sifive_u.h
+++ b/include/hw/riscv/sifive_u.h
@@ -30,9 +30,7 @@
 #include "qom/object.h"
 
 #define TYPE_RISCV_U_SOC "riscv.sifive.u.soc"
-typedef struct SiFiveUSoCState SiFiveUSoCState;
-DECLARE_INSTANCE_CHECKER(SiFiveUSoCState, RISCV_U_SOC,
-                         TYPE_RISCV_U_SOC)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveUSoCState, RISCV_U_SOC)
 
 struct SiFiveUSoCState {
     /*< private >*/
diff --git a/include/hw/sd/cadence_sdhci.h b/include/hw/sd/cadence_sdhci.h
index 6d6a2d9c0da..22cffb854ea 100644
--- a/include/hw/sd/cadence_sdhci.h
+++ b/include/hw/sd/cadence_sdhci.h
@@ -40,10 +40,8 @@ struct CadenceSDHCIState {
 
     SDHCIState sdhci;
 };
-typedef struct CadenceSDHCIState CadenceSDHCIState;
 
 #define TYPE_CADENCE_SDHCI  "cadence.sdhci"
-DECLARE_INSTANCE_CHECKER(CadenceSDHCIState, CADENCE_SDHCI,
-                         TYPE_CADENCE_SDHCI)
+OBJECT_DECLARE_SIMPLE_TYPE(CadenceSDHCIState, CADENCE_SDHCI)
 
 #endif /* CADENCE_SDHCI_H */
diff --git a/include/hw/ssi/sifive_spi.h b/include/hw/ssi/sifive_spi.h
index d32deaea0ec..c4f744230f2 100644
--- a/include/hw/ssi/sifive_spi.h
+++ b/include/hw/ssi/sifive_spi.h
@@ -26,9 +26,7 @@
 #define SIFIVE_SPI_REG_NUM  (0x78 / 4)
 
 #define TYPE_SIFIVE_SPI "sifive.spi"
-typedef struct SiFiveSPIState SiFiveSPIState;
-DECLARE_INSTANCE_CHECKER(SiFiveSPIState, SIFIVE_SPI,
-                         TYPE_SIFIVE_SPI)
+OBJECT_DECLARE_SIMPLE_TYPE(SiFiveSPIState, SIFIVE_SPI)
 
 struct SiFiveSPIState {
     SysBusDevice parent_obj;
diff --git a/include/hw/timer/npcm7xx_timer.h b/include/hw/timer/npcm7xx_timer.h
index ff1985f5ca5..8d41b66e966 100644
--- a/include/hw/timer/npcm7xx_timer.h
+++ b/include/hw/timer/npcm7xx_timer.h
@@ -108,7 +108,6 @@ struct NPCM7xxTimerCtrlState {
 };
 
 #define TYPE_NPCM7XX_TIMER "npcm7xx-timer"
-DECLARE_INSTANCE_CHECKER(NPCM7xxTimerCtrlState, NPCM7XX_TIMER,
-                         TYPE_NPCM7XX_TIMER)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxTimerCtrlState, NPCM7XX_TIMER)
 
 #endif /* NPCM7XX_TIMER_H */
diff --git a/include/hw/tricore/tricore_testdevice.h b/include/hw/tricore/tricore_testdevice.h
index 4d68f129cc1..f1266c85401 100644
--- a/include/hw/tricore/tricore_testdevice.h
+++ b/include/hw/tricore/tricore_testdevice.h
@@ -24,9 +24,7 @@
 #include "qom/object.h"
 
 #define TYPE_TRICORE_TESTDEVICE "tricore_testdevice"
-typedef struct TriCoreTestDeviceState TriCoreTestDeviceState;
-DECLARE_INSTANCE_CHECKER(TriCoreTestDeviceState, TRICORE_TESTDEVICE,
-                         TYPE_TRICORE_TESTDEVICE)
+OBJECT_DECLARE_SIMPLE_TYPE(TriCoreTestDeviceState, TRICORE_TESTDEVICE)
 
 struct TriCoreTestDeviceState {
     /* <private> */
diff --git a/include/hw/usb/hcd-dwc3.h b/include/hw/usb/hcd-dwc3.h
index 20402a9ad0b..9f2e64ee498 100644
--- a/include/hw/usb/hcd-dwc3.h
+++ b/include/hw/usb/hcd-dwc3.h
@@ -32,9 +32,7 @@
 
 #define TYPE_USB_DWC3 "usb_dwc3"
 
-typedef struct USBDWC3 USBDWC3;
-DECLARE_INSTANCE_CHECKER(USBDWC3, USB_DWC3,
-                         TYPE_USB_DWC3)
+OBJECT_DECLARE_SIMPLE_TYPE(USBDWC3, USB_DWC3)
 
 #define USB_DWC3_R_MAX ((0x530 / 4) + 1)
 #define DWC3_SIZE 0x10000
diff --git a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
index 701302ad044..2576193e673 100644
--- a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
+++ b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
@@ -29,9 +29,7 @@
 
 #define TYPE_XILINX_VERSAL_USB2_CTRL_REGS "xlnx.versal-usb2-ctrl-regs"
 
-typedef struct VersalUsb2CtrlRegs VersalUsb2CtrlRegs;
-DECLARE_INSTANCE_CHECKER(VersalUsb2CtrlRegs, XILINX_VERSAL_USB2_CTRL_REGS,
-                         TYPE_XILINX_VERSAL_USB2_CTRL_REGS)
+OBJECT_DECLARE_SIMPLE_TYPE(VersalUsb2CtrlRegs, XILINX_VERSAL_USB2_CTRL_REGS)
 
 #define USB2_REGS_R_MAX ((0x78 / 4) + 1)
 
diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c
index 165ab56eeaa..ee064e185c5 100644
--- a/hw/m68k/mcf5206.c
+++ b/hw/m68k/mcf5206.c
@@ -179,10 +179,8 @@ struct m5206_mbar_state {
     /* Include the UART vector registers here.  */
     uint8_t uivr[2];
 };
-typedef struct m5206_mbar_state m5206_mbar_state;
 
-DECLARE_INSTANCE_CHECKER(m5206_mbar_state, MCF5206_MBAR,
-                         TYPE_MCF5206_MBAR)
+OBJECT_DECLARE_SIMPLE_TYPE(m5206_mbar_state, MCF5206_MBAR)
 
 /* Interrupt controller.  */
 
diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index 20b06865b2b..fa8b23d2694 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -44,9 +44,7 @@
 #include "qom/object.h"
 
 #define TYPE_BOSTON "mips-boston"
-typedef struct BostonState BostonState;
-DECLARE_INSTANCE_CHECKER(BostonState, BOSTON,
-                         TYPE_BOSTON)
+OBJECT_DECLARE_SIMPLE_TYPE(BostonState, BOSTON)
 
 struct BostonState {
     SysBusDevice parent_obj;
diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c
index 5247acfeb5a..4dd60fff03f 100644
--- a/hw/misc/npcm7xx_clk.c
+++ b/hw/misc/npcm7xx_clk.c
@@ -110,14 +110,11 @@ static const uint32_t cold_reset_values[NPCM7XX_CLK_NR_REGS] = {
 /* Clock converter functions */
 
 #define TYPE_NPCM7XX_CLOCK_PLL "npcm7xx-clock-pll"
-DECLARE_INSTANCE_CHECKER(NPCM7xxClockPLLState, NPCM7XX_CLOCK_PLL,
-                         TYPE_NPCM7XX_CLOCK_PLL)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxClockPLLState, NPCM7XX_CLOCK_PLL)
 #define TYPE_NPCM7XX_CLOCK_SEL "npcm7xx-clock-sel"
-DECLARE_INSTANCE_CHECKER(NPCM7xxClockSELState, NPCM7XX_CLOCK_SEL,
-                         TYPE_NPCM7XX_CLOCK_SEL)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxClockSELState, NPCM7XX_CLOCK_SEL)
 #define TYPE_NPCM7XX_CLOCK_DIVIDER "npcm7xx-clock-divider"
-DECLARE_INSTANCE_CHECKER(NPCM7xxClockDividerState, NPCM7XX_CLOCK_DIVIDER,
-                         TYPE_NPCM7XX_CLOCK_DIVIDER)
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxClockDividerState, NPCM7XX_CLOCK_DIVIDER)
 
 static void npcm7xx_clk_update_pll(void *opaque)
 {
diff --git a/hw/net/can/ctucan_pci.c b/hw/net/can/ctucan_pci.c
index 1f277a7c363..4ce36dfa976 100644
--- a/hw/net/can/ctucan_pci.c
+++ b/hw/net/can/ctucan_pci.c
@@ -44,9 +44,7 @@
 
 #define TYPE_CTUCAN_PCI_DEV "ctucan_pci"
 
-typedef struct CtuCanPCIState CtuCanPCIState;
-DECLARE_INSTANCE_CHECKER(CtuCanPCIState, CTUCAN_PCI_DEV,
-                         TYPE_CTUCAN_PCI_DEV)
+OBJECT_DECLARE_SIMPLE_TYPE(CtuCanPCIState, CTUCAN_PCI_DEV)
 
 #define CTUCAN_PCI_CORE_COUNT     2
 #define CTUCAN_PCI_CORE_RANGE     0x10000
diff --git a/hw/s390x/vhost-user-fs-ccw.c b/hw/s390x/vhost-user-fs-ccw.c
index 5a72a22d48f..e905849a580 100644
--- a/hw/s390x/vhost-user-fs-ccw.c
+++ b/hw/s390x/vhost-user-fs-ccw.c
@@ -18,11 +18,9 @@ struct VHostUserFSCcw {
     VirtioCcwDevice parent_obj;
     VHostUserFS vdev;
 };
-typedef struct VHostUserFSCcw VHostUserFSCcw;
 
 #define TYPE_VHOST_USER_FS_CCW "vhost-user-fs-ccw"
-DECLARE_INSTANCE_CHECKER(VHostUserFSCcw, VHOST_USER_FS_CCW,
-                         TYPE_VHOST_USER_FS_CCW)
+OBJECT_DECLARE_SIMPLE_TYPE(VHostUserFSCcw, VHOST_USER_FS_CCW)
 
 
 static Property vhost_user_fs_ccw_properties[] = {
diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
index a678174b18c..cbed43adb64 100644
--- a/hw/sensor/adm1272.c
+++ b/hw/sensor/adm1272.c
@@ -19,9 +19,7 @@
 #include "qom/object.h"
 
 #define TYPE_ADM1272 "adm1272"
-typedef struct ADM1272State ADM1272State;
-DECLARE_INSTANCE_CHECKER(ADM1272State, ADM1272,
-                         TYPE_ADM1272)
+OBJECT_DECLARE_SIMPLE_TYPE(ADM1272State, ADM1272)
 
 #define ADM1272_RESTART_TIME            0xCC
 #define ADM1272_MFR_PEAK_IOUT           0xD0
diff --git a/hw/sensor/max34451.c b/hw/sensor/max34451.c
index 864f0bfc736..918c78b0f21 100644
--- a/hw/sensor/max34451.c
+++ b/hw/sensor/max34451.c
@@ -17,9 +17,7 @@
 #include "qom/object.h"
 
 #define TYPE_MAX34451 "max34451"
-typedef struct MAX34451State MAX34451State;
-DECLARE_INSTANCE_CHECKER(MAX34451State, MAX34451,
-                         TYPE_MAX34451)
+OBJECT_DECLARE_SIMPLE_TYPE(MAX34451State, MAX34451)
 
 #define MAX34451_MFR_MODE               0xD1
 #define MAX34451_MFR_PSEN_CONFIG        0xD2
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 08/12] npcm7xx_clk: Use DECLARE_INSTANCE_CHECKER
  2021-08-06 21:11 ` [PATCH for-6.2 08/12] npcm7xx_clk: Use DECLARE_INSTANCE_CHECKER Eduardo Habkost
@ 2021-08-07  7:59   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-08-07  7:59 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Paolo Bonzini, qemu-arm, Daniel P. Berrange, Havard Skinnemoen,
	Tyrone Ting

On 8/6/21 11:11 PM, Eduardo Habkost wrote:
> Use DECLARE_INSTANCE_CHECKER instead of defining the
> NPCM7XX_CLOCK_PLL, NPCM7XX_CLOCK_SEL, and NPCM7XX_CLOCK_DIVIDER
> macros manually.
> 
> These changes had to be done manually because the codeconverter
> script isn't smart enough to figure out that the typedefs exist
> in a separate header.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: qemu-arm@nongnu.org
> Cc: qemu-devel@nongnu.org
> ---
>  hw/misc/npcm7xx_clk.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 09/12] npcm7xx_otp: Use DECLARE_CLASS_CHECKERS
  2021-08-06 21:11 ` [PATCH for-6.2 09/12] npcm7xx_otp: Use DECLARE_CLASS_CHECKERS Eduardo Habkost
@ 2021-08-07  8:00   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-08-07  8:00 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Paolo Bonzini, qemu-arm, Daniel P. Berrange, Havard Skinnemoen,
	Tyrone Ting

On 8/6/21 11:11 PM, Eduardo Habkost wrote:
> Use DECLARE_CLASS_CHECKERS instead of defining the
> NPCM7XX_OTP_CLASS and NPCM7XX_OTP_GET_CLASS macros manually.
> 
> These changes had to be done manually because the typedef and the
> existing macro definitions were in different files.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: qemu-arm@nongnu.org
> Cc: qemu-devel@nongnu.org
> ---
>  include/hw/nvram/npcm7xx_otp.h | 5 +++--
>  hw/nvram/npcm7xx_otp.c         | 5 -----
>  2 files changed, 3 insertions(+), 7 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 11/12] [automated] Use OBJECT_DECLARE_TYPE when possible
  2021-08-06 21:11 ` [PATCH for-6.2 11/12] [automated] Use OBJECT_DECLARE_TYPE " Eduardo Habkost
@ 2021-08-07  8:02   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-08-07  8:02 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Kevin Wolf, Daniel P. Berrange, qemu-block, Richard Henderson,
	Greg Kurz, Max Reitz, qemu-ppc, Cédric Le Goater,
	Paolo Bonzini, David Gibson, John Snow, Gerd Hoffmann

On 8/6/21 11:11 PM, Eduardo Habkost wrote:
> Replace typedefs + DECLARE_OBJ_CHECKERS with equivalent
> OBJECT_DECLARE_TYPE macro.
> 
> Generated using:
> 
> $ ./scripts/codeconverter/converter.py -i \
>   --pattern=AddObjectDeclareType $(git grep -l '' -- '*.[ch]')
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: John Snow <jsnow@redhat.com>
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Max Reitz <mreitz@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Greg Kurz <groug@kaod.org>
> Cc: "Cédric Le Goater" <clg@kaod.org>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: qemu-block@nongnu.org
> Cc: qemu-devel@nongnu.org
> Cc: qemu-ppc@nongnu.org
> ---
>  hw/usb/u2f.h                | 6 +-----
>  include/crypto/tlscreds.h   | 5 +----
>  include/hw/ppc/spapr_drc.h  | 5 +----
>  include/hw/ppc/spapr_xive.h | 5 +----
>  include/qemu/accel.h        | 4 +---
>  hw/block/fdc-sysbus.c       | 5 +----
>  6 files changed, 6 insertions(+), 24 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 04/12] [automated] Add struct names to typedefs used by QOM types
  2021-08-06 21:11   ` Eduardo Habkost
@ 2021-08-07  8:03     ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-08-07  8:03 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: qemu-riscv, Paolo Bonzini, Thomas Huth, Bastian Koppelmann,
	Havard Skinnemoen, Tyrone Ting, qemu-arm, Marc-André Lureau,
	Vijai Kumar K, Daniel P. Berrange

On 8/6/21 11:11 PM, Eduardo Habkost wrote:
> Anonymous structs on QOM typedefs make the code harder to convert
> to OBJECT_DEFINE* macros, as the macros expect the struct name to
> exist.
> 
> Use a codeconverter rule to automatically add names to the
> structs used in QOM typedefs.
> 
> Generated using:
> 
>  $ ./scripts/codeconverter/converter.py -i \
>    --pattern=AddNamesToTypedefs $(git grep -l '' -- '*.[ch]')
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Thomas Huth <huth@tuxfamily.org>
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: Vijai Kumar K <vijai@behindbytes.com>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-riscv@nongnu.org
> ---
>  include/hw/adc/npcm7xx_adc.h            | 2 +-
>  include/hw/char/shakti_uart.h           | 2 +-
>  include/hw/tricore/tricore_testdevice.h | 2 +-
>  chardev/char-parallel.c                 | 4 ++--
>  hw/m68k/mcf5206.c                       | 2 +-
>  hw/misc/sbsa_ec.c                       | 2 +-
>  6 files changed, 7 insertions(+), 7 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 04/12] [automated] Add struct names to typedefs used by QOM types
@ 2021-08-07  8:03     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-08-07  8:03 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Daniel P. Berrange, qemu-riscv, Thomas Huth, Bastian Koppelmann,
	Havard Skinnemoen, Tyrone Ting, qemu-arm, Marc-André Lureau,
	Vijai Kumar K, Paolo Bonzini

On 8/6/21 11:11 PM, Eduardo Habkost wrote:
> Anonymous structs on QOM typedefs make the code harder to convert
> to OBJECT_DEFINE* macros, as the macros expect the struct name to
> exist.
> 
> Use a codeconverter rule to automatically add names to the
> structs used in QOM typedefs.
> 
> Generated using:
> 
>  $ ./scripts/codeconverter/converter.py -i \
>    --pattern=AddNamesToTypedefs $(git grep -l '' -- '*.[ch]')
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Thomas Huth <huth@tuxfamily.org>
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: Vijai Kumar K <vijai@behindbytes.com>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-riscv@nongnu.org
> ---
>  include/hw/adc/npcm7xx_adc.h            | 2 +-
>  include/hw/char/shakti_uart.h           | 2 +-
>  include/hw/tricore/tricore_testdevice.h | 2 +-
>  chardev/char-parallel.c                 | 4 ++--
>  hw/m68k/mcf5206.c                       | 2 +-
>  hw/misc/sbsa_ec.c                       | 2 +-
>  6 files changed, 7 insertions(+), 7 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 12/12] [automated] Use OBJECT_DECLARE_SIMPLE_TYPE when possible
  2021-08-06 21:11   ` Eduardo Habkost
@ 2021-08-07  8:09     ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-08-07  8:09 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Peter Maydell, Michael S. Tsirkin, Jason Wang, Bin Meng,
	Vijai Kumar K, Alistair Francis, Gerd Hoffmann, Klaus Jensen,
	Edgar E. Iglesias, Vikram Garhwal, Paul Burton, Tyrone Ting,
	David Hildenbrand, Havard Skinnemoen, Halil Pasic,
	Christian Borntraeger, Joel Stanley, Palmer Dabbelt, Pavel Pisa,
	Aleksandar Rikalo, Richard Henderson, Greg Kurz, qemu-s390x,
	qemu-arm, Cédric Le Goater, Keith Busch, Daniel P. Berrange,
	David Gibson, qemu-riscv, qemu-block, Francisco Iglesias,
	Andrew Jeffery, Bastian Koppelmann, Cornelia Huck,
	Laurent Vivier, Andrew Baumann, Thomas Huth, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

On 8/6/21 11:11 PM, Eduardo Habkost wrote:
> Replace typedef + DECLARE_INSTANCE_CHECKER with
> equivalent OBJECT_DECLARE_SIMPLE_TYPE macro.
> 
> Generated using:
> 
> $ ./scripts/codeconverter/converter.py -i \
>   --pattern=AddObjectDeclareSimpleType $(git grep -l '' -- '*.[ch]')
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Thomas Huth <huth@tuxfamily.org>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
> Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Klaus Jensen <its@irrelevant.dk>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Vijai Kumar K <vijai@behindbytes.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Bin Meng <bin.meng@windriver.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: "Cédric Le Goater" <clg@kaod.org>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
> Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Greg Kurz <groug@kaod.org>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-block@nongnu.org
> Cc: qemu-s390x@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-ppc@nongnu.org
> ---
>  hw/nvme/nvme.h                              | 10 +++-------
>  hw/usb/hcd-xhci-pci.h                       |  4 +---
>  hw/usb/hcd-xhci-sysbus.h                    |  4 +---
>  include/hw/adc/npcm7xx_adc.h                |  4 +---
>  include/hw/char/shakti_uart.h               |  4 +---
>  include/hw/dma/sifive_pdma.h                |  4 +---
>  include/hw/dma/xlnx_csu_dma.h               |  4 +---
>  include/hw/gpio/sifive_gpio.h               |  4 +---
>  include/hw/intc/m68k_irqc.h                 |  4 +---
>  include/hw/intc/sifive_clint.h              |  4 +---
>  include/hw/intc/sifive_plic.h               |  4 +---
>  include/hw/misc/aspeed_lpc.h                |  4 +---
>  include/hw/misc/bcm2835_cprman_internals.h  | 12 ++++--------
>  include/hw/misc/led.h                       |  3 +--
>  include/hw/misc/mchp_pfsoc_dmc.h            |  8 ++------
>  include/hw/misc/mchp_pfsoc_ioscb.h          |  4 +---
>  include/hw/misc/mchp_pfsoc_sysreg.h         |  4 +---
>  include/hw/misc/npcm7xx_clk.h               |  3 +--
>  include/hw/misc/npcm7xx_gcr.h               |  4 +---
>  include/hw/misc/npcm7xx_mft.h               |  4 +---
>  include/hw/misc/npcm7xx_pwm.h               |  3 +--
>  include/hw/misc/sifive_e_prci.h             |  4 +---
>  include/hw/misc/sifive_test.h               |  4 +---
>  include/hw/misc/sifive_u_otp.h              |  4 +---
>  include/hw/misc/sifive_u_prci.h             |  4 +---
>  include/hw/misc/xlnx-versal-xramc.h         |  4 +---
>  include/hw/net/npcm7xx_emc.h                |  4 +---
>  include/hw/net/xlnx-zynqmp-can.h            |  4 +---
>  include/hw/ppc/spapr_drc.h                  |  4 +---
>  include/hw/register.h                       |  3 +--
>  include/hw/riscv/microchip_pfsoc.h          |  4 +---
>  include/hw/riscv/shakti_c.h                 |  8 ++------
>  include/hw/riscv/sifive_e.h                 |  4 +---
>  include/hw/riscv/sifive_u.h                 |  4 +---
>  include/hw/sd/cadence_sdhci.h               |  4 +---
>  include/hw/ssi/sifive_spi.h                 |  4 +---
>  include/hw/timer/npcm7xx_timer.h            |  3 +--
>  include/hw/tricore/tricore_testdevice.h     |  4 +---
>  include/hw/usb/hcd-dwc3.h                   |  4 +---
>  include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  4 +---
>  hw/m68k/mcf5206.c                           |  4 +---
>  hw/mips/boston.c                            |  4 +---
>  hw/misc/npcm7xx_clk.c                       |  9 +++------
>  hw/net/can/ctucan_pci.c                     |  4 +---
>  hw/s390x/vhost-user-fs-ccw.c                |  4 +---
>  hw/sensor/adm1272.c                         |  4 +---
>  hw/sensor/max34451.c                        |  4 +---
>  47 files changed, 56 insertions(+), 154 deletions(-)

> diff --git a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
> index 701302ad044..2576193e673 100644
> --- a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
> +++ b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
> @@ -29,9 +29,7 @@
>  
>  #define TYPE_XILINX_VERSAL_USB2_CTRL_REGS "xlnx.versal-usb2-ctrl-regs"
>  
> -typedef struct VersalUsb2CtrlRegs VersalUsb2CtrlRegs;
> -DECLARE_INSTANCE_CHECKER(VersalUsb2CtrlRegs, XILINX_VERSAL_USB2_CTRL_REGS,
> -                         TYPE_XILINX_VERSAL_USB2_CTRL_REGS)
> +OBJECT_DECLARE_SIMPLE_TYPE(VersalUsb2CtrlRegs, XILINX_VERSAL_USB2_CTRL_REGS)

Unrelated to this patch, we should remove the _regs suffix from
this model.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 12/12] [automated] Use OBJECT_DECLARE_SIMPLE_TYPE when possible
@ 2021-08-07  8:09     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-08-07  8:09 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Peter Maydell, Michael S. Tsirkin, Andrew Jeffery, Jason Wang,
	Bin Meng, Laurent Vivier, Vijai Kumar K, Alistair Francis,
	Gerd Hoffmann, Klaus Jensen, Edgar E. Iglesias, Vikram Garhwal,
	Paul Burton, David Hildenbrand, Havard Skinnemoen, Halil Pasic,
	Christian Borntraeger, Joel Stanley, qemu-ppc, Pavel Pisa,
	Aleksandar Rikalo, Richard Henderson, Greg Kurz, qemu-s390x,
	qemu-arm, Cédric Le Goater, Keith Busch, qemu-riscv,
	David Gibson, Daniel P. Berrange, qemu-block, Francisco Iglesias,
	Thomas Huth, Bastian Koppelmann, Cornelia Huck, Andrew Baumann,
	Tyrone Ting, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

On 8/6/21 11:11 PM, Eduardo Habkost wrote:
> Replace typedef + DECLARE_INSTANCE_CHECKER with
> equivalent OBJECT_DECLARE_SIMPLE_TYPE macro.
> 
> Generated using:
> 
> $ ./scripts/codeconverter/converter.py -i \
>   --pattern=AddObjectDeclareSimpleType $(git grep -l '' -- '*.[ch]')
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Thomas Huth <huth@tuxfamily.org>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
> Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Klaus Jensen <its@irrelevant.dk>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Vijai Kumar K <vijai@behindbytes.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Bin Meng <bin.meng@windriver.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: "Cédric Le Goater" <clg@kaod.org>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
> Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Greg Kurz <groug@kaod.org>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-block@nongnu.org
> Cc: qemu-s390x@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-ppc@nongnu.org
> ---
>  hw/nvme/nvme.h                              | 10 +++-------
>  hw/usb/hcd-xhci-pci.h                       |  4 +---
>  hw/usb/hcd-xhci-sysbus.h                    |  4 +---
>  include/hw/adc/npcm7xx_adc.h                |  4 +---
>  include/hw/char/shakti_uart.h               |  4 +---
>  include/hw/dma/sifive_pdma.h                |  4 +---
>  include/hw/dma/xlnx_csu_dma.h               |  4 +---
>  include/hw/gpio/sifive_gpio.h               |  4 +---
>  include/hw/intc/m68k_irqc.h                 |  4 +---
>  include/hw/intc/sifive_clint.h              |  4 +---
>  include/hw/intc/sifive_plic.h               |  4 +---
>  include/hw/misc/aspeed_lpc.h                |  4 +---
>  include/hw/misc/bcm2835_cprman_internals.h  | 12 ++++--------
>  include/hw/misc/led.h                       |  3 +--
>  include/hw/misc/mchp_pfsoc_dmc.h            |  8 ++------
>  include/hw/misc/mchp_pfsoc_ioscb.h          |  4 +---
>  include/hw/misc/mchp_pfsoc_sysreg.h         |  4 +---
>  include/hw/misc/npcm7xx_clk.h               |  3 +--
>  include/hw/misc/npcm7xx_gcr.h               |  4 +---
>  include/hw/misc/npcm7xx_mft.h               |  4 +---
>  include/hw/misc/npcm7xx_pwm.h               |  3 +--
>  include/hw/misc/sifive_e_prci.h             |  4 +---
>  include/hw/misc/sifive_test.h               |  4 +---
>  include/hw/misc/sifive_u_otp.h              |  4 +---
>  include/hw/misc/sifive_u_prci.h             |  4 +---
>  include/hw/misc/xlnx-versal-xramc.h         |  4 +---
>  include/hw/net/npcm7xx_emc.h                |  4 +---
>  include/hw/net/xlnx-zynqmp-can.h            |  4 +---
>  include/hw/ppc/spapr_drc.h                  |  4 +---
>  include/hw/register.h                       |  3 +--
>  include/hw/riscv/microchip_pfsoc.h          |  4 +---
>  include/hw/riscv/shakti_c.h                 |  8 ++------
>  include/hw/riscv/sifive_e.h                 |  4 +---
>  include/hw/riscv/sifive_u.h                 |  4 +---
>  include/hw/sd/cadence_sdhci.h               |  4 +---
>  include/hw/ssi/sifive_spi.h                 |  4 +---
>  include/hw/timer/npcm7xx_timer.h            |  3 +--
>  include/hw/tricore/tricore_testdevice.h     |  4 +---
>  include/hw/usb/hcd-dwc3.h                   |  4 +---
>  include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  4 +---
>  hw/m68k/mcf5206.c                           |  4 +---
>  hw/mips/boston.c                            |  4 +---
>  hw/misc/npcm7xx_clk.c                       |  9 +++------
>  hw/net/can/ctucan_pci.c                     |  4 +---
>  hw/s390x/vhost-user-fs-ccw.c                |  4 +---
>  hw/sensor/adm1272.c                         |  4 +---
>  hw/sensor/max34451.c                        |  4 +---
>  47 files changed, 56 insertions(+), 154 deletions(-)

> diff --git a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
> index 701302ad044..2576193e673 100644
> --- a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
> +++ b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h
> @@ -29,9 +29,7 @@
>  
>  #define TYPE_XILINX_VERSAL_USB2_CTRL_REGS "xlnx.versal-usb2-ctrl-regs"
>  
> -typedef struct VersalUsb2CtrlRegs VersalUsb2CtrlRegs;
> -DECLARE_INSTANCE_CHECKER(VersalUsb2CtrlRegs, XILINX_VERSAL_USB2_CTRL_REGS,
> -                         TYPE_XILINX_VERSAL_USB2_CTRL_REGS)
> +OBJECT_DECLARE_SIMPLE_TYPE(VersalUsb2CtrlRegs, XILINX_VERSAL_USB2_CTRL_REGS)

Unrelated to this patch, we should remove the _regs suffix from
this model.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 05/12] [automated] Move QOM typedefs and add missing includes
  2021-08-06 21:11   ` Eduardo Habkost
@ 2021-08-07  8:13     ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-08-07  8:13 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Peter Maydell, Huacai Chen, Michael S. Tsirkin,
	Alexey Kardashevskiy, Jason Wang, Bin Meng, Vijai Kumar K,
	Taylor Simpson, Alistair Francis, Gerd Hoffmann, Tyrone Ting,
	Klaus Jensen, Edgar E. Iglesias, Vikram Garhwal, qemu-block,
	Stefan Berger, David Hildenbrand, Havard Skinnemoen, Halil Pasic,
	Christian Borntraeger, Hervé Poussineau, Joel Stanley,
	Marc-André Lureau, Bandan Das, Pavel Pisa,
	Aleksandar Rikalo, Corey Minyard, Richard Henderson, Greg Kurz,
	Dr. David Alan Gilbert, Alexander Bulekov, qemu-s390x, qemu-arm,
	Cédric Le Goater, Stefan Hajnoczi, Igor Mammedov,
	Keith Busch, Daniel P. Berrange, Palmer Dabbelt, David Gibson,
	qemu-riscv, Francisco Iglesias, Andrew Jeffery,
	Bastian Koppelmann, Juan Quintela, Laurent Vivier,
	Andrew Baumann, Thomas Huth, qemu-ppc, Cornelia Huck,
	Paolo Bonzini, Aurelien Jarno

On 8/6/21 11:11 PM, Eduardo Habkost wrote:
> Some typedefs and macros are defined after the type check macros.
> This makes it difficult to automatically replace their
> definitions with OBJECT_DECLARE_TYPE.
> 
> Patch generated using:
> 
>  $ ./scripts/codeconverter/converter.py -i --pattern=MoveSymbols \
>     $(git grep -l '' -- '*.[ch]')
> 
> which will:
> - split "typdef struct { ... } TypedefName" declarations
> - move the typedefs and #defines above the type check macros
> - add missing #include "qom/object.h" lines if necessary
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> Cc: Thomas Huth <huth@tuxfamily.org>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Igor Mammedov <imammedo@redhat.com>
> Cc: Alexander Bulekov <alxndr@bu.edu>
> Cc: Bandan Das <bsd@redhat.com>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: Huacai Chen <chenhuacai@kernel.org>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
> Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Klaus Jensen <its@irrelevant.dk>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Vijai Kumar K <vijai@behindbytes.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Bin Meng <bin.meng@windriver.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: Corey Minyard <minyard@acm.org>
> Cc: "Cédric Le Goater" <clg@kaod.org>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Greg Kurz <groug@kaod.org>
> Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
> Cc: "Hervé Poussineau" <hpoussin@reactos.org>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: Juan Quintela <quintela@redhat.com>
> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>
> Cc: Taylor Simpson <tsimpson@quicinc.com>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-block@nongnu.org
> Cc: qemu-s390x@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-ppc@nongnu.org
> ---
>  hw/nvme/nvme.h                              |  6 ++++--
>  hw/usb/hcd-uhci.h                           |  1 +
>  hw/usb/hcd-xhci-pci.h                       |  6 ++++--
>  hw/usb/hcd-xhci-sysbus.h                    |  6 ++++--
>  hw/usb/u2f.h                                |  6 ++++--
>  include/hw/acpi/acpi_dev_interface.h        |  2 +-
>  include/hw/adc/npcm7xx_adc.h                |  1 +
>  include/hw/arm/linux-boot-if.h              |  2 +-
>  include/hw/arm/npcm7xx.h                    | 11 +++++++----
>  include/hw/char/shakti_uart.h               |  6 ++++--
>  include/hw/core/accel-cpu.h                 |  1 +
>  include/hw/dma/sifive_pdma.h                |  1 +
>  include/hw/dma/xlnx_csu_dma.h               |  1 +
>  include/hw/fw-path-provider.h               |  2 +-
>  include/hw/gpio/npcm7xx_gpio.h              |  1 +
>  include/hw/hotplug.h                        |  2 +-
>  include/hw/i2c/npcm7xx_smbus.h              |  1 +
>  include/hw/intc/intc.h                      |  2 +-
>  include/hw/intc/m68k_irqc.h                 |  6 ++++--
>  include/hw/intc/sifive_clint.h              |  6 ++++--
>  include/hw/ipmi/ipmi.h                      |  2 +-
>  include/hw/mem/memory-device.h              |  2 +-
>  include/hw/mem/npcm7xx_mc.h                 |  1 +
>  include/hw/misc/aspeed_lpc.h                |  6 ++++--
>  include/hw/misc/bcm2835_cprman.h            |  1 +
>  include/hw/misc/bcm2835_cprman_internals.h  |  1 +
>  include/hw/misc/mchp_pfsoc_dmc.h            |  1 +
>  include/hw/misc/mchp_pfsoc_ioscb.h          |  1 +
>  include/hw/misc/mchp_pfsoc_sysreg.h         |  1 +
>  include/hw/misc/npcm7xx_clk.h               |  1 +
>  include/hw/misc/npcm7xx_gcr.h               |  1 +
>  include/hw/misc/npcm7xx_pwm.h               |  1 +
>  include/hw/misc/npcm7xx_rng.h               |  1 +
>  include/hw/misc/xlnx-versal-xramc.h         |  6 ++++--
>  include/hw/net/npcm7xx_emc.h                |  1 +
>  include/hw/net/xlnx-zynqmp-can.h            |  6 ++++--
>  include/hw/nmi.h                            |  2 +-
>  include/hw/nvram/npcm7xx_otp.h              |  1 +
>  include/hw/ppc/spapr_drc.h                  | 15 +++++++++------
>  include/hw/ppc/spapr_xive.h                 | 11 +++++++----
>  include/hw/ppc/vof.h                        |  1 +
>  include/hw/rdma/rdma.h                      |  2 +-
>  include/hw/riscv/microchip_pfsoc.h          |  1 +
>  include/hw/riscv/shakti_c.h                 | 11 +++++++----
>  include/hw/riscv/sifive_e.h                 |  6 ++++--
>  include/hw/riscv/sifive_u.h                 | 11 +++++++----
>  include/hw/rtc/m48t59.h                     |  2 +-
>  include/hw/sd/cadence_sdhci.h               |  1 +
>  include/hw/ssi/npcm7xx_fiu.h                |  1 +
>  include/hw/ssi/sifive_spi.h                 |  6 ++++--
>  include/hw/stream.h                         |  2 +-
>  include/hw/timer/npcm7xx_timer.h            |  1 +
>  include/hw/tricore/tricore_testdevice.h     |  6 ++++--
>  include/hw/usb/hcd-dwc3.h                   |  6 ++++--
>  include/hw/usb/msd.h                        |  1 +
>  include/hw/usb/xlnx-usb-subsystem.h         |  6 ++++--
>  include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  6 ++++--
>  include/hw/vmstate-if.h                     |  2 +-
>  include/hw/watchdog/sbsa_gwdt.h             |  6 ++++--
>  include/qom/object_interfaces.h             |  2 +-
>  include/sysemu/tpm.h                        |  2 +-
>  target/arm/idau.h                           |  2 +-
>  target/hexagon/cpu.h                        | 11 +++++++----
>  accel/tcg/tcg-all.c                         |  1 +
>  chardev/char-parallel.c                     |  1 +
>  hw/arm/bcm2836.c                            |  1 +
>  hw/m68k/mcf5206.c                           |  1 +
>  hw/mem/sparse-mem.c                         |  6 ++++--
>  hw/mips/loongson3_virt.c                    |  1 +
>  hw/misc/npcm7xx_clk.c                       |  1 +
>  hw/misc/sbsa_ec.c                           |  1 +
>  hw/net/can/ctucan_pci.c                     |  1 +
>  hw/nvram/npcm7xx_otp.c                      |  1 +
>  hw/s390x/vhost-user-fs-ccw.c                |  1 +
>  hw/sensor/adm1272.c                         |  6 ++++--
>  hw/sensor/max34451.c                        |  6 ++++--
>  hw/usb/u2f-emulated.c                       |  1 +
>  hw/usb/u2f-passthru.c                       |  1 +
>  hw/virtio/vhost-user-i2c-pci.c              |  1 +
>  tests/unit/check-qom-interface.c            |  2 +-
>  ui/vdagent.c                                |  1 +
>  81 files changed, 179 insertions(+), 82 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 05/12] [automated] Move QOM typedefs and add missing includes
@ 2021-08-07  8:13     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-08-07  8:13 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Peter Maydell, Michael S. Tsirkin, Alexey Kardashevskiy,
	Andrew Jeffery, Jason Wang, Bin Meng, David Hildenbrand,
	Laurent Vivier, Vijai Kumar K, Taylor Simpson, Alistair Francis,
	Gerd Hoffmann, Klaus Jensen, Edgar E. Iglesias, Vikram Garhwal,
	qemu-block, Juan Quintela, qemu-ppc, Huacai Chen,
	Havard Skinnemoen, Stefan Berger, Halil Pasic,
	Christian Borntraeger, Hervé Poussineau, Joel Stanley,
	Marc-André Lureau, Pavel Pisa, Aleksandar Rikalo,
	Corey Minyard, qemu-s390x, Richard Henderson, Greg Kurz,
	Dr. David Alan Gilbert, Alexander Bulekov, Bandan Das, qemu-arm,
	Cédric Le Goater, Stefan Hajnoczi, Paolo Bonzini,
	Keith Busch, qemu-riscv, David Gibson, Daniel P. Berrange,
	Francisco Iglesias, Thomas Huth, Bastian Koppelmann,
	Cornelia Huck, Andrew Baumann, Tyrone Ting, Palmer Dabbelt,
	Igor Mammedov, Aurelien Jarno

On 8/6/21 11:11 PM, Eduardo Habkost wrote:
> Some typedefs and macros are defined after the type check macros.
> This makes it difficult to automatically replace their
> definitions with OBJECT_DECLARE_TYPE.
> 
> Patch generated using:
> 
>  $ ./scripts/codeconverter/converter.py -i --pattern=MoveSymbols \
>     $(git grep -l '' -- '*.[ch]')
> 
> which will:
> - split "typdef struct { ... } TypedefName" declarations
> - move the typedefs and #defines above the type check macros
> - add missing #include "qom/object.h" lines if necessary
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> Cc: Thomas Huth <huth@tuxfamily.org>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Igor Mammedov <imammedo@redhat.com>
> Cc: Alexander Bulekov <alxndr@bu.edu>
> Cc: Bandan Das <bsd@redhat.com>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: Huacai Chen <chenhuacai@kernel.org>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
> Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Klaus Jensen <its@irrelevant.dk>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Vijai Kumar K <vijai@behindbytes.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Bin Meng <bin.meng@windriver.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: Corey Minyard <minyard@acm.org>
> Cc: "Cédric Le Goater" <clg@kaod.org>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Greg Kurz <groug@kaod.org>
> Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
> Cc: "Hervé Poussineau" <hpoussin@reactos.org>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: Juan Quintela <quintela@redhat.com>
> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>
> Cc: Taylor Simpson <tsimpson@quicinc.com>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-block@nongnu.org
> Cc: qemu-s390x@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-ppc@nongnu.org
> ---
>  hw/nvme/nvme.h                              |  6 ++++--
>  hw/usb/hcd-uhci.h                           |  1 +
>  hw/usb/hcd-xhci-pci.h                       |  6 ++++--
>  hw/usb/hcd-xhci-sysbus.h                    |  6 ++++--
>  hw/usb/u2f.h                                |  6 ++++--
>  include/hw/acpi/acpi_dev_interface.h        |  2 +-
>  include/hw/adc/npcm7xx_adc.h                |  1 +
>  include/hw/arm/linux-boot-if.h              |  2 +-
>  include/hw/arm/npcm7xx.h                    | 11 +++++++----
>  include/hw/char/shakti_uart.h               |  6 ++++--
>  include/hw/core/accel-cpu.h                 |  1 +
>  include/hw/dma/sifive_pdma.h                |  1 +
>  include/hw/dma/xlnx_csu_dma.h               |  1 +
>  include/hw/fw-path-provider.h               |  2 +-
>  include/hw/gpio/npcm7xx_gpio.h              |  1 +
>  include/hw/hotplug.h                        |  2 +-
>  include/hw/i2c/npcm7xx_smbus.h              |  1 +
>  include/hw/intc/intc.h                      |  2 +-
>  include/hw/intc/m68k_irqc.h                 |  6 ++++--
>  include/hw/intc/sifive_clint.h              |  6 ++++--
>  include/hw/ipmi/ipmi.h                      |  2 +-
>  include/hw/mem/memory-device.h              |  2 +-
>  include/hw/mem/npcm7xx_mc.h                 |  1 +
>  include/hw/misc/aspeed_lpc.h                |  6 ++++--
>  include/hw/misc/bcm2835_cprman.h            |  1 +
>  include/hw/misc/bcm2835_cprman_internals.h  |  1 +
>  include/hw/misc/mchp_pfsoc_dmc.h            |  1 +
>  include/hw/misc/mchp_pfsoc_ioscb.h          |  1 +
>  include/hw/misc/mchp_pfsoc_sysreg.h         |  1 +
>  include/hw/misc/npcm7xx_clk.h               |  1 +
>  include/hw/misc/npcm7xx_gcr.h               |  1 +
>  include/hw/misc/npcm7xx_pwm.h               |  1 +
>  include/hw/misc/npcm7xx_rng.h               |  1 +
>  include/hw/misc/xlnx-versal-xramc.h         |  6 ++++--
>  include/hw/net/npcm7xx_emc.h                |  1 +
>  include/hw/net/xlnx-zynqmp-can.h            |  6 ++++--
>  include/hw/nmi.h                            |  2 +-
>  include/hw/nvram/npcm7xx_otp.h              |  1 +
>  include/hw/ppc/spapr_drc.h                  | 15 +++++++++------
>  include/hw/ppc/spapr_xive.h                 | 11 +++++++----
>  include/hw/ppc/vof.h                        |  1 +
>  include/hw/rdma/rdma.h                      |  2 +-
>  include/hw/riscv/microchip_pfsoc.h          |  1 +
>  include/hw/riscv/shakti_c.h                 | 11 +++++++----
>  include/hw/riscv/sifive_e.h                 |  6 ++++--
>  include/hw/riscv/sifive_u.h                 | 11 +++++++----
>  include/hw/rtc/m48t59.h                     |  2 +-
>  include/hw/sd/cadence_sdhci.h               |  1 +
>  include/hw/ssi/npcm7xx_fiu.h                |  1 +
>  include/hw/ssi/sifive_spi.h                 |  6 ++++--
>  include/hw/stream.h                         |  2 +-
>  include/hw/timer/npcm7xx_timer.h            |  1 +
>  include/hw/tricore/tricore_testdevice.h     |  6 ++++--
>  include/hw/usb/hcd-dwc3.h                   |  6 ++++--
>  include/hw/usb/msd.h                        |  1 +
>  include/hw/usb/xlnx-usb-subsystem.h         |  6 ++++--
>  include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  6 ++++--
>  include/hw/vmstate-if.h                     |  2 +-
>  include/hw/watchdog/sbsa_gwdt.h             |  6 ++++--
>  include/qom/object_interfaces.h             |  2 +-
>  include/sysemu/tpm.h                        |  2 +-
>  target/arm/idau.h                           |  2 +-
>  target/hexagon/cpu.h                        | 11 +++++++----
>  accel/tcg/tcg-all.c                         |  1 +
>  chardev/char-parallel.c                     |  1 +
>  hw/arm/bcm2836.c                            |  1 +
>  hw/m68k/mcf5206.c                           |  1 +
>  hw/mem/sparse-mem.c                         |  6 ++++--
>  hw/mips/loongson3_virt.c                    |  1 +
>  hw/misc/npcm7xx_clk.c                       |  1 +
>  hw/misc/sbsa_ec.c                           |  1 +
>  hw/net/can/ctucan_pci.c                     |  1 +
>  hw/nvram/npcm7xx_otp.c                      |  1 +
>  hw/s390x/vhost-user-fs-ccw.c                |  1 +
>  hw/sensor/adm1272.c                         |  6 ++++--
>  hw/sensor/max34451.c                        |  6 ++++--
>  hw/usb/u2f-emulated.c                       |  1 +
>  hw/usb/u2f-passthru.c                       |  1 +
>  hw/virtio/vhost-user-i2c-pci.c              |  1 +
>  tests/unit/check-qom-interface.c            |  2 +-
>  ui/vdagent.c                                |  1 +
>  81 files changed, 179 insertions(+), 82 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends
  2021-08-06 21:11 [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Eduardo Habkost
                   ` (11 preceding siblings ...)
  2021-08-06 21:11   ` Eduardo Habkost
@ 2021-08-07  8:15 ` Philippe Mathieu-Daudé
  2021-08-09 18:00   ` Eduardo Habkost
  12 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-08-07  8:15 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel; +Cc: Paolo Bonzini, Daniel P. Berrange

On 8/6/21 11:11 PM, Eduardo Habkost wrote:
> This series gets rid of all manual usage of OBJECT_CHECK,
> OBJECT_CLASS_CHECK, and OBJECT_GET_CLASS.
> 
> All type check macros defined manually are replaced with
> DEFINE_*CHECKER* or OBJECT_DECLARE* macros.
> 
> All manual usage of OBJECT_CHECK/OBJECT_CLASS_CHECK/OBJECT_GET_CLASS
> is manually replaced with the corresponding type-specific wrappers.

Is INTERFACE_CHECK already converted / in good shape?



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 02/12] qom: Use DEVICE_*CLASS instead of OBJECT_*CLASS
  2021-08-06 21:11 ` [PATCH for-6.2 02/12] qom: Use DEVICE_*CLASS instead of OBJECT_*CLASS Eduardo Habkost
@ 2021-08-07  8:17   ` Philippe Mathieu-Daudé
  2021-08-10 11:56   ` Juan Quintela
  1 sibling, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-08-07  8:17 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Daniel P. Berrange, Michael S. Tsirkin, Juan Quintela,
	Markus Armbruster, Dr. David Alan Gilbert, Gerd Hoffmann,
	Paolo Bonzini

On 8/6/21 11:11 PM, Eduardo Habkost wrote:
> There are multiple functions where OBJECT_GET_CLASS or
> OBJECT_CLASS_CHECK are being used directly for
> DeviceClass/TYPE_DEVICE, instead of the DEVICE_GET_CLASS or
> DEVICE_CLASS wrappers.  There's no reason to not use the
> wrappers, so use them.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Juan Quintela <quintela@redhat.com>
> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: qemu-devel@nongnu.org
> ---
>  hw/pci/pci.c           | 3 +--
>  hw/usb/hcd-ehci-pci.c  | 2 +-
>  migration/savevm.c     | 3 +--
>  monitor/misc.c         | 3 +--
>  softmmu/qdev-monitor.c | 3 +--
>  5 files changed, 5 insertions(+), 9 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends
  2021-08-07  8:15 ` [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Philippe Mathieu-Daudé
@ 2021-08-09 18:00   ` Eduardo Habkost
  0 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-09 18:00 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: Paolo Bonzini, Daniel P. Berrange, qemu-devel

On Sat, Aug 07, 2021 at 10:15:52AM +0200, Philippe Mathieu-Daudé wrote:
> On 8/6/21 11:11 PM, Eduardo Habkost wrote:
> > This series gets rid of all manual usage of OBJECT_CHECK,
> > OBJECT_CLASS_CHECK, and OBJECT_GET_CLASS.
> > 
> > All type check macros defined manually are replaced with
> > DEFINE_*CHECKER* or OBJECT_DECLARE* macros.
> > 
> > All manual usage of OBJECT_CHECK/OBJECT_CLASS_CHECK/OBJECT_GET_CLASS
> > is manually replaced with the corresponding type-specific wrappers.
> 
> Is INTERFACE_CHECK already converted / in good shape?

Not yet.  I need to refresh my memory by looking at mailing list
archives, but I have a work in progress branch that I haven't
touched in a while (except for rebasing it) at:

https://gitlab.com/ehabkost/qemu/-/commits/work/qom-declare-interface-type/

Basically it introduces a DECLARE_INTERFACE_CHECKER macro instead
of reusing OBJECT_CHECK/DECLARE_INSTANCE_CHECKER.

-- 
Eduardo



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 05/12] [automated] Move QOM typedefs and add missing includes
  2021-08-06 21:11   ` Eduardo Habkost
@ 2021-08-10  6:06     ` Cornelia Huck
  -1 siblings, 0 replies; 45+ messages in thread
From: Cornelia Huck @ 2021-08-10  6:06 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Peter Maydell, Michael S. Tsirkin, Alexey Kardashevskiy,
	Andrew Jeffery, Jason Wang, Bin Meng, David Hildenbrand,
	Laurent Vivier, Vijai Kumar K, Taylor Simpson, Alistair Francis,
	Gerd Hoffmann, Klaus Jensen, Edgar E. Iglesias, Vikram Garhwal,
	qemu-block, Juan Quintela, qemu-ppc, Huacai Chen,
	Havard Skinnemoen, Halil Pasic, Christian Borntraeger,
	Hervé Poussineau, Joel Stanley, Marc-André Lureau,
	Pavel Pisa, Aleksandar Rikalo, Corey Minyard, qemu-s390x,
	Richard Henderson, Greg Kurz, Dr. David Alan Gilbert,
	Alexander Bulekov, Bandan Das, qemu-arm, Cédric Le Goater,
	Stefan Hajnoczi, Paolo Bonzini, Keith Busch, qemu-riscv,
	David Gibson, Daniel P. Berrange, Francisco Iglesias,
	Thomas Huth, Bastian Koppelmann, Stefan Berger,
	Philippe Mathieu-Daudé,
	Andrew Baumann, Tyrone Ting, Palmer Dabbelt, Igor Mammedov,
	Aurelien Jarno

On Fri, Aug 06 2021, Eduardo Habkost <ehabkost@redhat.com> wrote:

> Some typedefs and macros are defined after the type check macros.
> This makes it difficult to automatically replace their
> definitions with OBJECT_DECLARE_TYPE.
>
> Patch generated using:
>
>  $ ./scripts/codeconverter/converter.py -i --pattern=MoveSymbols \
>     $(git grep -l '' -- '*.[ch]')
>
> which will:
> - split "typdef struct { ... } TypedefName" declarations
> - move the typedefs and #defines above the type check macros
> - add missing #include "qom/object.h" lines if necessary
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> Cc: Thomas Huth <huth@tuxfamily.org>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Igor Mammedov <imammedo@redhat.com>
> Cc: Alexander Bulekov <alxndr@bu.edu>
> Cc: Bandan Das <bsd@redhat.com>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: Huacai Chen <chenhuacai@kernel.org>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
> Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Klaus Jensen <its@irrelevant.dk>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Vijai Kumar K <vijai@behindbytes.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Bin Meng <bin.meng@windriver.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: Corey Minyard <minyard@acm.org>
> Cc: "Cédric Le Goater" <clg@kaod.org>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Greg Kurz <groug@kaod.org>
> Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
> Cc: "Hervé Poussineau" <hpoussin@reactos.org>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: Juan Quintela <quintela@redhat.com>
> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>
> Cc: Taylor Simpson <tsimpson@quicinc.com>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-block@nongnu.org
> Cc: qemu-s390x@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-ppc@nongnu.org
> ---
>  hw/nvme/nvme.h                              |  6 ++++--
>  hw/usb/hcd-uhci.h                           |  1 +
>  hw/usb/hcd-xhci-pci.h                       |  6 ++++--
>  hw/usb/hcd-xhci-sysbus.h                    |  6 ++++--
>  hw/usb/u2f.h                                |  6 ++++--
>  include/hw/acpi/acpi_dev_interface.h        |  2 +-
>  include/hw/adc/npcm7xx_adc.h                |  1 +
>  include/hw/arm/linux-boot-if.h              |  2 +-
>  include/hw/arm/npcm7xx.h                    | 11 +++++++----
>  include/hw/char/shakti_uart.h               |  6 ++++--
>  include/hw/core/accel-cpu.h                 |  1 +
>  include/hw/dma/sifive_pdma.h                |  1 +
>  include/hw/dma/xlnx_csu_dma.h               |  1 +
>  include/hw/fw-path-provider.h               |  2 +-
>  include/hw/gpio/npcm7xx_gpio.h              |  1 +
>  include/hw/hotplug.h                        |  2 +-
>  include/hw/i2c/npcm7xx_smbus.h              |  1 +
>  include/hw/intc/intc.h                      |  2 +-
>  include/hw/intc/m68k_irqc.h                 |  6 ++++--
>  include/hw/intc/sifive_clint.h              |  6 ++++--
>  include/hw/ipmi/ipmi.h                      |  2 +-
>  include/hw/mem/memory-device.h              |  2 +-
>  include/hw/mem/npcm7xx_mc.h                 |  1 +
>  include/hw/misc/aspeed_lpc.h                |  6 ++++--
>  include/hw/misc/bcm2835_cprman.h            |  1 +
>  include/hw/misc/bcm2835_cprman_internals.h  |  1 +
>  include/hw/misc/mchp_pfsoc_dmc.h            |  1 +
>  include/hw/misc/mchp_pfsoc_ioscb.h          |  1 +
>  include/hw/misc/mchp_pfsoc_sysreg.h         |  1 +
>  include/hw/misc/npcm7xx_clk.h               |  1 +
>  include/hw/misc/npcm7xx_gcr.h               |  1 +
>  include/hw/misc/npcm7xx_pwm.h               |  1 +
>  include/hw/misc/npcm7xx_rng.h               |  1 +
>  include/hw/misc/xlnx-versal-xramc.h         |  6 ++++--
>  include/hw/net/npcm7xx_emc.h                |  1 +
>  include/hw/net/xlnx-zynqmp-can.h            |  6 ++++--
>  include/hw/nmi.h                            |  2 +-
>  include/hw/nvram/npcm7xx_otp.h              |  1 +
>  include/hw/ppc/spapr_drc.h                  | 15 +++++++++------
>  include/hw/ppc/spapr_xive.h                 | 11 +++++++----
>  include/hw/ppc/vof.h                        |  1 +
>  include/hw/rdma/rdma.h                      |  2 +-
>  include/hw/riscv/microchip_pfsoc.h          |  1 +
>  include/hw/riscv/shakti_c.h                 | 11 +++++++----
>  include/hw/riscv/sifive_e.h                 |  6 ++++--
>  include/hw/riscv/sifive_u.h                 | 11 +++++++----
>  include/hw/rtc/m48t59.h                     |  2 +-
>  include/hw/sd/cadence_sdhci.h               |  1 +
>  include/hw/ssi/npcm7xx_fiu.h                |  1 +
>  include/hw/ssi/sifive_spi.h                 |  6 ++++--
>  include/hw/stream.h                         |  2 +-
>  include/hw/timer/npcm7xx_timer.h            |  1 +
>  include/hw/tricore/tricore_testdevice.h     |  6 ++++--
>  include/hw/usb/hcd-dwc3.h                   |  6 ++++--
>  include/hw/usb/msd.h                        |  1 +
>  include/hw/usb/xlnx-usb-subsystem.h         |  6 ++++--
>  include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  6 ++++--
>  include/hw/vmstate-if.h                     |  2 +-
>  include/hw/watchdog/sbsa_gwdt.h             |  6 ++++--
>  include/qom/object_interfaces.h             |  2 +-
>  include/sysemu/tpm.h                        |  2 +-
>  target/arm/idau.h                           |  2 +-
>  target/hexagon/cpu.h                        | 11 +++++++----
>  accel/tcg/tcg-all.c                         |  1 +
>  chardev/char-parallel.c                     |  1 +
>  hw/arm/bcm2836.c                            |  1 +
>  hw/m68k/mcf5206.c                           |  1 +
>  hw/mem/sparse-mem.c                         |  6 ++++--
>  hw/mips/loongson3_virt.c                    |  1 +
>  hw/misc/npcm7xx_clk.c                       |  1 +
>  hw/misc/sbsa_ec.c                           |  1 +
>  hw/net/can/ctucan_pci.c                     |  1 +
>  hw/nvram/npcm7xx_otp.c                      |  1 +
>  hw/s390x/vhost-user-fs-ccw.c                |  1 +
>  hw/sensor/adm1272.c                         |  6 ++++--
>  hw/sensor/max34451.c                        |  6 ++++--
>  hw/usb/u2f-emulated.c                       |  1 +
>  hw/usb/u2f-passthru.c                       |  1 +
>  hw/virtio/vhost-user-i2c-pci.c              |  1 +
>  tests/unit/check-qom-interface.c            |  2 +-
>  ui/vdagent.c                                |  1 +
>  81 files changed, 179 insertions(+), 82 deletions(-)

Acked-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 05/12] [automated] Move QOM typedefs and add missing includes
@ 2021-08-10  6:06     ` Cornelia Huck
  0 siblings, 0 replies; 45+ messages in thread
From: Cornelia Huck @ 2021-08-10  6:06 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Daniel P. Berrange, Paolo Bonzini, Richard Henderson,
	Marc-André Lureau, Peter Maydell, Andrew Baumann,
	Philippe Mathieu-Daudé,
	Thomas Huth, Michael S. Tsirkin, Igor Mammedov,
	Alexander Bulekov, Bandan Das, Stefan Hajnoczi, Huacai Chen,
	Jiaxun Yang, Aurelien Jarno, Aleksandar Rikalo,
	Havard Skinnemoen, Tyrone Ting, Pavel Pisa, Vikram Garhwal,
	Jason Wang, Keith Busch, Klaus Jensen, Halil Pasic,
	Christian Borntraeger, David Hildenbrand, Gerd Hoffmann,
	Vijai Kumar K, Alistair Francis, Bin Meng, Palmer Dabbelt,
	Edgar E. Iglesias, Laurent Vivier, Corey Minyard,
	Cédric Le Goater, Andrew Jeffery, Joel Stanley,
	Francisco Iglesias, David Gibson, Greg Kurz,
	Alexey Kardashevskiy, Hervé Poussineau, Bastian Koppelmann,
	Juan Quintela, Dr. David Alan Gilbert, Stefan Berger,
	Taylor Simpson, qemu-arm, qemu-block, qemu-s390x, qemu-riscv,
	qemu-ppc

On Fri, Aug 06 2021, Eduardo Habkost <ehabkost@redhat.com> wrote:

> Some typedefs and macros are defined after the type check macros.
> This makes it difficult to automatically replace their
> definitions with OBJECT_DECLARE_TYPE.
>
> Patch generated using:
>
>  $ ./scripts/codeconverter/converter.py -i --pattern=MoveSymbols \
>     $(git grep -l '' -- '*.[ch]')
>
> which will:
> - split "typdef struct { ... } TypedefName" declarations
> - move the typedefs and #defines above the type check macros
> - add missing #include "qom/object.h" lines if necessary
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> Cc: Thomas Huth <huth@tuxfamily.org>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Igor Mammedov <imammedo@redhat.com>
> Cc: Alexander Bulekov <alxndr@bu.edu>
> Cc: Bandan Das <bsd@redhat.com>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: Huacai Chen <chenhuacai@kernel.org>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
> Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Klaus Jensen <its@irrelevant.dk>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Vijai Kumar K <vijai@behindbytes.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Bin Meng <bin.meng@windriver.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: Corey Minyard <minyard@acm.org>
> Cc: "Cédric Le Goater" <clg@kaod.org>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Greg Kurz <groug@kaod.org>
> Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
> Cc: "Hervé Poussineau" <hpoussin@reactos.org>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: Juan Quintela <quintela@redhat.com>
> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>
> Cc: Taylor Simpson <tsimpson@quicinc.com>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-block@nongnu.org
> Cc: qemu-s390x@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-ppc@nongnu.org
> ---
>  hw/nvme/nvme.h                              |  6 ++++--
>  hw/usb/hcd-uhci.h                           |  1 +
>  hw/usb/hcd-xhci-pci.h                       |  6 ++++--
>  hw/usb/hcd-xhci-sysbus.h                    |  6 ++++--
>  hw/usb/u2f.h                                |  6 ++++--
>  include/hw/acpi/acpi_dev_interface.h        |  2 +-
>  include/hw/adc/npcm7xx_adc.h                |  1 +
>  include/hw/arm/linux-boot-if.h              |  2 +-
>  include/hw/arm/npcm7xx.h                    | 11 +++++++----
>  include/hw/char/shakti_uart.h               |  6 ++++--
>  include/hw/core/accel-cpu.h                 |  1 +
>  include/hw/dma/sifive_pdma.h                |  1 +
>  include/hw/dma/xlnx_csu_dma.h               |  1 +
>  include/hw/fw-path-provider.h               |  2 +-
>  include/hw/gpio/npcm7xx_gpio.h              |  1 +
>  include/hw/hotplug.h                        |  2 +-
>  include/hw/i2c/npcm7xx_smbus.h              |  1 +
>  include/hw/intc/intc.h                      |  2 +-
>  include/hw/intc/m68k_irqc.h                 |  6 ++++--
>  include/hw/intc/sifive_clint.h              |  6 ++++--
>  include/hw/ipmi/ipmi.h                      |  2 +-
>  include/hw/mem/memory-device.h              |  2 +-
>  include/hw/mem/npcm7xx_mc.h                 |  1 +
>  include/hw/misc/aspeed_lpc.h                |  6 ++++--
>  include/hw/misc/bcm2835_cprman.h            |  1 +
>  include/hw/misc/bcm2835_cprman_internals.h  |  1 +
>  include/hw/misc/mchp_pfsoc_dmc.h            |  1 +
>  include/hw/misc/mchp_pfsoc_ioscb.h          |  1 +
>  include/hw/misc/mchp_pfsoc_sysreg.h         |  1 +
>  include/hw/misc/npcm7xx_clk.h               |  1 +
>  include/hw/misc/npcm7xx_gcr.h               |  1 +
>  include/hw/misc/npcm7xx_pwm.h               |  1 +
>  include/hw/misc/npcm7xx_rng.h               |  1 +
>  include/hw/misc/xlnx-versal-xramc.h         |  6 ++++--
>  include/hw/net/npcm7xx_emc.h                |  1 +
>  include/hw/net/xlnx-zynqmp-can.h            |  6 ++++--
>  include/hw/nmi.h                            |  2 +-
>  include/hw/nvram/npcm7xx_otp.h              |  1 +
>  include/hw/ppc/spapr_drc.h                  | 15 +++++++++------
>  include/hw/ppc/spapr_xive.h                 | 11 +++++++----
>  include/hw/ppc/vof.h                        |  1 +
>  include/hw/rdma/rdma.h                      |  2 +-
>  include/hw/riscv/microchip_pfsoc.h          |  1 +
>  include/hw/riscv/shakti_c.h                 | 11 +++++++----
>  include/hw/riscv/sifive_e.h                 |  6 ++++--
>  include/hw/riscv/sifive_u.h                 | 11 +++++++----
>  include/hw/rtc/m48t59.h                     |  2 +-
>  include/hw/sd/cadence_sdhci.h               |  1 +
>  include/hw/ssi/npcm7xx_fiu.h                |  1 +
>  include/hw/ssi/sifive_spi.h                 |  6 ++++--
>  include/hw/stream.h                         |  2 +-
>  include/hw/timer/npcm7xx_timer.h            |  1 +
>  include/hw/tricore/tricore_testdevice.h     |  6 ++++--
>  include/hw/usb/hcd-dwc3.h                   |  6 ++++--
>  include/hw/usb/msd.h                        |  1 +
>  include/hw/usb/xlnx-usb-subsystem.h         |  6 ++++--
>  include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  6 ++++--
>  include/hw/vmstate-if.h                     |  2 +-
>  include/hw/watchdog/sbsa_gwdt.h             |  6 ++++--
>  include/qom/object_interfaces.h             |  2 +-
>  include/sysemu/tpm.h                        |  2 +-
>  target/arm/idau.h                           |  2 +-
>  target/hexagon/cpu.h                        | 11 +++++++----
>  accel/tcg/tcg-all.c                         |  1 +
>  chardev/char-parallel.c                     |  1 +
>  hw/arm/bcm2836.c                            |  1 +
>  hw/m68k/mcf5206.c                           |  1 +
>  hw/mem/sparse-mem.c                         |  6 ++++--
>  hw/mips/loongson3_virt.c                    |  1 +
>  hw/misc/npcm7xx_clk.c                       |  1 +
>  hw/misc/sbsa_ec.c                           |  1 +
>  hw/net/can/ctucan_pci.c                     |  1 +
>  hw/nvram/npcm7xx_otp.c                      |  1 +
>  hw/s390x/vhost-user-fs-ccw.c                |  1 +
>  hw/sensor/adm1272.c                         |  6 ++++--
>  hw/sensor/max34451.c                        |  6 ++++--
>  hw/usb/u2f-emulated.c                       |  1 +
>  hw/usb/u2f-passthru.c                       |  1 +
>  hw/virtio/vhost-user-i2c-pci.c              |  1 +
>  tests/unit/check-qom-interface.c            |  2 +-
>  ui/vdagent.c                                |  1 +
>  81 files changed, 179 insertions(+), 82 deletions(-)

Acked-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 06/12] [automated] Split QOM "typedef struct T { ... } T" declarations
  2021-08-06 21:11   ` Eduardo Habkost
@ 2021-08-10  6:08     ` Cornelia Huck
  -1 siblings, 0 replies; 45+ messages in thread
From: Cornelia Huck @ 2021-08-10  6:08 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Peter Maydell, Michael S. Tsirkin, Bin Meng, Alistair Francis,
	Gerd Hoffmann, Klaus Jensen, Edgar E. Iglesias, qemu-block,
	qemu-ppc, David Hildenbrand, Havard Skinnemoen, Halil Pasic,
	Christian Borntraeger, Marc-André Lureau, Laurent Vivier,
	Richard Henderson, Greg Kurz, qemu-s390x, qemu-arm,
	Cédric Le Goater, Keith Busch, qemu-riscv, David Gibson,
	Daniel P. Berrange, Thomas Huth, Patrick Venture,
	Philippe Mathieu-Daudé,
	Andrew Baumann, Tyrone Ting, Palmer Dabbelt, Paolo Bonzini

On Fri, Aug 06 2021, Eduardo Habkost <ehabkost@redhat.com> wrote:

> Automatically split struct definition and typedef declaration in
> separate declarations, using a codeconverter rule.  The rule will
> only touch declarations of structs/typedefs actually used by QOM
> types.
>
> This will make automated changes to use OBJECT_DECLARE* macros
> easier to implement, because automated removal of typedef lines
> will be easier and safer.
>
> Generated using:
>
>   $ ./scripts/codeconverter/converter.py -i \
>     --pattern=QOMStructTypedefSplit $(git grep -l '' -- '*.[ch]')
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Patrick Venture <venture@google.com>
> Cc: Thomas Huth <huth@tuxfamily.org>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Klaus Jensen <its@irrelevant.dk>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Bin Meng <bin.meng@windriver.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> Cc: "Cédric Le Goater" <clg@kaod.org>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Greg Kurz <groug@kaod.org>
> Cc: Laurent Vivier <lvivier@redhat.com>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-block@nongnu.org
> Cc: qemu-s390x@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-ppc@nongnu.org
> ---
>  hw/nvme/nvme.h                      | 10 ++++++----
>  hw/usb/hcd-uhci.h                   |  5 +++--
>  hw/usb/u2f.h                        |  5 +++--
>  include/hw/adc/npcm7xx_adc.h        |  5 +++--
>  include/hw/arm/npcm7xx.h            | 10 ++++++----
>  include/hw/core/accel-cpu.h         |  5 +++--
>  include/hw/dma/sifive_pdma.h        |  5 +++--
>  include/hw/dma/xlnx_csu_dma.h       |  5 +++--
>  include/hw/gpio/npcm7xx_gpio.h      |  5 +++--
>  include/hw/i2c/npcm7xx_smbus.h      |  5 +++--
>  include/hw/mem/npcm7xx_mc.h         |  5 +++--
>  include/hw/misc/bcm2835_cprman.h    | 20 ++++++++++++--------
>  include/hw/misc/mchp_pfsoc_dmc.h    | 10 ++++++----
>  include/hw/misc/mchp_pfsoc_ioscb.h  |  5 +++--
>  include/hw/misc/mchp_pfsoc_sysreg.h |  5 +++--
>  include/hw/misc/npcm7xx_clk.h       | 15 +++++++++------
>  include/hw/misc/npcm7xx_gcr.h       |  5 +++--
>  include/hw/misc/npcm7xx_mft.h       |  5 +++--
>  include/hw/misc/npcm7xx_rng.h       |  5 +++--
>  include/hw/nvram/npcm7xx_otp.h      |  5 +++--
>  include/hw/riscv/microchip_pfsoc.h  | 10 ++++++----
>  include/hw/riscv/sifive_e.h         |  5 +++--
>  include/hw/sd/cadence_sdhci.h       |  5 +++--
>  include/qemu/accel.h                | 10 ++++++----
>  chardev/char-parallel.c             | 10 ++++++----
>  hw/i2c/i2c_mux_pca954x.c            |  5 +++--
>  hw/m68k/mcf5206.c                   |  5 +++--
>  hw/misc/sbsa_ec.c                   |  5 +++--
>  hw/s390x/vhost-user-fs-ccw.c        |  5 +++--
>  tests/qtest/pnv-xscom-test.c        |  5 +++--
>  30 files changed, 123 insertions(+), 82 deletions(-)

Acked-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 06/12] [automated] Split QOM "typedef struct T { ... } T" declarations
@ 2021-08-10  6:08     ` Cornelia Huck
  0 siblings, 0 replies; 45+ messages in thread
From: Cornelia Huck @ 2021-08-10  6:08 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Daniel P. Berrange, Paolo Bonzini, Marc-André Lureau,
	Patrick Venture, Thomas Huth, Keith Busch, Klaus Jensen,
	Michael S. Tsirkin, Halil Pasic, Christian Borntraeger,
	Richard Henderson, David Hildenbrand, Gerd Hoffmann,
	Havard Skinnemoen, Tyrone Ting, Alistair Francis, Bin Meng,
	Palmer Dabbelt, Edgar E. Iglesias, Peter Maydell, Andrew Baumann,
	Philippe Mathieu-Daudé,
	Cédric Le Goater, David Gibson, Greg Kurz, Laurent Vivier,
	qemu-block, qemu-s390x, qemu-arm, qemu-riscv, qemu-ppc

On Fri, Aug 06 2021, Eduardo Habkost <ehabkost@redhat.com> wrote:

> Automatically split struct definition and typedef declaration in
> separate declarations, using a codeconverter rule.  The rule will
> only touch declarations of structs/typedefs actually used by QOM
> types.
>
> This will make automated changes to use OBJECT_DECLARE* macros
> easier to implement, because automated removal of typedef lines
> will be easier and safer.
>
> Generated using:
>
>   $ ./scripts/codeconverter/converter.py -i \
>     --pattern=QOMStructTypedefSplit $(git grep -l '' -- '*.[ch]')
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Patrick Venture <venture@google.com>
> Cc: Thomas Huth <huth@tuxfamily.org>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Klaus Jensen <its@irrelevant.dk>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Bin Meng <bin.meng@windriver.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> Cc: "Cédric Le Goater" <clg@kaod.org>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Greg Kurz <groug@kaod.org>
> Cc: Laurent Vivier <lvivier@redhat.com>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-block@nongnu.org
> Cc: qemu-s390x@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-ppc@nongnu.org
> ---
>  hw/nvme/nvme.h                      | 10 ++++++----
>  hw/usb/hcd-uhci.h                   |  5 +++--
>  hw/usb/u2f.h                        |  5 +++--
>  include/hw/adc/npcm7xx_adc.h        |  5 +++--
>  include/hw/arm/npcm7xx.h            | 10 ++++++----
>  include/hw/core/accel-cpu.h         |  5 +++--
>  include/hw/dma/sifive_pdma.h        |  5 +++--
>  include/hw/dma/xlnx_csu_dma.h       |  5 +++--
>  include/hw/gpio/npcm7xx_gpio.h      |  5 +++--
>  include/hw/i2c/npcm7xx_smbus.h      |  5 +++--
>  include/hw/mem/npcm7xx_mc.h         |  5 +++--
>  include/hw/misc/bcm2835_cprman.h    | 20 ++++++++++++--------
>  include/hw/misc/mchp_pfsoc_dmc.h    | 10 ++++++----
>  include/hw/misc/mchp_pfsoc_ioscb.h  |  5 +++--
>  include/hw/misc/mchp_pfsoc_sysreg.h |  5 +++--
>  include/hw/misc/npcm7xx_clk.h       | 15 +++++++++------
>  include/hw/misc/npcm7xx_gcr.h       |  5 +++--
>  include/hw/misc/npcm7xx_mft.h       |  5 +++--
>  include/hw/misc/npcm7xx_rng.h       |  5 +++--
>  include/hw/nvram/npcm7xx_otp.h      |  5 +++--
>  include/hw/riscv/microchip_pfsoc.h  | 10 ++++++----
>  include/hw/riscv/sifive_e.h         |  5 +++--
>  include/hw/sd/cadence_sdhci.h       |  5 +++--
>  include/qemu/accel.h                | 10 ++++++----
>  chardev/char-parallel.c             | 10 ++++++----
>  hw/i2c/i2c_mux_pca954x.c            |  5 +++--
>  hw/m68k/mcf5206.c                   |  5 +++--
>  hw/misc/sbsa_ec.c                   |  5 +++--
>  hw/s390x/vhost-user-fs-ccw.c        |  5 +++--
>  tests/qtest/pnv-xscom-test.c        |  5 +++--
>  30 files changed, 123 insertions(+), 82 deletions(-)

Acked-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 07/12] [automated] Use DECLARE_*CHECKER* macros when possible
  2021-08-06 21:11   ` Eduardo Habkost
@ 2021-08-10  6:09     ` Cornelia Huck
  -1 siblings, 0 replies; 45+ messages in thread
From: Cornelia Huck @ 2021-08-10  6:09 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Peter Maydell, Michael S. Tsirkin, Andrew Jeffery, Jason Wang,
	Bin Meng, Vijai Kumar K, Taylor Simpson, Alistair Francis,
	Gerd Hoffmann, Klaus Jensen, Edgar E. Iglesias, Vikram Garhwal,
	qemu-block, qemu-ppc, David Hildenbrand, Havard Skinnemoen,
	Halil Pasic, Christian Borntraeger, Joel Stanley,
	Marc-André Lureau, qemu-s390x, Richard Henderson, Greg Kurz,
	Alexander Bulekov, Bandan Das, qemu-arm, Cédric Le Goater,
	Stefan Hajnoczi, Paolo Bonzini, Keith Busch, qemu-riscv,
	David Gibson, Daniel P. Berrange, Francisco Iglesias,
	Thomas Huth, Patrick Venture, Laurent Vivier, Tyrone Ting,
	Palmer Dabbelt, Bastian Koppelmann, Igor Mammedov

On Fri, Aug 06 2021, Eduardo Habkost <ehabkost@redhat.com> wrote:

> Converting existing QOM types to OBJECT_DECLARE_TYPE is not
> always trivial (due to inconsistent type/macro naming schemes),
> but at least converting existing manual QOM type checking macros
> to use DECLARE_*CHECKER* is a simpler process, and should at
> least discourage people from defining new QOM type checker macros
> manually.
>
> Generated using:
>
>   $ ./scripts/codeconverter/converter.py -i \
>     --pattern=TypeCheckMacro $(git grep -l '' -- '*.[ch]')
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Patrick Venture <venture@google.com>
> Cc: Thomas Huth <huth@tuxfamily.org>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Igor Mammedov <imammedo@redhat.com>
> Cc: Alexander Bulekov <alxndr@bu.edu>
> Cc: Bandan Das <bsd@redhat.com>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Klaus Jensen <its@irrelevant.dk>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: Vijai Kumar K <vijai@behindbytes.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Bin Meng <bin.meng@windriver.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: "Cédric Le Goater" <clg@kaod.org>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
> Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Greg Kurz <groug@kaod.org>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: Taylor Simpson <tsimpson@quicinc.com>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-block@nongnu.org
> Cc: qemu-s390x@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-ppc@nongnu.org
> ---
>  hw/nvme/nvme.h                              | 12 ++++++------
>  hw/usb/hcd-xhci-pci.h                       |  4 ++--
>  hw/usb/hcd-xhci-sysbus.h                    |  4 ++--
>  hw/usb/u2f.h                                |  8 ++------
>  include/hw/adc/npcm7xx_adc.h                |  4 ++--
>  include/hw/arm/npcm7xx.h                    | 15 ++++-----------
>  include/hw/char/shakti_uart.h               |  4 ++--
>  include/hw/dma/sifive_pdma.h                |  4 ++--
>  include/hw/dma/xlnx_csu_dma.h               |  4 ++--
>  include/hw/gpio/npcm7xx_gpio.h              |  4 ++--
>  include/hw/i2c/npcm7xx_smbus.h              |  4 ++--
>  include/hw/intc/m68k_irqc.h                 |  4 ++--
>  include/hw/intc/sifive_clint.h              |  4 ++--
>  include/hw/mem/npcm7xx_mc.h                 |  3 ++-
>  include/hw/misc/aspeed_lpc.h                |  3 ++-
>  include/hw/misc/mchp_pfsoc_dmc.h            | 10 ++++------
>  include/hw/misc/mchp_pfsoc_ioscb.h          |  4 ++--
>  include/hw/misc/mchp_pfsoc_sysreg.h         |  5 ++---
>  include/hw/misc/npcm7xx_clk.h               |  3 ++-
>  include/hw/misc/npcm7xx_gcr.h               |  3 ++-
>  include/hw/misc/npcm7xx_mft.h               |  4 ++--
>  include/hw/misc/npcm7xx_pwm.h               |  4 ++--
>  include/hw/misc/npcm7xx_rng.h               |  3 ++-
>  include/hw/misc/xlnx-versal-xramc.h         |  4 ++--
>  include/hw/net/npcm7xx_emc.h                |  4 ++--
>  include/hw/net/xlnx-zynqmp-can.h            |  4 ++--
>  include/hw/nvram/npcm7xx_otp.h              |  3 ++-
>  include/hw/ppc/spapr_drc.h                  | 13 ++++---------
>  include/hw/ppc/spapr_xive.h                 |  7 ++-----
>  include/hw/riscv/microchip_pfsoc.h          |  9 ++++-----
>  include/hw/riscv/shakti_c.h                 |  8 ++++----
>  include/hw/riscv/sifive_e.h                 |  8 ++++----
>  include/hw/riscv/sifive_u.h                 |  8 ++++----
>  include/hw/sd/cadence_sdhci.h               |  4 ++--
>  include/hw/ssi/npcm7xx_fiu.h                |  3 ++-
>  include/hw/ssi/sifive_spi.h                 |  3 ++-
>  include/hw/timer/npcm7xx_timer.h            |  4 ++--
>  include/hw/tricore/tricore_testdevice.h     |  4 ++--
>  include/hw/usb/hcd-dwc3.h                   |  4 ++--
>  include/hw/usb/xlnx-usb-subsystem.h         |  4 ++--
>  include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  4 ++--
>  include/hw/watchdog/sbsa_gwdt.h             |  4 ++--
>  include/qemu/accel.h                        |  8 ++------
>  target/hexagon/cpu.h                        |  8 ++------
>  chardev/char-parallel.c                     |  6 ++----
>  hw/i2c/i2c_mux_pca954x.c                    |  4 ++--
>  hw/m68k/mcf5206.c                           |  3 ++-
>  hw/mem/sparse-mem.c                         |  3 ++-
>  hw/misc/sbsa_ec.c                           |  3 ++-
>  hw/s390x/vhost-user-fs-ccw.c                |  4 ++--
>  hw/sensor/adm1272.c                         |  3 ++-
>  hw/sensor/max34451.c                        |  3 ++-
>  hw/usb/u2f-emulated.c                       |  4 ++--
>  hw/usb/u2f-passthru.c                       |  4 ++--
>  54 files changed, 126 insertions(+), 146 deletions(-)

Acked-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 07/12] [automated] Use DECLARE_*CHECKER* macros when possible
@ 2021-08-10  6:09     ` Cornelia Huck
  0 siblings, 0 replies; 45+ messages in thread
From: Cornelia Huck @ 2021-08-10  6:09 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Daniel P. Berrange, Paolo Bonzini, Marc-André Lureau,
	Patrick Venture, Thomas Huth, Michael S. Tsirkin, Igor Mammedov,
	Alexander Bulekov, Bandan Das, Stefan Hajnoczi, Keith Busch,
	Klaus Jensen, Halil Pasic, Christian Borntraeger,
	Richard Henderson, David Hildenbrand, Gerd Hoffmann,
	Havard Skinnemoen, Tyrone Ting, Vijai Kumar K, Alistair Francis,
	Bin Meng, Palmer Dabbelt, Edgar E. Iglesias, Peter Maydell,
	Laurent Vivier, Cédric Le Goater, Andrew Jeffery,
	Joel Stanley, Jason Wang, Vikram Garhwal, Francisco Iglesias,
	David Gibson, Greg Kurz, Bastian Koppelmann, Taylor Simpson,
	qemu-block, qemu-s390x, qemu-arm, qemu-riscv, qemu-ppc

On Fri, Aug 06 2021, Eduardo Habkost <ehabkost@redhat.com> wrote:

> Converting existing QOM types to OBJECT_DECLARE_TYPE is not
> always trivial (due to inconsistent type/macro naming schemes),
> but at least converting existing manual QOM type checking macros
> to use DECLARE_*CHECKER* is a simpler process, and should at
> least discourage people from defining new QOM type checker macros
> manually.
>
> Generated using:
>
>   $ ./scripts/codeconverter/converter.py -i \
>     --pattern=TypeCheckMacro $(git grep -l '' -- '*.[ch]')
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Patrick Venture <venture@google.com>
> Cc: Thomas Huth <huth@tuxfamily.org>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Igor Mammedov <imammedo@redhat.com>
> Cc: Alexander Bulekov <alxndr@bu.edu>
> Cc: Bandan Das <bsd@redhat.com>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Klaus Jensen <its@irrelevant.dk>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: Vijai Kumar K <vijai@behindbytes.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Bin Meng <bin.meng@windriver.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: "Cédric Le Goater" <clg@kaod.org>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
> Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Greg Kurz <groug@kaod.org>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: Taylor Simpson <tsimpson@quicinc.com>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-block@nongnu.org
> Cc: qemu-s390x@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-ppc@nongnu.org
> ---
>  hw/nvme/nvme.h                              | 12 ++++++------
>  hw/usb/hcd-xhci-pci.h                       |  4 ++--
>  hw/usb/hcd-xhci-sysbus.h                    |  4 ++--
>  hw/usb/u2f.h                                |  8 ++------
>  include/hw/adc/npcm7xx_adc.h                |  4 ++--
>  include/hw/arm/npcm7xx.h                    | 15 ++++-----------
>  include/hw/char/shakti_uart.h               |  4 ++--
>  include/hw/dma/sifive_pdma.h                |  4 ++--
>  include/hw/dma/xlnx_csu_dma.h               |  4 ++--
>  include/hw/gpio/npcm7xx_gpio.h              |  4 ++--
>  include/hw/i2c/npcm7xx_smbus.h              |  4 ++--
>  include/hw/intc/m68k_irqc.h                 |  4 ++--
>  include/hw/intc/sifive_clint.h              |  4 ++--
>  include/hw/mem/npcm7xx_mc.h                 |  3 ++-
>  include/hw/misc/aspeed_lpc.h                |  3 ++-
>  include/hw/misc/mchp_pfsoc_dmc.h            | 10 ++++------
>  include/hw/misc/mchp_pfsoc_ioscb.h          |  4 ++--
>  include/hw/misc/mchp_pfsoc_sysreg.h         |  5 ++---
>  include/hw/misc/npcm7xx_clk.h               |  3 ++-
>  include/hw/misc/npcm7xx_gcr.h               |  3 ++-
>  include/hw/misc/npcm7xx_mft.h               |  4 ++--
>  include/hw/misc/npcm7xx_pwm.h               |  4 ++--
>  include/hw/misc/npcm7xx_rng.h               |  3 ++-
>  include/hw/misc/xlnx-versal-xramc.h         |  4 ++--
>  include/hw/net/npcm7xx_emc.h                |  4 ++--
>  include/hw/net/xlnx-zynqmp-can.h            |  4 ++--
>  include/hw/nvram/npcm7xx_otp.h              |  3 ++-
>  include/hw/ppc/spapr_drc.h                  | 13 ++++---------
>  include/hw/ppc/spapr_xive.h                 |  7 ++-----
>  include/hw/riscv/microchip_pfsoc.h          |  9 ++++-----
>  include/hw/riscv/shakti_c.h                 |  8 ++++----
>  include/hw/riscv/sifive_e.h                 |  8 ++++----
>  include/hw/riscv/sifive_u.h                 |  8 ++++----
>  include/hw/sd/cadence_sdhci.h               |  4 ++--
>  include/hw/ssi/npcm7xx_fiu.h                |  3 ++-
>  include/hw/ssi/sifive_spi.h                 |  3 ++-
>  include/hw/timer/npcm7xx_timer.h            |  4 ++--
>  include/hw/tricore/tricore_testdevice.h     |  4 ++--
>  include/hw/usb/hcd-dwc3.h                   |  4 ++--
>  include/hw/usb/xlnx-usb-subsystem.h         |  4 ++--
>  include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  4 ++--
>  include/hw/watchdog/sbsa_gwdt.h             |  4 ++--
>  include/qemu/accel.h                        |  8 ++------
>  target/hexagon/cpu.h                        |  8 ++------
>  chardev/char-parallel.c                     |  6 ++----
>  hw/i2c/i2c_mux_pca954x.c                    |  4 ++--
>  hw/m68k/mcf5206.c                           |  3 ++-
>  hw/mem/sparse-mem.c                         |  3 ++-
>  hw/misc/sbsa_ec.c                           |  3 ++-
>  hw/s390x/vhost-user-fs-ccw.c                |  4 ++--
>  hw/sensor/adm1272.c                         |  3 ++-
>  hw/sensor/max34451.c                        |  3 ++-
>  hw/usb/u2f-emulated.c                       |  4 ++--
>  hw/usb/u2f-passthru.c                       |  4 ++--
>  54 files changed, 126 insertions(+), 146 deletions(-)

Acked-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 12/12] [automated] Use OBJECT_DECLARE_SIMPLE_TYPE when possible
  2021-08-06 21:11   ` Eduardo Habkost
@ 2021-08-10  6:12     ` Cornelia Huck
  -1 siblings, 0 replies; 45+ messages in thread
From: Cornelia Huck @ 2021-08-10  6:12 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Peter Maydell, Michael S. Tsirkin, Andrew Jeffery, Jason Wang,
	Bin Meng, Laurent Vivier, Klaus Jensen, Alistair Francis,
	Gerd Hoffmann, Vijai Kumar K, Edgar E. Iglesias, Vikram Garhwal,
	Paul Burton, David Hildenbrand, Havard Skinnemoen, Halil Pasic,
	Christian Borntraeger, Joel Stanley, qemu-ppc, Pavel Pisa,
	Aleksandar Rikalo, Richard Henderson, Greg Kurz, qemu-s390x,
	qemu-arm, Cédric Le Goater, Keith Busch, qemu-riscv,
	David Gibson, Daniel P. Berrange, qemu-block, Francisco Iglesias,
	Thomas Huth, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Tyrone Ting, Palmer Dabbelt, Paolo Bonzini,
	Aurelien Jarno

On Fri, Aug 06 2021, Eduardo Habkost <ehabkost@redhat.com> wrote:

> Replace typedef + DECLARE_INSTANCE_CHECKER with
> equivalent OBJECT_DECLARE_SIMPLE_TYPE macro.
>
> Generated using:
>
> $ ./scripts/codeconverter/converter.py -i \
>   --pattern=AddObjectDeclareSimpleType $(git grep -l '' -- '*.[ch]')
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Thomas Huth <huth@tuxfamily.org>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
> Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Klaus Jensen <its@irrelevant.dk>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Vijai Kumar K <vijai@behindbytes.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Bin Meng <bin.meng@windriver.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: "Cédric Le Goater" <clg@kaod.org>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
> Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Greg Kurz <groug@kaod.org>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-block@nongnu.org
> Cc: qemu-s390x@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-ppc@nongnu.org
> ---
>  hw/nvme/nvme.h                              | 10 +++-------
>  hw/usb/hcd-xhci-pci.h                       |  4 +---
>  hw/usb/hcd-xhci-sysbus.h                    |  4 +---
>  include/hw/adc/npcm7xx_adc.h                |  4 +---
>  include/hw/char/shakti_uart.h               |  4 +---
>  include/hw/dma/sifive_pdma.h                |  4 +---
>  include/hw/dma/xlnx_csu_dma.h               |  4 +---
>  include/hw/gpio/sifive_gpio.h               |  4 +---
>  include/hw/intc/m68k_irqc.h                 |  4 +---
>  include/hw/intc/sifive_clint.h              |  4 +---
>  include/hw/intc/sifive_plic.h               |  4 +---
>  include/hw/misc/aspeed_lpc.h                |  4 +---
>  include/hw/misc/bcm2835_cprman_internals.h  | 12 ++++--------
>  include/hw/misc/led.h                       |  3 +--
>  include/hw/misc/mchp_pfsoc_dmc.h            |  8 ++------
>  include/hw/misc/mchp_pfsoc_ioscb.h          |  4 +---
>  include/hw/misc/mchp_pfsoc_sysreg.h         |  4 +---
>  include/hw/misc/npcm7xx_clk.h               |  3 +--
>  include/hw/misc/npcm7xx_gcr.h               |  4 +---
>  include/hw/misc/npcm7xx_mft.h               |  4 +---
>  include/hw/misc/npcm7xx_pwm.h               |  3 +--
>  include/hw/misc/sifive_e_prci.h             |  4 +---
>  include/hw/misc/sifive_test.h               |  4 +---
>  include/hw/misc/sifive_u_otp.h              |  4 +---
>  include/hw/misc/sifive_u_prci.h             |  4 +---
>  include/hw/misc/xlnx-versal-xramc.h         |  4 +---
>  include/hw/net/npcm7xx_emc.h                |  4 +---
>  include/hw/net/xlnx-zynqmp-can.h            |  4 +---
>  include/hw/ppc/spapr_drc.h                  |  4 +---
>  include/hw/register.h                       |  3 +--
>  include/hw/riscv/microchip_pfsoc.h          |  4 +---
>  include/hw/riscv/shakti_c.h                 |  8 ++------
>  include/hw/riscv/sifive_e.h                 |  4 +---
>  include/hw/riscv/sifive_u.h                 |  4 +---
>  include/hw/sd/cadence_sdhci.h               |  4 +---
>  include/hw/ssi/sifive_spi.h                 |  4 +---
>  include/hw/timer/npcm7xx_timer.h            |  3 +--
>  include/hw/tricore/tricore_testdevice.h     |  4 +---
>  include/hw/usb/hcd-dwc3.h                   |  4 +---
>  include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  4 +---
>  hw/m68k/mcf5206.c                           |  4 +---
>  hw/mips/boston.c                            |  4 +---
>  hw/misc/npcm7xx_clk.c                       |  9 +++------
>  hw/net/can/ctucan_pci.c                     |  4 +---
>  hw/s390x/vhost-user-fs-ccw.c                |  4 +---
>  hw/sensor/adm1272.c                         |  4 +---
>  hw/sensor/max34451.c                        |  4 +---
>  47 files changed, 56 insertions(+), 154 deletions(-)

Acked-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 12/12] [automated] Use OBJECT_DECLARE_SIMPLE_TYPE when possible
@ 2021-08-10  6:12     ` Cornelia Huck
  0 siblings, 0 replies; 45+ messages in thread
From: Cornelia Huck @ 2021-08-10  6:12 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Daniel P. Berrange, Paolo Bonzini, Thomas Huth, Paul Burton,
	Aleksandar Rikalo, Philippe Mathieu-Daudé,
	Aurelien Jarno, Jiaxun Yang, Havard Skinnemoen, Tyrone Ting,
	Pavel Pisa, Vikram Garhwal, Jason Wang, Keith Busch,
	Klaus Jensen, Michael S. Tsirkin, Richard Henderson,
	David Hildenbrand, Halil Pasic, Christian Borntraeger,
	Gerd Hoffmann, Vijai Kumar K, Alistair Francis, Bin Meng,
	Palmer Dabbelt, Edgar E. Iglesias, Peter Maydell, Laurent Vivier,
	Cédric Le Goater, Andrew Jeffery, Joel Stanley,
	Andrew Baumann, Francisco Iglesias, David Gibson, Greg Kurz,
	Bastian Koppelmann, qemu-arm, qemu-block, qemu-s390x, qemu-riscv,
	qemu-ppc

On Fri, Aug 06 2021, Eduardo Habkost <ehabkost@redhat.com> wrote:

> Replace typedef + DECLARE_INSTANCE_CHECKER with
> equivalent OBJECT_DECLARE_SIMPLE_TYPE macro.
>
> Generated using:
>
> $ ./scripts/codeconverter/converter.py -i \
>   --pattern=AddObjectDeclareSimpleType $(git grep -l '' -- '*.[ch]')
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Thomas Huth <huth@tuxfamily.org>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: Havard Skinnemoen <hskinnemoen@google.com>
> Cc: Tyrone Ting <kfting@nuvoton.com>
> Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
> Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Klaus Jensen <its@irrelevant.dk>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Vijai Kumar K <vijai@behindbytes.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Bin Meng <bin.meng@windriver.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: "Cédric Le Goater" <clg@kaod.org>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
> Cc: Francisco Iglesias <francisco.iglesias@xilinx.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Greg Kurz <groug@kaod.org>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-block@nongnu.org
> Cc: qemu-s390x@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-ppc@nongnu.org
> ---
>  hw/nvme/nvme.h                              | 10 +++-------
>  hw/usb/hcd-xhci-pci.h                       |  4 +---
>  hw/usb/hcd-xhci-sysbus.h                    |  4 +---
>  include/hw/adc/npcm7xx_adc.h                |  4 +---
>  include/hw/char/shakti_uart.h               |  4 +---
>  include/hw/dma/sifive_pdma.h                |  4 +---
>  include/hw/dma/xlnx_csu_dma.h               |  4 +---
>  include/hw/gpio/sifive_gpio.h               |  4 +---
>  include/hw/intc/m68k_irqc.h                 |  4 +---
>  include/hw/intc/sifive_clint.h              |  4 +---
>  include/hw/intc/sifive_plic.h               |  4 +---
>  include/hw/misc/aspeed_lpc.h                |  4 +---
>  include/hw/misc/bcm2835_cprman_internals.h  | 12 ++++--------
>  include/hw/misc/led.h                       |  3 +--
>  include/hw/misc/mchp_pfsoc_dmc.h            |  8 ++------
>  include/hw/misc/mchp_pfsoc_ioscb.h          |  4 +---
>  include/hw/misc/mchp_pfsoc_sysreg.h         |  4 +---
>  include/hw/misc/npcm7xx_clk.h               |  3 +--
>  include/hw/misc/npcm7xx_gcr.h               |  4 +---
>  include/hw/misc/npcm7xx_mft.h               |  4 +---
>  include/hw/misc/npcm7xx_pwm.h               |  3 +--
>  include/hw/misc/sifive_e_prci.h             |  4 +---
>  include/hw/misc/sifive_test.h               |  4 +---
>  include/hw/misc/sifive_u_otp.h              |  4 +---
>  include/hw/misc/sifive_u_prci.h             |  4 +---
>  include/hw/misc/xlnx-versal-xramc.h         |  4 +---
>  include/hw/net/npcm7xx_emc.h                |  4 +---
>  include/hw/net/xlnx-zynqmp-can.h            |  4 +---
>  include/hw/ppc/spapr_drc.h                  |  4 +---
>  include/hw/register.h                       |  3 +--
>  include/hw/riscv/microchip_pfsoc.h          |  4 +---
>  include/hw/riscv/shakti_c.h                 |  8 ++------
>  include/hw/riscv/sifive_e.h                 |  4 +---
>  include/hw/riscv/sifive_u.h                 |  4 +---
>  include/hw/sd/cadence_sdhci.h               |  4 +---
>  include/hw/ssi/sifive_spi.h                 |  4 +---
>  include/hw/timer/npcm7xx_timer.h            |  3 +--
>  include/hw/tricore/tricore_testdevice.h     |  4 +---
>  include/hw/usb/hcd-dwc3.h                   |  4 +---
>  include/hw/usb/xlnx-versal-usb2-ctrl-regs.h |  4 +---
>  hw/m68k/mcf5206.c                           |  4 +---
>  hw/mips/boston.c                            |  4 +---
>  hw/misc/npcm7xx_clk.c                       |  9 +++------
>  hw/net/can/ctucan_pci.c                     |  4 +---
>  hw/s390x/vhost-user-fs-ccw.c                |  4 +---
>  hw/sensor/adm1272.c                         |  4 +---
>  hw/sensor/max34451.c                        |  4 +---
>  47 files changed, 56 insertions(+), 154 deletions(-)

Acked-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 02/12] qom: Use DEVICE_*CLASS instead of OBJECT_*CLASS
  2021-08-06 21:11 ` [PATCH for-6.2 02/12] qom: Use DEVICE_*CLASS instead of OBJECT_*CLASS Eduardo Habkost
  2021-08-07  8:17   ` Philippe Mathieu-Daudé
@ 2021-08-10 11:56   ` Juan Quintela
  2021-08-10 14:22     ` Eduardo Habkost
  1 sibling, 1 reply; 45+ messages in thread
From: Juan Quintela @ 2021-08-10 11:56 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Daniel P. Berrange, Michael S. Tsirkin, Markus Armbruster,
	qemu-devel, Dr. David Alan Gilbert, Gerd Hoffmann, Paolo Bonzini

Eduardo Habkost <ehabkost@redhat.com> wrote:
> There are multiple functions where OBJECT_GET_CLASS or
> OBJECT_CLASS_CHECK are being used directly for
> DeviceClass/TYPE_DEVICE, instead of the DEVICE_GET_CLASS or
> DEVICE_CLASS wrappers.  There's no reason to not use the
> wrappers, so use them.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>



> -        DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, list->data,
> -                                             TYPE_DEVICE);
> +        DeviceClass *dc = DEVICE_CLASS(list->data);

Finding where DEVICE_CLASS is defined is .... interesting.



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 05/12] [automated] Move QOM typedefs and add missing includes
  2021-08-06 21:11   ` Eduardo Habkost
@ 2021-08-10 12:01     ` Juan Quintela
  -1 siblings, 0 replies; 45+ messages in thread
From: Juan Quintela @ 2021-08-10 12:01 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Peter Maydell, Michael S. Tsirkin, Alexey Kardashevskiy,
	Andrew Jeffery, Jason Wang, Bin Meng, David Hildenbrand,
	qemu-devel, Laurent Vivier, Vijai Kumar K, Taylor Simpson,
	Alistair Francis, Gerd Hoffmann, Klaus Jensen, Edgar E. Iglesias,
	Vikram Garhwal, qemu-block, Stefan Berger, qemu-ppc, Huacai Chen,
	Havard Skinnemoen, Halil Pasic, Christian Borntraeger,
	Hervé Poussineau, Joel Stanley, Marc-André Lureau,
	Pavel Pisa, Aleksandar Rikalo, Corey Minyard, qemu-s390x,
	Richard Henderson, Greg Kurz, Dr. David Alan Gilbert,
	Alexander Bulekov, Bandan Das, qemu-arm, Cédric Le Goater,
	Stefan Hajnoczi, Paolo Bonzini, Keith Busch, qemu-riscv,
	David Gibson, Daniel P. Berrange, Francisco Iglesias,
	Thomas Huth, Bastian Koppelmann, Cornelia Huck,
	Philippe Mathieu-Daudé,
	Andrew Baumann, Tyrone Ting, Palmer Dabbelt, Igor Mammedov,
	Aurelien Jarno

Eduardo Habkost <ehabkost@redhat.com> wrote:
> Some typedefs and macros are defined after the type check macros.
> This makes it difficult to automatically replace their
> definitions with OBJECT_DECLARE_TYPE.
>
> Patch generated using:
>
>  $ ./scripts/codeconverter/converter.py -i --pattern=MoveSymbols \
>     $(git grep -l '' -- '*.[ch]')
>
> which will:
> - split "typdef struct { ... } TypedefName" declarations
> - move the typedefs and #defines above the type check macros
> - add missing #include "qom/object.h" lines if necessary
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

Just curious, how did my name ended on the CC'd list?  I don't see any
file that I touched or that is migration related.

Later, Juan.



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 05/12] [automated] Move QOM typedefs and add missing includes
@ 2021-08-10 12:01     ` Juan Quintela
  0 siblings, 0 replies; 45+ messages in thread
From: Juan Quintela @ 2021-08-10 12:01 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, Daniel P. Berrange, Paolo Bonzini, Richard Henderson,
	Marc-André Lureau, Peter Maydell, Andrew Baumann,
	Philippe Mathieu-Daudé,
	Thomas Huth, Michael S. Tsirkin, Igor Mammedov,
	Alexander Bulekov, Bandan Das, Stefan Hajnoczi, Huacai Chen,
	Jiaxun Yang, Aurelien Jarno, Aleksandar Rikalo,
	Havard Skinnemoen, Tyrone Ting, Pavel Pisa, Vikram Garhwal,
	Jason Wang, Keith Busch, Klaus Jensen, Cornelia Huck,
	Halil Pasic, Christian Borntraeger, David Hildenbrand,
	Gerd Hoffmann, Vijai Kumar K, Alistair Francis, Bin Meng,
	Palmer Dabbelt, Edgar E. Iglesias, Laurent Vivier, Corey Minyard,
	Cédric Le Goater, Andrew Jeffery, Joel Stanley,
	Francisco Iglesias, David Gibson, Greg Kurz,
	Alexey Kardashevskiy, Hervé Poussineau, Bastian Koppelmann,
	Dr. David Alan Gilbert, Stefan Berger, Taylor Simpson, qemu-arm,
	qemu-block, qemu-s390x, qemu-riscv, qemu-ppc

Eduardo Habkost <ehabkost@redhat.com> wrote:
> Some typedefs and macros are defined after the type check macros.
> This makes it difficult to automatically replace their
> definitions with OBJECT_DECLARE_TYPE.
>
> Patch generated using:
>
>  $ ./scripts/codeconverter/converter.py -i --pattern=MoveSymbols \
>     $(git grep -l '' -- '*.[ch]')
>
> which will:
> - split "typdef struct { ... } TypedefName" declarations
> - move the typedefs and #defines above the type check macros
> - add missing #include "qom/object.h" lines if necessary
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

Just curious, how did my name ended on the CC'd list?  I don't see any
file that I touched or that is migration related.

Later, Juan.



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 05/12] [automated] Move QOM typedefs and add missing includes
  2021-08-10 12:01     ` Juan Quintela
@ 2021-08-10 13:06       ` Eduardo Habkost
  -1 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-10 13:06 UTC (permalink / raw)
  To: Juan Quintela
  Cc: Peter Maydell, Michael S. Tsirkin, Alexey Kardashevskiy,
	Andrew Jeffery, Jason Wang, Bin Meng, David Hildenbrand,
	qemu-devel, Laurent Vivier, Vijai Kumar K, Taylor Simpson,
	Alistair Francis, Gerd Hoffmann, Klaus Jensen, Edgar E. Iglesias,
	Vikram Garhwal, qemu-block, Stefan Berger, qemu-ppc, Huacai Chen,
	Havard Skinnemoen, Halil Pasic, Christian Borntraeger,
	Hervé Poussineau, Joel Stanley, Marc-André Lureau,
	Pavel Pisa, Aleksandar Rikalo, Corey Minyard, qemu-s390x,
	Richard Henderson, Greg Kurz, Dr. David Alan Gilbert,
	Alexander Bulekov, Bandan Das, qemu-arm, Cédric Le Goater,
	Stefan Hajnoczi, Paolo Bonzini, Keith Busch, qemu-riscv,
	David Gibson, Daniel P. Berrange, Francisco Iglesias,
	Thomas Huth, Bastian Koppelmann, Cornelia Huck,
	Philippe Mathieu-Daudé,
	Andrew Baumann, Tyrone Ting, Palmer Dabbelt, Igor Mammedov,
	Aurelien Jarno

On Tue, Aug 10, 2021 at 02:01:40PM +0200, Juan Quintela wrote:
> Eduardo Habkost <ehabkost@redhat.com> wrote:
> > Some typedefs and macros are defined after the type check macros.
> > This makes it difficult to automatically replace their
> > definitions with OBJECT_DECLARE_TYPE.
> >
> > Patch generated using:
> >
> >  $ ./scripts/codeconverter/converter.py -i --pattern=MoveSymbols \
> >     $(git grep -l '' -- '*.[ch]')
> >
> > which will:
> > - split "typdef struct { ... } TypedefName" declarations
> > - move the typedefs and #defines above the type check macros
> > - add missing #include "qom/object.h" lines if necessary
> >
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> 
> Reviewed-by: Juan Quintela <quintela@redhat.com>

Thanks!

> 
> Just curious, how did my name ended on the CC'd list?  I don't see any
> file that I touched or that is migration related.

include/hw/vmstate-if.h is in the migration section in
MAINTAINERS.

-- 
Eduardo



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 05/12] [automated] Move QOM typedefs and add missing includes
@ 2021-08-10 13:06       ` Eduardo Habkost
  0 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-10 13:06 UTC (permalink / raw)
  To: Juan Quintela
  Cc: qemu-devel, Daniel P. Berrange, Paolo Bonzini, Richard Henderson,
	Marc-André Lureau, Peter Maydell, Andrew Baumann,
	Philippe Mathieu-Daudé,
	Thomas Huth, Michael S. Tsirkin, Igor Mammedov,
	Alexander Bulekov, Bandan Das, Stefan Hajnoczi, Huacai Chen,
	Jiaxun Yang, Aurelien Jarno, Aleksandar Rikalo,
	Havard Skinnemoen, Tyrone Ting, Pavel Pisa, Vikram Garhwal,
	Jason Wang, Keith Busch, Klaus Jensen, Cornelia Huck,
	Halil Pasic, Christian Borntraeger, David Hildenbrand,
	Gerd Hoffmann, Vijai Kumar K, Alistair Francis, Bin Meng,
	Palmer Dabbelt, Edgar E. Iglesias, Laurent Vivier, Corey Minyard,
	Cédric Le Goater, Andrew Jeffery, Joel Stanley,
	Francisco Iglesias, David Gibson, Greg Kurz,
	Alexey Kardashevskiy, Hervé Poussineau, Bastian Koppelmann,
	Dr. David Alan Gilbert, Stefan Berger, Taylor Simpson, qemu-arm,
	qemu-block, qemu-s390x, qemu-riscv, qemu-ppc

On Tue, Aug 10, 2021 at 02:01:40PM +0200, Juan Quintela wrote:
> Eduardo Habkost <ehabkost@redhat.com> wrote:
> > Some typedefs and macros are defined after the type check macros.
> > This makes it difficult to automatically replace their
> > definitions with OBJECT_DECLARE_TYPE.
> >
> > Patch generated using:
> >
> >  $ ./scripts/codeconverter/converter.py -i --pattern=MoveSymbols \
> >     $(git grep -l '' -- '*.[ch]')
> >
> > which will:
> > - split "typdef struct { ... } TypedefName" declarations
> > - move the typedefs and #defines above the type check macros
> > - add missing #include "qom/object.h" lines if necessary
> >
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> 
> Reviewed-by: Juan Quintela <quintela@redhat.com>

Thanks!

> 
> Just curious, how did my name ended on the CC'd list?  I don't see any
> file that I touched or that is migration related.

include/hw/vmstate-if.h is in the migration section in
MAINTAINERS.

-- 
Eduardo



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH for-6.2 02/12] qom: Use DEVICE_*CLASS instead of OBJECT_*CLASS
  2021-08-10 11:56   ` Juan Quintela
@ 2021-08-10 14:22     ` Eduardo Habkost
  0 siblings, 0 replies; 45+ messages in thread
From: Eduardo Habkost @ 2021-08-10 14:22 UTC (permalink / raw)
  To: Juan Quintela
  Cc: Daniel P. Berrange, Michael S. Tsirkin, Markus Armbruster,
	qemu-devel, Dr. David Alan Gilbert, Gerd Hoffmann, Paolo Bonzini

On Tue, Aug 10, 2021 at 01:56:25PM +0200, Juan Quintela wrote:
> > -        DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, list->data,
> > -                                             TYPE_DEVICE);
> > +        DeviceClass *dc = DEVICE_CLASS(list->data);
> 
> Finding where DEVICE_CLASS is defined is .... interesting.

That's a valid concern, but I wonder what we can do to address
this.  The existing practice of defining all macros manually
leads to a high number of mistakes and inconsistencies[1].

Now, once all QOM types are converted to the new macros (which is
work in progress), maybe we could replace:

  DEVICE_CLASS(oc)
  DEVICE_GET_CLASS(dev)

with more grep-friendly expressions like:

  CLASS(DEVICE, oc)
  GET_CLASS(DEVICE, dev)

The type of those expressions would still be (DeviceClass*).

---

[1] These are some of the fixes for bugs or inconsistencies that were
already merged to qemu.git:

6a567fbcf0b8 nubus: Delete unused NUBUS_BRIDGE macro
98b49b2bea15 spapr: Remove unnecessary DRC type-checker macros
08e14bb7e060 platform-bus: Delete macros for non-existing typedef
5c8b0f2cc799 can_emu: Delete macros for non-existing typedef
f58b770fbbd9 virtio-ccw: Fix definition of VIRTIO_CCW_BUS_GET_CLASS

These are fixes for broken QOM macros I submitted recently:

[PATCH for-6.2 1/6] acpi: Delete broken ACPI_GED_X86 macro
[PATCH for-6.2 2/6] sbsa_gwdt: Delete broken SBSA_*CLASS macros

And these are some other inconsistencies that are still in the
current tree, that need to be addressed:

hw/i386/kvm/i8254.c:45:1: type name mismatch: TYPE_KVM_I8254 vs KVM_PIT
hw/net/e1000.c:158:1: type name mismatch: TYPE_E1000_BASE vs E1000
hw/rtc/m48t59-isa.c:38:1: mismatching class type for M48TXX_ISA (M48txxISADeviceClass)
hw/rtc/m48t59-isa.c:131:1: class type declared here (None)
hw/rtc/m48t59.c:47:1: mismatching class type for M48TXX_SYS_BUS (M48txxSysBusDeviceClass)
hw/rtc/m48t59.c:654:1: class type declared here (None)
hw/s390x/virtio-ccw.h:63:1: typedef name mismatch: VirtioCcwBusState is defined as struct VirtioBusState
hw/s390x/virtio-ccw.h:59:1: typedef is here
hw/scsi/megasas.c:137:1: type name mismatch: TYPE_MEGASAS_BASE vs MEGASAS
hw/virtio/virtio-pci.h:29:1: typedef name mismatch: VirtioPCIBusState is defined as struct VirtioBusState
hw/virtio/virtio-pci.h:25:1: typedef is here
include/exec/memory.h:48:1: mismatching instance type for RAM_DISCARD_MANAGER (RamDiscardManager)
softmmu/memory.c:3418:1: instance type declared here (None)
include/hw/isa/superio.h:20:1: mismatching instance type for ISA_SUPERIO (ISASuperIODevice)
hw/isa/isa-superio.c:180:1: instance type declared here (None)
include/hw/s390x/event-facility.h:197:1: type name mismatch: TYPE_SCLP_EVENT_FACILITY vs EVENT_FACILITY
include/hw/s390x/s390-ccw.h:22:1: type name mismatch: TYPE_S390_CCW vs S390_CCW_DEVICE
include/hw/vfio/vfio-amd-xgbe.h:43:1: type name mismatch: TYPE_VFIO_AMD_XGBE vs VFIO_AMD_XGBE_DEVICE
include/hw/vfio/vfio-calxeda-xgmac.h:40:1: type name mismatch: TYPE_VFIO_CALXEDA_XGMAC vs VFIO_CALXEDA_XGMAC_DEVICE
include/hw/vfio/vfio-platform.h:73:1: type name mismatch: TYPE_VFIO_PLATFORM vs VFIO_PLATFORM_DEVICE
include/hw/watchdog/wdt_diag288.h:10:1: type name mismatch: TYPE_WDT_DIAG288 vs DIAG288
migration/migration.h:141:1: type name mismatch: TYPE_MIGRATION vs MIGRATION_OBJ
target/ppc/cpu.h:1253:1: mismatching instance type for PPC_VIRTUAL_HYPERVISOR (PPCVirtualHypervisor)
target/ppc/cpu_init.c:9090:1: instance type declared here (None)

-- 
Eduardo



^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2021-08-10 14:22 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-06 21:11 [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Eduardo Habkost
2021-08-06 21:11 ` [PATCH for-6.2 01/12] accel: Rename TYPE_ACCEL to TYPE_ACCEL_BASE Eduardo Habkost
2021-08-06 21:11   ` Eduardo Habkost
2021-08-06 21:11 ` [PATCH for-6.2 02/12] qom: Use DEVICE_*CLASS instead of OBJECT_*CLASS Eduardo Habkost
2021-08-07  8:17   ` Philippe Mathieu-Daudé
2021-08-10 11:56   ` Juan Quintela
2021-08-10 14:22     ` Eduardo Habkost
2021-08-06 21:11 ` [PATCH for-6.2 03/12] scripts/codeconverter: Update to latest version Eduardo Habkost
2021-08-06 21:11 ` [PATCH for-6.2 04/12] [automated] Add struct names to typedefs used by QOM types Eduardo Habkost
2021-08-06 21:11   ` Eduardo Habkost
2021-08-07  8:03   ` Philippe Mathieu-Daudé
2021-08-07  8:03     ` Philippe Mathieu-Daudé
2021-08-06 21:11 ` [PATCH for-6.2 05/12] [automated] Move QOM typedefs and add missing includes Eduardo Habkost
2021-08-06 21:11   ` Eduardo Habkost
2021-08-07  8:13   ` Philippe Mathieu-Daudé
2021-08-07  8:13     ` Philippe Mathieu-Daudé
2021-08-10  6:06   ` Cornelia Huck
2021-08-10  6:06     ` Cornelia Huck
2021-08-10 12:01   ` Juan Quintela
2021-08-10 12:01     ` Juan Quintela
2021-08-10 13:06     ` Eduardo Habkost
2021-08-10 13:06       ` Eduardo Habkost
2021-08-06 21:11 ` [PATCH for-6.2 06/12] [automated] Split QOM "typedef struct T { ... } T" declarations Eduardo Habkost
2021-08-06 21:11   ` Eduardo Habkost
2021-08-10  6:08   ` Cornelia Huck
2021-08-10  6:08     ` Cornelia Huck
2021-08-06 21:11 ` [PATCH for-6.2 07/12] [automated] Use DECLARE_*CHECKER* macros when possible Eduardo Habkost
2021-08-06 21:11   ` Eduardo Habkost
2021-08-10  6:09   ` Cornelia Huck
2021-08-10  6:09     ` Cornelia Huck
2021-08-06 21:11 ` [PATCH for-6.2 08/12] npcm7xx_clk: Use DECLARE_INSTANCE_CHECKER Eduardo Habkost
2021-08-07  7:59   ` Philippe Mathieu-Daudé
2021-08-06 21:11 ` [PATCH for-6.2 09/12] npcm7xx_otp: Use DECLARE_CLASS_CHECKERS Eduardo Habkost
2021-08-07  8:00   ` Philippe Mathieu-Daudé
2021-08-06 21:11 ` [PATCH for-6.2 10/12] [automated] Use DECLARE_OBJ_CHECKERS when possible Eduardo Habkost
2021-08-06 21:11 ` [PATCH for-6.2 11/12] [automated] Use OBJECT_DECLARE_TYPE " Eduardo Habkost
2021-08-07  8:02   ` Philippe Mathieu-Daudé
2021-08-06 21:11 ` [PATCH for-6.2 12/12] [automated] Use OBJECT_DECLARE_SIMPLE_TYPE " Eduardo Habkost
2021-08-06 21:11   ` Eduardo Habkost
2021-08-07  8:09   ` Philippe Mathieu-Daudé
2021-08-07  8:09     ` Philippe Mathieu-Daudé
2021-08-10  6:12   ` Cornelia Huck
2021-08-10  6:12     ` Cornelia Huck
2021-08-07  8:15 ` [PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends Philippe Mathieu-Daudé
2021-08-09 18:00   ` Eduardo Habkost

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.