/* Returns 0 on success otherwise negative errno. In the error case, dwc may contain some buffers allocated but not all which were requested.  */
static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
/* Returns 0 on success otherwise negative errno. In the error case, dwc may contain some buffers allocated but not all which were requested.  */
static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
{
	int			num;
	int			i;
	num = DWC3_NUM_INT(dwc->hwparams.hwparams1);
	dwc->num_event_buffers = num;
	dwc->ev_buffs = memalign(CONFIG_SYS_CACHELINE_SIZE,
				 sizeof(*dwc->ev_buffs) * num);
	if (!dwc->ev_buffs)
		return -ENOMEM;
	for (i = 0; i < num; i++) {
		struct dwc3_event_buffer	*evt;
		evt = dwc3_alloc_one_event_buffer(dwc, length);
		if (IS_ERR(evt)) {
			dev_err(dwc->dev, "can't allocate event buffer\n");
			return PTR_ERR(evt);
		}
		dwc->ev_buffs[i] = evt;
	}
	return 0;
}