[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 11/23] hw/i2c/mpc_i2c: Prefer DEFINE_TYPES() macro
From: |
Bernhard Beschow |
Subject: |
Re: [PATCH 11/23] hw/i2c/mpc_i2c: Prefer DEFINE_TYPES() macro |
Date: |
Mon, 23 Sep 2024 22:01:35 +0000 |
Am 23. September 2024 10:49:53 UTC schrieb BALATON Zoltan <balaton@eik.bme.hu>:
>On Mon, 23 Sep 2024, Bernhard Beschow wrote:
>> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
>> ---
>> hw/i2c/mpc_i2c.c | 20 ++++++++------------
>> 1 file changed, 8 insertions(+), 12 deletions(-)
>>
>> diff --git a/hw/i2c/mpc_i2c.c b/hw/i2c/mpc_i2c.c
>> index 3d79c15653..16f4309ea9 100644
>> --- a/hw/i2c/mpc_i2c.c
>> +++ b/hw/i2c/mpc_i2c.c
>> @@ -20,7 +20,6 @@
>> #include "qemu/osdep.h"
>> #include "hw/i2c/i2c.h"
>> #include "hw/irq.h"
>> -#include "qemu/module.h"
>> #include "hw/sysbus.h"
>> #include "migration/vmstate.h"
>> #include "qom/object.h"
>> @@ -345,16 +344,13 @@ static void mpc_i2c_class_init(ObjectClass *klass,
>> void *data)
>> dc->desc = "MPC I2C Controller";
>> }
>>
>> -static const TypeInfo mpc_i2c_type_info = {
>> - .name = TYPE_MPC_I2C,
>> - .parent = TYPE_SYS_BUS_DEVICE,
>> - .instance_size = sizeof(MPCI2CState),
>> - .class_init = mpc_i2c_class_init,
>> +static const TypeInfo types[] = {
>> + {
>> + .name = TYPE_MPC_I2C,
>> + .parent = TYPE_SYS_BUS_DEVICE,
>> + .instance_size = sizeof(MPCI2CState),
>> + .class_init = mpc_i2c_class_init,
>> + },
>> };
>>
>> -static void mpc_i2c_register_types(void)
>> -{
>> - type_register_static(&mpc_i2c_type_info);
>> -}
>> -
>> -type_init(mpc_i2c_register_types)
>> +DEFINE_TYPES(types)
>
>What's the advantage of this when we have a single device? For these devices
>this looks like just code churn to me.
It is still shorter and also more modern style. As a nice side effect it also
helps in my experimental branch (which may never ship).
Best regards,
Bernhard
>
>Regards,
>BALATON Zoltan
- [PATCH 07/23] hw/ppc/e500: Extract ppce500_ccsr.c, (continued)
- [PATCH 07/23] hw/ppc/e500: Extract ppce500_ccsr.c, Bernhard Beschow, 2024/09/23
- [PATCH 08/23] hw/ppc/ppce500_ccsr: Log access to unimplemented registers, Bernhard Beschow, 2024/09/23
- [PATCH 12/23] hw/pci-host/ppce500: Reuse TYPE_PPC_E500_PCI_BRIDGE define, Bernhard Beschow, 2024/09/23
- [PATCH 11/23] hw/i2c/mpc_i2c: Prefer DEFINE_TYPES() macro, Bernhard Beschow, 2024/09/23
- Re: [PATCH 11/23] hw/i2c/mpc_i2c: Prefer DEFINE_TYPES() macro, Cédric Le Goater, 2024/09/25
- [PATCH 09/23] hw/ppc/mpc8544_guts: Populate POR PLL ratio status register, Bernhard Beschow, 2024/09/23
[PATCH 10/23] hw/i2c/mpc_i2c: Convert DPRINTF to trace events for register access, Bernhard Beschow, 2024/09/23