sys/bus/u4b/usb_request.c
usb_error_t
usbd_req_get_config_desc_full(struct usb_device *udev, struct lock *lock,
    struct usb_config_descriptor **ppcd, struct malloc_type *mtype,
    uint8_t index)
{
	struct usb_config_descriptor cd;
	struct usb_config_descriptor *cdesc;
	uint16_t len;
	usb_error_t err;

	DPRINTFN(4, "index=%d\n", index);

	*ppcd = NULL;

	err = usbd_req_get_config_desc(udev, lock, &cd, index);
	if (err) {
		return (err);
	}
	/* get full descriptor */
	len = UGETW(cd.wTotalLength);
	if (len < sizeof(*cdesc)) {
		/* corrupt descriptor */
		return (USB_ERR_INVAL);
	}
	cdesc = kmalloc(len, mtype, M_WAITOK);
	err = usbd_req_get_desc(udev, lock, NULL, cdesc, len, len, 0,
	    UDESC_CONFIG, index, 3);
	if (err) {
		kfree(cdesc, mtype);
		return (err);
	}
	/* make sure that the device is not fooling us: */
	USETW(cdesc->wTotalLength, len);

	*ppcd = cdesc;

	return (0);			/* success */
}
/*------------------------------------------------------------------------*
 *	usbd_req_get_config_desc_full
 *
 * This function gets the complete USB configuration descriptor and
 * ensures that "wTotalLength" is correct.
 *
 * Returns:
 *    0: Success
 * Else: Failure
 *------------------------------------------------------------------------*/
usbd_req_get_config_desc_full
This function gets the complete USB configuration descriptor and
ensures that "wTotalLength" is correct.

Success
Else: Failure
usbd_req_get_config_desc_full This function gets the complete USB configuration descriptor and ensures that " wTotalLength " is correct . Success Else : Failure
usb_error_t
usbd_req_get_config_desc_full(struct usb_device *udev, struct lock *lock,
    struct usb_config_descriptor **ppcd, struct malloc_type *mtype,
    uint8_t index)
{
	struct usb_config_descriptor cd;
	struct usb_config_descriptor *cdesc;
	uint16_t len;
	usb_error_t err;
	DPRINTFN(4, "index=%d\n", index);
	*ppcd = NULL;
	err = usbd_req_get_config_desc(udev, lock, &cd, index);
	if (err) {
		return (err);
	}
	len = UGETW(cd.wTotalLength);
	if (len < sizeof(*cdesc)) {
		return (USB_ERR_INVAL);
	}
	cdesc = kmalloc(len, mtype, M_WAITOK);
	err = usbd_req_get_desc(udev, lock, NULL, cdesc, len, len, 0,
	    UDESC_CONFIG, index, 3);
	if (err) {
		kfree(cdesc, mtype);
		return (err);
	}
	USETW(cdesc->wTotalLength, len);
	*ppcd = cdesc;
	return (0);			
}
usb_error_t usbd_req_get_config_desc_full ( struct usb_device * udev , struct lock * lock , struct usb_config_descriptor * * ppcd , struct malloc_type * mtype , uint8_t index ) { struct usb_config_descriptor cd ; struct usb_config_descriptor * cdesc ; uint16_t len ; usb_error_t err ; DPRINTFN ( 4 , " \n " , index ) ; * ppcd = NULL ; err = usbd_req_get_config_desc ( udev , lock , & cd , index ) ; if ( err ) { return ( err ) ; } len = UGETW ( cd . wTotalLength ) ; if ( len < sizeof ( * cdesc ) ) { return ( USB_ERR_INVAL ) ; } cdesc = kmalloc ( len , mtype , M_WAITOK ) ; err = usbd_req_get_desc ( udev , lock , NULL , cdesc , len , len , 0 , UDESC_CONFIG , index , 3 ) ; if ( err ) { kfree ( cdesc , mtype ) ; return ( err ) ; } USETW ( cdesc -> wTotalLength , len ) ; * ppcd = cdesc ; return ( 0 ) ; }
usbd_req_get_config_desc_full
 This function gets the complete USB configuration descriptor and
 ensures that "wTotalLength" is correct.
usbd_req_get_config_desc_full This function gets the complete USB configuration descriptor and ensures that " wTotalLength " is correct .
/* get full descriptor */ /* corrupt descriptor */ /* make sure that the device is not fooling us: */ /* success */