1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-27 06:54:36 +00:00

Merge pull request #372 from denis2342/claim

libztex: check returnvalue of libusb_claim_interface() and release the
This commit is contained in:
Con Kolivas 2012-12-25 05:12:45 -08:00
commit eaa935b193

View File

@ -370,12 +370,17 @@ static int libztex_configureFpgaHS(struct libztex_device *ztex, const char* firm
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--) {
fp = open_bitstream("ztex", firmware);
if (!fp) {
applog(LOG_ERR, "%s: failed to read bitstream '%s'", ztex->repr, firmware);
libusb_release_interface(ztex->hndl, settings[1]);
return -2;
}
@ -409,6 +414,7 @@ static int libztex_configureFpgaHS(struct libztex_device *ztex, const char* firm
libztex_getFpgaState(ztex, &state);
if (!state.fpgaConfigured) {
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;
}
}
@ -462,7 +468,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);
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;
}
}