aboutsummaryrefslogtreecommitdiff
path: root/hw/usb/bus.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2013-04-18 11:57:21 +0200
committerGerd Hoffmann <kraxel@redhat.com>2013-04-23 08:43:10 +0200
commit3b7e759a4110690c9617b1ffa6a7c96a343a330d (patch)
tree9c25bc23d516efee566ae1e027e5dbf3968c74fa /hw/usb/bus.c
parente449f26bed42b1d8c6efefcd8dc768f23f19458f (diff)
usb: better speed mismatch error reporting
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 <kraxel@redhat.com>
Diffstat (limited to 'hw/usb/bus.c')
-rw-r--r--hw/usb/bus.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index b10c290cf4..d1827be101 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -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;
}