From patchwork Tue Oct 19 10:33:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 68310 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 857A2B70D1 for ; Tue, 19 Oct 2010 21:42:21 +1100 (EST) Received: from localhost ([127.0.0.1]:55772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P89e6-0001Zs-3v for incoming@patchwork.ozlabs.org; Tue, 19 Oct 2010 06:42:18 -0400 Received: from [140.186.70.92] (port=33049 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P89Vq-0005Y9-Eb for qemu-devel@nongnu.org; Tue, 19 Oct 2010 06:34:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P89Vg-0004nk-LZ for qemu-devel@nongnu.org; Tue, 19 Oct 2010 06:33:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11503) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P89Vg-0004ng-Ea for qemu-devel@nongnu.org; Tue, 19 Oct 2010 06:33:36 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9JAXZBe018003 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 19 Oct 2010 06:33:35 -0400 Received: from playa.tlv.redhat.com (dhcp-2-227.tlv.redhat.com [10.35.2.227]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9JAXW5q010122 for ; Tue, 19 Oct 2010 06:33:35 -0400 From: Alon Levy To: qemu-devel@nongnu.org Date: Tue, 19 Oct 2010 12:33:30 +0200 Message-Id: <1287484411-13611-3-git-send-email-alevy@redhat.com> In-Reply-To: <1287484411-13611-1-git-send-email-alevy@redhat.com> References: <1287484411-13611-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 2/3] usb: add public usb_device_by_id X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org --- hw/usb-bus.c | 16 ++++++++++++++++ hw/usb.h | 1 + 2 files changed, 17 insertions(+), 0 deletions(-) diff --git a/hw/usb-bus.c b/hw/usb-bus.c index b692503..d732bd3 100644 --- a/hw/usb-bus.c +++ b/hw/usb-bus.c @@ -189,6 +189,22 @@ int usb_device_detach(USBDevice *dev) return 0; } +USBDevice *usb_device_by_id(const char* id) +{ + USBBus *bus; + DeviceState *qdev; + USBDevice *dev; + + QTAILQ_FOREACH(bus, &busses, next) { + qdev = qdev_find_recursive(&bus->qbus, id); + if (qdev != NULL) { + dev = DO_UPCAST(USBDevice, qdev, qdev); + return dev; + } + } + return NULL; +} + int usb_device_delete_addr(int busnr, int addr) { USBBus *bus; diff --git a/hw/usb.h b/hw/usb.h index 00d2802..e70fccd 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -317,6 +317,7 @@ void usb_unregister_port(USBBus *bus, USBPort *port); int usb_device_attach(USBDevice *dev); int usb_device_detach(USBDevice *dev); int usb_device_delete_addr(int busnr, int addr); +USBDevice *usb_device_by_id(const char* id); static inline USBBus *usb_bus_from_device(USBDevice *d) {