/* Returns zero on success, or else the status code returned by the underlying usb_control_msg() call.  */
int usb_clear_halt(struct usb_host_virt_dev *dev, int pipe)
/* Returns zero on success, or else the status code returned by the underlying usb_control_msg() call.  */
int usb_clear_halt(struct usb_host_virt_dev *dev, int pipe)
{
    int result;
    int endp = usb_pipeendpoint(pipe);
    if (usb_pipein(pipe))
    {
        endp |= USB_DIR_IN;
    }
    result = usb_control_msg(dev,
                             usb_sndctrlpipe(dev, 0),
                             USB_REQ_CLEAR_FEATURE,
                             USB_RECIP_ENDPOINT,
                             USB_ENDPOINT_HALT,
                             endp,
                             NULL,
                             0,
                             USB_CTRL_SET_TIMEOUT);
    if (result < 0)
    {
        return result;
    }
    usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 0);
    return 0;
}