From patchwork Thu Oct 21 06:36: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: 68522 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 030871007D4 for ; Thu, 21 Oct 2010 17:40:27 +1100 (EST) Received: from localhost ([127.0.0.1]:52504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8op6-00077F-0G for incoming@patchwork.ozlabs.org; Thu, 21 Oct 2010 02:40:24 -0400 Received: from [140.186.70.92] (port=44295 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8olS-0005zJ-NT for qemu-devel@nongnu.org; Thu, 21 Oct 2010 02:36:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8olR-0001UO-QP for qemu-devel@nongnu.org; Thu, 21 Oct 2010 02:36:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38205) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8olR-0001UG-Ip for qemu-devel@nongnu.org; Thu, 21 Oct 2010 02:36:37 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9L6aauu020931 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 21 Oct 2010 02:36:36 -0400 Received: from playa.redhat.com (vpn-6-82.tlv.redhat.com [10.35.6.82]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id o9L6aVSX001577 for ; Thu, 21 Oct 2010 02:36:35 -0400 From: Alon Levy To: qemu-devel@nongnu.org Date: Thu, 21 Oct 2010 08:36:30 +0200 Message-Id: <1287642991-21114-3-git-send-email-alevy@redhat.com> In-Reply-To: <1287642991-21114-1-git-send-email-alevy@redhat.com> References: <1287642991-21114-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 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) {