qom: remove redundant typedef when use OBJECT_DECLARE_SIMPLE_TYPE

When OBJECT_DECLARE_SIMPLE_TYPE is used, it automatically provides
the typedef, so we don’t have to define it ourselves.

Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20251023063429.1400398-1-phind.uet@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
Nguyen Dinh Phi 2025-10-23 14:34:28 +08:00 committed by Philippe Mathieu-Daudé
parent 1a8ffd6172
commit b12c1b3724
23 changed files with 43 additions and 75 deletions

View file

@ -68,7 +68,6 @@ typedef struct CryptoDevBackendLKCFSession {
QCryptoAkCipherOptions akcipher_opts; QCryptoAkCipherOptions akcipher_opts;
} CryptoDevBackendLKCFSession; } CryptoDevBackendLKCFSession;
typedef struct CryptoDevBackendLKCF CryptoDevBackendLKCF;
typedef struct CryptoDevLKCFTask CryptoDevLKCFTask; typedef struct CryptoDevLKCFTask CryptoDevLKCFTask;
struct CryptoDevLKCFTask { struct CryptoDevLKCFTask {
CryptoDevBackendLKCFSession *sess; CryptoDevBackendLKCFSession *sess;

View file

@ -93,7 +93,10 @@
#define ISR_RXRDY(CH) (((CH) & 1) ? BIT(5) : BIT(1)) #define ISR_RXRDY(CH) (((CH) & 1) ? BIT(5) : BIT(1))
#define ISR_BREAK(CH) (((CH) & 1) ? BIT(6) : BIT(2)) #define ISR_BREAK(CH) (((CH) & 1) ? BIT(6) : BIT(2))
typedef struct IPOctalState IPOctalState; #define TYPE_IPOCTAL "ipoctal232"
OBJECT_DECLARE_SIMPLE_TYPE(IPOctalState, IPOCTAL)
typedef struct SCC2698Channel SCC2698Channel; typedef struct SCC2698Channel SCC2698Channel;
typedef struct SCC2698Block SCC2698Block; typedef struct SCC2698Block SCC2698Block;
@ -122,10 +125,6 @@ struct IPOctalState {
uint8_t irq_vector; uint8_t irq_vector;
}; };
#define TYPE_IPOCTAL "ipoctal232"
OBJECT_DECLARE_SIMPLE_TYPE(IPOctalState, IPOCTAL)
static const VMStateDescription vmstate_scc2698_channel = { static const VMStateDescription vmstate_scc2698_channel = {
.name = "scc2698_channel", .name = "scc2698_channel",
.version_id = 1, .version_id = 1,

View file

@ -56,7 +56,6 @@ struct XenConsole {
CharBackend chr; CharBackend chr;
int backlog; int backlog;
}; };
typedef struct XenConsole XenConsole;
#define TYPE_XEN_CONSOLE_DEVICE "xen-console" #define TYPE_XEN_CONSOLE_DEVICE "xen-console"
OBJECT_DECLARE_SIMPLE_TYPE(XenConsole, XEN_CONSOLE_DEVICE) OBJECT_DECLARE_SIMPLE_TYPE(XenConsole, XEN_CONSOLE_DEVICE)

View file

@ -111,7 +111,8 @@ typedef enum {
pl330_chan_fault = 15, pl330_chan_fault = 15,
} PL330ChanState; } PL330ChanState;
typedef struct PL330State PL330State; #define TYPE_PL330 "pl330"
OBJECT_DECLARE_SIMPLE_TYPE(PL330State, PL330)
typedef struct PL330Chan { typedef struct PL330Chan {
uint32_t src; uint32_t src;
@ -274,9 +275,6 @@ struct PL330State {
AddressSpace *mem_as; AddressSpace *mem_as;
}; };
#define TYPE_PL330 "pl330"
OBJECT_DECLARE_SIMPLE_TYPE(PL330State, PL330)
static const VMStateDescription vmstate_pl330 = { static const VMStateDescription vmstate_pl330 = {
.name = "pl330", .name = "pl330",
.version_id = 2, .version_id = 2,

View file

@ -130,7 +130,6 @@ struct eTSEC {
/* Whether we should flush the rx queue when buffer becomes available. */ /* Whether we should flush the rx queue when buffer becomes available. */
bool need_flush; bool need_flush;
}; };
typedef struct eTSEC eTSEC;
#define TYPE_ETSEC_COMMON "eTSEC" #define TYPE_ETSEC_COMMON "eTSEC"
OBJECT_DECLARE_SIMPLE_TYPE(eTSEC, ETSEC_COMMON) OBJECT_DECLARE_SIMPLE_TYPE(eTSEC, ETSEC_COMMON)

View file

@ -62,8 +62,6 @@ struct XenNetDev {
NICState *nic; NICState *nic;
}; };
typedef struct XenNetDev XenNetDev;
#define TYPE_XEN_NET_DEVICE "xen-net-device" #define TYPE_XEN_NET_DEVICE "xen-net-device"
OBJECT_DECLARE_SIMPLE_TYPE(XenNetDev, XEN_NET_DEVICE) OBJECT_DECLARE_SIMPLE_TYPE(XenNetDev, XEN_NET_DEVICE)

View file

@ -230,7 +230,9 @@ struct PCIBonitoState {
MemoryRegion bonito_localio; MemoryRegion bonito_localio;
}; };
typedef struct PCIBonitoState PCIBonitoState;
#define TYPE_PCI_BONITO "Bonito"
OBJECT_DECLARE_SIMPLE_TYPE(PCIBonitoState, PCI_BONITO)
struct BonitoState { struct BonitoState {
PCIHostState parent_obj; PCIHostState parent_obj;
@ -239,9 +241,6 @@ struct BonitoState {
MemoryRegion pci_mem; MemoryRegion pci_mem;
}; };
#define TYPE_PCI_BONITO "Bonito"
OBJECT_DECLARE_SIMPLE_TYPE(PCIBonitoState, PCI_BONITO)
static void bonito_writel(void *opaque, hwaddr addr, static void bonito_writel(void *opaque, hwaddr addr,
uint64_t val, unsigned size) uint64_t val, unsigned size)
{ {

View file

@ -19,7 +19,6 @@
#define TYPE_PEF_GUEST "pef-guest" #define TYPE_PEF_GUEST "pef-guest"
OBJECT_DECLARE_SIMPLE_TYPE(PefGuest, PEF_GUEST) OBJECT_DECLARE_SIMPLE_TYPE(PefGuest, PEF_GUEST)
typedef struct PefGuest PefGuest;
typedef struct PefGuestClass PefGuestClass; typedef struct PefGuestClass PefGuestClass;
struct PefGuestClass { struct PefGuestClass {

View file

@ -123,11 +123,13 @@ typedef struct {
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
typedef struct MTPState MTPState;
typedef struct MTPControl MTPControl; typedef struct MTPControl MTPControl;
typedef struct MTPData MTPData; typedef struct MTPData MTPData;
typedef struct MTPObject MTPObject; typedef struct MTPObject MTPObject;
#define TYPE_USB_MTP "usb-mtp"
OBJECT_DECLARE_SIMPLE_TYPE(MTPState, USB_MTP)
enum { enum {
EP_DATA_IN = 1, EP_DATA_IN = 1,
EP_DATA_OUT, EP_DATA_OUT,
@ -236,9 +238,6 @@ typedef struct {
/* string and other data follows */ /* string and other data follows */
} QEMU_PACKED ObjectInfo; } QEMU_PACKED ObjectInfo;
#define TYPE_USB_MTP "usb-mtp"
OBJECT_DECLARE_SIMPLE_TYPE(MTPState, USB_MTP)
#define QEMU_STORAGE_ID 0x00010001 #define QEMU_STORAGE_ID 0x00010001
#define MTP_FLAG_WRITABLE 0 #define MTP_FLAG_WRITABLE 0

View file

@ -109,10 +109,12 @@ typedef struct {
#define UAS_STREAM_BM_ATTR 4 #define UAS_STREAM_BM_ATTR 4
#define UAS_MAX_STREAMS (1 << UAS_STREAM_BM_ATTR) #define UAS_MAX_STREAMS (1 << UAS_STREAM_BM_ATTR)
typedef struct UASDevice UASDevice;
typedef struct UASRequest UASRequest; typedef struct UASRequest UASRequest;
typedef struct UASStatus UASStatus; typedef struct UASStatus UASStatus;
#define TYPE_USB_UAS "usb-uas"
OBJECT_DECLARE_SIMPLE_TYPE(UASDevice, USB_UAS)
struct UASDevice { struct UASDevice {
USBDevice dev; USBDevice dev;
SCSIBus bus; SCSIBus bus;
@ -133,9 +135,6 @@ struct UASDevice {
USBPacket *status3[UAS_MAX_STREAMS + 1]; USBPacket *status3[UAS_MAX_STREAMS + 1];
}; };
#define TYPE_USB_UAS "usb-uas"
OBJECT_DECLARE_SIMPLE_TYPE(UASDevice, USB_UAS)
struct UASRequest { struct UASRequest {
uint16_t tag; uint16_t tag;
uint64_t lun; uint64_t lun;

View file

@ -77,7 +77,6 @@ struct SerialState {
QEMUTimer *modem_status_poll; QEMUTimer *modem_status_poll;
MemoryRegion io; MemoryRegion io;
}; };
typedef struct SerialState SerialState;
extern const VMStateDescription vmstate_serial; extern const VMStateDescription vmstate_serial;
extern const MemoryRegionOps serial_io_ops; extern const MemoryRegionOps serial_io_ops;

View file

@ -32,7 +32,8 @@ struct LASIPS2PortDeviceClass {
DeviceRealize parent_realize; DeviceRealize parent_realize;
}; };
typedef struct LASIPS2State LASIPS2State; #define TYPE_LASIPS2 "lasips2"
OBJECT_DECLARE_SIMPLE_TYPE(LASIPS2State, LASIPS2)
struct LASIPS2Port { struct LASIPS2Port {
DeviceState parent_obj; DeviceState parent_obj;
@ -74,7 +75,4 @@ struct LASIPS2State {
qemu_irq irq; qemu_irq irq;
}; };
#define TYPE_LASIPS2 "lasips2"
OBJECT_DECLARE_SIMPLE_TYPE(LASIPS2State, LASIPS2)
#endif /* HW_INPUT_LASIPS2_H */ #endif /* HW_INPUT_LASIPS2_H */

View file

@ -29,13 +29,15 @@
#include "hw/qdev-core.h" #include "hw/qdev-core.h"
#include "qom/object.h" #include "qom/object.h"
typedef struct AUXSlave AUXSlave;
typedef enum AUXCommand AUXCommand; typedef enum AUXCommand AUXCommand;
typedef enum AUXReply AUXReply; typedef enum AUXReply AUXReply;
#define TYPE_AUXTOI2C "aux-to-i2c-bridge" #define TYPE_AUXTOI2C "aux-to-i2c-bridge"
OBJECT_DECLARE_SIMPLE_TYPE(AUXTOI2CState, AUXTOI2C) OBJECT_DECLARE_SIMPLE_TYPE(AUXTOI2CState, AUXTOI2C)
#define TYPE_AUX_SLAVE "aux-slave"
OBJECT_DECLARE_SIMPLE_TYPE(AUXSlave, AUX_SLAVE)
enum AUXCommand { enum AUXCommand {
WRITE_I2C = 0, WRITE_I2C = 0,
READ_I2C = 1, READ_I2C = 1,
@ -73,9 +75,6 @@ struct AUXBus {
AddressSpace aux_addr_space; AddressSpace aux_addr_space;
}; };
#define TYPE_AUX_SLAVE "aux-slave"
OBJECT_DECLARE_SIMPLE_TYPE(AUXSlave, AUX_SLAVE)
struct AUXSlave { struct AUXSlave {
/* < private > */ /* < private > */
DeviceState parent_obj; DeviceState parent_obj;

View file

@ -23,7 +23,8 @@
#define MPHI_MMIO_SIZE 0x1000 #define MPHI_MMIO_SIZE 0x1000
typedef struct BCM2835MphiState BCM2835MphiState; #define TYPE_BCM2835_MPHI "bcm2835-mphi"
OBJECT_DECLARE_SIMPLE_TYPE(BCM2835MphiState, BCM2835_MPHI)
struct BCM2835MphiState { struct BCM2835MphiState {
SysBusDevice parent_obj; SysBusDevice parent_obj;
@ -37,8 +38,4 @@ struct BCM2835MphiState {
uint32_t swirq; uint32_t swirq;
}; };
#define TYPE_BCM2835_MPHI "bcm2835-mphi"
OBJECT_DECLARE_SIMPLE_TYPE(BCM2835MphiState, BCM2835_MPHI)
#endif #endif

View file

@ -35,8 +35,8 @@
* value of 100,000 the duty cycle for that PWM is 10%. * value of 100,000 the duty cycle for that PWM is 10%.
*/ */
#define NPCM7XX_PWM_MAX_DUTY 1000000 #define NPCM7XX_PWM_MAX_DUTY 1000000
#define TYPE_NPCM7XX_PWM "npcm7xx-pwm"
typedef struct NPCM7xxPWMState NPCM7xxPWMState; OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxPWMState, NPCM7XX_PWM)
/** /**
* struct NPCM7xxPWM - The state of a single PWM channel. * struct NPCM7xxPWM - The state of a single PWM channel.
@ -100,7 +100,4 @@ struct NPCM7xxPWMState {
uint32_t piir; uint32_t piir;
}; };
#define TYPE_NPCM7XX_PWM "npcm7xx-pwm"
OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxPWMState, NPCM7XX_PWM)
#endif /* NPCM7XX_PWM_H */ #endif /* NPCM7XX_PWM_H */

View file

@ -14,7 +14,8 @@
#include "qom/object.h" #include "qom/object.h"
#include "hw/pci-host/pnv_phb.h" #include "hw/pci-host/pnv_phb.h"
typedef struct PnvPHB3 PnvPHB3; #define TYPE_PNV_PHB3 "pnv-phb3"
OBJECT_DECLARE_SIMPLE_TYPE(PnvPHB3, PNV_PHB3)
/* /*
* PHB3 XICS Source for MSIs * PHB3 XICS Source for MSIs
@ -115,9 +116,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(PnvPHB3RootBus, PNV_PHB3_ROOT_BUS)
/* /*
* PHB3 PCIe Host Bridge for PowerNV machines (POWER8) * PHB3 PCIe Host Bridge for PowerNV machines (POWER8)
*/ */
#define TYPE_PNV_PHB3 "pnv-phb3"
OBJECT_DECLARE_SIMPLE_TYPE(PnvPHB3, PNV_PHB3)
#define PNV_PHB3_NUM_M64 16 #define PNV_PHB3_NUM_M64 16
#define PNV_PHB3_NUM_REGS (0x1000 >> 3) #define PNV_PHB3_NUM_REGS (0x1000 >> 3)
#define PNV_PHB3_NUM_LSI 8 #define PNV_PHB3_NUM_LSI 8

View file

@ -17,8 +17,11 @@
#include "hw/ppc/xive.h" #include "hw/ppc/xive.h"
#include "qom/object.h" #include "qom/object.h"
#define TYPE_PNV_PHB4 "pnv-phb4"
OBJECT_DECLARE_SIMPLE_TYPE(PnvPHB4, PNV_PHB4)
typedef struct PnvPhb4PecStack PnvPhb4PecStack; typedef struct PnvPhb4PecStack PnvPhb4PecStack;
typedef struct PnvPHB4 PnvPHB4;
/* /*
* We have one such address space wrapper per possible device under * We have one such address space wrapper per possible device under
@ -59,9 +62,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(PnvPHB4RootBus, PNV_PHB4_ROOT_BUS)
/* /*
* PHB4 PCIe Host Bridge for PowerNV machines (POWER9) * PHB4 PCIe Host Bridge for PowerNV machines (POWER9)
*/ */
#define TYPE_PNV_PHB4 "pnv-phb4"
OBJECT_DECLARE_SIMPLE_TYPE(PnvPHB4, PNV_PHB4)
#define PNV_PHB4_MAX_LSIs 8 #define PNV_PHB4_MAX_LSIs 8
#define PNV_PHB4_MAX_INTs 4096 #define PNV_PHB4_MAX_INTs 4096
#define PNV_PHB4_MAX_MIST (PNV_PHB4_MAX_INTs >> 2) #define PNV_PHB4_MAX_MIST (PNV_PHB4_MAX_INTs >> 2)

View file

@ -164,7 +164,9 @@ struct DBDMAState {
DBDMA_channel channels[DBDMA_CHANNELS]; DBDMA_channel channels[DBDMA_CHANNELS];
QEMUBH *bh; QEMUBH *bh;
}; };
typedef struct DBDMAState DBDMAState;
#define TYPE_MAC_DBDMA "mac-dbdma"
OBJECT_DECLARE_SIMPLE_TYPE(DBDMAState, MAC_DBDMA)
/* Externally callable functions */ /* Externally callable functions */
@ -173,7 +175,4 @@ void DBDMA_register_channel(void *dbdma, int nchan, qemu_irq irq,
void *opaque); void *opaque);
void DBDMA_kick(DBDMAState *dbdma); void DBDMA_kick(DBDMAState *dbdma);
#define TYPE_MAC_DBDMA "mac-dbdma"
OBJECT_DECLARE_SIMPLE_TYPE(DBDMAState, MAC_DBDMA)
#endif #endif

View file

@ -24,18 +24,15 @@
#define TYPE_RISCV_IOMMU "riscv-iommu" #define TYPE_RISCV_IOMMU "riscv-iommu"
OBJECT_DECLARE_SIMPLE_TYPE(RISCVIOMMUState, RISCV_IOMMU) OBJECT_DECLARE_SIMPLE_TYPE(RISCVIOMMUState, RISCV_IOMMU)
typedef struct RISCVIOMMUState RISCVIOMMUState;
#define TYPE_RISCV_IOMMU_MEMORY_REGION "riscv-iommu-mr" #define TYPE_RISCV_IOMMU_MEMORY_REGION "riscv-iommu-mr"
typedef struct RISCVIOMMUSpace RISCVIOMMUSpace; typedef struct RISCVIOMMUSpace RISCVIOMMUSpace;
#define TYPE_RISCV_IOMMU_PCI "riscv-iommu-pci" #define TYPE_RISCV_IOMMU_PCI "riscv-iommu-pci"
OBJECT_DECLARE_SIMPLE_TYPE(RISCVIOMMUStatePci, RISCV_IOMMU_PCI) OBJECT_DECLARE_SIMPLE_TYPE(RISCVIOMMUStatePci, RISCV_IOMMU_PCI)
typedef struct RISCVIOMMUStatePci RISCVIOMMUStatePci;
#define TYPE_RISCV_IOMMU_SYS "riscv-iommu-device" #define TYPE_RISCV_IOMMU_SYS "riscv-iommu-device"
OBJECT_DECLARE_SIMPLE_TYPE(RISCVIOMMUStateSys, RISCV_IOMMU_SYS) OBJECT_DECLARE_SIMPLE_TYPE(RISCVIOMMUStateSys, RISCV_IOMMU_SYS)
typedef struct RISCVIOMMUStateSys RISCVIOMMUStateSys;
#define FDT_IRQ_TYPE_EDGE_LOW 1 #define FDT_IRQ_TYPE_EDGE_LOW 1

View file

@ -10,7 +10,9 @@
#define MAX_SCSI_DEVS 255 #define MAX_SCSI_DEVS 255
typedef struct SCSIBus SCSIBus; #define TYPE_SCSI_BUS "SCSI"
OBJECT_DECLARE_SIMPLE_TYPE(SCSIBus, SCSI_BUS)
typedef struct SCSIBusInfo SCSIBusInfo; typedef struct SCSIBusInfo SCSIBusInfo;
typedef struct SCSIDevice SCSIDevice; typedef struct SCSIDevice SCSIDevice;
typedef struct SCSIRequest SCSIRequest; typedef struct SCSIRequest SCSIRequest;
@ -151,9 +153,6 @@ struct SCSIBusInfo {
void (*drained_end)(SCSIBus *bus); void (*drained_end)(SCSIBus *bus);
}; };
#define TYPE_SCSI_BUS "SCSI"
OBJECT_DECLARE_SIMPLE_TYPE(SCSIBus, SCSI_BUS)
struct SCSIBus { struct SCSIBus {
BusState qbus; BusState qbus;
int busnr; int busnr;

View file

@ -12,7 +12,8 @@
#include "hw/vfio/vfio-container.h" #include "hw/vfio/vfio-container.h"
#include "hw/vfio/vfio-cpr.h" #include "hw/vfio/vfio-cpr.h"
typedef struct VFIOLegacyContainer VFIOLegacyContainer; OBJECT_DECLARE_SIMPLE_TYPE(VFIOLegacyContainer, VFIO_IOMMU_LEGACY);
typedef struct VFIODevice VFIODevice; typedef struct VFIODevice VFIODevice;
typedef struct VFIOGroup { typedef struct VFIOGroup {
@ -35,6 +36,4 @@ struct VFIOLegacyContainer {
VFIOContainerCPR cpr; VFIOContainerCPR cpr;
}; };
OBJECT_DECLARE_SIMPLE_TYPE(VFIOLegacyContainer, VFIO_IOMMU_LEGACY);
#endif /* HW_VFIO_CONTAINER_LEGACY_H */ #endif /* HW_VFIO_CONTAINER_LEGACY_H */

View file

@ -29,7 +29,8 @@ struct virtio_serial_conf {
OBJECT_DECLARE_TYPE(VirtIOSerialPort, VirtIOSerialPortClass, OBJECT_DECLARE_TYPE(VirtIOSerialPort, VirtIOSerialPortClass,
VIRTIO_SERIAL_PORT) VIRTIO_SERIAL_PORT)
typedef struct VirtIOSerial VirtIOSerial; #define TYPE_VIRTIO_SERIAL "virtio-serial-device"
OBJECT_DECLARE_SIMPLE_TYPE(VirtIOSerial, VIRTIO_SERIAL)
#define TYPE_VIRTIO_SERIAL_BUS "virtio-serial-bus" #define TYPE_VIRTIO_SERIAL_BUS "virtio-serial-bus"
OBJECT_DECLARE_SIMPLE_TYPE(VirtIOSerialBus, VIRTIO_SERIAL_BUS) OBJECT_DECLARE_SIMPLE_TYPE(VirtIOSerialBus, VIRTIO_SERIAL_BUS)
@ -221,7 +222,5 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port);
*/ */
void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle); void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle);
#define TYPE_VIRTIO_SERIAL "virtio-serial-device"
OBJECT_DECLARE_SIMPLE_TYPE(VirtIOSerial, VIRTIO_SERIAL)
#endif #endif

View file

@ -85,7 +85,9 @@ typedef struct qemu_can_filter {
#define QEMU_CAN_INV_FILTER 0x20000000U #define QEMU_CAN_INV_FILTER 0x20000000U
typedef struct CanBusClientState CanBusClientState; typedef struct CanBusClientState CanBusClientState;
typedef struct CanBusState CanBusState;
#define TYPE_CAN_BUS "can-bus"
OBJECT_DECLARE_SIMPLE_TYPE(CanBusState, CAN_BUS)
typedef struct CanBusClientInfo { typedef struct CanBusClientInfo {
bool (*can_receive)(CanBusClientState *); bool (*can_receive)(CanBusClientState *);
@ -105,9 +107,6 @@ struct CanBusClientState {
bool fd_mode; bool fd_mode;
}; };
#define TYPE_CAN_BUS "can-bus"
OBJECT_DECLARE_SIMPLE_TYPE(CanBusState, CAN_BUS)
int can_bus_filter_match(struct qemu_can_filter *filter, qemu_canid_t can_id); int can_bus_filter_match(struct qemu_can_filter *filter, qemu_canid_t can_id);
int can_bus_insert_client(CanBusState *bus, CanBusClientState *client); int can_bus_insert_client(CanBusState *bus, CanBusClientState *client);