From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=37330 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8C5l-0001a9-N2 for qemu-devel@nongnu.org; Tue, 19 Oct 2010 09:19:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8Bwl-0007dk-Ic for qemu-devel@nongnu.org; Tue, 19 Oct 2010 09:11:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57240) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8Bwl-0007dY-CH for qemu-devel@nongnu.org; Tue, 19 Oct 2010 09:09:43 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9JD9gtt017439 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 19 Oct 2010 09:09:42 -0400 Message-ID: <4CBD9892.2040301@redhat.com> Date: Tue, 19 Oct 2010 15:09:38 +0200 From: Gerd Hoffmann MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 2/3] usb: add public usb_device_by_id References: <1287484411-13611-1-git-send-email-alevy@redhat.com> <1287484411-13611-3-git-send-email-alevy@redhat.com> In-Reply-To: <1287484411-13611-3-git-send-email-alevy@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alon Levy Cc: qemu-devel@nongnu.org > +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; > + } > + } You don't need qdev_find_recursive here. Have a look at the usb_info() code to see how to loop over all usb devices. Then compare id with USBDevice->qdev.id. cheers, Gerd