Browse Source

Merge remote-tracking branch 'denis2342/claim' into bfgminer

Luke Dashjr 13 years ago
parent
commit
fcbaa629aa
1 changed files with 8 additions and 2 deletions
  1. 8 2
      libztex.c

+ 8 - 2
libztex.c

@@ -374,12 +374,17 @@ static int libztex_configureFpgaHS(struct libztex_device *ztex, const char* firm
 		return cnt;
 		return cnt;
 	}
 	}
 
 
-	libusb_claim_interface(ztex->hndl, settings[1]);
+	err = libusb_claim_interface(ztex->hndl, settings[1]);
+	if (err != LIBUSB_SUCCESS) {
+		applog(LOG_ERR, "%s: failed to claim interface for hs transfer", ztex->repr);
+		return -4;
+	}
 
 
 	for (tries = 3; tries > 0; tries--) {
 	for (tries = 3; tries > 0; tries--) {
 		fp = open_bitstream("ztex", firmware);
 		fp = open_bitstream("ztex", firmware);
 		if (!fp) {
 		if (!fp) {
 			applog(LOG_ERR, "%s: failed to read bitstream '%s'", ztex->repr, firmware);
 			applog(LOG_ERR, "%s: failed to read bitstream '%s'", ztex->repr, firmware);
+			libusb_release_interface(ztex->hndl, settings[1]);
 			return -2;
 			return -2;
 		}
 		}
 
 
@@ -413,6 +418,7 @@ static int libztex_configureFpgaHS(struct libztex_device *ztex, const char* firm
 		libztex_getFpgaState(ztex, &state);
 		libztex_getFpgaState(ztex, &state);
 		if (!state.fpgaConfigured) {
 		if (!state.fpgaConfigured) {
 			applog(LOG_ERR, "%s: HS FPGA configuration failed: DONE pin does not go high", ztex->repr);
 			applog(LOG_ERR, "%s: HS FPGA configuration failed: DONE pin does not go high", ztex->repr);
+			libusb_release_interface(ztex->hndl, settings[1]);
 			return -3;
 			return -3;
 		}
 		}
 	}
 	}
@@ -466,7 +472,7 @@ static int libztex_configureFpgaLS(struct libztex_device *ztex, const char* firm
 			cnt = libusb_control_transfer(ztex->hndl, 0x40, 0x32, 0, 0, buf, length, 5000);
 			cnt = libusb_control_transfer(ztex->hndl, 0x40, 0x32, 0, 0, buf, length, 5000);
 			if (cnt != length)
 			if (cnt != length)
 			{
 			{
-				applog(LOG_ERR, "%s: Failed send hs fpga data", ztex->repr);
+				applog(LOG_ERR, "%s: Failed send ls fpga data", ztex->repr);
 				break;
 				break;
 			}
 			}
 		}
 		}