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/block/fdc.c | 21 +++++++++++++-------- hw/block/m25p80.c | 11 +++++++---- hw/block/nand.c | 1 + hw/block/onenand.c | 6 ++++-- 4 files changed, 25 insertions(+), 14 deletions(-) (limited to 'hw/block') diff --git a/hw/block/fdc.c b/hw/block/fdc.c index e9ed3ee..70bfb13 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -46,6 +46,7 @@ #include "qemu/main-loop.h" #include "qemu/module.h" #include "trace.h" +#include "qom/object.h" /********************************************************/ /* debug Floppy devices */ @@ -64,16 +65,17 @@ /* qdev floppy bus */ #define TYPE_FLOPPY_BUS "floppy-bus" +typedef struct FloppyBus FloppyBus; #define FLOPPY_BUS(obj) OBJECT_CHECK(FloppyBus, (obj), TYPE_FLOPPY_BUS) typedef struct FDCtrl FDCtrl; typedef struct FDrive FDrive; static FDrive *get_drv(FDCtrl *fdctrl, int unit); -typedef struct FloppyBus { +struct FloppyBus { BusState bus; FDCtrl *fdc; -} FloppyBus; +}; static const TypeInfo floppy_bus_info = { .name = TYPE_FLOPPY_BUS, @@ -494,15 +496,16 @@ static const BlockDevOps fd_block_ops = { #define TYPE_FLOPPY_DRIVE "floppy" +typedef struct FloppyDrive FloppyDrive; #define FLOPPY_DRIVE(obj) \ OBJECT_CHECK(FloppyDrive, (obj), TYPE_FLOPPY_DRIVE) -typedef struct FloppyDrive { +struct FloppyDrive { DeviceState qdev; uint32_t unit; BlockConf conf; FloppyDriveType type; -} FloppyDrive; +}; static Property floppy_drive_properties[] = { DEFINE_PROP_UINT32("unit", FloppyDrive, unit, -1), @@ -886,19 +889,21 @@ static FloppyDriveType get_fallback_drive_type(FDrive *drv) } #define TYPE_SYSBUS_FDC "base-sysbus-fdc" +typedef struct FDCtrlSysBus FDCtrlSysBus; #define SYSBUS_FDC(obj) OBJECT_CHECK(FDCtrlSysBus, (obj), TYPE_SYSBUS_FDC) -typedef struct FDCtrlSysBus { +struct FDCtrlSysBus { /*< private >*/ SysBusDevice parent_obj; /*< public >*/ struct FDCtrl state; -} FDCtrlSysBus; +}; +typedef struct FDCtrlISABus FDCtrlISABus; #define ISA_FDC(obj) OBJECT_CHECK(FDCtrlISABus, (obj), TYPE_ISA_FDC) -typedef struct FDCtrlISABus { +struct FDCtrlISABus { ISADevice parent_obj; uint32_t iobase; @@ -907,7 +912,7 @@ typedef struct FDCtrlISABus { struct FDCtrl state; int32_t bootindexA; int32_t bootindexB; -} FDCtrlISABus; +}; static uint32_t fdctrl_read (void *opaque, uint32_t reg) { diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 1582445..9de4f9b 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -33,6 +33,7 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "trace.h" +#include "qom/object.h" /* Fields for FlashPartInfo->flags */ @@ -414,7 +415,7 @@ typedef enum { #define M25P80_INTERNAL_DATA_BUFFER_SZ 16 -typedef struct Flash { +struct Flash { SSISlave parent_obj; BlockBackend *blk; @@ -454,12 +455,14 @@ typedef struct Flash { const FlashPartInfo *pi; -} Flash; +}; +typedef struct Flash Flash; -typedef struct M25P80Class { +struct M25P80Class { SSISlaveClass parent_class; FlashPartInfo *pi; -} M25P80Class; +}; +typedef struct M25P80Class M25P80Class; #define TYPE_M25P80 "m25p80-generic" #define M25P80(obj) \ diff --git a/hw/block/nand.c b/hw/block/nand.c index 654e0cb..7c7a08b 100644 --- a/hw/block/nand.c +++ b/hw/block/nand.c @@ -27,6 +27,7 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/module.h" +#include "qom/object.h" # define NAND_CMD_READ0 0x00 # define NAND_CMD_READ1 0x01 diff --git a/hw/block/onenand.c b/hw/block/onenand.c index 898ac56..5fe235d 100644 --- a/hw/block/onenand.c +++ b/hw/block/onenand.c @@ -31,6 +31,7 @@ #include "qemu/error-report.h" #include "qemu/log.h" #include "qemu/module.h" +#include "qom/object.h" /* 11 for 2kB-page OneNAND ("2nd generation") and 10 for 1kB-page chips */ #define PAGE_SHIFT 11 @@ -39,9 +40,10 @@ #define BLOCK_SHIFT (PAGE_SHIFT + 6) #define TYPE_ONE_NAND "onenand" +typedef struct OneNANDState OneNANDState; #define ONE_NAND(obj) OBJECT_CHECK(OneNANDState, (obj), TYPE_ONE_NAND) -typedef struct OneNANDState { +struct OneNANDState { SysBusDevice parent_obj; struct { @@ -85,7 +87,7 @@ typedef struct OneNANDState { int secs_cur; int blocks; uint8_t *blockwp; -} OneNANDState; +}; enum { ONEN_BUF_BLOCK = 0, -- 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/block/fdc.c | 13 ++++++++----- hw/block/m25p80.c | 8 ++------ hw/block/nand.c | 4 ++-- hw/block/onenand.c | 3 ++- 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'hw/block') diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 70bfb13..224bac5 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -66,7 +66,8 @@ #define TYPE_FLOPPY_BUS "floppy-bus" typedef struct FloppyBus FloppyBus; -#define FLOPPY_BUS(obj) OBJECT_CHECK(FloppyBus, (obj), TYPE_FLOPPY_BUS) +DECLARE_INSTANCE_CHECKER(FloppyBus, FLOPPY_BUS, + TYPE_FLOPPY_BUS) typedef struct FDCtrl FDCtrl; typedef struct FDrive FDrive; @@ -497,8 +498,8 @@ static const BlockDevOps fd_block_ops = { #define TYPE_FLOPPY_DRIVE "floppy" typedef struct FloppyDrive FloppyDrive; -#define FLOPPY_DRIVE(obj) \ - OBJECT_CHECK(FloppyDrive, (obj), TYPE_FLOPPY_DRIVE) +DECLARE_INSTANCE_CHECKER(FloppyDrive, FLOPPY_DRIVE, + TYPE_FLOPPY_DRIVE) struct FloppyDrive { DeviceState qdev; @@ -890,7 +891,8 @@ static FloppyDriveType get_fallback_drive_type(FDrive *drv) #define TYPE_SYSBUS_FDC "base-sysbus-fdc" typedef struct FDCtrlSysBus FDCtrlSysBus; -#define SYSBUS_FDC(obj) OBJECT_CHECK(FDCtrlSysBus, (obj), TYPE_SYSBUS_FDC) +DECLARE_INSTANCE_CHECKER(FDCtrlSysBus, SYSBUS_FDC, + TYPE_SYSBUS_FDC) struct FDCtrlSysBus { /*< private >*/ @@ -901,7 +903,8 @@ struct FDCtrlSysBus { }; typedef struct FDCtrlISABus FDCtrlISABus; -#define ISA_FDC(obj) OBJECT_CHECK(FDCtrlISABus, (obj), TYPE_ISA_FDC) +DECLARE_INSTANCE_CHECKER(FDCtrlISABus, ISA_FDC, + TYPE_ISA_FDC) struct FDCtrlISABus { ISADevice parent_obj; diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 9de4f9b..8dae779 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -465,12 +465,8 @@ struct M25P80Class { typedef struct M25P80Class M25P80Class; #define TYPE_M25P80 "m25p80-generic" -#define M25P80(obj) \ - OBJECT_CHECK(Flash, (obj), TYPE_M25P80) -#define M25P80_CLASS(klass) \ - OBJECT_CLASS_CHECK(M25P80Class, (klass), TYPE_M25P80) -#define M25P80_GET_CLASS(obj) \ - OBJECT_GET_CLASS(M25P80Class, (obj), TYPE_M25P80) +DECLARE_OBJ_CHECKERS(Flash, M25P80Class, + M25P80, TYPE_M25P80) static inline Manufacturer get_man(Flash *s) { diff --git a/hw/block/nand.c b/hw/block/nand.c index 7c7a08b..5c8112e 100644 --- a/hw/block/nand.c +++ b/hw/block/nand.c @@ -90,8 +90,8 @@ struct NANDFlashState { #define TYPE_NAND "nand" -#define NAND(obj) \ - OBJECT_CHECK(NANDFlashState, (obj), TYPE_NAND) +DECLARE_INSTANCE_CHECKER(NANDFlashState, NAND, + TYPE_NAND) static void mem_and(uint8_t *dest, const uint8_t *src, size_t n) { diff --git a/hw/block/onenand.c b/hw/block/onenand.c index 5fe235d..19f55ab 100644 --- a/hw/block/onenand.c +++ b/hw/block/onenand.c @@ -41,7 +41,8 @@ #define TYPE_ONE_NAND "onenand" typedef struct OneNANDState OneNANDState; -#define ONE_NAND(obj) OBJECT_CHECK(OneNANDState, (obj), TYPE_ONE_NAND) +DECLARE_INSTANCE_CHECKER(OneNANDState, ONE_NAND, + TYPE_ONE_NAND) struct OneNANDState { SysBusDevice parent_obj; -- cgit v1.1