usb: udc: allow adding and removing the same gadget device
authorRoger Quadros <rogerq@ti.com>
Mon, 3 Apr 2017 12:20:29 +0000 (15:20 +0300)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Tue, 11 Apr 2017 07:58:29 +0000 (10:58 +0300)
allow usb_del_gadget_udc() and usb add_gadget_udc() to be called
repeatedly on the same gadget->dev structure.

We need to clear the gadget->dev structure so that kobject_init()
doesn't complain about already initialized object.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/udc/core.c

index d685d82dcf487c9f53bb3cd821424159d2e445d1..efce68e9a8e038557bdc36c8263bad03cef7e108 100644 (file)
@@ -1273,6 +1273,7 @@ void usb_del_gadget_udc(struct usb_gadget *gadget)
        flush_work(&gadget->work);
        device_unregister(&udc->dev);
        device_unregister(&gadget->dev);
+       memset(&gadget->dev, 0x00, sizeof(gadget->dev));
 }
 EXPORT_SYMBOL_GPL(usb_del_gadget_udc);