]> Git Repo - qemu.git/commitdiff
usb: better speed mismatch error reporting
authorGerd Hoffmann <[email protected]>
Thu, 18 Apr 2013 09:57:21 +0000 (11:57 +0200)
committerGerd Hoffmann <[email protected]>
Tue, 23 Apr 2013 06:43:10 +0000 (08:43 +0200)
Report the supported speeds for device and port in the error message.
Also add the speeds to the tracepoint.  And while being at it drop
the redundant error message in usb_desc_attach, usb_device_attach will
report the error anyway.

Signed-off-by: Gerd Hoffmann <[email protected]>
hw/usb/bus.c
hw/usb/desc.c
trace-events

index b10c290cf40d437745a21244538c4df6960d150a..d1827be10152185b7e2099ad2ca0f51e43da5d78 100644 (file)
@@ -417,19 +417,47 @@ void usb_release_port(USBDevice *dev)
     bus->nfree++;
 }
 
+static void usb_mask_to_str(char *dest, size_t size,
+                            unsigned int speedmask)
+{
+    static const struct {
+        unsigned int mask;
+        const char *name;
+    } speeds[] = {
+        { .mask = USB_SPEED_MASK_FULL,  .name = "full"  },
+        { .mask = USB_SPEED_MASK_HIGH,  .name = "high"  },
+        { .mask = USB_SPEED_MASK_SUPER, .name = "super" },
+    };
+    int i, pos = 0;
+
+    for (i = 0; i < ARRAY_SIZE(speeds); i++) {
+        if (speeds[i].mask & speedmask) {
+            pos += snprintf(dest + pos, size - pos, "%s%s",
+                            pos ? "+" : "",
+                            speeds[i].name);
+        }
+    }
+}
+
 int usb_device_attach(USBDevice *dev)
 {
     USBBus *bus = usb_bus_from_device(dev);
     USBPort *port = dev->port;
+    char devspeed[32], portspeed[32];
 
     assert(port != NULL);
     assert(!dev->attached);
-    trace_usb_port_attach(bus->busnr, port->path);
+    usb_mask_to_str(devspeed, sizeof(devspeed), dev->speedmask);
+    usb_mask_to_str(portspeed, sizeof(portspeed), port->speedmask);
+    trace_usb_port_attach(bus->busnr, port->path,
+                          devspeed, portspeed);
 
     if (!(port->speedmask & dev->speedmask)) {
-        error_report("Warning: speed mismatch trying to attach "
-                     "usb device %s to bus %s",
-                     dev->product_desc, bus->qbus.name);
+        error_report("Warning: speed mismatch trying to attach"
+                     " usb device \"%s\" (%s speed)"
+                     " to bus \"%s\", port \"%s\" (%s speed)",
+                     dev->product_desc, devspeed,
+                     bus->qbus.name, port->path, portspeed);
         return -1;
     }
 
index b38938132699f352f151f3a7b04ac57949f82161..fce303e9c883be107fd6c4de9e0913c9ba8e2799 100644 (file)
@@ -522,8 +522,6 @@ void usb_desc_attach(USBDevice *dev)
     } else if (desc->full && (dev->port->speedmask & USB_SPEED_MASK_FULL)) {
         dev->speed = USB_SPEED_FULL;
     } else {
-        fprintf(stderr, "usb: port/device speed mismatch for \"%s\"\n",
-                usb_device_get_product_desc(dev));
         return;
     }
     usb_desc_setdefaults(dev);
index e587487a3bb151296fbdf3d62bee107df645cae8..ffaa3f472e1c62ebabd65a9a89d13d90f2d36d5d 100644 (file)
@@ -277,7 +277,7 @@ usb_packet_state_fault(int bus, const char *port, int ep, void *p, const char *o
 
 # hw/usb/bus.c
 usb_port_claim(int bus, const char *port) "bus %d, port %s"
-usb_port_attach(int bus, const char *port) "bus %d, port %s"
+usb_port_attach(int bus, const char *port, const char *devspeed, const char *portspeed) "bus %d, port %s, devspeed %s, portspeed %s"
 usb_port_detach(int bus, const char *port) "bus %d, port %s"
 usb_port_release(int bus, const char *port) "bus %d, port %s"
 
This page took 0.029571 seconds and 4 git commands to generate.