[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v8 01/18] hw/usb/bus: Add an auto-hub flag to the USB bus



usb_claim_port() plugs a usb-hub into the last free port, so that more
devices fit. Every bus gets that today, and a controller cannot turn
it off.

Add auto_hub and have usb_claim_port() check it. usb_bus_new() turns it
on.

No functional change.

Suggested-by: Gerd Hoffmann <kraxel@xxxxxxxxxx>
Signed-off-by: Jamin Lin <jamin_lin@xxxxxxxxxxxxxx>
---
 include/hw/usb/usb.h | 1 +
 hw/usb/bus.c         | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/hw/usb/usb.h b/include/hw/usb/usb.h
index cbd4711933..cc1d6d74b1 100644
--- a/include/hw/usb/usb.h
+++ b/include/hw/usb/usb.h
@@ -484,6 +484,7 @@ struct USBBus {
     int busnr;
     int nfree;
     int nused;
+    bool auto_hub;
     QTAILQ_HEAD(, USBPort) free;
     QTAILQ_HEAD(, USBPort) used;
     QTAILQ_ENTRY(USBBus) next;
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 5cc5ffec33..92f67de4fe 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -92,6 +92,7 @@ void usb_bus_new(USBBus *bus, size_t bus_size,
     qbus_set_bus_hotplug_handler(BUS(bus));
     bus->ops = ops;
     bus->busnr = next_usb_bus++;
+    bus->auto_hub = true;
     QTAILQ_INIT(&bus->free);
     QTAILQ_INIT(&bus->used);
     QTAILQ_INSERT_TAIL(&busses, bus, next);
@@ -413,7 +414,8 @@ void usb_claim_port(USBDevice *dev, Error **errp)
             return;
         }
     } else {
-        if (bus->nfree == 1 && strcmp(object_get_typename(OBJECT(dev)), 
"usb-hub") != 0) {
+        if (bus->nfree == 1 && bus->auto_hub &&
+            strcmp(object_get_typename(OBJECT(dev)), "usb-hub") != 0) {
             /* Create a new hub and chain it on */
             hub = USB_DEVICE(qdev_try_new("usb-hub"));
             if (hub) {
-- 
2.43.0



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.