Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85da852d authored by Li Jun's avatar Li Jun Committed by Peter Chen
Browse files

usb: chipidea: otg: gadget module load and unload support



This patch is to support load and unload gadget driver in full OTG mode.

Signed-off-by: default avatarLi Jun <jun.li@freescale.com>
Signed-off-by: default avatarPeter Chen <peter.chen@freescale.com>
Tested-by: default avatarJiada Wang <jiada_wang@mentor.com>
Cc: <stable@vger.kernel.org> #v4.0+
parent 251b3c8b
Loading
Loading
Loading
Loading
+17 −0
Original line number Original line Diff line number Diff line
@@ -1751,6 +1751,22 @@ static int ci_udc_start(struct usb_gadget *gadget,
	return retval;
	return retval;
}
}


static void ci_udc_stop_for_otg_fsm(struct ci_hdrc *ci)
{
	if (!ci_otg_is_fsm_mode(ci))
		return;

	mutex_lock(&ci->fsm.lock);
	if (ci->fsm.otg->state == OTG_STATE_A_PERIPHERAL) {
		ci->fsm.a_bidl_adis_tmout = 1;
		ci_hdrc_otg_fsm_start(ci);
	} else if (ci->fsm.otg->state == OTG_STATE_B_PERIPHERAL) {
		ci->fsm.protocol = PROTO_UNDEF;
		ci->fsm.otg->state = OTG_STATE_UNDEFINED;
	}
	mutex_unlock(&ci->fsm.lock);
}

/**
/**
 * ci_udc_stop: unregister a gadget driver
 * ci_udc_stop: unregister a gadget driver
 */
 */
@@ -1775,6 +1791,7 @@ static int ci_udc_stop(struct usb_gadget *gadget)
	ci->driver = NULL;
	ci->driver = NULL;
	spin_unlock_irqrestore(&ci->lock, flags);
	spin_unlock_irqrestore(&ci->lock, flags);


	ci_udc_stop_for_otg_fsm(ci);
	return 0;
	return 0;
}
}