Re: [PATCH v4 5/5] usb: gadget: udc-core: independent registration of gadgets and gadget drivers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux