hw/i3c/aspeed_i3c: Switch to DEFINE_TYPES() and align parent_obj naming
Following review feedback, update the Aspeed I3C device to use the DEFINE_TYPES() macro instead of an explicit type registration function. DEFINE_TYPES() is the currently recommended approach in QEMU for registering multiple TypeInfo entries and avoids boilerplate type_init() code. Additionally, rename embedded SysBusDevice fields from "parent" to "parent_obj" to comply with the QEMU coding style guidelines for QOM objects. No functional change. Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Tested-by: Jithu Joseph <jithu.joseph@oss.qualcomm.com> Link: https://lore.kernel.org/qemu-devel/20260225021158.1586584-3-jamin_lin@aspeedtech.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
Jamin Lin committed
Feb 25, 2026 at 02:12 UTC
cd0e4771075e0cdd0b41d2714b910aa9eaa78e13
2 files changed
+21
-30
hw/i3c/aspeed_i3c.c
+15
-20
@@ -337,13 +337,6 @@ static void aspeed_i3c_device_class_init(ObjectClass *klass, const void *data)
337
device_class_set_props(dc, aspeed_i3c_device_properties);
338
}
339
340
-static const TypeInfo aspeed_i3c_device_info = {
341
- .name = TYPE_ASPEED_I3C_DEVICE,
342
- .parent = TYPE_SYS_BUS_DEVICE,
343
- .instance_size = sizeof(AspeedI3CDevice),
344
- .class_init = aspeed_i3c_device_class_init,
345
-};
346
-
340
static const VMStateDescription vmstate_aspeed_i3c = {
341
.name = TYPE_ASPEED_I3C,
342
.version_id = 1,
@@ -366,18 +359,20 @@ static void aspeed_i3c_class_init(ObjectClass *klass, const void *data)
359
dc->vmsd = &vmstate_aspeed_i3c;
360
}
361
369
-static const TypeInfo aspeed_i3c_info = {
370
- .name = TYPE_ASPEED_I3C,
371
- .parent = TYPE_SYS_BUS_DEVICE,
372
- .instance_init = aspeed_i3c_instance_init,
373
- .instance_size = sizeof(AspeedI3CState),
374
- .class_init = aspeed_i3c_class_init,
362
+static const TypeInfo aspeed_i3c_types[] = {
363
+ {
364
+ .name = TYPE_ASPEED_I3C,
365
+ .parent = TYPE_SYS_BUS_DEVICE,
366
+ .instance_init = aspeed_i3c_instance_init,
367
+ .instance_size = sizeof(AspeedI3CState),
368
+ .class_init = aspeed_i3c_class_init,
369
+ },
370
+ {
371
+ .name = TYPE_ASPEED_I3C_DEVICE,
372
+ .parent = TYPE_SYS_BUS_DEVICE,
373
+ .instance_size = sizeof(AspeedI3CDevice),
374
+ .class_init = aspeed_i3c_device_class_init,
375
+ },
376
};
377
377
-static void aspeed_i3c_register_types(void)
378
-{
379
- type_register_static(&aspeed_i3c_device_info);
380
- type_register_static(&aspeed_i3c_info);
381
-}
382
-
383
-type_init(aspeed_i3c_register_types);
378
+DEFINE_TYPES(aspeed_i3c_types)
include/hw/i3c/aspeed_i3c.h
+6
-10
@@ -21,28 +21,24 @@ OBJECT_DECLARE_TYPE(AspeedI3CState, AspeedI3CClass, ASPEED_I3C)
21
#define ASPEED_I3C_NR_DEVICES 6
22
23
OBJECT_DECLARE_SIMPLE_TYPE(AspeedI3CDevice, ASPEED_I3C_DEVICE)
24
-typedef struct AspeedI3CDevice {
25
- /* <private> */
26
- SysBusDevice parent;
24
+struct AspeedI3CDevice {
25
+ SysBusDevice parent_obj;
26
28
- /* <public> */
27
MemoryRegion mr;
28
qemu_irq irq;
29
30
uint8_t id;
31
uint32_t regs[ASPEED_I3C_DEVICE_NR_REGS];
34
-} AspeedI3CDevice;
32
+};
33
36
-typedef struct AspeedI3CState {
37
- /* <private> */
38
- SysBusDevice parent;
34
+struct AspeedI3CState {
35
+ SysBusDevice parent_obj;
36
40
- /* <public> */
37
MemoryRegion iomem;
38
MemoryRegion iomem_container;
39
qemu_irq irq;
40
41
uint32_t regs[ASPEED_I3C_NR_REGS];
42
AspeedI3CDevice devices[ASPEED_I3C_NR_DEVICES];
47
-} AspeedI3CState;
43
+};
44
#endif /* ASPEED_I3C_H */