From mboxrd@z Thu Jan 1 00:00:00 1970 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 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> Subject: [Qemu-devel] [PATCH 2/3] usb: add public usb_device_by_id List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@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) { -- 1.7.3.1