mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 06:48:05 +00:00
Merge pull request #348 from denis2342/ztex
libztex: removed an unused struct member (ztex->valid)
This commit is contained in:
commit
031ba75cad
31
libztex.c
31
libztex.c
@ -100,6 +100,19 @@ enum check_result
|
|||||||
CHECK_RESCAN,
|
CHECK_RESCAN,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool libztex_firmwareReset(struct libusb_device_handle *hndl, bool enable)
|
||||||
|
{
|
||||||
|
uint8_t reset = enable;
|
||||||
|
int cnt = libusb_control_transfer(hndl, 0x40, 0xA0, 0xE600, 0, &reset, 1, 1000);
|
||||||
|
if (cnt < 0)
|
||||||
|
{
|
||||||
|
applog(LOG_ERR, "Ztex reset %d failed: %s", libusb_error_name(cnt), enable);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static enum check_result libztex_checkDevice(struct libusb_device *dev)
|
static enum check_result libztex_checkDevice(struct libusb_device *dev)
|
||||||
{
|
{
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
@ -245,14 +258,8 @@ static enum check_result libztex_checkDevice(struct libusb_device *dev)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset 1
|
if (libztex_firmwareReset(hndl, true))
|
||||||
buf[0] = 1;
|
|
||||||
cnt = libusb_control_transfer(hndl, 0x40, 0xA0, 0xE600, 0, buf, 1,1000);
|
|
||||||
if (cnt < 0)
|
|
||||||
{
|
|
||||||
applog(LOG_ERR, "Ztex reset 1 failed: %s", libusb_error_name(cnt));
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < length; i+= 256) {
|
for (i = 0; i < length; i+= 256) {
|
||||||
// firmware wants data in small chunks like 256 bytes
|
// firmware wants data in small chunks like 256 bytes
|
||||||
@ -265,14 +272,8 @@ static enum check_result libztex_checkDevice(struct libusb_device *dev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset 0
|
if (libztex_firmwareReset(hndl, false))
|
||||||
buf[0] = 0;
|
|
||||||
err = libusb_control_transfer(hndl, 0x40, 0xA0, 0xE600, 0, buf, 1,1000);
|
|
||||||
if (err < 0)
|
|
||||||
{
|
|
||||||
applog(LOG_ERR, "Ztex reset 0 failed: %s", libusb_error_name(err));
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
|
|
||||||
applog(LOG_ERR, "Ztex device: succesfully wrote firmware");
|
applog(LOG_ERR, "Ztex device: succesfully wrote firmware");
|
||||||
ret = CHECK_RESCAN;
|
ret = CHECK_RESCAN;
|
||||||
@ -696,7 +697,6 @@ int libztex_prepare_device(struct libusb_device *dev, struct libztex_device** zt
|
|||||||
newdev->usbbus = libusb_get_bus_number(dev);
|
newdev->usbbus = libusb_get_bus_number(dev);
|
||||||
newdev->usbaddress = libusb_get_device_address(dev);
|
newdev->usbaddress = libusb_get_device_address(dev);
|
||||||
sprintf(newdev->repr, "ZTEX %s-1", newdev->snString);
|
sprintf(newdev->repr, "ZTEX %s-1", newdev->snString);
|
||||||
newdev->valid = true;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -777,7 +777,6 @@ int libztex_scanDevices(struct libztex_dev_list*** devs_p)
|
|||||||
|
|
||||||
ztex->bitFileName = NULL;
|
ztex->bitFileName = NULL;
|
||||||
ztex->numberOfFpgas = -1;
|
ztex->numberOfFpgas = -1;
|
||||||
ztex->valid = false;
|
|
||||||
|
|
||||||
err = libztex_prepare_device(list[usbdevices[i]], &ztex);
|
err = libztex_prepare_device(list[usbdevices[i]], &ztex);
|
||||||
if (unlikely(err != 0)) {
|
if (unlikely(err != 0)) {
|
||||||
|
@ -47,7 +47,6 @@ struct libztex_device {
|
|||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
struct libztex_device *root;
|
struct libztex_device *root;
|
||||||
int16_t fpgaNum;
|
int16_t fpgaNum;
|
||||||
bool valid;
|
|
||||||
struct libusb_device_descriptor descriptor;
|
struct libusb_device_descriptor descriptor;
|
||||||
libusb_device_handle *hndl;
|
libusb_device_handle *hndl;
|
||||||
unsigned char usbbus;
|
unsigned char usbbus;
|
||||||
|
Loading…
Reference in New Issue
Block a user