From nobody Mon Feb 9 08:09:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558681851; cv=none; d=zoho.com; s=zohoarc; b=eYD6C46iirl0dv1saWDfdO/zv9FonIhT8mZN7jpPIqwQKUG+9jbHyYHa/8o0oQ1PhnN/SYWovnq/1ShrF8C9c/3ufcWWjMFULyN9cqbEibfofGgA21IsY/3fBlsoX6l9wlnvToWFzqV/9Ay5JyHeFSIjQpC8XQ4RD2R1pK3YTpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558681851; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=CQECXBT+TkzLx6IilzWhlYHkZKLGt0O5u5ZViRuXazM=; b=DcPD1KZKCnGA9/v0W1cDJsDUYmmB8dIKXuGfwrMWbUnHezXzWou7BTdnSg0CCEg8zTPaNBpRpim/HlhSkuo9krJJ3U8eRwtV31YlNjw2e0BEenhEHaSU+dfZPK3GM5Nclm0PntAgNiYwYlxQEEgzhaX21E0JpIsS7HtnJTJmEek= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558681851789408.9951189823705; Fri, 24 May 2019 00:10:51 -0700 (PDT) Received: from localhost ([127.0.0.1]:50199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hU4Li-00038t-OI for importer@patchew.org; Fri, 24 May 2019 03:10:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hU4EY-0005PS-Tx for qemu-devel@nongnu.org; Fri, 24 May 2019 03:03:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hU4EX-0006Hq-0U for qemu-devel@nongnu.org; Fri, 24 May 2019 03:03:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45392) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hU4EV-0006GE-2F for qemu-devel@nongnu.org; Fri, 24 May 2019 03:03:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 14D73308793A for ; Fri, 24 May 2019 07:03:14 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-101.ams2.redhat.com [10.36.116.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85F9817D5D; Fri, 24 May 2019 07:03:11 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DBE311753B; Fri, 24 May 2019 09:03:10 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 24 May 2019 09:03:09 +0200 Message-Id: <20190524070310.4952-5-kraxel@redhat.com> In-Reply-To: <20190524070310.4952-1-kraxel@redhat.com> References: <20190524070310.4952-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 24 May 2019 07:03:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 4/5] usb-hub: add usb_hub_port_update() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Helper function to update port status bits which depends on the connected device. We need the same logic for device attach and port reset, so factor it out. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/usb/dev-hub.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c index 1cc92a5f9abe..29f4d6723e26 100644 --- a/hw/usb/dev-hub.c +++ b/hw/usb/dev-hub.c @@ -188,18 +188,28 @@ static bool usb_hub_port_clear(USBHubPort *port, uint= 16_t status) return usb_hub_port_change(port, status); } =20 +static bool usb_hub_port_update(USBHubPort *port) +{ + bool notify =3D false; + + if (port->port.dev && port->port.dev->attached) { + notify =3D usb_hub_port_set(port, PORT_STAT_CONNECTION); + if (port->port.dev->speed =3D=3D USB_SPEED_LOW) { + usb_hub_port_set(port, PORT_STAT_LOW_SPEED); + } else { + usb_hub_port_clear(port, PORT_STAT_LOW_SPEED); + } + } + return notify; +} + static void usb_hub_attach(USBPort *port1) { USBHubState *s =3D port1->opaque; USBHubPort *port =3D &s->ports[port1->index]; =20 trace_usb_hub_attach(s->dev.addr, port1->index + 1); - usb_hub_port_set(port, PORT_STAT_CONNECTION); - if (port->port.dev->speed =3D=3D USB_SPEED_LOW) { - usb_hub_port_set(port, PORT_STAT_LOW_SPEED); - } else { - usb_hub_port_clear(port, PORT_STAT_LOW_SPEED); - } + usb_hub_port_update(port); usb_wakeup(s->intr, 0); } =20 @@ -287,12 +297,7 @@ static void usb_hub_handle_reset(USBDevice *dev) port->wPortStatus =3D 0; port->wPortChange =3D 0; usb_hub_port_set(port, PORT_STAT_POWER); - if (port->port.dev && port->port.dev->attached) { - usb_hub_port_set(port, PORT_STAT_CONNECTION); - if (port->port.dev->speed =3D=3D USB_SPEED_LOW) { - usb_hub_port_set(port, PORT_STAT_LOW_SPEED); - } - } + usb_hub_port_update(port); } } =20 --=20 2.18.1