usb-linux: track aurbs in list

This patch adds code to track all async urbs in a linked list,
so we can find them without having to pass around a opaque
pointer to them.  Prerequisite for the cleanups.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2011-05-16 09:13:05 +02:00
parent 9056a2972a
commit 7a8fc83f34
1 changed files with 11 additions and 7 deletions

View File

@ -121,6 +121,7 @@ typedef struct USBHostDevice {
Notifier exit; Notifier exit;
struct endp_data endp_table[MAX_ENDPOINTS]; struct endp_data endp_table[MAX_ENDPOINTS];
QLIST_HEAD(, AsyncURB) aurbs;
/* Host side address */ /* Host side address */
int bus_num; int bus_num;
@ -223,22 +224,27 @@ struct AsyncURB
{ {
struct usbdevfs_urb urb; struct usbdevfs_urb urb;
struct usbdevfs_iso_packet_desc isocpd[ISO_FRAME_DESC_PER_URB]; struct usbdevfs_iso_packet_desc isocpd[ISO_FRAME_DESC_PER_URB];
USBHostDevice *hdev;
QLIST_ENTRY(AsyncURB) next;
/* For regular async urbs */ /* For regular async urbs */
USBPacket *packet; USBPacket *packet;
USBHostDevice *hdev;
/* For buffered iso handling */ /* For buffered iso handling */
int iso_frame_idx; /* -1 means in flight */ int iso_frame_idx; /* -1 means in flight */
}; };
static AsyncURB *async_alloc(void) static AsyncURB *async_alloc(USBHostDevice *s)
{ {
return (AsyncURB *) qemu_mallocz(sizeof(AsyncURB)); AsyncURB *aurb = qemu_mallocz(sizeof(AsyncURB));
aurb->hdev = s;
QLIST_INSERT_HEAD(&s->aurbs, aurb, next);
return aurb;
} }
static void async_free(AsyncURB *aurb) static void async_free(AsyncURB *aurb)
{ {
QLIST_REMOVE(aurb, next);
qemu_free(aurb); qemu_free(aurb);
} }
@ -661,8 +667,7 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket *p)
return usb_host_handle_iso_data(s, p, p->pid == USB_TOKEN_IN); return usb_host_handle_iso_data(s, p, p->pid == USB_TOKEN_IN);
} }
aurb = async_alloc(); aurb = async_alloc(s);
aurb->hdev = s;
aurb->packet = p; aurb->packet = p;
urb = &aurb->urb; urb = &aurb->urb;
@ -787,8 +792,7 @@ static int usb_host_handle_control(USBDevice *dev, USBPacket *p,
return USB_RET_STALL; return USB_RET_STALL;
} }
aurb = async_alloc(); aurb = async_alloc(s);
aurb->hdev = s;
aurb->packet = p; aurb->packet = p;
/* /*