On Mon, 22 Jul 2013, Felipe Balbi wrote: > indeed. Added a flush_work() call to usb_del_gadget_udc() > > > Also, what happens if two state transitions occur before the work queue > > gets around to executing the work routine? > > do we need to care about that at all ? It's a queue anyway, transitions > will still be notified in order. The "queue" in "workqueue" doesn't refer to the individual calls for a particular work_struct. If you call schedule_work(&gadget->work) twice in quick succession, the work routine is likely to get executed only once. I don't know if that would be a problem in this case -- the effect would be that some state transitions would appear to be skipped over. If nobody cares about anything but the current state, this would be okay. > @@ -311,6 +320,7 @@ found: > kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE); > device_unregister(&udc->dev); > device_unregister(&gadget->dev); > + flush_work(&gadget->work); Shouldn't the flush_work() call come before device_unregister()? You don't want to call sysfs_notify() on an unregistered device. 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