From db1015e92e04835c9eb50c29625fe566d1202dbd Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Thu, 3 Sep 2020 16:43:22 -0400 Subject: Move QOM typedefs and add missing includes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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=QOMStructTypedefSplit $(git grep -l '' -- '*.[ch]') which will split "typdef struct { ... } TypedefName" declarations. Followed by: $ ./scripts/codeconverter/converter.py -i --pattern=MoveSymbols \ $(git grep -l '' -- '*.[ch]') which will: - move the typedefs and #defines above the type check macros - add missing #include "qom/object.h" lines if necessary Reviewed-by: Daniel P. Berrangé Reviewed-by: Juan Quintela Message-Id: <20200831210740.126168-9-ehabkost@redhat.com> Reviewed-by: Juan Quintela Message-Id: <20200831210740.126168-10-ehabkost@redhat.com> Message-Id: <20200831210740.126168-11-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/rtc/ds1338.c | 6 ++++-- hw/rtc/exynos4210_rtc.c | 6 ++++-- hw/rtc/m41t80.c | 6 ++++-- hw/rtc/m48t59-isa.c | 11 +++++++---- hw/rtc/m48t59.c | 11 +++++++---- hw/rtc/sun4v-rtc.c | 6 ++++-- hw/rtc/twl92230.c | 6 ++++-- 7 files changed, 34 insertions(+), 18 deletions(-) (limited to 'hw/rtc') diff --git a/hw/rtc/ds1338.c b/hw/rtc/ds1338.c index 588a9ba..8b2b797 100644 --- a/hw/rtc/ds1338.c +++ b/hw/rtc/ds1338.c @@ -16,6 +16,7 @@ #include "migration/vmstate.h" #include "qemu/bcd.h" #include "qemu/module.h" +#include "qom/object.h" /* Size of NVRAM including both the user-accessible area and the * secondary register area. @@ -29,9 +30,10 @@ #define CTRL_OSF 0x20 #define TYPE_DS1338 "ds1338" +typedef struct DS1338State DS1338State; #define DS1338(obj) OBJECT_CHECK(DS1338State, (obj), TYPE_DS1338) -typedef struct DS1338State { +struct DS1338State { I2CSlave parent_obj; int64_t offset; @@ -39,7 +41,7 @@ typedef struct DS1338State { uint8_t nvram[NVRAM_SIZE]; int32_t ptr; bool addr_byte; -} DS1338State; +}; static const VMStateDescription vmstate_ds1338 = { .name = "ds1338", diff --git a/hw/rtc/exynos4210_rtc.c b/hw/rtc/exynos4210_rtc.c index f85483a..a95f07e 100644 --- a/hw/rtc/exynos4210_rtc.c +++ b/hw/rtc/exynos4210_rtc.c @@ -38,6 +38,7 @@ #include "hw/irq.h" #include "hw/arm/exynos4210.h" +#include "qom/object.h" #define DEBUG_RTC 0 @@ -84,10 +85,11 @@ #define RTC_BASE_FREQ 32768 #define TYPE_EXYNOS4210_RTC "exynos4210.rtc" +typedef struct Exynos4210RTCState Exynos4210RTCState; #define EXYNOS4210_RTC(obj) \ OBJECT_CHECK(Exynos4210RTCState, (obj), TYPE_EXYNOS4210_RTC) -typedef struct Exynos4210RTCState { +struct Exynos4210RTCState { SysBusDevice parent_obj; MemoryRegion iomem; @@ -113,7 +115,7 @@ typedef struct Exynos4210RTCState { qemu_irq alm_irq; /* alarm irq */ struct tm current_tm; /* current time */ -} Exynos4210RTCState; +}; #define TICCKSEL(value) ((value & (0x0F << 4)) >> 4) diff --git a/hw/rtc/m41t80.c b/hw/rtc/m41t80.c index 914ecac..31445e9 100644 --- a/hw/rtc/m41t80.c +++ b/hw/rtc/m41t80.c @@ -14,14 +14,16 @@ #include "qemu/timer.h" #include "qemu/bcd.h" #include "hw/i2c/i2c.h" +#include "qom/object.h" #define TYPE_M41T80 "m41t80" +typedef struct M41t80State M41t80State; #define M41T80(obj) OBJECT_CHECK(M41t80State, (obj), TYPE_M41T80) -typedef struct M41t80State { +struct M41t80State { I2CSlave parent_obj; int8_t addr; -} M41t80State; +}; static void m41t80_realize(DeviceState *dev, Error **errp) { diff --git a/hw/rtc/m48t59-isa.c b/hw/rtc/m48t59-isa.c index 50430b7..dc608e0 100644 --- a/hw/rtc/m48t59-isa.c +++ b/hw/rtc/m48t59-isa.c @@ -30,8 +30,11 @@ #include "m48t59-internal.h" #include "qapi/error.h" #include "qemu/module.h" +#include "qom/object.h" #define TYPE_M48TXX_ISA "isa-m48txx" +typedef struct M48txxISADeviceClass M48txxISADeviceClass; +typedef struct M48txxISAState M48txxISAState; #define M48TXX_ISA_GET_CLASS(obj) \ OBJECT_GET_CLASS(M48txxISADeviceClass, (obj), TYPE_M48TXX_ISA) #define M48TXX_ISA_CLASS(klass) \ @@ -39,17 +42,17 @@ #define M48TXX_ISA(obj) \ OBJECT_CHECK(M48txxISAState, (obj), TYPE_M48TXX_ISA) -typedef struct M48txxISAState { +struct M48txxISAState { ISADevice parent_obj; M48t59State state; uint32_t io_base; MemoryRegion io; -} M48txxISAState; +}; -typedef struct M48txxISADeviceClass { +struct M48txxISADeviceClass { ISADeviceClass parent_class; M48txxInfo info; -} M48txxISADeviceClass; +}; static M48txxInfo m48txx_isa_info[] = { { diff --git a/hw/rtc/m48t59.c b/hw/rtc/m48t59.c index b428a06..9f5a96a 100644 --- a/hw/rtc/m48t59.c +++ b/hw/rtc/m48t59.c @@ -40,8 +40,11 @@ #include "m48t59-internal.h" #include "migration/vmstate.h" +#include "qom/object.h" #define TYPE_M48TXX_SYS_BUS "sysbus-m48txx" +typedef struct M48txxSysBusDeviceClass M48txxSysBusDeviceClass; +typedef struct M48txxSysBusState M48txxSysBusState; #define M48TXX_SYS_BUS_GET_CLASS(obj) \ OBJECT_GET_CLASS(M48txxSysBusDeviceClass, (obj), TYPE_M48TXX_SYS_BUS) #define M48TXX_SYS_BUS_CLASS(klass) \ @@ -56,16 +59,16 @@ * http://www.st.com/stonline/products/literature/od/7001/m48t59y.pdf */ -typedef struct M48txxSysBusState { +struct M48txxSysBusState { SysBusDevice parent_obj; M48t59State state; MemoryRegion io; -} M48txxSysBusState; +}; -typedef struct M48txxSysBusDeviceClass { +struct M48txxSysBusDeviceClass { SysBusDeviceClass parent_class; M48txxInfo info; -} M48txxSysBusDeviceClass; +}; static M48txxInfo m48txx_sysbus_info[] = { { diff --git a/hw/rtc/sun4v-rtc.c b/hw/rtc/sun4v-rtc.c index 52caea8..b5ebefd 100644 --- a/hw/rtc/sun4v-rtc.c +++ b/hw/rtc/sun4v-rtc.c @@ -16,16 +16,18 @@ #include "qemu/timer.h" #include "hw/rtc/sun4v-rtc.h" #include "trace.h" +#include "qom/object.h" #define TYPE_SUN4V_RTC "sun4v_rtc" +typedef struct Sun4vRtc Sun4vRtc; #define SUN4V_RTC(obj) OBJECT_CHECK(Sun4vRtc, (obj), TYPE_SUN4V_RTC) -typedef struct Sun4vRtc { +struct Sun4vRtc { SysBusDevice parent_obj; MemoryRegion iomem; -} Sun4vRtc; +}; static uint64_t sun4v_rtc_read(void *opaque, hwaddr addr, unsigned size) diff --git a/hw/rtc/twl92230.c b/hw/rtc/twl92230.c index d0011be..d46f214 100644 --- a/hw/rtc/twl92230.c +++ b/hw/rtc/twl92230.c @@ -29,13 +29,15 @@ #include "sysemu/sysemu.h" #include "qemu/bcd.h" #include "qemu/module.h" +#include "qom/object.h" #define VERBOSE 1 #define TYPE_TWL92230 "twl92230" +typedef struct MenelausState MenelausState; #define TWL92230(obj) OBJECT_CHECK(MenelausState, (obj), TYPE_TWL92230) -typedef struct MenelausState { +struct MenelausState { I2CSlave parent_obj; int firstbyte; @@ -71,7 +73,7 @@ typedef struct MenelausState { uint16_t rtc_next_vmstate; qemu_irq out[4]; uint8_t pwrbtn_state; -} MenelausState; +}; static inline void menelaus_update(MenelausState *s) { -- cgit v1.1 From 8110fa1d94f2997badc2af39231a1d279c5bb1ee Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 31 Aug 2020 17:07:33 -0400 Subject: Use DECLARE_*CHECKER* macros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generated using: $ ./scripts/codeconverter/converter.py -i \ --pattern=TypeCheckMacro $(git grep -l '' -- '*.[ch]') Reviewed-by: Daniel P. Berrangé Reviewed-by: Juan Quintela Message-Id: <20200831210740.126168-12-ehabkost@redhat.com> Reviewed-by: Juan Quintela Message-Id: <20200831210740.126168-13-ehabkost@redhat.com> Message-Id: <20200831210740.126168-14-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/rtc/ds1338.c | 3 ++- hw/rtc/exynos4210_rtc.c | 4 ++-- hw/rtc/m41t80.c | 3 ++- hw/rtc/m48t59-isa.c | 8 ++------ hw/rtc/m48t59.c | 8 ++------ hw/rtc/sun4v-rtc.c | 3 ++- hw/rtc/twl92230.c | 3 ++- 7 files changed, 14 insertions(+), 18 deletions(-) (limited to 'hw/rtc') diff --git a/hw/rtc/ds1338.c b/hw/rtc/ds1338.c index 8b2b797..10fac3d 100644 --- a/hw/rtc/ds1338.c +++ b/hw/rtc/ds1338.c @@ -31,7 +31,8 @@ #define TYPE_DS1338 "ds1338" typedef struct DS1338State DS1338State; -#define DS1338(obj) OBJECT_CHECK(DS1338State, (obj), TYPE_DS1338) +DECLARE_INSTANCE_CHECKER(DS1338State, DS1338, + TYPE_DS1338) struct DS1338State { I2CSlave parent_obj; diff --git a/hw/rtc/exynos4210_rtc.c b/hw/rtc/exynos4210_rtc.c index a95f07e..f8a4fe8 100644 --- a/hw/rtc/exynos4210_rtc.c +++ b/hw/rtc/exynos4210_rtc.c @@ -86,8 +86,8 @@ #define TYPE_EXYNOS4210_RTC "exynos4210.rtc" typedef struct Exynos4210RTCState Exynos4210RTCState; -#define EXYNOS4210_RTC(obj) \ - OBJECT_CHECK(Exynos4210RTCState, (obj), TYPE_EXYNOS4210_RTC) +DECLARE_INSTANCE_CHECKER(Exynos4210RTCState, EXYNOS4210_RTC, + TYPE_EXYNOS4210_RTC) struct Exynos4210RTCState { SysBusDevice parent_obj; diff --git a/hw/rtc/m41t80.c b/hw/rtc/m41t80.c index 31445e9..0b7048c 100644 --- a/hw/rtc/m41t80.c +++ b/hw/rtc/m41t80.c @@ -18,7 +18,8 @@ #define TYPE_M41T80 "m41t80" typedef struct M41t80State M41t80State; -#define M41T80(obj) OBJECT_CHECK(M41t80State, (obj), TYPE_M41T80) +DECLARE_INSTANCE_CHECKER(M41t80State, M41T80, + TYPE_M41T80) struct M41t80State { I2CSlave parent_obj; diff --git a/hw/rtc/m48t59-isa.c b/hw/rtc/m48t59-isa.c index dc608e0..cae315e 100644 --- a/hw/rtc/m48t59-isa.c +++ b/hw/rtc/m48t59-isa.c @@ -35,12 +35,8 @@ #define TYPE_M48TXX_ISA "isa-m48txx" typedef struct M48txxISADeviceClass M48txxISADeviceClass; typedef struct M48txxISAState M48txxISAState; -#define M48TXX_ISA_GET_CLASS(obj) \ - OBJECT_GET_CLASS(M48txxISADeviceClass, (obj), TYPE_M48TXX_ISA) -#define M48TXX_ISA_CLASS(klass) \ - OBJECT_CLASS_CHECK(M48txxISADeviceClass, (klass), TYPE_M48TXX_ISA) -#define M48TXX_ISA(obj) \ - OBJECT_CHECK(M48txxISAState, (obj), TYPE_M48TXX_ISA) +DECLARE_OBJ_CHECKERS(M48txxISAState, M48txxISADeviceClass, + M48TXX_ISA, TYPE_M48TXX_ISA) struct M48txxISAState { ISADevice parent_obj; diff --git a/hw/rtc/m48t59.c b/hw/rtc/m48t59.c index 9f5a96a..6525206 100644 --- a/hw/rtc/m48t59.c +++ b/hw/rtc/m48t59.c @@ -45,12 +45,8 @@ #define TYPE_M48TXX_SYS_BUS "sysbus-m48txx" typedef struct M48txxSysBusDeviceClass M48txxSysBusDeviceClass; typedef struct M48txxSysBusState M48txxSysBusState; -#define M48TXX_SYS_BUS_GET_CLASS(obj) \ - OBJECT_GET_CLASS(M48txxSysBusDeviceClass, (obj), TYPE_M48TXX_SYS_BUS) -#define M48TXX_SYS_BUS_CLASS(klass) \ - OBJECT_CLASS_CHECK(M48txxSysBusDeviceClass, (klass), TYPE_M48TXX_SYS_BUS) -#define M48TXX_SYS_BUS(obj) \ - OBJECT_CHECK(M48txxSysBusState, (obj), TYPE_M48TXX_SYS_BUS) +DECLARE_OBJ_CHECKERS(M48txxSysBusState, M48txxSysBusDeviceClass, + M48TXX_SYS_BUS, TYPE_M48TXX_SYS_BUS) /* * Chipset docs: diff --git a/hw/rtc/sun4v-rtc.c b/hw/rtc/sun4v-rtc.c index b5ebefd..18979d2 100644 --- a/hw/rtc/sun4v-rtc.c +++ b/hw/rtc/sun4v-rtc.c @@ -21,7 +21,8 @@ #define TYPE_SUN4V_RTC "sun4v_rtc" typedef struct Sun4vRtc Sun4vRtc; -#define SUN4V_RTC(obj) OBJECT_CHECK(Sun4vRtc, (obj), TYPE_SUN4V_RTC) +DECLARE_INSTANCE_CHECKER(Sun4vRtc, SUN4V_RTC, + TYPE_SUN4V_RTC) struct Sun4vRtc { SysBusDevice parent_obj; diff --git a/hw/rtc/twl92230.c b/hw/rtc/twl92230.c index d46f214..4f83eff 100644 --- a/hw/rtc/twl92230.c +++ b/hw/rtc/twl92230.c @@ -35,7 +35,8 @@ #define TYPE_TWL92230 "twl92230" typedef struct MenelausState MenelausState; -#define TWL92230(obj) OBJECT_CHECK(MenelausState, (obj), TYPE_TWL92230) +DECLARE_INSTANCE_CHECKER(MenelausState, TWL92230, + TYPE_TWL92230) struct MenelausState { I2CSlave parent_obj; -- cgit v1.1