usb-hub: report status changes only once
authorGerd Hoffmann <kraxel@redhat.com>
Wed, 20 Mar 2013 11:40:11 +0000 (12:40 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 3 Apr 2013 09:39:43 +0000 (11:39 +0200)
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/dev-hub.c

index a5f092b..0b71abd 100644 (file)
@@ -33,6 +33,7 @@ typedef struct USBHubPort {
     USBPort port;
     uint16_t wPortStatus;
     uint16_t wPortChange;
+    uint16_t wPortChange_reported;
 } USBHubPort;
 
 typedef struct USBHubState {
@@ -467,8 +468,11 @@ static void usb_hub_handle_data(USBDevice *dev, USBPacket *p)
             status = 0;
             for(i = 0; i < NUM_PORTS; i++) {
                 port = &s->ports[i];
-                if (port->wPortChange)
+                if (port->wPortChange &&
+                    port->wPortChange_reported != port->wPortChange) {
                     status |= (1 << (i + 1));
+                }
+                port->wPortChange_reported = port->wPortChange;
             }
             if (status != 0) {
                 for(i = 0; i < n; i++) {