Re: [PATCH v4 5/5] usb: gadget: udc-core: independent registration of gadgets and gadget drivers
From: Alan Stern
Date: Mon Mar 16 2015 - 10:52:02 EST
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-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/