usb: hub: remote wakeup support.
authorGerd Hoffmann <kraxel@redhat.com>
Wed, 15 Dec 2010 11:26:59 +0000 (12:26 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 11 Jan 2011 16:01:02 +0000 (17:01 +0100)
This patch makes the usb hub handle remote wakeup requests from devices
properly by updating the port status register and forwarding the wakeup
to the upstream port.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb-hub.c

index 8837bd9efef226d7fa8b06bd6eb5cb0e8772c0ed..8a80151da2713f5d5e8a24156ffbbb48e91d1c8e 100644 (file)
@@ -245,6 +245,17 @@ static void usb_hub_detach(USBPort *port1)
     }
 }
 
+static void usb_hub_wakeup(USBDevice *dev)
+{
+    USBHubState *s = dev->port->opaque;
+    USBHubPort *port = &s->ports[dev->port->index];
+
+    if (port->wPortStatus & PORT_STAT_SUSPEND) {
+        port->wPortChange |= PORT_STAT_C_SUSPEND;
+        usb_wakeup(&s->dev);
+    }
+}
+
 static void usb_hub_handle_reset(USBDevice *dev)
 {
     /* XXX: do it */
@@ -502,6 +513,7 @@ static void usb_hub_handle_destroy(USBDevice *dev)
 static USBPortOps usb_hub_port_ops = {
     .attach = usb_hub_attach,
     .detach = usb_hub_detach,
+    .wakeup = usb_hub_wakeup,
 };
 
 static int usb_hub_initfn(USBDevice *dev)