/* Resets the endpoint toggle, and sets dev->ep_{in,out} pointers. For control endpoints, both the input and output sides are handled.  */
static void usb_enable_endpoint(struct usb_host_virt_dev *dev, struct usb_host_virt_endpoint *ep)
/* Resets the endpoint toggle, and sets dev->ep_{in,out} pointers. For control endpoints, both the input and output sides are handled.  */
static void usb_enable_endpoint(struct usb_host_virt_dev *dev, struct usb_host_virt_endpoint *ep)
{
    unsigned int epaddr = ep->desc.bEndpointAddress;
    unsigned int epnum = epaddr & USB_ENDPOINT_NUMBER_MASK;
    int is_control = 0;
    is_control = ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_CONTROL);
    if (usb_endpoint_out(epaddr) || is_control)
    {
        usb_settoggle(dev, epnum, 1, 0);
        dev->ep_out[epnum] = ep;
    }
    if (!usb_endpoint_out(epaddr) || is_control)
    {
        usb_settoggle(dev, epnum, 0, 0);
        dev->ep_in[epnum] = ep;
    }
    return;
}