static usbd_status
alloc_all_endpoints(struct umidi_softc *sc)
{
	usbd_status err;
	struct umidi_endpoint *ep;
	int i;

	if (UMQ_ISTYPE(sc, UMQ_TYPE_FIXED_EP)) {
		err = alloc_all_endpoints_fixed_ep(sc);
	} else if (UMQ_ISTYPE(sc, UMQ_TYPE_YAMAHA)) {
		err = alloc_all_endpoints_yamaha(sc);
	} else {
		err = alloc_all_endpoints_genuine(sc);
	}
	if (err!=USBD_NORMAL_COMPLETION)
		return err;

	ep = sc->sc_endpoints;
	for (i=sc->sc_out_num_endpoints+sc->sc_in_num_endpoints; i>0; i--) {
		err = alloc_pipe(ep++);
		if (err!=USBD_NORMAL_COMPLETION) {
			for (; ep!=sc->sc_endpoints; ep--)
				free_pipe(ep-1);
			free(sc->sc_endpoints, M_USBDEV);
			sc->sc_endpoints = sc->sc_out_ep = sc->sc_in_ep = NULL;
			break;
		}
	}
	return err;
}
示例#2
0
文件: umidi.c 项目: bluhm/sys
static usbd_status
alloc_all_endpoints(struct umidi_softc *sc)
{
	usbd_status err;
	struct umidi_endpoint *ep;
	int i;

	sc->sc_out_num_jacks = sc->sc_in_num_jacks = 0;

	if (UMQ_ISTYPE(sc, UMQ_TYPE_FIXED_EP))
		err = alloc_all_endpoints_fixed_ep(sc);
	else if (UMQ_ISTYPE(sc, UMQ_TYPE_YAMAHA))
		err = alloc_all_endpoints_yamaha(sc);
	else
		err = alloc_all_endpoints_genuine(sc);
	if (err!=USBD_NORMAL_COMPLETION)
		return err;

	ep = sc->sc_endpoints;
	for (i=sc->sc_out_num_endpoints+sc->sc_in_num_endpoints; i>0; i--) {
		err = alloc_pipe(ep);
		if (err!=USBD_NORMAL_COMPLETION) {
			while(ep != sc->sc_endpoints) {
				ep--;
				free_pipe(ep);
			}
			free(sc->sc_endpoints, M_USBDEV,
			    (sc->sc_out_num_endpoints + sc->sc_in_num_endpoints)
			    * sizeof(*sc->sc_endpoints));
			sc->sc_endpoints = sc->sc_out_ep = sc->sc_in_ep = NULL;
			break;
		}
		ep++;
	}
	return err;
}