Patchwork [08/10] usb-hub: report status changes only once

login
register
mail settings
Submitter Gerd Hoffmann
Date April 3, 2013, 9:43 a.m.
Message ID <1364982220-4755-9-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/233330/
State New
Headers show

Comments

Gerd Hoffmann - April 3, 2013, 9:43 a.m.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/dev-hub.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Patch

diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c
index a5f092b..0b71abd 100644
--- a/hw/usb/dev-hub.c
+++ b/hw/usb/dev-hub.c
@@ -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++) {