From: Jamin Lin <jamin_lin@aspeedtech.com>
To: "Alistair Francis" <alistair@alistair23.me>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Cédric Le Goater" <clg@kaod.org>,
"Steven Lee" <steven_lee@aspeedtech.com>,
"Troy Lee" <leetroy@gmail.com>,
"Kane Chen" <kane_chen@aspeedtech.com>,
"Andrew Jeffery" <andrew@codeconstruct.com.au>,
"Joel Stanley" <joel@jms.id.au>,
"Ninad Palsule" <ninad@linux.ibm.com>,
"Jason Wang" <jasowang@redhat.com>,
"open list:STM32F205" <qemu-arm@nongnu.org>,
"open list:All patches CC here" <qemu-devel@nongnu.org>
Cc: Jamin Lin <jamin_lin@aspeedtech.com>, Troy Lee <troy_lee@aspeedtech.com>
Subject: [PATCH v1 22/24] hw/i2c/aspeed_i2c: Convert to DEFINE_TYPES() with inlined TypeInfo
Date: Mon, 1 Jun 2026 02:50:33 +0000 [thread overview]
Message-ID: <20260601024959.2347639-23-jamin_lin@aspeedtech.com> (raw)
In-Reply-To: <20260601024959.2347639-1-jamin_lin@aspeedtech.com>
Replace the legacy type_register_static()/type_init() registration
pattern with the modern DEFINE_TYPES() macro.
Inline 9 standalone TypeInfo variables (aspeed_i2c_bus_info,
aspeed_i2c_bus_slave_info, aspeed_i2c_info as abstract base,
aspeed_2400_i2c_info, aspeed_2500_i2c_info, aspeed_2600_i2c_info,
aspeed_1030_i2c_info and aspeed_2700_i2c_info) directly into the
'aspeed_i2c_types[]' array, removing the need for
separate declarations.
No functional change.
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
hw/i2c/aspeed_i2c.c | 113 +++++++++++++++++++-------------------------
1 file changed, 48 insertions(+), 65 deletions(-)
diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c
index 80c4457500..4a6732a185 100644
--- a/hw/i2c/aspeed_i2c.c
+++ b/hw/i2c/aspeed_i2c.c
@@ -1372,16 +1372,6 @@ static void aspeed_i2c_class_init(ObjectClass *klass, const void *data)
dc->desc = "Aspeed I2C Controller";
}
-static const TypeInfo aspeed_i2c_info = {
- .name = TYPE_ASPEED_I2C,
- .parent = TYPE_SYS_BUS_DEVICE,
- .instance_init = aspeed_i2c_instance_init,
- .instance_size = sizeof(AspeedI2CState),
- .class_init = aspeed_i2c_class_init,
- .class_size = sizeof(AspeedI2CClass),
- .abstract = true,
-};
-
static int aspeed_i2c_bus_new_slave_event(AspeedI2CBus *bus,
enum i2c_event event)
{
@@ -1500,13 +1490,6 @@ static void aspeed_i2c_bus_slave_class_init(ObjectClass *klass,
sc->send_async = aspeed_i2c_bus_slave_send_async;
}
-static const TypeInfo aspeed_i2c_bus_slave_info = {
- .name = TYPE_ASPEED_I2C_BUS_SLAVE,
- .parent = TYPE_I2C_SLAVE,
- .instance_size = sizeof(AspeedI2CBusSlave),
- .class_init = aspeed_i2c_bus_slave_class_init,
-};
-
static void aspeed_i2c_bus_reset_hold(Object *obj, ResetType type)
{
AspeedI2CBus *s = ASPEED_I2C_BUS(obj);
@@ -1565,13 +1548,6 @@ static void aspeed_i2c_bus_class_init(ObjectClass *klass, const void *data)
device_class_set_props(dc, aspeed_i2c_bus_properties);
}
-static const TypeInfo aspeed_i2c_bus_info = {
- .name = TYPE_ASPEED_I2C_BUS,
- .parent = TYPE_SYS_BUS_DEVICE,
- .instance_size = sizeof(AspeedI2CBus),
- .class_init = aspeed_i2c_bus_class_init,
-};
-
static qemu_irq aspeed_2400_i2c_bus_get_irq(AspeedI2CBus *bus)
{
return bus->controller->irq;
@@ -1605,12 +1581,6 @@ static void aspeed_2400_i2c_class_init(ObjectClass *klass, const void *data)
aic->mem_size = 0x1000;
}
-static const TypeInfo aspeed_2400_i2c_info = {
- .name = TYPE_ASPEED_2400_I2C,
- .parent = TYPE_ASPEED_I2C,
- .class_init = aspeed_2400_i2c_class_init,
-};
-
static qemu_irq aspeed_2500_i2c_bus_get_irq(AspeedI2CBus *bus)
{
return bus->controller->irq;
@@ -1640,12 +1610,6 @@ static void aspeed_2500_i2c_class_init(ObjectClass *klass, const void *data)
aic->mem_size = 0x1000;
}
-static const TypeInfo aspeed_2500_i2c_info = {
- .name = TYPE_ASPEED_2500_I2C,
- .parent = TYPE_ASPEED_I2C,
- .class_init = aspeed_2500_i2c_class_init,
-};
-
static qemu_irq aspeed_2600_i2c_bus_get_irq(AspeedI2CBus *bus)
{
return bus->irq;
@@ -1669,12 +1633,6 @@ static void aspeed_2600_i2c_class_init(ObjectClass *klass, const void *data)
aic->mem_size = 0x1000;
}
-static const TypeInfo aspeed_2600_i2c_info = {
- .name = TYPE_ASPEED_2600_I2C,
- .parent = TYPE_ASPEED_I2C,
- .class_init = aspeed_2600_i2c_class_init,
-};
-
static void aspeed_1030_i2c_class_init(ObjectClass *klass, const void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -1693,12 +1651,6 @@ static void aspeed_1030_i2c_class_init(ObjectClass *klass, const void *data)
aic->mem_size = 0x10000;
}
-static const TypeInfo aspeed_1030_i2c_info = {
- .name = TYPE_ASPEED_1030_I2C,
- .parent = TYPE_ASPEED_I2C,
- .class_init = aspeed_1030_i2c_class_init,
-};
-
static void aspeed_2700_i2c_class_init(ObjectClass *klass, const void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -1720,25 +1672,56 @@ static void aspeed_2700_i2c_class_init(ObjectClass *klass, const void *data)
aic->has_dma64 = true;
}
-static const TypeInfo aspeed_2700_i2c_info = {
- .name = TYPE_ASPEED_2700_I2C,
- .parent = TYPE_ASPEED_I2C,
- .class_init = aspeed_2700_i2c_class_init,
+static const TypeInfo aspeed_i2c_types[] = {
+ {
+ .name = TYPE_ASPEED_I2C_BUS,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(AspeedI2CBus),
+ .class_init = aspeed_i2c_bus_class_init,
+ },
+ {
+ .name = TYPE_ASPEED_I2C_BUS_SLAVE,
+ .parent = TYPE_I2C_SLAVE,
+ .instance_size = sizeof(AspeedI2CBusSlave),
+ .class_init = aspeed_i2c_bus_slave_class_init,
+ },
+ {
+ .name = TYPE_ASPEED_I2C,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_init = aspeed_i2c_instance_init,
+ .instance_size = sizeof(AspeedI2CState),
+ .class_init = aspeed_i2c_class_init,
+ .class_size = sizeof(AspeedI2CClass),
+ .abstract = true,
+ },
+ {
+ .name = TYPE_ASPEED_1030_I2C,
+ .parent = TYPE_ASPEED_I2C,
+ .class_init = aspeed_1030_i2c_class_init,
+ },
+ {
+ .name = TYPE_ASPEED_2400_I2C,
+ .parent = TYPE_ASPEED_I2C,
+ .class_init = aspeed_2400_i2c_class_init,
+ },
+ {
+ .name = TYPE_ASPEED_2500_I2C,
+ .parent = TYPE_ASPEED_I2C,
+ .class_init = aspeed_2500_i2c_class_init,
+ },
+ {
+ .name = TYPE_ASPEED_2600_I2C,
+ .parent = TYPE_ASPEED_I2C,
+ .class_init = aspeed_2600_i2c_class_init,
+ },
+ {
+ .name = TYPE_ASPEED_2700_I2C,
+ .parent = TYPE_ASPEED_I2C,
+ .class_init = aspeed_2700_i2c_class_init,
+ }
};
-static void aspeed_i2c_register_types(void)
-{
- type_register_static(&aspeed_i2c_bus_info);
- type_register_static(&aspeed_i2c_bus_slave_info);
- type_register_static(&aspeed_i2c_info);
- type_register_static(&aspeed_2400_i2c_info);
- type_register_static(&aspeed_2500_i2c_info);
- type_register_static(&aspeed_2600_i2c_info);
- type_register_static(&aspeed_1030_i2c_info);
- type_register_static(&aspeed_2700_i2c_info);
-}
-
-type_init(aspeed_i2c_register_types)
+DEFINE_TYPES(aspeed_i2c_types)
I2CBus *aspeed_i2c_get_bus(AspeedI2CState *s, int busnr)
--
2.43.0
next prev parent reply other threads:[~2026-06-01 2:51 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 2:50 [PATCH v1 00/24] hw/aspeed: Convert all Aspeed devices to DEFINE_TYPES() with inlined TypeInfo Jamin Lin
2026-06-01 2:50 ` [PATCH v1 01/24] hw/misc/aspeed_hace: Convert " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 02/24] hw/misc/aspeed_lpc: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 03/24] hw/misc/aspeed_ltpi: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 04/24] hw/misc/aspeed_pwm: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 05/24] hw/misc/aspeed_sbc: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 06/24] hw/misc/aspeed_scu: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 07/24] hw/misc/aspeed_sdmc: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 08/24] hw/misc:aspeed_sli: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 09/24] hw/misc/aspeed_xdma: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 10/24] hw/adc/aspeed_adc: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 11/24] hw/arm/aspeed_ast1700: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 12/24] hw/gpio/aspeed_gpio: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 13/24] hw/gpio/aspeed_sgpio: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 14/24] hw/intc/aspeed_intc: convert " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 15/24] hw/intc/aspeed_vic: Convert " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 16/24] hw/rtc/aspeed_rtc: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 17/24] hw/watchdog/wdt_aspeed: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 18/24] hw/nvram/aspeed_otp: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 19/24] hw/timer/aspeed_timer: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 20/24] hw/fsi/aspeed_apb2opb: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 21/24] hw/pci-host/aspeed_pcie: " Jamin Lin
2026-06-01 2:50 ` Jamin Lin [this message]
2026-06-01 2:50 ` [PATCH v1 23/24] hw/net/ftgmac100: " Jamin Lin
2026-06-01 2:50 ` [PATCH v1 24/24] hw/ssi/aspeed_smc: " Jamin Lin
2026-06-01 8:49 ` [PATCH v1 00/24] hw/aspeed: Convert all Aspeed devices " Cédric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260601024959.2347639-23-jamin_lin@aspeedtech.com \
--to=jamin_lin@aspeedtech.com \
--cc=alistair@alistair23.me \
--cc=andrew@codeconstruct.com.au \
--cc=clg@kaod.org \
--cc=jasowang@redhat.com \
--cc=joel@jms.id.au \
--cc=kane_chen@aspeedtech.com \
--cc=leetroy@gmail.com \
--cc=ninad@linux.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=steven_lee@aspeedtech.com \
--cc=troy_lee@aspeedtech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.