/* The descriptor is assumed to be properly initialized (ie: you got it through __rpipe_get_descr()).  */
static int __rpipe_set_descr(struct wahc *wa, struct usb_rpipe_descriptor *descr, u16 index)
/* The descriptor is assumed to be properly initialized (ie: you got it through __rpipe_get_descr()).  */
static int __rpipe_set_descr(struct wahc *wa, struct usb_rpipe_descriptor *descr, u16 index)
{
	ssize_t result;
	struct device *dev = &wa->usb_iface->dev;
	result = usb_control_msg(
		wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0),
		USB_REQ_SET_DESCRIPTOR,
		USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_RPIPE,
		USB_DT_RPIPE<<8, index, descr, sizeof(*descr),
		HZ / 10);
	if (result < 0) {
		dev_err(dev, "rpipe %u: set descriptor failed: %d\n",
			index, (int)result);
		goto error;
	}
	if (result < sizeof(*descr)) {
		dev_err(dev, "rpipe %u: sent short descriptor "
			"(%zd vs %zd bytes required)\n",
			index, result, sizeof(*descr));
		result = -EINVAL;
		goto error;
	}
	result = 0;
error:
	return result;
}