Commit 4a80a67657 for qemu.org
commit 4a80a676571788eebc0965c1e74112986a742539
Author: Jamin Lin <jamin_lin@aspeedtech.com>
Date: Thu Apr 23 07:18:14 2026 +0200
hw/usb/hcd-ehci: Introduce common properties macro for sysbus and pci
EHCI properties are currently defined separately in both sysbus and
PCI implementations, leading to duplicated code for common fields
such as "maxframes".
Introduce DEFINE_EHCI_COMMON_PROPERTIES() to consolidate shared
property definitions and reuse them across both EHCISysBusState
and EHCIPCIState.
This reduces code duplication and keeps property definitions
consistent between different EHCI device variants.
No functional change.
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260424080508.53992-8-jamin_lin@aspeedtech.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
index 9febcc1031..fd35d25340 100644
--- a/hw/usb/hcd-ehci-pci.c
+++ b/hw/usb/hcd-ehci-pci.c
@@ -136,7 +136,7 @@ static void usb_ehci_pci_write_config(PCIDevice *dev, uint32_t addr,
}
static const Property ehci_pci_properties[] = {
- DEFINE_PROP_UINT32("maxframes", EHCIPCIState, ehci.maxframes, 128),
+ DEFINE_EHCI_COMMON_PROPERTIES(EHCIPCIState),
};
static const VMStateDescription vmstate_ehci_pci = {
diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c
index b31032bbf3..7f7c7f8a2f 100644
--- a/hw/usb/hcd-ehci-sysbus.c
+++ b/hw/usb/hcd-ehci-sysbus.c
@@ -31,7 +31,7 @@ static const VMStateDescription vmstate_ehci_sysbus = {
};
static const Property ehci_sysbus_properties[] = {
- DEFINE_PROP_UINT32("maxframes", EHCISysBusState, ehci.maxframes, 128),
+ DEFINE_EHCI_COMMON_PROPERTIES(EHCISysBusState),
DEFINE_PROP_BOOL("companion-enable", EHCISysBusState, ehci.companion_enable,
false),
};
diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index 4234591cb4..d038ee1e31 100644
--- a/hw/usb/hcd-ehci.h
+++ b/hw/usb/hcd-ehci.h
@@ -307,6 +307,9 @@ struct EHCIState {
VMChangeStateEntry *vmstate;
};
+#define DEFINE_EHCI_COMMON_PROPERTIES(_state) \
+ DEFINE_PROP_UINT32("maxframes", _state, ehci.maxframes, 128)
+
extern const VMStateDescription vmstate_ehci;
void usb_ehci_init(EHCIState *s, DeviceState *dev);