> On Thu, 28 Aug 2014, Alan Stern wrote: > > > Okay, so we need to add a "vbus_is_on" flag to the usb_gadget > > structure. The gadget driver will set this flag in its connect > > callback and clear the flag in its disconnect callback. If the UDC > > driver doesn't have a Vbus handler, it will invoke the connect > > callback just once during startup, and it will invoke the disconnect > > callback just once during removal. > > After more thought, if the vbus_is_on flag is going to be controlled by > the gadget driver rather than the UDC driver, then it really belongs in > the gadget driver's private data structure and not in struct usb_gadget. > Also, a better name for the flag would be "is_connected". > Yes, we should have some places to change "is_connected", that is one of thing we are discussing. > > The gadget driver should include an adjust_pullup() routine. It > > should get called whenever a function is activated or deactivated, and > > also by the connect and disconnect callbacks. The logic is simple: > > > > If (any functions are deactivated) > > turn off the pullup > > else if (gadget->vbus_is_on) > > turn on the pullup > > else > > turn off the pullup > > This logic can be compressed a little: > > if (!is_connected || any functions are deactivated) > turn off the pullup > else > turn on the pullup > Thanks, Alan. I have a similar implementation at below, http://www.spinics.net/lists/linux-usb/msg111976.html Peter -- 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