Don't bother having a separate cancellable transfer struct for usb transfers, simply include the list in the usb_transfer struct.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/usbutils.c b/usbutils.c
index 19d1854..f5ccbd6 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -98,11 +98,6 @@
int cgusb_transfers;
static struct list_head ct_list;
-struct cancellable_transfer {
- cgsem_t *cgsem;
- struct list_head list;
-};
-
#ifdef USE_BFLSC
// N.B. transfer size is 512 with USB2.0, but only 64 with USB1.1
static struct usb_epinfo bas_epinfos[] = {
@@ -2219,7 +2214,7 @@ struct usb_transfer {
cgsem_t cgsem;
struct libusb_transfer *transfer;
bool cancellable;
- struct cancellable_transfer ct;
+ struct list_head list;
};
static void init_usb_transfer(struct usb_transfer *ut)
@@ -2239,7 +2234,7 @@ static void complete_usb_transfer(struct usb_transfer *ut)
cg_wlock(&cgusb_fd_lock);
cgusb_transfers--;
if (ut->cancellable)
- list_del(&ut->ct.list);
+ list_del(&ut->list);
cg_wunlock(&cgusb_fd_lock);
}
@@ -2311,8 +2306,8 @@ static int usb_submit_transfer(struct usb_transfer *ut, struct libusb_transfer *
cgusb_transfers++;
if (cancellable) {
ut->cancellable = true;
- INIT_LIST_HEAD(&ut->ct.list);
- list_add(&ct_list, &ut->ct.list);
+ INIT_LIST_HEAD(&ut->list);
+ list_add(&ct_list, &ut->list);
} else
ut->cancellable = false;
cg_wunlock(&cgusb_fd_lock);