Browse Source

Klondike update driver code to current git

nfactor-troky
Kano 11 years ago
parent
commit
4d2fa5bf17
  1. 27
      cgminer/driver-klondike.c

27
cgminer/driver-klondike.c

@ -142,7 +142,7 @@ static char *SendCmdGetReply(struct cgpu_info *klncgpu, char Cmd, int device, in @@ -142,7 +142,7 @@ static char *SendCmdGetReply(struct cgpu_info *klncgpu, char Cmd, int device, in
applog(LOG_ERR, "%s (%s) Cmd:%c Dev:%d, write failed (%d:%d)", klncgpu->drv->dname, klncgpu->device_path, Cmd, device, sent, err);
}
while(retries-- > 0 && klninfo->shutdown == false) {
nmsleep(REPLY_WAIT_TIME);
cgsleep_ms(REPLY_WAIT_TIME);
while(*(klninfo->replies + chkreply*REPLY_BUFSIZE) != Cmd || *(klninfo->replies + chkreply*REPLY_BUFSIZE + 2) != device) {
if (++chkreply == MAX_REPLY_COUNT)
chkreply = 0;
@ -212,7 +212,7 @@ static bool klondike_init(struct cgpu_info *klncgpu) @@ -212,7 +212,7 @@ static bool klondike_init(struct cgpu_info *klncgpu)
int size = 2;
if (opt_klondike_options != NULL) { // boundaries are checked by device, with valid values returned
sscanf(opt_klondike_options, "%hu,%lf,%lf,%hhu", &cfgset.hashclock, &temp1, &temp2, &cfgset.fantarget);
sscanf(opt_klondike_options, "%hu:%lf:%lf:%hhu", &cfgset.hashclock, &temp1, &temp2, &cfgset.fantarget);
cfgset.temptarget = cvtCToKln(temp1);
cfgset.tempcritical = cvtCToKln(temp2);
cfgset.fantarget = (int)255*cfgset.fantarget/100;
@ -270,7 +270,7 @@ static bool klondike_detect_one(struct libusb_device *dev, struct usb_find_devic @@ -270,7 +270,7 @@ static bool klondike_detect_one(struct libusb_device *dev, struct usb_find_devic
if (err < 0 || sent != 2) {
applog(LOG_ERR, "%s (%s) detect write failed (%d:%d)", klncgpu->drv->dname, devpath, sent, err);
}
nmsleep(REPLY_WAIT_TIME*10);
cgsleep_ms(REPLY_WAIT_TIME*10);
err = usb_read(klncgpu, reply, REPLY_SIZE, &recd, C_GETRESULTS);
if (err < 0) {
applog(LOG_ERR, "%s (%s) detect read failed (%d:%d)", klncgpu->drv->dname, devpath, recd, err);
@ -300,7 +300,7 @@ static void klondike_detect(void) @@ -300,7 +300,7 @@ static void klondike_detect(void)
usb_detect(&klondike_drv, klondike_detect_one);
}
static void klondike_identify(struct cgpu_info *klncgpu)
static void klondike_identify(__maybe_unused struct cgpu_info *klncgpu)
{
//SendCmdGetReply(klncgpu, 'I', 0, 0, NULL);
}
@ -352,9 +352,9 @@ static void *klondike_get_replies(void *userdata) @@ -352,9 +352,9 @@ static void *klondike_get_replies(void *userdata)
replybuf[0] = 0;
err = usb_read(klncgpu, replybuf+1, REPLY_SIZE, &recd, C_GETRESULTS);
if (recd == REPLY_SIZE) {
if (!err && recd == REPLY_SIZE) {
if (opt_log_level <= LOG_DEBUG) {
char *hexdata = bin2hex(replybuf+1, recd);
char *hexdata = bin2hex((unsigned char *)(replybuf+1), recd);
applog(LOG_DEBUG, "%s (%s) reply [%s:%s]", klncgpu->drv->dname, klncgpu->device_path, replybuf+1, hexdata);
free(hexdata);
}
@ -389,7 +389,6 @@ static bool klondike_thread_prepare(struct thr_info *thr) @@ -389,7 +389,6 @@ static bool klondike_thread_prepare(struct thr_info *thr)
{
struct cgpu_info *klncgpu = thr->cgpu;
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
struct timeval now;
if (thr_info_create(&(klninfo->replies_thr), NULL, klondike_get_replies, (void *)klncgpu)) {
applog(LOG_ERR, "%s%i: thread create failed", klncgpu->drv->name, klncgpu->device_id);
@ -398,7 +397,7 @@ static bool klondike_thread_prepare(struct thr_info *thr) @@ -398,7 +397,7 @@ static bool klondike_thread_prepare(struct thr_info *thr)
pthread_detach(klninfo->replies_thr.pth);
// let the listening get started
nmsleep(100);
cgsleep_ms(100);
return klondike_init(klncgpu);
}
@ -468,7 +467,7 @@ static bool klondike_send_work(struct cgpu_info *klncgpu, int dev, struct work * @@ -468,7 +467,7 @@ static bool klondike_send_work(struct cgpu_info *klncgpu, int dev, struct work *
// remove old work
HASH_ITER(hh, klncgpu->queued_work, work, tmp) {
if (work->queued && (work->subid == (dev*256 + ((klninfo->devinfo[dev].nextworkid-2*MAX_WORK_COUNT) & 0xFF))))
if (work->queued && (work->subid == (int)(dev*256 + ((klninfo->devinfo[dev].nextworkid-2*MAX_WORK_COUNT) & 0xFF))))
work_completed(klncgpu, work);
}
return true;
@ -508,7 +507,7 @@ static int64_t klondike_scanwork(struct thr_info *thr) @@ -508,7 +507,7 @@ static int64_t klondike_scanwork(struct thr_info *thr)
if (klncgpu->usbinfo.nodev)
return -1;
restart_wait(200);
restart_wait(thr, 200);
if (klninfo->status != NULL) {
rd_lock(&(klninfo->stat_lock));
for(dev = 0; dev <= klninfo->status->slavecount; dev++) {
@ -528,7 +527,7 @@ static int64_t klondike_scanwork(struct thr_info *thr) @@ -528,7 +527,7 @@ static int64_t klondike_scanwork(struct thr_info *thr)
}
static void get_klondike_statline_before(char *buf, struct cgpu_info *klncgpu)
static void get_klondike_statline_before(char *buf, size_t siz, struct cgpu_info *klncgpu)
{
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
uint8_t temp = 0xFF;
@ -547,7 +546,7 @@ static void get_klondike_statline_before(char *buf, struct cgpu_info *klncgpu) @@ -547,7 +546,7 @@ static void get_klondike_statline_before(char *buf, struct cgpu_info *klncgpu)
fan /= klninfo->status->slavecount+1;
rd_unlock(&(klninfo->stat_lock));
tailsprintf(buf, " %3.0fC %3d% | ", cvtKlnToC(temp), fan*100/255);
tailsprintf(buf, siz, " %3.0fC %3d%% | ", cvtKlnToC(temp), fan*100/255);
}
static struct api_data *klondike_api_stats(struct cgpu_info *klncgpu)
@ -573,13 +572,13 @@ static struct api_data *klondike_api_stats(struct cgpu_info *klncgpu) @@ -573,13 +572,13 @@ static struct api_data *klondike_api_stats(struct cgpu_info *klncgpu)
unsigned int iFan = (unsigned int)100 * klninfo->cfg[dev].fantarget / 255;
sprintf(buf, "Fan Percent %d", dev);
root = api_add_int(root, buf, &iFan, true);
root = api_add_int(root, buf, (int *)(&iFan), true);
iFan = 0;
if (klninfo->status[dev].fanspeed > 0)
iFan = (unsigned int)TACH_FACTOR / klninfo->status[dev].fanspeed;
sprintf(buf, "Fan RPM %d", dev);
root = api_add_int(root, buf, &iFan, true);
root = api_add_int(root, buf, (int *)(&iFan), true);
if (klninfo->devinfo[dev].chipstats != NULL) {
char data[128];

Loading…
Cancel
Save