/* Copies descriptors into the buffer, returning the length or a negative error code if they can't all be copied. Useful when assembling descriptors for an associated set of interfaces used as part of configuring a composite device; or in other cases where sets of descriptors need to be marshaled.  */
int usb_descriptor_fillbuf(void *buf, unsigned buflen, const struct usb_descriptor_header **src)
/* Copies descriptors into the buffer, returning the length or a negative error code if they can't all be copied. Useful when assembling descriptors for an associated set of interfaces used as part of configuring a composite device; or in other cases where sets of descriptors need to be marshaled.  */
int usb_descriptor_fillbuf(void *buf, unsigned buflen, const struct usb_descriptor_header **src)
{
	u8	*dest = buf;
	if (!src)
		return -EINVAL;
	for (; NULL != *src; src++) {
		unsigned		len = (*src)->bLength;
		if (len > buflen)
			return -EINVAL;
		memcpy(dest, *src, len);
		buflen -= len;
		dest += len;
	}
	return dest - (u8 *)buf;
}