Add a usb_reset by cgpu function to usbutils.
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
diff --git a/usbutils.c b/usbutils.c
index a940f1b..c7b1448 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2623,6 +2623,24 @@ err_retry:
return err;
}
+void usb_reset(struct cgpu_info *cgpu)
+{
+ int pstate, err = 0;
+
+ DEVRLOCK(cgpu, pstate);
+ if (!cgpu->usbinfo.nodev) {
+ err = libusb_reset_device(cgpu->usbdev->handle);
+ applog(LOG_WARNING, "%s %i attempted reset got err:(%d) %s",
+ cgpu->drv->name, cgpu->device_id, err, libusb_error_name(err));
+ }
+ if (NODEV(err)) {
+ cg_ruwlock(&cgpu->usbinfo.devlock);
+ release_cgpu(cgpu);
+ DEVWUNLOCK(cgpu, pstate);
+ } else
+ DEVRUNLOCK(cgpu, pstate);
+}
+
int _usb_read(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_t bufsiz,
int *processed, int timeout, const char *end, enum usb_cmds cmd, bool readonce, bool cancellable)
{
diff --git a/usbutils.h b/usbutils.h
index d53d98e..586a469 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -429,6 +429,7 @@ bool usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct usb_find
void usb_detect(struct device_drv *drv, struct cgpu_info *(*device_detect)(struct libusb_device *, struct usb_find_devices *));
struct api_data *api_usb_stats(int *count);
void update_usb_stats(struct cgpu_info *cgpu);
+void usb_reset(struct cgpu_info *cgpu);
int _usb_read(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_t bufsiz, int *processed, int timeout, const char *end, enum usb_cmds cmd, bool readonce, bool cancellable);
int _usb_write(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_t bufsiz, int *processed, int timeout, enum usb_cmds);
int _usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint32_t *data, int siz, unsigned int timeout, enum usb_cmds cmd);