[PATCH 4/9] hw/char/sh_serial: Consolidate OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES

Zhao Liu posted 9 patches 6 months ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, Yoshinori Sato <ysato@users.sourceforge.jp>, Magnus Damm <magnus.damm@gmail.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>, Nicholas Piggin <npiggin@gmail.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, Harsh Prateek Bora <harshpb@linux.ibm.com>, Peter Maydell <peter.maydell@linaro.org>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Richard Henderson <richard.henderson@linaro.org>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Thomas Huth <thuth@redhat.com>
[PATCH 4/9] hw/char/sh_serial: Consolidate OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
Posted by Zhao Liu 6 months ago
The QOM type of SHSerialState is declared by OBJECT_DECLARE_SIMPLE_TYPE,
which means it doesn't need the class!

Therefore, use OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES to implement
the type, then there's no need for class definition.

Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
 hw/char/sh_serial.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c
index 6abd80386fb4..8ccc2234ba4d 100644
--- a/hw/char/sh_serial.c
+++ b/hw/char/sh_serial.c
@@ -78,9 +78,7 @@ struct SHSerialState {
     qemu_irq bri;
 };
 
-typedef struct {} SHSerialStateClass;
-
-OBJECT_DEFINE_TYPE(SHSerialState, sh_serial, SH_SERIAL, SYS_BUS_DEVICE)
+OBJECT_DEFINE_SIMPLE_TYPE(SHSerialState, sh_serial, SH_SERIAL, SYS_BUS_DEVICE)
 
 static void sh_serial_clear_fifo(SHSerialState *s)
 {
-- 
2.34.1


Re: [PATCH 4/9] hw/char/sh_serial: Consolidate OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
Posted by BALATON Zoltan 6 months ago
On Wed, 14 May 2025, Zhao Liu wrote:
> The QOM type of SHSerialState is declared by OBJECT_DECLARE_SIMPLE_TYPE,
> which means it doesn't need the class!
>
> Therefore, use OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES to implement

Patch uses OBJECT_DEFINE_SIMPLE_TYPE not 
OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES so change commit message to 
match the patch.

Regards,
BALATON Zoltan

> the type, then there's no need for class definition.
>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> hw/char/sh_serial.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c
> index 6abd80386fb4..8ccc2234ba4d 100644
> --- a/hw/char/sh_serial.c
> +++ b/hw/char/sh_serial.c
> @@ -78,9 +78,7 @@ struct SHSerialState {
>     qemu_irq bri;
> };
>
> -typedef struct {} SHSerialStateClass;
> -
> -OBJECT_DEFINE_TYPE(SHSerialState, sh_serial, SH_SERIAL, SYS_BUS_DEVICE)
> +OBJECT_DEFINE_SIMPLE_TYPE(SHSerialState, sh_serial, SH_SERIAL, SYS_BUS_DEVICE)
>
> static void sh_serial_clear_fifo(SHSerialState *s)
> {
>
Re: [PATCH 4/9] hw/char/sh_serial: Consolidate OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
Posted by Zhao Liu 6 months ago
On Wed, May 14, 2025 at 02:07:41PM +0200, BALATON Zoltan wrote:
> Date: Wed, 14 May 2025 14:07:41 +0200
> From: BALATON Zoltan <balaton@eik.bme.hu>
> Subject: Re: [PATCH 4/9] hw/char/sh_serial: Consolidate
>  OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
> 
> On Wed, 14 May 2025, Zhao Liu wrote:
> > The QOM type of SHSerialState is declared by OBJECT_DECLARE_SIMPLE_TYPE,
> > which means it doesn't need the class!
> > 
> > Therefore, use OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES to implement
> 
> Patch uses OBJECT_DEFINE_SIMPLE_TYPE not
> OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES so change commit message to match
> the patch.

Good catch! Thanks!

Regards,
Zhao