/* Returns the number of bytes received on success, or else the status code returned by the underlying usb_control_msg() call.  */
int usb_get_device_descriptor(struct usb_device *dev, unsigned int size)
/* Returns the number of bytes received on success, or else the status code returned by the underlying usb_control_msg() call.  */
int usb_get_device_descriptor(struct usb_device *dev, unsigned int size)
{
	struct usb_device_descriptor *desc;
	int ret;
	if (size > sizeof(*desc))
		return -EINVAL;
	desc = kmalloc(sizeof(*desc), GFP_NOIO);
	if (!desc)
		return -ENOMEM;
	ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, size);
	if (ret >= 0)
		memcpy(&dev->descriptor, desc, size);
	kfree(desc);
	return ret;
}