[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 23/26] hw/usb/usb-hcd: Use EHCI type definitions
On 7/4/20 7:15 PM, BALATON Zoltan wrote: > On Sat, 4 Jul 2020, Philippe Mathieu-Daudé wrote: >> Various machine/board/soc models create EHCI device instances >> with the generic QDEV API, and don't need to access USB internals. >> >> Simplify header inclusions by moving the QOM type names into a >> simple header, with no need to include other "hw/usb" headers. >> >> Suggested-by: BALATON Zoltan <balaton@xxxxxxxxxx> >> Signed-off-by: Philippe Mathieu-Daudé <f4bug@xxxxxxxxx> >> --- >> hw/usb/hcd-ehci.h | 11 +---------- >> include/hw/usb/chipidea.h | 2 +- >> include/hw/usb/usb-hcd.h | 11 +++++++++++ >> hw/arm/allwinner-h3.c | 1 - >> hw/arm/exynos4210.c | 2 +- >> hw/arm/sbsa-ref.c | 3 ++- >> hw/arm/xilinx_zynq.c | 2 +- >> hw/ppc/sam460ex.c | 1 - >> hw/usb/chipidea.c | 1 + >> hw/usb/hcd-ehci-sysbus.c | 1 + >> 10 files changed, 19 insertions(+), 16 deletions(-) >> >> diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h >> index 337b3ad05c..da70767409 100644 >> --- a/hw/usb/hcd-ehci.h >> +++ b/hw/usb/hcd-ehci.h >> @@ -23,6 +23,7 @@ >> #include "hw/pci/pci.h" >> #include "hw/sysbus.h" >> #include "usb-internal.h" >> +#include "hw/usb/usb-hcd.h" >> >> #define CAPA_SIZE 0x10 >> >> @@ -316,7 +317,6 @@ void usb_ehci_realize(EHCIState *s, DeviceState >> *dev, Error **errp); >> 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 { >> @@ -327,15 +327,6 @@ typedef struct EHCIPCIState { >> EHCIState ehci; >> } EHCIPCIState; >> >> - >> -#define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb" >> -#define TYPE_PLATFORM_EHCI "platform-ehci-usb" >> -#define TYPE_EXYNOS4210_EHCI "exynos4210-ehci-usb" >> -#define TYPE_AW_H3_EHCI "aw-h3-ehci-usb" >> -#define TYPE_TEGRA2_EHCI "tegra2-ehci-usb" >> -#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) \ >> diff --git a/include/hw/usb/chipidea.h b/include/hw/usb/chipidea.h >> index 1ec2e9dbda..28f46291de 100644 >> --- a/include/hw/usb/chipidea.h >> +++ b/include/hw/usb/chipidea.h >> @@ -2,6 +2,7 @@ >> #define CHIPIDEA_H >> >> #include "hw/usb/hcd-ehci.h" >> +#include "hw/usb/usb-hcd.h" >> >> typedef struct ChipideaState { >> /*< private >*/ >> @@ -10,7 +11,6 @@ typedef struct ChipideaState { >> MemoryRegion iomem[3]; >> } ChipideaState; >> >> -#define TYPE_CHIPIDEA "usb-chipidea" >> #define CHIPIDEA(obj) OBJECT_CHECK(ChipideaState, (obj), TYPE_CHIPIDEA) >> >> #endif /* CHIPIDEA_H */ >> diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h >> index 21fdfaf22d..74af3a4533 100644 >> --- a/include/hw/usb/usb-hcd.h >> +++ b/include/hw/usb/usb-hcd.h >> @@ -13,4 +13,15 @@ >> #define TYPE_SYSBUS_OHCI "sysbus-ohci" >> #define TYPE_PCI_OHCI "pci-ohci" >> >> +/* EHCI */ >> +#define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb" >> +#define TYPE_PCI_EHCI "pci-ehci-usb" >> +#define TYPE_PLATFORM_EHCI "platform-ehci-usb" >> +#define TYPE_EXYNOS4210_EHCI "exynos4210-ehci-usb" >> +#define TYPE_AW_H3_EHCI "aw-h3-ehci-usb" >> +#define TYPE_TEGRA2_EHCI "tegra2-ehci-usb" >> +#define TYPE_PPC4xx_EHCI "ppc4xx-ehci-usb" >> +#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb" >> +#define TYPE_CHIPIDEA "usb-chipidea" >> + >> #endif >> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c >> index d1d90ffa79..8b7adddc27 100644 >> --- a/hw/arm/allwinner-h3.c >> +++ b/hw/arm/allwinner-h3.c >> @@ -29,7 +29,6 @@ >> #include "hw/char/serial.h" >> #include "hw/misc/unimp.h" >> #include "hw/usb/usb-hcd.h" >> -#include "hw/usb/hcd-ehci.h" >> #include "hw/loader.h" >> #include "sysemu/sysemu.h" >> #include "hw/arm/allwinner-h3.h" >> diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c >> index fa639806ec..692fb02159 100644 >> --- a/hw/arm/exynos4210.c >> +++ b/hw/arm/exynos4210.c >> @@ -35,7 +35,7 @@ >> #include "hw/qdev-properties.h" >> #include "hw/arm/exynos4210.h" >> #include "hw/sd/sdhci.h" >> -#include "hw/usb/hcd-ehci.h" >> +#include "hw/usb/usb-hcd.h" >> >> #define EXYNOS4210_CHIPID_ADDR 0x10000000 >> >> diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c >> index 021e7c1b8b..4e4c338ae9 100644 >> --- a/hw/arm/sbsa-ref.c >> +++ b/hw/arm/sbsa-ref.c >> @@ -38,6 +38,7 @@ >> #include "hw/loader.h" >> #include "hw/pci-host/gpex.h" >> #include "hw/qdev-properties.h" >> +#include "hw/usb/usb-hcd.h" >> #include "hw/char/pl011.h" >> #include "net/net.h" >> >> @@ -485,7 +486,7 @@ static void create_ehci(const SBSAMachineState *sms) >> hwaddr base = sbsa_ref_memmap[SBSA_EHCI].base; >> int irq = sbsa_ref_irqmap[SBSA_EHCI]; >> >> - sysbus_create_simple("platform-ehci-usb", base, >> + sysbus_create_simple(TYPE_PLATFORM_EHCI, base, >> qdev_get_gpio_in(sms->gic, irq)); >> } >> >> diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c >> index ed970273f3..9ccdc03095 100644 >> --- a/hw/arm/xilinx_zynq.c >> +++ b/hw/arm/xilinx_zynq.c >> @@ -29,7 +29,7 @@ >> #include "hw/loader.h" >> #include "hw/misc/zynq-xadc.h" >> #include "hw/ssi/ssi.h" >> -#include "hw/usb/chipidea.h" >> +#include "hw/usb/usb-hcd.h" >> #include "qemu/error-report.h" >> #include "hw/sd/sdhci.h" >> #include "hw/char/cadence_uart.h" >> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c >> index ac60d17a86..3f7cf0d1ae 100644 >> --- a/hw/ppc/sam460ex.c >> +++ b/hw/ppc/sam460ex.c >> @@ -37,7 +37,6 @@ >> #include "hw/i2c/smbus_eeprom.h" >> #include "hw/usb/usb.h" >> #include "hw/usb/usb-hcd.h" >> -#include "hw/usb/hcd-ehci.h" >> #include "hw/ppc/fdt.h" >> #include "hw/qdev-properties.h" >> #include "hw/pci/pci.h" >> diff --git a/hw/usb/chipidea.c b/hw/usb/chipidea.c >> index 3dcd22ccba..e81f63295e 100644 >> --- a/hw/usb/chipidea.c >> +++ b/hw/usb/chipidea.c >> @@ -11,6 +11,7 @@ >> >> #include "qemu/osdep.h" >> #include "hw/usb/hcd-ehci.h" >> +#include "hw/usb/usb-hcd.h" >> #include "hw/usb/chipidea.h" >> #include "qemu/log.h" >> #include "qemu/module.h" >> diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c >> index 3730736540..b7debc1934 100644 >> --- a/hw/usb/hcd-ehci-sysbus.c >> +++ b/hw/usb/hcd-ehci-sysbus.c >> @@ -18,6 +18,7 @@ >> #include "qemu/osdep.h" >> #include "hw/qdev-properties.h" >> #include "hw/usb/hcd-ehci.h" >> +#include "hw/usb/usb-hcd.h" >> #include "migration/vmstate.h" >> #include "qemu/module.h" > > Do these last two still need hw/usb/hcd-ehci.h? If so do they get > hw/usb/usb-hcd.h via that one so do they need to explicitely include it > again? chipidea.c implements an HCI, so it uses the hcd-ehci.h internals, else we get: usb/chipidea.c:96:5: error: unknown type name ‘EHCIState’ 96 | EHCIState *ehci = &SYS_BUS_EHCI(obj)->ehci; | ^~~~~~~~~ hw/usb/chipidea.c:152:5: error: unknown type name ‘SysBusEHCIClass’ 152 | SysBusEHCIClass *sec = SYS_BUS_EHCI_CLASS(klass); | ^~~~~~~~~~~~~~~ hw/usb/chipidea.c:152:28: error: implicit declaration of function ‘SYS_BUS_EHCI_CLASS’ [-Werror=implicit-function-declaration] 152 | SysBusEHCIClass *sec = SYS_BUS_EHCI_CLASS(klass); | ^~~~~~~~~~~~~~~~~~ Similarly with hcd-ehci-sysbus.c: hw/usb/hcd-ehci-sysbus.c:30:50: error: ‘vmstate_ehci’ undeclared here (not in a function) 30 | VMSTATE_STRUCT(ehci, EHCISysBusState, 2, vmstate_ehci, EHCIState), | ^~~~~~~~~~~~ hw/usb/hcd-ehci-sysbus.c:45:26: error: implicit declaration of function ‘SYS_BUS_EHCI’; did you mean ‘TYPE_SYS_BUS_EHCI’? [-Werror=implicit-function-declaration] 45 | EHCISysBusState *i = SYS_BUS_EHCI(dev); | ^~~~~~~~~~~~ | TYPE_SYS_BUS_EHCI hw/usb/hcd-ehci-sysbus.c:48:5: error: implicit declaration of function ‘usb_ehci_realize’; did you mean ‘usb_ehci_sysbus_realize’? [-Werror=implicit-function-declaration] 48 | usb_ehci_realize(s, dev, errp); | ^~~~~~~~~~~~~~~~ | usb_ehci_sysbus_realize hw/usb/hcd-ehci-sysbus.c:74:5: error: implicit declaration of function ‘usb_ehci_init’ [-Werror=implicit-function-declaration] 74 | usb_ehci_init(s, DEVICE(obj)); | ^~~~~~~~~~~~~ The idea of "hw/usb/usb-hcd.h" is to keep USB internals opaque to machine/board/soc using controllers, they just want to use the devices. I'll see how to reword the description to make that clearer. > > Regards, > BALATON Zoltan
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |