From patchwork Thu Nov 1 15:54:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 196262 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 883812C0348 for ; Fri, 2 Nov 2012 02:55:10 +1100 (EST) Received: from localhost ([::1]:48593 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTx6q-0004Dd-MZ for incoming@patchwork.ozlabs.org; Thu, 01 Nov 2012 11:55:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTx6Y-0004Bs-Sn for qemu-devel@nongnu.org; Thu, 01 Nov 2012 11:54:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTx6V-000810-OG for qemu-devel@nongnu.org; Thu, 01 Nov 2012 11:54:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60472) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTx6V-0007xl-4o for qemu-devel@nongnu.org; Thu, 01 Nov 2012 11:54:47 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qA1Fskg8014617 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 1 Nov 2012 11:54:46 -0400 Received: from rincewind.home.kraxel.org (ovpn-116-42.ams2.redhat.com [10.36.116.42]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qA1FsjJh000412; Thu, 1 Nov 2012 11:54:45 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id AA01642939; Thu, 1 Nov 2012 16:54:44 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 1 Nov 2012 16:54:17 +0100 Message-Id: <1351785284-15384-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1351785284-15384-1-git-send-email-kraxel@redhat.com> References: <1351785284-15384-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 04/31] xhci: add xhci_port_notify X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Create a function to notify the guest about port status changes and put it into use. Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-xhci.c | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 62cca90..3af4639 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -2348,6 +2348,21 @@ static bool xhci_port_have_device(XHCIPort *port) return true; } +static void xhci_port_notify(XHCIPort *port, uint32_t bits) +{ + XHCIEvent ev = { ER_PORT_STATUS_CHANGE, CC_SUCCESS, + port->portnr << 24 }; + + if ((port->portsc & bits) == bits) { + return; + } + port->portsc |= bits; + if (!xhci_running(port->xhci)) { + return; + } + xhci_event(port->xhci, &ev, 0); +} + static void xhci_port_update(XHCIPort *port, int is_detach) { port->portsc = PORTSC_PP; @@ -2369,13 +2384,7 @@ static void xhci_port_update(XHCIPort *port, int is_detach) } } - if (xhci_running(port->xhci)) { - port->portsc |= PORTSC_CSC; - XHCIEvent ev = { ER_PORT_STATUS_CHANGE, CC_SUCCESS, - port->portnr << 24}; - xhci_event(port->xhci, &ev, 0); - DPRINTF("xhci: port change event for port %d\n", port->portnr); - } + xhci_port_notify(port, PORTSC_CSC); } static void xhci_reset(DeviceState *dev) @@ -2865,18 +2874,12 @@ static void xhci_wakeup(USBPort *usbport) { XHCIState *xhci = usbport->opaque; XHCIPort *port = xhci_lookup_port(xhci, usbport); - XHCIEvent ev = { ER_PORT_STATUS_CHANGE, CC_SUCCESS, - port->portnr << 24}; if (get_field(port->portsc, PORTSC_PLS) != PLS_U3) { return; } set_field(&port->portsc, PLS_RESUME, PORTSC_PLS); - if (port->portsc & PORTSC_PLC) { - return; - } - port->portsc |= PORTSC_PLC; - xhci_event(xhci, &ev, 0); + xhci_port_notify(port, PORTSC_PLC); } static void xhci_complete(USBPort *port, USBPacket *packet)