Re: Gadget driver ->disconnect callback during unbinding

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

 



Hi Alan,

Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> writes:
> Felipe:
>
> A UDC driver will invoke the gadget driver's ->disconnect callback
> whenever the D+ pullup is turned off.  During gadget driver unbinding,
> this happens automatically when usb_gadget_remove_driver() calls
> usb_gadget_disconnect().

usb_gadget_disconnect() only calls UDC's ->pullup(), not gadget driver's
->disconnect()

int usb_gadget_disconnect(struct usb_gadget *gadget)
{
	int ret = 0;

	if (!gadget->ops->pullup) {
		ret = -EOPNOTSUPP;
		goto out;
	}

	if (gadget->deactivated) {
		/*
		 * If gadget is deactivated we only save new state.
		 * Gadget will stay disconnected after activation.
		 */
		gadget->connected = false;
		goto out;
	}

	ret = gadget->ops->pullup(gadget, 0);
	if (!ret)
		gadget->connected = 0;

out:
	trace_usb_gadget_disconnect(gadget, ret);

	return ret;
}
EXPORT_SYMBOL_GPL(usb_gadget_disconnect);

> But immediately thereafter, usb_gadget_remove_driver() calls the gadget 
> driver's ->disconnect callback directly!  Do we have any reason for 
> doing this?  I don't see point to it.  Should that call be removed?

Unless I'm missing something, that call is necessary :-) Have you faced
any issues with it? Are there any UDCs calling gadget driver's
->disconnect() from ->pullup() ?

-- 
balbi

Attachment: signature.asc
Description: PGP signature


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

  Powered by Linux