On Mon, 16 Mar 2015, Ruslan Bilovol wrote:

> >> +     if (ret) {
> >> +             struct usb_gadget_driver *tmp;
> >> +
> >> +             list_for_each_entry(tmp, &gadget_driver_pending_list, 
> >> pending)
> >> +                     if (tmp == driver) {
> >> +                             list_del(&driver->pending);
> >> +                             ret = 0;
> >> +                             break;
> >> +                     }
> >> +     }
> >
> > You could avoid this loop and simply do list_del(&driver->pending), if
> > you made sure driver->pending was initialized.
> 
> It would be good to avoid this loop but the question is how to make sure
> that driver->pending is not only initialized (prev and next are not NULL),
> but also contains valid data?

It's easy.  In usb_gadget_probe_driver() do
INIT_LIST_HEAD(&driver->pending), and in usb_gadget_remove_driver()  
replace your list_del() with list_del_init().

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to