python/CMakeLists.txt: rework Python development files detection
[libftdi] / src / ftdi_stream.c
index 75f1ace..d146afd 100644 (file)
@@ -3,6 +3,7 @@
                              -------------------
     copyright            : (C) 2009 Micah Dowty 2010 Uwe Bonnes
     email                : opensource@intra2net.com
+    SPDX-License-Identifier: (LGPL-2.1-only AND MIT)
  ***************************************************************************/
 
 /***************************************************************************
@@ -240,16 +241,17 @@ ftdi_readstream(struct ftdi_context *ftdi,
     {
         FTDIProgressInfo  *progress = &state.progress;
         const double progressInterval = 1.0;
-        struct timeval timeout = { 0, ftdi->usb_read_timeout * 1000};
+        struct timeval timeout = { ftdi->usb_read_timeout / 1000,
+            (ftdi->usb_read_timeout % 1000) * 1000 };
         struct timeval now;
 
-        int err = libusb_handle_events_timeout(ftdi->usb_ctx, &timeout);
-        if (err ==  LIBUSB_ERROR_INTERRUPTED)
+        int xfer_err = libusb_handle_events_timeout(ftdi->usb_ctx, &timeout);
+        if (xfer_err ==  LIBUSB_ERROR_INTERRUPTED)
             /* restart interrupted events */
-            err = libusb_handle_events_timeout(ftdi->usb_ctx, &timeout);
+            xfer_err = libusb_handle_events_timeout(ftdi->usb_ctx, &timeout);
         if (!state.result)
         {
-            state.result = err;
+            state.result = xfer_err;
         }
         if (state.activity == 0)
             state.result = 1;