diff --git a/devicemodel/hw/pci/xhci.c b/devicemodel/hw/pci/xhci.c index ea616adf1..cb09fd8e3 100644 --- a/devicemodel/hw/pci/xhci.c +++ b/devicemodel/hw/pci/xhci.c @@ -373,7 +373,7 @@ struct pci_xhci_vdev { int (*excap_write)(struct pci_xhci_vdev *, uint64_t, uint64_t); int usb2_port_start; int usb3_port_start; - uint8_t *native_assign_ports[USB_NATIVE_NUM_BUS]; + uint8_t native_assign_ports[USB_NATIVE_NUM_BUS][USB_NATIVE_NUM_PORT]; struct timespec mf_prev_time; /* previous time of accessing MFINDEX */ }; @@ -500,8 +500,7 @@ pci_xhci_native_usb_dev_conn_cb(void *hci_data, void *dev_data) UPRINTF(LDBG, "%04x:%04x %d-%d connecting.\r\n", di->vid, di->pid, di->bus, di->port); - if (!xdev->native_assign_ports[di->bus] || - !xdev->native_assign_ports[di->bus][di->port]) { + if (!xdev->native_assign_ports[di->bus][di->port]) { UPRINTF(LDBG, "%04x:%04x %d-%d doesn't belong to this vm, bye." "\r\n", di->vid, di->pid, di->bus, di->port); goto errout; @@ -3361,15 +3360,6 @@ pci_xhci_parse_bus_port(struct pci_xhci_vdev *xdev, char *opts) goto errout; } - if (!xdev->native_assign_ports[bus]) { - xdev->native_assign_ports[bus] = calloc(USB_NATIVE_NUM_PORT, - sizeof(uint8_t)); - if (!xdev->native_assign_ports[bus]) { - rc = -3; - goto errout; - } - } - xdev->native_assign_ports[bus][port] = 1; errout: if (rc) diff --git a/devicemodel/include/usb_core.h b/devicemodel/include/usb_core.h index 8727b8b4e..add4cb4e5 100644 --- a/devicemodel/include/usb_core.h +++ b/devicemodel/include/usb_core.h @@ -223,8 +223,8 @@ enum USB_ERRCODE { #define NATIVE_USBSYS_DEVDIR "/sys/bus/usb/devices" #define NATIVE_USB2_SPEED "480" #define NATIVE_USB3_SPEED "5000" -#define USB_NATIVE_NUM_PORT 255 -#define USB_NATIVE_NUM_BUS 255 +#define USB_NATIVE_NUM_PORT 20 +#define USB_NATIVE_NUM_BUS 4 extern int usb_log_level; inline int usb_get_log_level(void) { return usb_log_level; }