/* Return: 0 if successful, negative error code otherwise  */
int dwc2_hcd_qh_add(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
/* Return: 0 if successful, negative error code otherwise  */
int dwc2_hcd_qh_add(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
{
	int status;
	u32 intr_mask;
	if (dbg_qh(qh))
		dev_vdbg(hsotg->dev, "%s()\n", __func__);
	if (!list_empty(&qh->qh_list_entry))
		return 0;
	if (dwc2_qh_is_non_per(qh)) {
		list_add_tail(&qh->qh_list_entry,
			      &hsotg->non_periodic_sched_inactive);
		return 0;
	}
	status = dwc2_schedule_periodic(hsotg, qh);
	if (status)
		return status;
	if (!hsotg->periodic_qh_count) {
		intr_mask = readl(hsotg->regs + GINTMSK);
		intr_mask |= GINTSTS_SOF;
		writel(intr_mask, hsotg->regs + GINTMSK);
	}
	hsotg->periodic_qh_count++;
	return 0;
}