usbutils use a heap buffer for bulk read rather than stack
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
diff --git a/usbutils.c b/usbutils.c
index 031f544..25e8f02 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2292,9 +2292,7 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro
bool first = true;
char *search;
int endlen;
-
- // We add 4: 1 for null, 2 for FTDI status and 1 to round to 4 bytes
- unsigned char usbbuf[USB_MAX_READ+4], *ptr;
+ unsigned char *ptr, *usbbuf = cgpu->usbinfo.bulkbuf;
size_t usbbufread;
DEVLOCK(cgpu, pstate);
diff --git a/usbutils.h b/usbutils.h
index 9f3c283..75f1e51 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -184,6 +184,8 @@ struct cg_usb_device {
#define USB_NOSTAT 0
+#define USB_MAX_READ 8192
+
struct cg_usb_info {
uint8_t bus_number;
uint8_t device_address;
@@ -215,6 +217,13 @@ struct cg_usb_info {
double total_read_delay;
uint64_t write_delay_count;
double total_write_delay;
+
+ /*
+ * We add 4: 1 for null, 2 for FTDI status and 1 to round to 4 bytes
+ * If a single device ever has multiple end points then it will need
+ * multiple of these
+ */
+ unsigned char bulkbuf[USB_MAX_READ+4];
};
enum usb_cmds {