Convert the bitfury driver to use the hash_driver_work version of hash_work.
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
diff --git a/cgminer.c b/cgminer.c
index da4eaad..6ed3523 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -5974,7 +5974,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
cgtime(&work->tv_staged);
}
-static struct work *get_work(struct thr_info *thr, const int thr_id)
+struct work *get_work(struct thr_info *thr, const int thr_id)
{
struct work *work = NULL;
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 0cb9fef..e5757f5 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -220,18 +220,24 @@ static bool bitfury_checkresults(struct thr_info *thr, struct work *work, uint32
return false;
}
-static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
- int64_t __maybe_unused max_nonce)
+static int64_t bitfury_scanwork(struct thr_info *thr)
{
struct cgpu_info *bitfury = thr->cgpu;
struct bitfury_info *info = bitfury->device_data;
struct timeval tv_now;
+ struct work *work;
double nonce_rate;
int64_t ret = 0;
int amount, i;
char buf[45];
int ms_diff;
+ work = get_work(thr, thr->id);
+ if (unlikely(thr->work_restart)) {
+ free_work(work);
+ return 0;
+ }
+
buf[0] = 'W';
memcpy(buf + 1, work->midstate, 32);
memcpy(buf + 33, work->data + 64, 12);
@@ -298,8 +304,7 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
cascade:
for (i = BF1ARRAY_SIZE; i > 0; i--)
info->prevwork[i] = info->prevwork[i - 1];
- info->prevwork[0] = copy_work(work);
- work->blk.nonce = 0xffffffff;
+ info->prevwork[0] = work;
info->cycles++;
info->total_nonces += info->nonces;
@@ -358,7 +363,8 @@ struct device_drv bitfury_drv = {
.dname = "bitfury",
.name = "BF1",
.drv_detect = bitfury_detect,
- .scanhash = bitfury_scanhash,
+ .hash_work = &hash_driver_work,
+ .scanwork = bitfury_scanwork,
.get_api_stats = bitfury_api_stats,
.reinit_device = bitfury_init,
.thread_shutdown = bitfury_shutdown,
diff --git a/miner.h b/miner.h
index a32103a..ca7738d 100644
--- a/miner.h
+++ b/miner.h
@@ -1384,6 +1384,7 @@ extern void submit_tested_work(struct thr_info *thr, struct work *work);
extern bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
extern bool submit_noffset_nonce(struct thr_info *thr, struct work *work, uint32_t nonce,
int noffset);
+extern struct work *get_work(struct thr_info *thr, const int thr_id);
extern struct work *get_queued(struct cgpu_info *cgpu);
extern struct work *__find_work_bymidstate(struct work *que, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
extern struct work *find_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);