From 61c2ac571429ff5d6ef4ed42803af58df74373e0 Mon Sep 17 00:00:00 2001 From: Kano Date: Fri, 27 Sep 2013 14:57:22 +1000 Subject: [PATCH 1/3] usbutils - usb_bulk_transfer fix the buf/data fix --- usbutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usbutils.c b/usbutils.c index ba2c9d33..2b3390bd 100644 --- a/usbutils.c +++ b/usbutils.c @@ -2288,7 +2288,7 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo, STATS_TIMEVAL(&tv_start); cg_rlock(&cgusb_fd_lock); - err = libusb_bulk_transfer(dev_handle, endpoint, data, + err = libusb_bulk_transfer(dev_handle, endpoint, buf, length, transferred, timeout); errn = errno; cg_runlock(&cgusb_fd_lock); From 9b9dde1667cf37b6462a575ad3d57e3ff5b0c568 Mon Sep 17 00:00:00 2001 From: Kano Date: Fri, 27 Sep 2013 16:56:25 +1000 Subject: [PATCH 2/3] usbutils - fix USBDEBUG warnings --- usbutils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usbutils.c b/usbutils.c index 2b3390bd..b0a4e95f 100644 --- a/usbutils.c +++ b/usbutils.c @@ -2343,7 +2343,7 @@ int _usb_read(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_t usbdev = cgpu->usbdev; ftdi = (usbdev->usb_type == USB_TYPE_FTDI); - USBDEBUG("USB debug: _usb_read(%s (nodev=%s),intinfo=%d,epinfo=%d,buf=%p,bufsiz=%zu,proc=%p,timeout=%u,end=%s,cmd=%s,ftdi=%s,readonce=%s)", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), intinfo, epinfo, buf, bufsiz, processed, timeout, end ? (char *)str_text((char *)end) : "NULL", usb_cmdname(cmd), bool_str(ftdi), bool_str(readonce)); + USBDEBUG("USB debug: _usb_read(%s (nodev=%s),intinfo=%d,epinfo=%d,buf=%p,bufsiz=%d,proc=%p,timeout=%u,end=%s,cmd=%s,ftdi=%s,readonce=%s)", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), intinfo, epinfo, buf, (int)bufsiz, processed, timeout, end ? (char *)str_text((char *)end) : "NULL", usb_cmdname(cmd), bool_str(ftdi), bool_str(readonce)); if (bufsiz > USB_MAX_READ) quit(1, "%s USB read request %d too large (max=%d)", cgpu->drv->name, (int)bufsiz, USB_MAX_READ); @@ -2402,7 +2402,7 @@ int _usb_read(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_t cgtime(&tv_finish); ptr[got] = '\0'; - USBDEBUG("USB debug: @_usb_read(%s (nodev=%s)) first=%s err=%d%s got=%d ptr='%s' usbbufread=%zu", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), bool_str(first), err, isnodev(err), got, (char *)str_text((char *)ptr), usbbufread); + USBDEBUG("USB debug: @_usb_read(%s (nodev=%s)) first=%s err=%d%s got=%d ptr='%s' usbbufread=%d", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), bool_str(first), err, isnodev(err), got, (char *)str_text((char *)ptr), (int)usbbufread); IOERR_CHECK(cgpu, err); @@ -2505,7 +2505,7 @@ int _usb_read(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_t cgtime(&tv_finish); ptr[got] = '\0'; - USBDEBUG("USB debug: @_usb_read(%s (nodev=%s)) first=%s err=%d%s got=%d ptr='%s' usbbufread=%zu", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), bool_str(first), err, isnodev(err), got, (char *)str_text((char *)ptr), usbbufread); + USBDEBUG("USB debug: @_usb_read(%s (nodev=%s)) first=%s err=%d%s got=%d ptr='%s' usbbufread=%d", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), bool_str(first), err, isnodev(err), got, (char *)str_text((char *)ptr), (int)usbbufread); IOERR_CHECK(cgpu, err); @@ -2597,7 +2597,7 @@ int _usb_write(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_ DEVLOCK(cgpu, pstate); - USBDEBUG("USB debug: _usb_write(%s (nodev=%s),intinfo=%d,epinfo=%d,buf='%s',bufsiz=%zu,proc=%p,timeout=%u,cmd=%s)", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), intinfo, epinfo, (char *)str_text(buf), bufsiz, processed, timeout, usb_cmdname(cmd)); + USBDEBUG("USB debug: _usb_write(%s (nodev=%s),intinfo=%d,epinfo=%d,buf='%s',bufsiz=%d,proc=%p,timeout=%u,cmd=%s)", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), intinfo, epinfo, (char *)str_text(buf), (int)bufsiz, processed, timeout, usb_cmdname(cmd)); *processed = 0; From f9476743c2c4d30490f8bfb56eb16c8b4c9eaead Mon Sep 17 00:00:00 2001 From: Kano Date: Fri, 27 Sep 2013 18:48:41 +1000 Subject: [PATCH 3/3] icarus ensure all cmr interfaces are initialised properly --- driver-icarus.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/driver-icarus.c b/driver-icarus.c index 8ffe3908..59fd5541 100644 --- a/driver-icarus.c +++ b/driver-icarus.c @@ -297,7 +297,7 @@ static void icarus_initialise(struct cgpu_info *icarus, int baud) return; // Latency - usb_ftdi_set_latency(icarus); + _usb_ftdi_set_latency(icarus, info->intinfo); if (icarus->usbinfo.nodev) return; @@ -890,13 +890,6 @@ static bool icarus_detect_one(struct libusb_device *dev, struct usb_find_devices cgtmp->usbinfo.usbstat = USB_NOSTAT; - if (!add_cgpu(cgtmp)) { - usb_uninit(cgtmp); - continue; - } - - update_usb_stats(cgtmp); - intmp = (struct ICARUS_INFO *)malloc(sizeof(struct ICARUS_INFO)); if (unlikely(!intmp)) quit(1, "Failed2 to malloc ICARUS_INFO"); @@ -907,6 +900,16 @@ static bool icarus_detect_one(struct libusb_device *dev, struct usb_find_devices memcpy(intmp, info, sizeof(struct ICARUS_INFO)); intmp->intinfo = i; + + icarus_initialise(cgtmp, baud); + + if (!add_cgpu(cgtmp)) { + usb_uninit(cgtmp); + free(intmp); + continue; + } + + update_usb_stats(cgtmp); } }