On Fri, 2 May 2025 at 04:34, Nicholas Piggin <[email protected]> wrote:
>
> This also adds some missing constants rather than open-coding
> offsets and sizes.
>
> Signed-off-by: Nicholas Piggin <[email protected]>
> ---
> hw/usb/hcd-xhci.h | 16 ++++++++++++++++
> hw/usb/hcd-xhci.c | 48 ++++++++++++++++++++++-------------------------
> 2 files changed, 38 insertions(+), 26 deletions(-)
>
> diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
> index ee364efd0ab..20059fcf66c 100644
> --- a/hw/usb/hcd-xhci.h
> +++ b/hw/usb/hcd-xhci.h
> @@ -115,6 +115,22 @@ typedef enum TRBCCode {
> CC_SPLIT_TRANSACTION_ERROR
> } TRBCCode;
>
> +/* Register regions */
> +#define XHCI_REGS_LENGTH_CAP 0x40
> +#define XHCI_REGS_LENGTH_OPER 0x400
Old code defines LEN_OPER as
(0x400 + XHCI_PORT_PR_SZ * XHCI_MAXPORTS), not just 0x400.
If this is fixing a bug, please keep the bug fixes in
their own commits, not mixed in with renaming or moving
constant definitions.
> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
> index abd2002d2c0..c12b72cb9d8 100644
> --- a/hw/usb/hcd-xhci.c
> +++ b/hw/usb/hcd-xhci.c
> @@ -46,22 +46,14 @@
> #define COMMAND_LIMIT 256
> #define TRANSFER_LIMIT 256
>
> -#define LEN_CAP 0x40
> -#define LEN_OPER (0x400 + XHCI_PORT_PR_SZ * XHCI_MAXPORTS)
> -#define LEN_RUNTIME ((XHCI_MAXINTRS + 1) * XHCI_INTR_IR_SZ)
> -#define LEN_DOORBELL ((XHCI_MAXSLOTS + 1) * 0x20)
> for (i = 0; i < xhci->numports; i++) {
> XHCIPort *port = &xhci->ports[i];
> - uint32_t offset = OFF_OPER + 0x400 + XHCI_PORT_PR_SZ * i;
> + uint32_t offset = XHCI_REGS_OFFSET_PORT + XHCI_PORT_PR_SZ * i;
Old code uses OPER offset, new code is using PORT offset.
> port->xhci = xhci;
> memory_region_init_io(&port->mem, OBJECT(dev), &xhci_port_ops, port,
> port->name, XHCI_PORT_PR_SZ);
> --
> 2.47.1
thanks
-- PMM