From c74c7423915d6c9a9858af39de6ce6e0768c2106 Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Fri, 18 Mar 2022 01:15:54 +0000 Subject: [PATCH] Simplify hackrf_libusb_transfer_callback. There are now only two possible outcomes to this function: either we successfully resubmitted a transfer, or the transfer is finished and we end up calling transfer_finished(). So we can go ahead and simplify it accordingly. --- host/libhackrf/src/hackrf.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/host/libhackrf/src/hackrf.c b/host/libhackrf/src/hackrf.c index 8a5337dd..e028285a 100644 --- a/host/libhackrf/src/hackrf.c +++ b/host/libhackrf/src/hackrf.c @@ -1755,21 +1755,14 @@ static void LIBUSB_CALL hackrf_libusb_transfer_callback(struct libusb_transfer* // cancelled or restarted, not both. pthread_mutex_unlock(&device->transfer_lock); - if (!resubmit || result < 0) { - transfer_finished(device, usb_transfer); - } - } else { - transfer_finished(device, usb_transfer); + if (resubmit && result == LIBUSB_SUCCESS) + return; } - } else if(usb_transfer->status == LIBUSB_TRANSFER_CANCELLED) { - transfer_finished(device, usb_transfer); - } else { - /* Other cases LIBUSB_TRANSFER_NO_DEVICE - LIBUSB_TRANSFER_ERROR, LIBUSB_TRANSFER_TIMED_OUT - LIBUSB_TRANSFER_STALL, LIBUSB_TRANSFER_OVERFLOW .... - */ - transfer_finished(device, usb_transfer); } + + // Unless we resubmitted this transfer and returned above, + // it's now finished. + transfer_finished(device, usb_transfer); } static int kill_transfer_thread(hackrf_device* device)