aboutsummaryrefslogtreecommitdiff
path: root/hw/usb
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-09-11 19:26:51 +0100
committerPeter Maydell <peter.maydell@linaro.org>2020-09-11 19:26:51 +0100
commitf4ef8c9cc10b3bee829b9775879d4ff9f77c2442 (patch)
tree8245341c3ebfe98b9673bf7a8cb818b6d494c76f /hw/usb
parent2499453eb1cbb68a45d7562a180afd7659007fd4 (diff)
parentb84bf23c88699098973de3bdec316c796f1b3794 (diff)
downloadqemu-f4ef8c9cc10b3bee829b9775879d4ff9f77c2442.zip
qemu-f4ef8c9cc10b3bee829b9775879d4ff9f77c2442.tar.gz
qemu-f4ef8c9cc10b3bee829b9775879d4ff9f77c2442.tar.bz2
Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging
QOM boilerplate cleanup Documentation build fix: * memory: Remove kernel-doc comment marker (Eduardo Habkost) QOM cleanups: * Rename QOM macros for consistency between TYPE_* and type checking constants (Eduardo Habkost) QOM new macros: * OBJECT_DECLARE_* and OBJECT_DEFINE_* macros (Daniel P. Berrangé) * DECLARE_*_CHECKER macros (Eduardo Habkost) Automated QOM boilerplate changes: * Automated changes to use DECLARE_*_CHECKER (Eduardo Habkost * Automated changes to use OBJECT_DECLARE* (Eduardo Habkost) # gpg: Signature made Thu 10 Sep 2020 19:17:49 BST # gpg: using RSA key 5A322FD5ABC4D3DBACCFD1AA2807936F984DC5A6 # gpg: issuer "ehabkost@redhat.com" # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" [full] # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6 * remotes/ehabkost/tags/machine-next-pull-request: (33 commits) virtio-vga: Use typedef name for instance_size vhost-user-vga: Use typedef name for instance_size xilinx_axienet: Use typedef name for instance_size lpc_ich9: Use typedef name for instance_size omap_intc: Use typedef name for instance_size xilinx_axidma: Use typedef name for instance_size tusb6010: Rename TUSB to TUSB6010 pc87312: Rename TYPE_PC87312_SUPERIO to TYPE_PC87312 vfio: Rename PCI_VFIO to VFIO_PCI usb: Rename USB_SERIAL_DEV to USB_SERIAL sabre: Rename SABRE_DEVICE to SABRE rs6000_mc: Rename RS6000MC_DEVICE to RS6000MC filter-rewriter: Rename FILTER_COLO_REWRITER to FILTER_REWRITER esp: Rename ESP_STATE to ESP ahci: Rename ICH_AHCI to ICH9_AHCI vmgenid: Rename VMGENID_DEVICE to TYPE_VMGENID vfio: Rename VFIO_AP_DEVICE_TYPE to TYPE_VFIO_AP_DEVICE dev-smartcard-reader: Rename CCID_DEV_NAME to TYPE_USB_CCID_DEV ap-device: Rename AP_DEVICE_TYPE to TYPE_AP_DEVICE gpex: Fix type checking function name ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/usb')
-rw-r--r--hw/usb/ccid-card-emulated.c7
-rw-r--r--hw/usb/ccid-card-passthru.c5
-rw-r--r--hw/usb/ccid.h14
-rw-r--r--hw/usb/dev-audio.c9
-rw-r--r--hw/usb/dev-hid.c9
-rw-r--r--hw/usb/dev-hub.c9
-rw-r--r--hw/usb/dev-mtp.c4
-rw-r--r--hw/usb/dev-network.c9
-rw-r--r--hw/usb/dev-serial.c11
-rw-r--r--hw/usb/dev-smartcard-reader.c23
-rw-r--r--hw/usb/dev-storage.c9
-rw-r--r--hw/usb/dev-uas.c4
-rw-r--r--hw/usb/dev-wacom.c9
-rw-r--r--hw/usb/hcd-dwc2.h9
-rw-r--r--hw/usb/hcd-ehci.h36
-rw-r--r--hw/usb/hcd-ohci-pci.c9
-rw-r--r--hw/usb/hcd-ohci.h9
-rw-r--r--hw/usb/hcd-uhci.c4
-rw-r--r--hw/usb/hcd-xhci.h7
-rw-r--r--hw/usb/host-libusb.c7
-rw-r--r--hw/usb/redirect.c4
-rw-r--r--hw/usb/tusb6010.c13
22 files changed, 132 insertions, 88 deletions
diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
index 0f1afd6..5e4649d 100644
--- a/hw/usb/ccid-card-emulated.c
+++ b/hw/usb/ccid-card-emulated.c
@@ -35,6 +35,7 @@
#include "ccid.h"
#include "hw/qdev-properties.h"
#include "qapi/error.h"
+#include "qom/object.h"
#define DPRINTF(card, lvl, fmt, ...) \
do {\
@@ -45,8 +46,9 @@ do {\
#define TYPE_EMULATED_CCID "ccid-card-emulated"
-#define EMULATED_CCID_CARD(obj) \
- OBJECT_CHECK(EmulatedState, (obj), TYPE_EMULATED_CCID)
+typedef struct EmulatedState EmulatedState;
+DECLARE_INSTANCE_CHECKER(EmulatedState, EMULATED_CCID_CARD,
+ TYPE_EMULATED_CCID)
#define BACKEND_NSS_EMULATED_NAME "nss-emulated"
#define BACKEND_CERTIFICATES_NAME "certificates"
@@ -58,7 +60,6 @@ enum {
#define DEFAULT_BACKEND BACKEND_NSS_EMULATED
-typedef struct EmulatedState EmulatedState;
enum {
EMUL_READER_INSERT = 0,
diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index bb325db..e8e9d37 100644
--- a/hw/usb/ccid-card-passthru.c
+++ b/hw/usb/ccid-card-passthru.c
@@ -20,6 +20,7 @@
#include "qemu/sockets.h"
#include "ccid.h"
#include "qapi/error.h"
+#include "qom/object.h"
#define DPRINTF(card, lvl, fmt, ...) \
do { \
@@ -64,8 +65,8 @@ struct PassthruState {
};
#define TYPE_CCID_PASSTHRU "ccid-card-passthru"
-#define PASSTHRU_CCID_CARD(obj) \
- OBJECT_CHECK(PassthruState, (obj), TYPE_CCID_PASSTHRU)
+DECLARE_INSTANCE_CHECKER(PassthruState, PASSTHRU_CCID_CARD,
+ TYPE_CCID_PASSTHRU)
/*
* VSCard protocol over chardev
diff --git a/hw/usb/ccid.h b/hw/usb/ccid.h
index 531bf28..ef2bb34 100644
--- a/hw/usb/ccid.h
+++ b/hw/usb/ccid.h
@@ -11,23 +11,21 @@
#define CCID_H
#include "hw/qdev-core.h"
+#include "qom/object.h"
typedef struct CCIDCardState CCIDCardState;
typedef struct CCIDCardInfo CCIDCardInfo;
#define TYPE_CCID_CARD "ccid-card"
-#define CCID_CARD(obj) \
- OBJECT_CHECK(CCIDCardState, (obj), TYPE_CCID_CARD)
-#define CCID_CARD_CLASS(klass) \
- OBJECT_CLASS_CHECK(CCIDCardClass, (klass), TYPE_CCID_CARD)
-#define CCID_CARD_GET_CLASS(obj) \
- OBJECT_GET_CLASS(CCIDCardClass, (obj), TYPE_CCID_CARD)
+typedef struct CCIDCardClass CCIDCardClass;
+DECLARE_OBJ_CHECKERS(CCIDCardState, CCIDCardClass,
+ CCID_CARD, TYPE_CCID_CARD)
/*
* callbacks to be used by the CCID device (hw/usb-ccid.c) to call
* into the smartcard device (hw/ccid-card-*.c)
*/
-typedef struct CCIDCardClass {
+struct CCIDCardClass {
/*< private >*/
DeviceClass parent_class;
/*< public >*/
@@ -37,7 +35,7 @@ typedef struct CCIDCardClass {
uint32_t len);
void (*realize)(CCIDCardState *card, Error **errp);
void (*unrealize)(CCIDCardState *card);
-} CCIDCardClass;
+};
/*
* state of the CCID Card device (i.e. hw/ccid-card-*.c)
diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c
index 1371c44..65247ca 100644
--- a/hw/usb/dev-audio.c
+++ b/hw/usb/dev-audio.c
@@ -36,6 +36,7 @@
#include "migration/vmstate.h"
#include "desc.h"
#include "audio/audio.h"
+#include "qom/object.h"
static void usb_audio_reinit(USBDevice *dev, unsigned channels);
@@ -633,7 +634,7 @@ static uint8_t *streambuf_get(struct streambuf *buf, size_t *len)
return data;
}
-typedef struct USBAudioState {
+struct USBAudioState {
/* qemu interfaces */
USBDevice dev;
QEMUSoundCard card;
@@ -652,10 +653,12 @@ typedef struct USBAudioState {
uint32_t debug;
uint32_t buffer_user, buffer;
bool multi;
-} USBAudioState;
+};
+typedef struct USBAudioState USBAudioState;
#define TYPE_USB_AUDIO "usb-audio"
-#define USB_AUDIO(obj) OBJECT_CHECK(USBAudioState, (obj), TYPE_USB_AUDIO)
+DECLARE_INSTANCE_CHECKER(USBAudioState, USB_AUDIO,
+ TYPE_USB_AUDIO)
static void output_callback(void *opaque, int avail)
{
diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c
index c73f7b2..05cfe6b 100644
--- a/hw/usb/dev-hid.c
+++ b/hw/usb/dev-hid.c
@@ -34,18 +34,21 @@
#include "hw/input/hid.h"
#include "hw/usb/hid.h"
#include "hw/qdev-properties.h"
+#include "qom/object.h"
-typedef struct USBHIDState {
+struct USBHIDState {
USBDevice dev;
USBEndpoint *intr;
HIDState hid;
uint32_t usb_version;
char *display;
uint32_t head;
-} USBHIDState;
+};
+typedef struct USBHIDState USBHIDState;
#define TYPE_USB_HID "usb-hid"
-#define USB_HID(obj) OBJECT_CHECK(USBHIDState, (obj), TYPE_USB_HID)
+DECLARE_INSTANCE_CHECKER(USBHIDState, USB_HID,
+ TYPE_USB_HID)
enum {
STR_MANUFACTURER = 1,
diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c
index 5f19dd9..7a182f9 100644
--- a/hw/usb/dev-hub.c
+++ b/hw/usb/dev-hub.c
@@ -32,6 +32,7 @@
#include "desc.h"
#include "qemu/error-report.h"
#include "qemu/module.h"
+#include "qom/object.h"
#define MAX_PORTS 8
@@ -41,17 +42,19 @@ typedef struct USBHubPort {
uint16_t wPortChange;
} USBHubPort;
-typedef struct USBHubState {
+struct USBHubState {
USBDevice dev;
USBEndpoint *intr;
uint32_t num_ports;
bool port_power;
QEMUTimer *port_timer;
USBHubPort ports[MAX_PORTS];
-} USBHubState;
+};
+typedef struct USBHubState USBHubState;
#define TYPE_USB_HUB "usb-hub"
-#define USB_HUB(obj) OBJECT_CHECK(USBHubState, (obj), TYPE_USB_HUB)
+DECLARE_INSTANCE_CHECKER(USBHubState, USB_HUB,
+ TYPE_USB_HUB)
#define ClearHubFeature (0x2000 | USB_REQ_CLEAR_FEATURE)
#define ClearPortFeature (0x2300 | USB_REQ_CLEAR_FEATURE)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 15a2243..c61c0e0 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -28,6 +28,7 @@
#include "migration/vmstate.h"
#include "desc.h"
#include "qemu/units.h"
+#include "qom/object.h"
/* ----------------------------------------------------------------------- */
@@ -237,7 +238,8 @@ typedef struct {
} QEMU_PACKED ObjectInfo;
#define TYPE_USB_MTP "usb-mtp"
-#define USB_MTP(obj) OBJECT_CHECK(MTPState, (obj), TYPE_USB_MTP)
+DECLARE_INSTANCE_CHECKER(MTPState, USB_MTP,
+ TYPE_USB_MTP)
#define QEMU_STORAGE_ID 0x00010001
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index c697567..cd32f57 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -37,6 +37,7 @@
#include "qemu/iov.h"
#include "qemu/module.h"
#include "qemu/cutils.h"
+#include "qom/object.h"
/*#define TRAFFIC_DEBUG*/
/* Thanks to NetChip Technologies for donating this product ID.
@@ -629,7 +630,7 @@ struct rndis_response {
uint8_t buf[];
};
-typedef struct USBNetState {
+struct USBNetState {
USBDevice dev;
enum rndis_state rndis_state;
@@ -651,10 +652,12 @@ typedef struct USBNetState {
NICState *nic;
NICConf conf;
QTAILQ_HEAD(, rndis_response) rndis_resp;
-} USBNetState;
+};
+typedef struct USBNetState USBNetState;
#define TYPE_USB_NET "usb-net"
-#define USB_NET(obj) OBJECT_CHECK(USBNetState, (obj), TYPE_USB_NET)
+DECLARE_INSTANCE_CHECKER(USBNetState, USB_NET,
+ TYPE_USB_NET)
static int is_rndis(USBNetState *s)
{
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index 7e50e3b..1a038a2 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -19,6 +19,7 @@
#include "desc.h"
#include "chardev/char-serial.h"
#include "chardev/char-fe.h"
+#include "qom/object.h"
//#define DEBUG_Serial
@@ -96,7 +97,7 @@ do { printf("usb-serial: " fmt , ## __VA_ARGS__); } while (0)
#define FTDI_TEMT (1<<6) // Transmitter Empty
#define FTDI_FIFO (1<<7) // Error in FIFO
-typedef struct {
+struct USBSerialState {
USBDevice dev;
USBEndpoint *intr;
uint8_t recv_buf[RECV_BUF];
@@ -108,10 +109,12 @@ typedef struct {
QEMUSerialSetParams params;
int latency; /* ms */
CharBackend cs;
-} USBSerialState;
+};
+typedef struct USBSerialState USBSerialState;
#define TYPE_USB_SERIAL "usb-serial-dev"
-#define USB_SERIAL_DEV(obj) OBJECT_CHECK(USBSerialState, (obj), TYPE_USB_SERIAL)
+DECLARE_INSTANCE_CHECKER(USBSerialState, USB_SERIAL,
+ TYPE_USB_SERIAL)
enum {
STR_MANUFACTURER = 1,
@@ -514,7 +517,7 @@ static void usb_serial_event(void *opaque, QEMUChrEvent event)
static void usb_serial_realize(USBDevice *dev, Error **errp)
{
- USBSerialState *s = USB_SERIAL_DEV(dev);
+ USBSerialState *s = USB_SERIAL(dev);
Error *local_err = NULL;
usb_desc_create_serial(dev);
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index fcfe216..59b2248 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -46,6 +46,7 @@
#include "desc.h"
#include "ccid.h"
+#include "qom/object.h"
#define DPRINTF(s, lvl, fmt, ...) \
do { \
@@ -59,8 +60,10 @@ do { \
#define D_MORE_INFO 3
#define D_VERBOSE 4
-#define CCID_DEV_NAME "usb-ccid"
-#define USB_CCID_DEV(obj) OBJECT_CHECK(USBCCIDState, (obj), CCID_DEV_NAME)
+#define TYPE_USB_CCID_DEV "usb-ccid"
+typedef struct USBCCIDState USBCCIDState;
+DECLARE_INSTANCE_CHECKER(USBCCIDState, USB_CCID_DEV,
+ TYPE_USB_CCID_DEV)
/*
* The two options for variable sized buffers:
* make them constant size, for large enough constant,
@@ -274,14 +277,15 @@ typedef struct BulkIn {
uint32_t pos;
} BulkIn;
-typedef struct CCIDBus {
+struct CCIDBus {
BusState qbus;
-} CCIDBus;
+};
+typedef struct CCIDBus CCIDBus;
/*
* powered - defaults to true, changed by PowerOn/PowerOff messages
*/
-typedef struct USBCCIDState {
+struct USBCCIDState {
USBDevice dev;
USBEndpoint *intr;
USBEndpoint *bulk;
@@ -309,7 +313,7 @@ typedef struct USBCCIDState {
uint8_t powered;
uint8_t notify_slot_change;
uint8_t debug;
-} USBCCIDState;
+};
/*
* CCID Spec chapter 4: CCID uses a standard device descriptor per Chapter 9,
@@ -1173,7 +1177,8 @@ static Property ccid_props[] = {
};
#define TYPE_CCID_BUS "ccid-bus"
-#define CCID_BUS(obj) OBJECT_CHECK(CCIDBus, (obj), TYPE_CCID_BUS)
+DECLARE_INSTANCE_CHECKER(CCIDBus, CCID_BUS,
+ TYPE_CCID_BUS)
static const TypeInfo ccid_bus_info = {
.name = TYPE_CCID_BUS,
@@ -1457,7 +1462,7 @@ static void ccid_class_initfn(ObjectClass *klass, void *data)
}
static const TypeInfo ccid_info = {
- .name = CCID_DEV_NAME,
+ .name = TYPE_USB_CCID_DEV,
.parent = TYPE_USB_DEVICE,
.instance_size = sizeof(USBCCIDState),
.class_init = ccid_class_initfn,
@@ -1490,7 +1495,7 @@ static void ccid_register_types(void)
type_register_static(&ccid_bus_info);
type_register_static(&ccid_card_type_info);
type_register_static(&ccid_info);
- usb_legacy_register(CCID_DEV_NAME, "ccid", NULL);
+ usb_legacy_register(TYPE_USB_CCID_DEV, "ccid", NULL);
}
type_init(ccid_register_types)
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index 405a4cc..6483403 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -22,6 +22,7 @@
#include "sysemu/block-backend.h"
#include "qapi/visitor.h"
#include "qemu/cutils.h"
+#include "qom/object.h"
//#define DEBUG_MSD
@@ -50,7 +51,7 @@ struct usb_msd_csw {
uint8_t status;
};
-typedef struct {
+struct MSDState {
USBDevice dev;
enum USBMSDMode mode;
uint32_t scsi_off;
@@ -65,10 +66,12 @@ typedef struct {
BlockConf conf;
uint32_t removable;
SCSIDevice *scsi_dev;
-} MSDState;
+};
+typedef struct MSDState MSDState;
#define TYPE_USB_STORAGE "usb-storage-dev"
-#define USB_STORAGE_DEV(obj) OBJECT_CHECK(MSDState, (obj), TYPE_USB_STORAGE)
+DECLARE_INSTANCE_CHECKER(MSDState, USB_STORAGE_DEV,
+ TYPE_USB_STORAGE)
struct usb_msd_cbw {
uint32_t sig;
diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c
index a3a4d41..c36c8e7 100644
--- a/hw/usb/dev-uas.c
+++ b/hw/usb/dev-uas.c
@@ -23,6 +23,7 @@
#include "hw/qdev-properties.h"
#include "hw/scsi/scsi.h"
#include "scsi/constants.h"
+#include "qom/object.h"
/* --------------------------------------------------------------------- */
@@ -132,7 +133,8 @@ struct UASDevice {
};
#define TYPE_USB_UAS "usb-uas"
-#define USB_UAS(obj) OBJECT_CHECK(UASDevice, (obj), TYPE_USB_UAS)
+DECLARE_INSTANCE_CHECKER(UASDevice, USB_UAS,
+ TYPE_USB_UAS)
struct UASRequest {
uint16_t tag;
diff --git a/hw/usb/dev-wacom.c b/hw/usb/dev-wacom.c
index 76fc5a5..85c4d82 100644
--- a/hw/usb/dev-wacom.c
+++ b/hw/usb/dev-wacom.c
@@ -33,12 +33,13 @@
#include "migration/vmstate.h"
#include "qemu/module.h"
#include "desc.h"
+#include "qom/object.h"
/* Interface requests */
#define WACOM_GET_REPORT 0x2101
#define WACOM_SET_REPORT 0x2109
-typedef struct USBWacomState {
+struct USBWacomState {
USBDevice dev;
USBEndpoint *intr;
QEMUPutMouseEntry *eh_entry;
@@ -51,10 +52,12 @@ typedef struct USBWacomState {
} mode;
uint8_t idle;
int changed;
-} USBWacomState;
+};
+typedef struct USBWacomState USBWacomState;
#define TYPE_USB_WACOM "usb-wacom-tablet"
-#define USB_WACOM(obj) OBJECT_CHECK(USBWacomState, (obj), TYPE_USB_WACOM)
+DECLARE_INSTANCE_CHECKER(USBWacomState, USB_WACOM,
+ TYPE_USB_WACOM)
enum {
STR_MANUFACTURER = 1,
diff --git a/hw/usb/hcd-dwc2.h b/hw/usb/hcd-dwc2.h
index 54111d8..919e3e4 100644
--- a/hw/usb/hcd-dwc2.h
+++ b/hw/usb/hcd-dwc2.h
@@ -24,6 +24,7 @@
#include "hw/sysbus.h"
#include "hw/usb.h"
#include "sysemu/dma.h"
+#include "qom/object.h"
#define DWC2_MMIO_SIZE 0x11000
@@ -180,11 +181,7 @@ struct DWC2Class {
};
#define TYPE_DWC2_USB "dwc2-usb"
-#define DWC2_USB(obj) \
- OBJECT_CHECK(DWC2State, (obj), TYPE_DWC2_USB)
-#define DWC2_USB_CLASS(klass) \
- OBJECT_CLASS_CHECK(DWC2Class, (klass), TYPE_DWC2_USB)
-#define DWC2_USB_GET_CLASS(obj) \
- OBJECT_GET_CLASS(DWC2Class, (obj), TYPE_DWC2_USB)
+DECLARE_OBJ_CHECKERS(DWC2State, DWC2Class,
+ DWC2_USB, TYPE_DWC2_USB)
#endif
diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index 57b38cf..1301ce0 100644
--- a/hw/usb/hcd-ehci.h
+++ b/hw/usb/hcd-ehci.h
@@ -23,6 +23,7 @@
#include "sysemu/dma.h"
#include "hw/pci/pci.h"
#include "hw/sysbus.h"
+#include "qom/object.h"
#ifndef EHCI_DEBUG
#define EHCI_DEBUG 0
@@ -328,15 +329,17 @@ void usb_ehci_unrealize(EHCIState *s, DeviceState *dev);
void ehci_reset(void *opaque);
#define TYPE_PCI_EHCI "pci-ehci-usb"
-#define PCI_EHCI(obj) OBJECT_CHECK(EHCIPCIState, (obj), TYPE_PCI_EHCI)
+typedef struct EHCIPCIState EHCIPCIState;
+DECLARE_INSTANCE_CHECKER(EHCIPCIState, PCI_EHCI,
+ TYPE_PCI_EHCI)
-typedef struct EHCIPCIState {
+struct EHCIPCIState {
/*< private >*/
PCIDevice pcidev;
/*< public >*/
EHCIState ehci;
-} EHCIPCIState;
+};
#define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb"
@@ -347,22 +350,20 @@ typedef struct EHCIPCIState {
#define TYPE_PPC4xx_EHCI "ppc4xx-ehci-usb"
#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb"
-#define SYS_BUS_EHCI(obj) \
- OBJECT_CHECK(EHCISysBusState, (obj), TYPE_SYS_BUS_EHCI)
-#define SYS_BUS_EHCI_CLASS(class) \
- OBJECT_CLASS_CHECK(SysBusEHCIClass, (class), TYPE_SYS_BUS_EHCI)
-#define SYS_BUS_EHCI_GET_CLASS(obj) \
- OBJECT_GET_CLASS(SysBusEHCIClass, (obj), TYPE_SYS_BUS_EHCI)
+typedef struct EHCISysBusState EHCISysBusState;
+typedef struct SysBusEHCIClass SysBusEHCIClass;
+DECLARE_OBJ_CHECKERS(EHCISysBusState, SysBusEHCIClass,
+ SYS_BUS_EHCI, TYPE_SYS_BUS_EHCI)
-typedef struct EHCISysBusState {
+struct EHCISysBusState {
/*< private >*/
SysBusDevice parent_obj;
/*< public >*/
EHCIState ehci;
-} EHCISysBusState;
+};
-typedef struct SysBusEHCIClass {
+struct SysBusEHCIClass {
/*< private >*/
SysBusDeviceClass parent_class;
/*< public >*/
@@ -371,17 +372,18 @@ typedef struct SysBusEHCIClass {
uint16_t opregbase;
uint16_t portscbase;
uint16_t portnr;
-} SysBusEHCIClass;
+};
-#define FUSBH200_EHCI(obj) \
- OBJECT_CHECK(FUSBH200EHCIState, (obj), TYPE_FUSBH200_EHCI)
+typedef struct FUSBH200EHCIState FUSBH200EHCIState;
+DECLARE_INSTANCE_CHECKER(FUSBH200EHCIState, FUSBH200_EHCI,
+ TYPE_FUSBH200_EHCI)
-typedef struct FUSBH200EHCIState {
+struct FUSBH200EHCIState {
/*< private >*/
EHCISysBusState parent_obj;
/*< public >*/
MemoryRegion mem_vendor;
-} FUSBH200EHCIState;
+};
#endif
diff --git a/hw/usb/hcd-ohci-pci.c b/hw/usb/hcd-ohci-pci.c
index a7fb166..f8168a0 100644
--- a/hw/usb/hcd-ohci-pci.c
+++ b/hw/usb/hcd-ohci-pci.c
@@ -29,11 +29,14 @@
#include "hw/qdev-properties.h"
#include "trace.h"
#include "hcd-ohci.h"
+#include "qom/object.h"
#define TYPE_PCI_OHCI "pci-ohci"
-#define PCI_OHCI(obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI)
+typedef struct OHCIPCIState OHCIPCIState;
+DECLARE_INSTANCE_CHECKER(OHCIPCIState, PCI_OHCI,
+ TYPE_PCI_OHCI)
-typedef struct {
+struct OHCIPCIState {
/*< private >*/
PCIDevice parent_obj;
/*< public >*/
@@ -42,7 +45,7 @@ typedef struct {
char *masterbus;
uint32_t num_ports;
uint32_t firstport;
-} OHCIPCIState;
+};
/**
* A typical PCI OHCI will additionally set PERR in its configspace to
diff --git a/hw/usb/hcd-ohci.h b/hw/usb/hcd-ohci.h
index 5c8819a..6e28e97 100644
--- a/hw/usb/hcd-ohci.h
+++ b/hw/usb/hcd-ohci.h
@@ -23,6 +23,7 @@
#include "sysemu/dma.h"
#include "hw/usb.h"
+#include "qom/object.h"
/* Number of Downstream Ports on the root hub: */
#define OHCI_MAX_PORTS 15
@@ -92,9 +93,11 @@ typedef struct OHCIState {
} OHCIState;
#define TYPE_SYSBUS_OHCI "sysbus-ohci"
-#define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj), TYPE_SYSBUS_OHCI)
+typedef struct OHCISysBusState OHCISysBusState;
+DECLARE_INSTANCE_CHECKER(OHCISysBusState, SYSBUS_OHCI,
+ TYPE_SYSBUS_OHCI)
-typedef struct {
+struct OHCISysBusState {
/*< private >*/
SysBusDevice parent_obj;
/*< public >*/
@@ -104,7 +107,7 @@ typedef struct {
uint32_t num_ports;
uint32_t firstport;
dma_addr_t dma_offset;
-} OHCISysBusState;
+};
extern const VMStateDescription vmstate_ohci_state;
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 37f7beb..27ca237 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -39,6 +39,7 @@
#include "trace.h"
#include "qemu/main-loop.h"
#include "qemu/module.h"
+#include "qom/object.h"
#define FRAME_TIMER_FREQ 1000
@@ -160,7 +161,8 @@ static void uhci_queue_fill(UHCIQueue *q, UHCI_TD *td);
static void uhci_resume(void *opaque);
#define TYPE_UHCI "pci-uhci-usb"
-#define UHCI(obj) OBJECT_CHECK(UHCIState, (obj), TYPE_UHCI)
+DECLARE_INSTANCE_CHECKER(UHCIState, UHCI,
+ TYPE_UHCI)
static inline int32_t uhci_queue_token(UHCI_TD *td)
{
diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
index 946af51..2110c03 100644
--- a/hw/usb/hcd-xhci.h
+++ b/hw/usb/hcd-xhci.h
@@ -21,13 +21,15 @@
#ifndef HW_USB_HCD_XHCI_H
#define HW_USB_HCD_XHCI_H
+#include "qom/object.h"
#define TYPE_XHCI "base-xhci"
#define TYPE_NEC_XHCI "nec-usb-xhci"
#define TYPE_QEMU_XHCI "qemu-xhci"
-#define XHCI(obj) \
- OBJECT_CHECK(XHCIState, (obj), TYPE_XHCI)
+typedef struct XHCIState XHCIState;
+DECLARE_INSTANCE_CHECKER(XHCIState, XHCI,
+ TYPE_XHCI)
#define MAXPORTS_2 15
#define MAXPORTS_3 15
@@ -39,7 +41,6 @@
/* Very pessimistic, let's hope it's enough for all cases */
#define EV_QUEUE (((3 * 24) + 16) * MAXSLOTS)
-typedef struct XHCIState XHCIState;
typedef struct XHCIStreamContext XHCIStreamContext;
typedef struct XHCIEPContext XHCIEPContext;
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 08604f7..2ba1de6 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -34,6 +34,7 @@
*/
#include "qemu/osdep.h"
+#include "qom/object.h"
#ifndef CONFIG_WIN32
#include <poll.h>
#endif
@@ -60,10 +61,10 @@
/* ------------------------------------------------------------------------ */
#define TYPE_USB_HOST_DEVICE "usb-host"
-#define USB_HOST_DEVICE(obj) \
- OBJECT_CHECK(USBHostDevice, (obj), TYPE_USB_HOST_DEVICE)
-
typedef struct USBHostDevice USBHostDevice;
+DECLARE_INSTANCE_CHECKER(USBHostDevice, USB_HOST_DEVICE,
+ TYPE_USB_HOST_DEVICE)
+
typedef struct USBHostRequest USBHostRequest;
typedef struct USBHostIsoXfer USBHostIsoXfer;
typedef struct USBHostIsoRing USBHostIsoRing;
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 417a60a..a079ecd 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -45,6 +45,7 @@
#include "hw/usb.h"
#include "migration/qemu-file-types.h"
#include "migration/vmstate.h"
+#include "qom/object.h"
/* ERROR is defined below. Remove any previous definition. */
#undef ERROR
@@ -144,7 +145,8 @@ struct USBRedirDevice {
};
#define TYPE_USB_REDIR "usb-redir"
-#define USB_REDIRECT(obj) OBJECT_CHECK(USBRedirDevice, (obj), TYPE_USB_REDIR)
+DECLARE_INSTANCE_CHECKER(USBRedirDevice, USB_REDIRECT,
+ TYPE_USB_REDIR)
static void usbredir_hello(void *priv, struct usb_redir_hello_header *h);
static void usbredir_device_connect(void *priv,
diff --git a/hw/usb/tusb6010.c b/hw/usb/tusb6010.c
index 27eb28d..dd20996 100644
--- a/hw/usb/tusb6010.c
+++ b/hw/usb/tusb6010.c
@@ -28,11 +28,14 @@
#include "hw/hw.h"
#include "hw/irq.h"
#include "hw/sysbus.h"
+#include "qom/object.h"
#define TYPE_TUSB6010 "tusb6010"
-#define TUSB(obj) OBJECT_CHECK(TUSBState, (obj), TYPE_TUSB6010)
+typedef struct TUSBState TUSBState;
+DECLARE_INSTANCE_CHECKER(TUSBState, TUSB6010,
+ TYPE_TUSB6010)
-typedef struct TUSBState {
+struct TUSBState {
SysBusDevice parent_obj;
MemoryRegion iomem[2];
@@ -68,7 +71,7 @@ typedef struct TUSBState {
uint32_t pullup[2];
uint32_t control_config;
uint32_t otg_timer_val;
-} TUSBState;
+};
#define TUSB_DEVCLOCK 60000000 /* 60 MHz */
@@ -776,7 +779,7 @@ static void tusb6010_irq(void *opaque, int source, int level)
static void tusb6010_reset(DeviceState *dev)
{
- TUSBState *s = TUSB(dev);
+ TUSBState *s = TUSB6010(dev);
int i;
s->test_reset = TUSB_PROD_TEST_RESET_VAL;
@@ -812,7 +815,7 @@ static void tusb6010_reset(DeviceState *dev)
static void tusb6010_realize(DeviceState *dev, Error **errp)
{
- TUSBState *s = TUSB(dev);
+ TUSBState *s = TUSB6010(dev);
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
s->otg_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, tusb_otg_tick, s);