Received: from [140.186.70.92] (port=36848 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8C59-0001NL-RX for qemu-devel@nongnu.org; Tue, 19 Oct 2010 09:18:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8C04-0008D0-3E for qemu-devel@nongnu.org; Tue, 19 Oct 2010 09:13:51 -0400 Received: from mx4-phx2.redhat.com ([209.132.183.25]:33417) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8C03-0008Ct-Sc for qemu-devel@nongnu.org; Tue, 19 Oct 2010 09:13:08 -0400 Date: Tue, 19 Oct 2010 09:13:07 -0400 (EDT) From: Alon Levy Message-ID: <304691519.861701287493987348.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com> In-Reply-To: <4CBD9892.2040301@redhat.com> Subject: Re: [Qemu-devel] [PATCH 2/3] usb: add public usb_device_by_id MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org ----- "Gerd Hoffmann" wrote: > > +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 There is no problem to loop over all usb devices. But first of all I don't want to loop on used, since then I miss any detached devices, so I actually do want the same behavior of qdev_find_recursive, and since it's already available, why rewrite it in a different compilation unit? Alon