From a9835b04724f541a24d0a9749895da97cd77c4d3 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 20 Oct 2013 11:46:45 +1100 Subject: [PATCH] Implement a shutdown routine for the hashfast driver. --- driver-hashfast.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/driver-hashfast.c b/driver-hashfast.c index 558a5e10..048ea773 100644 --- a/driver-hashfast.c +++ b/driver-hashfast.c @@ -755,12 +755,28 @@ static void hfa_init(struct cgpu_info *hashfast) usb_buffer_enable(hashfast); } +static void hfa_free_all_work(struct hashfast_info *info) +{ + while (info->device_sequence_tail != info->hash_sequence_head) { + struct work *work; + + if (++info->hash_sequence_tail >= info->num_sequence) + info->hash_sequence_tail = 0; + if (unlikely(!(work = info->works[info->hash_sequence_tail]))) + break; + free_work(work); + info->works[info->hash_sequence_tail] = NULL; + } +} + static void hfa_shutdown(struct thr_info *thr) { struct cgpu_info *hashfast = thr->cgpu; struct hashfast_info *info = hashfast->device_data; + hfa_send_frame(hashfast, HF_USB_CMD(OP_USB_SHUTDOWN), 0, NULL, 0); pthread_join(info->read_thr, NULL); + hfa_free_all_work(info); } struct device_drv hashfast_drv = {