Revision 079d0b7f hw/usb.c

b/hw/usb.c
140 140
    int request, value, index;
141 141
    int ret = 0;
142 142

  
143
    assert(p->devep == 0);
143
    assert(p->ep->nr == 0);
144 144

  
145 145
    request = (s->setup_buf[0] << 8) | s->setup_buf[1];
146 146
    value   = (s->setup_buf[3] << 8) | s->setup_buf[2];
......
186 186

  
187 187
static int do_token_out(USBDevice *s, USBPacket *p)
188 188
{
189
    assert(p->devep == 0);
189
    assert(p->ep->nr == 0);
190 190

  
191 191
    switch(s->setup_state) {
192 192
    case SETUP_STATE_ACK:
......
289 289
    if (dev == NULL) {
290 290
        return USB_RET_NODEV;
291 291
    }
292
    assert(dev->addr == p->devaddr);
292
    assert(dev == p->ep->dev);
293 293
    assert(dev->state == USB_STATE_DEFAULT);
294 294
    assert(p->state == USB_PACKET_SETUP);
295 295

  
296
    if (p->devep == 0) {
296
    if (p->ep->nr == 0) {
297 297
        /* control pipe */
298 298
        switch (p->pid) {
299 299
        case USB_TOKEN_SETUP:
......
315 315
    }
316 316

  
317 317
    if (ret == USB_RET_ASYNC) {
318
        p->ep = usb_ep_get(dev, p->pid, p->devep);
319 318
        p->state = USB_PACKET_ASYNC;
320 319
    }
321 320
    return ret;
......
347 346
    qemu_iovec_init(&p->iov, 1);
348 347
}
349 348

  
350
void usb_packet_setup(USBPacket *p, int pid, uint8_t addr, uint8_t ep)
349
void usb_packet_setup(USBPacket *p, int pid, USBEndpoint *ep)
351 350
{
352 351
    assert(!usb_packet_is_inflight(p));
353 352
    p->state = USB_PACKET_SETUP;
354 353
    p->pid = pid;
355
    p->devaddr = addr;
356
    p->devep = ep;
354
    p->ep = ep;
357 355
    p->result = 0;
358 356
    qemu_iovec_reset(&p->iov);
359 357
}
......
464 462

  
465 463
struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid, int ep)
466 464
{
467
    struct USBEndpoint *eps = pid == USB_TOKEN_IN ? dev->ep_in : dev->ep_out;
465
    struct USBEndpoint *eps;
466

  
467
    if (dev == NULL) {
468
        return NULL;
469
    }
470
    eps = (pid == USB_TOKEN_IN) ? dev->ep_in : dev->ep_out;
468 471
    if (ep == 0) {
469 472
        return &dev->ep_ctl;
470 473
    }

Also available in: Unified diff