static void musb_packet(MUSBState *s, MUSBEndPoint *ep,

                int epnum, int pid, int len, USBCallback cb, int dir)

{

    USBDevice *dev;

    int ret;

    int idx = epnum && dir;

    int ttype;



    /* ep->type[0,1] contains:

     * in bits 7:6 the speed (0 - invalid, 1 - high, 2 - full, 3 - slow)

     * in bits 5:4 the transfer type (BULK / INT)

     * in bits 3:0 the EP num

     */

    ttype = epnum ? (ep->type[idx] >> 4) & 3 : 0;



    ep->timeout[dir] = musb_timeout(ttype,

                    ep->type[idx] >> 6, ep->interval[idx]);

    ep->interrupt[dir] = ttype == USB_ENDPOINT_XFER_INT;

    ep->delayed_cb[dir] = cb;



    /* A wild guess on the FADDR semantics... */

    usb_packet_setup(&ep->packey[dir].p, pid, ep->faddr[idx],

                     ep->type[idx] & 0xf);

    usb_packet_addbuf(&ep->packey[dir].p, ep->buf[idx], len);

    ep->packey[dir].ep = ep;

    ep->packey[dir].dir = dir;



    dev = usb_find_device(&s->port, ep->packey[dir].p.devaddr);

    ret = usb_handle_packet(dev, &ep->packey[dir].p);



    if (ret == USB_RET_ASYNC) {

        ep->status[dir] = len;

        return;

    }



    ep->status[dir] = ret;

    musb_schedule_cb(&s->port, &ep->packey[dir].p);

}

static void musb_packet(MUSBState *s, MUSBEndPoint *ep,

                int epnum, int pid, int len, USBCallback cb, int dir)

{

    USBDevice *dev;

    int ret;

    int idx = epnum && dir;

    int ttype;



    









    ttype = epnum ? (ep->type[idx] >> 4) & 3 : 0;



    ep->timeout[dir] = musb_timeout(ttype,

                    ep->type[idx] >> 6, ep->interval[idx]);

    ep->interrupt[dir] = ttype == USB_ENDPOINT_XFER_INT;

    ep->delayed_cb[dir] = cb;



    

    usb_packet_setup(&ep->packey[dir].p, pid, ep->faddr[idx],

                     ep->type[idx] & 0xf);

    usb_packet_addbuf(&ep->packey[dir].p, ep->buf[idx], len);

    ep->packey[dir].ep = ep;

    ep->packey[dir].dir = dir;



    dev = usb_find_device(&s->port, ep->packey[dir].p.devaddr);

    ret = usb_handle_packet(dev, &ep->packey[dir].p);



    if (ret == USB_RET_ASYNC) {

        ep->status[dir] = len;

        return;

    }



    ep->status[dir] = ret;

    musb_schedule_cb(&s->port, &ep->packey[dir].p);

}

static void FUNC_0(MUSBState *VAR_0, MUSBEndPoint *VAR_1,

                int VAR_2, int VAR_3, int VAR_4, USBCallback VAR_5, int VAR_6)

{

    USBDevice *dev;

    int VAR_7;

    int VAR_8 = VAR_2 && VAR_6;

    int VAR_9;



    









    VAR_9 = VAR_2 ? (VAR_1->type[VAR_8] >> 4) & 3 : 0;



    VAR_1->timeout[VAR_6] = musb_timeout(VAR_9,

                    VAR_1->type[VAR_8] >> 6, VAR_1->interval[VAR_8]);

    VAR_1->interrupt[VAR_6] = VAR_9 == USB_ENDPOINT_XFER_INT;

    VAR_1->delayed_cb[VAR_6] = VAR_5;



    

    usb_packet_setup(&VAR_1->packey[VAR_6].p, VAR_3, VAR_1->faddr[VAR_8],

                     VAR_1->type[VAR_8] & 0xf);

    usb_packet_addbuf(&VAR_1->packey[VAR_6].p, VAR_1->buf[VAR_8], VAR_4);

    VAR_1->packey[VAR_6].VAR_1 = VAR_1;

    VAR_1->packey[VAR_6].VAR_6 = VAR_6;



    dev = usb_find_device(&VAR_0->port, VAR_1->packey[VAR_6].p.devaddr);

    VAR_7 = usb_handle_packet(dev, &VAR_1->packey[VAR_6].p);



    if (VAR_7 == USB_RET_ASYNC) {

        VAR_1->status[VAR_6] = VAR_4;

        return;

    }



    VAR_1->status[VAR_6] = VAR_7;

    musb_schedule_cb(&VAR_0->port, &VAR_1->packey[VAR_6].p);

}

static void FUNC_0(MUSBState *VAR_0, MUSBEndPoint *VAR_1,
int VAR_2, int VAR_3, int VAR_4, USBCallback VAR_5, int VAR_6)
{ USBDevice *dev; int VAR_7; int VAR_8 = VAR_2 && VAR_6; int VAR_9; VAR_9 = VAR_2 ? (VAR_1->type[VAR_8] >> 4) & 3 : 0; VAR_1->timeout[VAR_6] = musb_timeout(VAR_9,
VAR_1->type[VAR_8] >> 6, VAR_1->interval[VAR_8]); VAR_1->interrupt[VAR_6] = VAR_9 == USB_ENDPOINT_XFER_INT; VAR_1->delayed_cb[VAR_6] = VAR_5; usb_packet_setup(&VAR_1->packey[VAR_6].p, VAR_3, VAR_1->faddr[VAR_8],
VAR_1->type[VAR_8] & 0xf); usb_packet_addbuf(&VAR_1->packey[VAR_6].p, VAR_1->buf[VAR_8], VAR_4); VAR_1->packey[VAR_6].VAR_1 = VAR_1; VAR_1->packey[VAR_6].VAR_6 = VAR_6; dev = usb_find_device(&VAR_0->port, VAR_1->packey[VAR_6].p.devaddr); VAR_7 = usb_handle_packet(dev, &VAR_1->packey[VAR_6].p); if (VAR_7 == USB_RET_ASYNC) { VAR_1->status[VAR_6] = VAR_4; return; } VAR_1->status[VAR_6] = VAR_7; musb_schedule_cb(&VAR_0->port, &VAR_1->packey[VAR_6].p); }