sys/dev/usbmisc/ugen/ugen.c
static usb_config_descriptor_t *
ugen_get_cdesc(struct ugen_softc *sc, int index, int *lenp)
{
	usb_config_descriptor_t *cdesc, *tdesc, cdescr;
	int len;
	usbd_status err;

	if (index == USB_CURRENT_CONFIG_INDEX) {
		tdesc = usbd_get_config_descriptor(sc->sc_udev);
		len = UGETW(tdesc->wTotalLength);
		if (lenp)
			*lenp = len;
		cdesc = kmalloc(len, M_TEMP, M_INTWAIT);
		memcpy(cdesc, tdesc, len);
		DPRINTFN(5,("ugen_get_cdesc: current, len=%d\n", len));
	} else {
		err = usbd_get_config_desc(sc->sc_udev, index, &cdescr);
		if (err)
			return (0);
		len = UGETW(cdescr.wTotalLength);
		DPRINTFN(5,("ugen_get_cdesc: index=%d, len=%d\n", index, len));
		if (lenp)
			*lenp = len;
		cdesc = kmalloc(len, M_TEMP, M_INTWAIT);
		err = usbd_get_config_desc_full(sc->sc_udev, index, cdesc, len);
		if (err) {
			kfree(cdesc, M_TEMP);
			return (0);
		}
	}
	return (cdesc);
}
/* Retrieve a complete descriptor for a certain device and index. */
Retrieve a complete descriptor for a certain device and index.
Retrieve a complete descriptor for a certain device and index .
static usb_config_descriptor_t *
ugen_get_cdesc(struct ugen_softc *sc, int index, int *lenp)
{
	usb_config_descriptor_t *cdesc, *tdesc, cdescr;
	int len;
	usbd_status err;
	if (index == USB_CURRENT_CONFIG_INDEX) {
		tdesc = usbd_get_config_descriptor(sc->sc_udev);
		len = UGETW(tdesc->wTotalLength);
		if (lenp)
			*lenp = len;
		cdesc = kmalloc(len, M_TEMP, M_INTWAIT);
		memcpy(cdesc, tdesc, len);
		DPRINTFN(5,("ugen_get_cdesc: current, len=%d\n", len));
	} else {
		err = usbd_get_config_desc(sc->sc_udev, index, &cdescr);
		if (err)
			return (0);
		len = UGETW(cdescr.wTotalLength);
		DPRINTFN(5,("ugen_get_cdesc: index=%d, len=%d\n", index, len));
		if (lenp)
			*lenp = len;
		cdesc = kmalloc(len, M_TEMP, M_INTWAIT);
		err = usbd_get_config_desc_full(sc->sc_udev, index, cdesc, len);
		if (err) {
			kfree(cdesc, M_TEMP);
			return (0);
		}
	}
	return (cdesc);
}
static usb_config_descriptor_t * ugen_get_cdesc ( struct ugen_softc * sc , int index , int * lenp ) { usb_config_descriptor_t * cdesc , * tdesc , cdescr ; int len ; usbd_status err ; if ( index == USB_CURRENT_CONFIG_INDEX ) { tdesc = usbd_get_config_descriptor ( sc -> sc_udev ) ; len = UGETW ( tdesc -> wTotalLength ) ; if ( lenp ) * lenp = len ; cdesc = kmalloc ( len , M_TEMP , M_INTWAIT ) ; memcpy ( cdesc , tdesc , len ) ; DPRINTFN ( 5 , ( " \n " , len ) ) ; } else { err = usbd_get_config_desc ( sc -> sc_udev , index , & cdescr ) ; if ( err ) return ( 0 ) ; len = UGETW ( cdescr . wTotalLength ) ; DPRINTFN ( 5 , ( " \n " , index , len ) ) ; if ( lenp ) * lenp = len ; cdesc = kmalloc ( len , M_TEMP , M_INTWAIT ) ; err = usbd_get_config_desc_full ( sc -> sc_udev , index , cdesc , len ) ; if ( err ) { kfree ( cdesc , M_TEMP ) ; return ( 0 ) ; } } return ( cdesc ) ; }
Retrieve a complete descriptor for a certain device and index.
Retrieve a complete descriptor for a certain device and index .