From 18143137f8f8924eecea902867546c6beb64ff71 Mon Sep 17 00:00:00 2001
Message-Id: <18143137f8f8924eecea902867546c6beb64ff71.1369821827.git.minovotn@redhat.com>
In-Reply-To: <2675121a5ff1ee361e9f5d33b9e8a97e4d65114f.1369821827.git.minovotn@redhat.com>
References: <2675121a5ff1ee361e9f5d33b9e8a97e4d65114f.1369821827.git.minovotn@redhat.com>
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Mon, 13 May 2013 15:21:44 +0200
Subject: [PATCH 2/2] usb-hub: report status changes only once

RH-Author: Gerd Hoffmann <kraxel@redhat.com>
Message-id: <1368458504-16570-3-git-send-email-kraxel@redhat.com>
Patchwork-id: 51334
O-Subject: [RHEL-6.5 qemu-kvm PATCH 2/2] usb-hub: report status changes only once
Bugzilla: 905851
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit a309ee6e0a256f690760abfba44fceaa52a7c2f3)
---
 hw/usb-hub.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 hw/usb-hub.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/usb-hub.c b/hw/usb-hub.c
index cf5f401..4457024 100644
--- a/hw/usb-hub.c
+++ b/hw/usb-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 {
@@ -416,8 +417,11 @@ static int 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++) {
-- 
1.7.11.7

