Cancel any SPI transfers in progress in nanofury after initial setup.
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
diff --git a/driver-bitfury.c b/driver-bitfury.c
index d5fbf32..765724f 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -277,7 +277,7 @@ out_close:
return false;
}
-static bool nf1_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
+static bool nf1_detect_one(struct cgpu_info *bitfury, struct bitfury_info __maybe_unused *info)
{
bool ret = false;
int i;
@@ -285,21 +285,23 @@ static bool nf1_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
/* Set all pins to GPIO mode */
for (i = 0; i < 9; i++) {
if (!mcp2210_set_gpio_pindes(bitfury, i, MCP2210_PIN_GPIO))
- return ret;
+ goto out;
}
/* Set all pins to input mode */
for (i = 0; i < 9; i++) {
if (!mcp2210_set_gpio_pindir(bitfury, i, MCP2210_GPIO_INPUT))
- return ret;
+ goto out;
}
+
+ /* Set LED and PWR pins to output and high */
if (!mcp2210_set_gpio_pindir(bitfury, NF1_PIN_LED, MCP2210_GPIO_OUTPUT))
- return ret;
+ goto out;
if (!mcp2210_set_gpio_pinval(bitfury, NF1_PIN_LED, MCP2210_GPIO_PIN_HIGH))
- return ret;
+ goto out;
if (!mcp2210_set_gpio_pindir(bitfury, NF1_PIN_PWR_EN, MCP2210_GPIO_OUTPUT))
- return ret;
+ goto out;
if (!mcp2210_set_gpio_pinval(bitfury, NF1_PIN_PWR_EN, MCP2210_GPIO_PIN_HIGH))
- return ret;
+ goto out;
if (opt_debug) {
struct gpio_pin gp;
@@ -320,6 +322,10 @@ static bool nf1_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
bitfury->device_id, i, gp.pin[i]);
}
}
+
+ /* Cancel any transfers in progress */
+ if (!mcp2210_spi_cancel(bitfury))
+ goto out;
out:
return ret;
}
diff --git a/mcp2210.h b/mcp2210.h
index 3c811dd..563fdd3 100644
--- a/mcp2210.h
+++ b/mcp2210.h
@@ -51,5 +51,6 @@ bool mcp2210_get_gpio_pinval(struct cgpu_info *cgpu, int pin, int *val);
bool mcp2210_set_gpio_pinval(struct cgpu_info *cgpu, int pin, int val);
bool mcp2210_get_gpio_pindir(struct cgpu_info *cgpu, int pin, int *dir);
bool mcp2210_set_gpio_pindir(struct cgpu_info *cgpu, int pin, int dir);
+bool mcp2210_spi_cancel(struct cgpu_info *cgpu);
#endif /* MCP2210_H */