Revision 4ff658fb hw/usb.c

b/hw/usb.c
313 313
{
314 314
    int ret;
315 315

  
316
    assert(p->owner == NULL);
316 317
    ret = dev->info->handle_packet(dev, p);
318
    if (ret == USB_RET_ASYNC) {
319
        if (p->owner == NULL) {
320
            p->owner = dev;
321
        } else {
322
            /* We'll end up here when usb_handle_packet is called
323
             * recursively due to a hub being in the chain.  Nothing
324
             * to do.  Leave p->owner pointing to the device, not the
325
             * hub. */;
326
        }
327
    }
317 328
    return ret;
318 329
}
330

  
331
/* Notify the controller that an async packet is complete.  This should only
332
   be called for packets previously deferred by returning USB_RET_ASYNC from
333
   handle_packet. */
334
void usb_packet_complete(USBDevice *dev, USBPacket *p)
335
{
336
    /* Note: p->owner != dev is possible in case dev is a hub */
337
    assert(p->owner != NULL);
338
    dev->port->ops->complete(dev, p);
339
    p->owner = NULL;
340
}
341

  
342
/* Cancel an active packet.  The packed must have been deferred by
343
   returning USB_RET_ASYNC from handle_packet, and not yet
344
   completed.  */
345
void usb_cancel_packet(USBPacket * p)
346
{
347
    assert(p->owner != NULL);
348
    p->cancel_cb(p, p->cancel_opaque);
349
    p->owner = NULL;
350
}

Also available in: Unified diff