/* __cdns3_gadget_ep_clear_halt Clears stall on selected endpoint Should be called after acquiring spin_lock and selecting ep @ep: endpoint object to clear stall on  */
int __cdns3_gadget_ep_clear_halt(struct cdns3_endpoint *priv_ep)
/* __cdns3_gadget_ep_clear_halt Clears stall on selected endpoint Should be called after acquiring spin_lock and selecting ep @ep: endpoint object to clear stall on  */
int __cdns3_gadget_ep_clear_halt(struct cdns3_endpoint *priv_ep)
{
	struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
	struct usb_request *request;
	int ret = 0;
	int val;
	trace_cdns3_halt(priv_ep, 0, 0);
	writel(EP_CMD_CSTALL | EP_CMD_EPRST, &priv_dev->regs->ep_cmd);
	readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val,
				  !(val & EP_CMD_EPRST), 100);
	if (ret)
		return -EINVAL;
	priv_ep->flags &= ~(EP_STALLED | EP_STALL_PENDING);
	request = cdns3_next_request(&priv_ep->pending_req_list);
	if (request)
		cdns3_rearm_transfer(priv_ep, 1);
	cdns3_start_all_request(priv_dev, priv_ep);
	return ret;
}