From patchwork Thu Nov 1 15:54:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 196261 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 246702C0348 for ; Fri, 2 Nov 2012 02:55:08 +1100 (EST) Received: from localhost ([::1]:48565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTx6n-0004CC-Uw for incoming@patchwork.ozlabs.org; Thu, 01 Nov 2012 11:55:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTx6W-0004Bq-Tt 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-000809-KY for qemu-devel@nongnu.org; Thu, 01 Nov 2012 11:54:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36948) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTx6V-0007xq-4m 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 qA1FskU3013617 (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 qA1Fsj8E000408; Thu, 1 Nov 2012 11:54:45 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 9B806426BB; Thu, 1 Nov 2012 16:54:44 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 1 Nov 2012 16:54:16 +0100 Message-Id: <1351785284-15384-4-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 03/31] xhci: add xhci_port_have_device 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 Factor out the code which checks whenever a usb device is attached to the port in question. No functional change. Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-xhci.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index f5ab692..62cca90 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -2337,11 +2337,21 @@ static void xhci_process_commands(XHCIState *xhci) } } +static bool xhci_port_have_device(XHCIPort *port) +{ + if (!port->uport->dev || !port->uport->dev->attached) { + return false; /* no device present */ + } + if (!((1 << port->uport->dev->speed) & port->speedmask)) { + return false; /* speed mismatch */ + } + return true; +} + static void xhci_port_update(XHCIPort *port, int is_detach) { port->portsc = PORTSC_PP; - if (port->uport->dev && port->uport->dev->attached && !is_detach && - (1 << port->uport->dev->speed) & port->speedmask) { + if (!is_detach && xhci_port_have_device(port)) { port->portsc |= PORTSC_CCS; switch (port->uport->dev->speed) { case USB_SPEED_LOW: