From 58bb4d486de43d2bb09acd621b6f4310e1a9d526 Mon Sep 17 00:00:00 2001 From: Kano Date: Wed, 5 Jun 2013 01:44:50 +1000 Subject: [PATCH] usb_ftdi_set_latency LOG_ERRs if called incorrectly --- usbutils.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/usbutils.c b/usbutils.c index fa98014e..13167af0 100644 --- a/usbutils.c +++ b/usbutils.c @@ -2493,6 +2493,18 @@ int usb_ftdi_set_latency(struct cgpu_info *cgpu) { int err; + if (cgpu->usbdev->usb_type != USB_TYPE_FTDI) { + applog(LOG_ERR, "%s: cgid %d latency request on non-FTDI device", + cgpu->drv->name, cgpu->cgminer_id); + return LIBUSB_ERROR_NOT_SUPPORTED; + } + + if (cgpu->usbdev->found->latency == LATENCY_UNUSED) { + applog(LOG_ERR, "%s: cgid %d invalid latency (UNUSED)", + cgpu->drv->name, cgpu->cgminer_id); + return LIBUSB_ERROR_NOT_SUPPORTED; + } + err = usb_transfer_data(cgpu, FTDI_TYPE_OUT, FTDI_REQUEST_LATENCY, cgpu->usbdev->found->latency, cgpu->usbdev->found->interface, NULL, 0, C_LATENCY);