[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/3] usb: add public usb_device_by_id
From: |
Alon Levy |
Subject: |
Re: [Qemu-devel] [PATCH 2/3] usb: add public usb_device_by_id |
Date: |
Tue, 19 Oct 2010 09:13:07 -0400 (EDT) |
----- "Gerd Hoffmann" <address@hidden> 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