USB usb_init() consistent err/warning/debug messages
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
diff --git a/usbutils.c b/usbutils.c
index 422962f..31489a0 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -781,11 +781,15 @@ bool usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct usb_find
const struct libusb_interface_descriptor *idesc;
const struct libusb_endpoint_descriptor *epdesc;
unsigned char strbuf[STRBUFLEN+1];
+ char devstr[STRBUFLEN+1];
int err, i, j, k;
cgpu->usbinfo.bus_number = libusb_get_bus_number(dev);
cgpu->usbinfo.device_address = libusb_get_device_address(dev);
+ sprintf(devstr, "- %s device %d:%d", found->name,
+ cgpu->usbinfo.bus_number, cgpu->usbinfo.device_address);
+
cgusb = calloc(1, sizeof(*cgusb));
cgusb->found = found;
@@ -793,7 +797,9 @@ bool usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct usb_find
err = libusb_get_device_descriptor(dev, cgusb->descriptor);
if (err) {
- applog(LOG_ERR, "USB init failed to get descriptor, err %d", err);
+ applog(LOG_DEBUG,
+ "USB init failed to get descriptor, err %d %s",
+ err, devstr);
goto dame;
}
@@ -801,31 +807,39 @@ bool usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct usb_find
if (err) {
switch (err) {
case LIBUSB_ERROR_ACCESS:
- applog(LOG_ERR, "USB init open device failed, err %d, you dont have priviledge to access the device", err);
+ applog(LOG_ERR,
+ "USB init open device failed, err %d, "
+ "you dont have priviledge to access %s",
+ err, devstr);
break;
#ifdef WIN32
// Windows specific message
case LIBUSB_ERROR_NOT_SUPPORTED:
- applog(LOG_ERR, "USB init, open device failed, err %d, you need to install a Windows USB driver for the device", err);
+ applog(LOG_ERR,
+ "USB init, open device failed, err %d, "
+ "you need to install a Windows USB driver for %s",
+ err, devstr);
break;
#endif
default:
- applog(LOG_ERR, "USB init, open device failed, err %d", err);
+ applog(LOG_DEBUG,
+ "USB init, open failed, err %d %s",
+ err, devstr);
}
goto dame;
}
if (libusb_kernel_driver_active(cgusb->handle, found->config) == 1) {
- applog(LOG_DEBUG, "USB init, kernel attached ...");
+ applog(LOG_DEBUG, "USB init, kernel attached ... %s", devstr);
err = libusb_detach_kernel_driver(cgusb->handle, found->config);
- if (err == 0)
- applog(LOG_DEBUG, "USB init, kernel detached successfully");
- else {
+ if (err == 0) {
+ applog(LOG_DEBUG,
+ "USB init, kernel detached successfully %s",
+ devstr);
+ } else {
applog(LOG_WARNING,
- "USB init, kernel detach failed, err %s - %s device %d:%d in use?",
- err, found->name,
- (int)(cgpu->usbinfo.bus_number),
- (int)(cgpu->usbinfo.device_address));
+ "USB init, kernel detach failed, err %d in use? %s",
+ err, devstr);
goto cldame;
}
}
@@ -834,21 +848,23 @@ bool usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct usb_find
if (err) {
switch(err) {
case LIBUSB_ERROR_BUSY:
- applog(LOG_WARNING, "USB init, set config - %s device %d:%d in use",
- found->name, (int)(cgpu->usbinfo.bus_number),
- (int)(cgpu->usbinfo.device_address));
+ applog(LOG_WARNING,
+ "USB init, set config %d in use %s",
+ found->config, devstr);
break;
default:
- applog(LOG_DEBUG, "USB init, failed to set config to %d, err %d",
- found->config, err);
+ applog(LOG_DEBUG,
+ "USB init, failed to set config to %d, err %d %s",
+ found->config, err, devstr);
}
goto cldame;
}
err = libusb_get_active_config_descriptor(dev, &config);
if (err) {
- applog(LOG_DEBUG, "USB init, failed to get config descriptor %d, err %d",
- found->config, err);
+ applog(LOG_DEBUG,
+ "USB init, failed to get config descriptor %d, err %d %s",
+ found->config, err, devstr);
goto cldame;
}
@@ -881,8 +897,17 @@ bool usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct usb_find
err = libusb_claim_interface(cgusb->handle, found->interface);
if (err) {
- applog(LOG_DEBUG, "USB init, claim interface %d failed, err %d",
- found->interface, err);
+ switch(err) {
+ case LIBUSB_ERROR_BUSY:
+ applog(LOG_WARNING,
+ "USB init, claim interface %d in use %s",
+ found->interface, devstr);
+ break;
+ default:
+ applog(LOG_DEBUG,
+ "USB init, claim interface %d failed, err %d %s",
+ found->interface, err, devstr);
+ }
goto cldame;
}
@@ -916,7 +941,10 @@ bool usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct usb_find
// cgusb->fwVersion <- for temp1/temp2 decision? or serial? (driver-modminer.c)
// cgusb->interfaceVersion
- applog(LOG_DEBUG, "USB init device bus_number=%d device_address=%d usbver=%04x prod='%s' manuf='%s' serial='%s'", (int)(cgpu->usbinfo.bus_number), (int)(cgpu->usbinfo.device_address), cgusb->usbver, cgusb->prod_string, cgusb->manuf_string, cgusb->serial_string);
+ applog(LOG_DEBUG,
+ "USB init %s usbver=%04x prod='%s' manuf='%s' serial='%s'",
+ devstr, cgusb->usbver, cgusb->prod_string,
+ cgusb->manuf_string, cgusb->serial_string);
cgpu->usbdev = cgusb;