Commit 8e4de07304a7e7fe75c1c8b51cb03990f8b22938

Con Kolivas 2014-01-04T21:26:57

Don't set GPIO pin designations after initial setting in nanofury since the direction and values will be changed.

diff --git a/driver-bitfury.c b/driver-bitfury.c
index 5f59402..da303b6 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -284,7 +284,7 @@ static void nf1_close(struct cgpu_info *bitfury)
 
 	/* Set all pins to input mode, ignoring return code */
 	for (i = 0; i < 9; i++)
-		mcp2210_set_gpio_pindir(bitfury, i, MCP2210_GPIO_INPUT);
+		mcp2210_set_gpio_input(bitfury, i);
 }
 
 static void spi_clear_buf(struct bitfury_info *info)
@@ -424,7 +424,7 @@ static bool nf1_spi_reset(struct cgpu_info *bitfury)
 			return false;
 	}
 
-	if (!mcp2210_set_gpio_pindir(bitfury, NF1_PIN_SCK_OVR, MCP2210_GPIO_INPUT))
+	if (!mcp2210_set_gpio_input(bitfury, NF1_PIN_SCK_OVR))
 		return false;
 
 	return true;
@@ -488,7 +488,7 @@ static bool nf1_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
 	}
 	/* Set all pins to input mode */
 	for (i = 0; i < 9; i++) {
-		if (!mcp2210_set_gpio_pindir(bitfury, i, MCP2210_GPIO_INPUT))
+		if (!mcp2210_set_gpio_input(bitfury, i))
 			goto out;
 	}
 
diff --git a/mcp2210.c b/mcp2210.c
index aef94bd..ede8546 100644
--- a/mcp2210.c
+++ b/mcp2210.c
@@ -108,7 +108,7 @@ bool mcp2210_get_gpio_pin(struct cgpu_info *cgpu, int pin, int *des)
 	return true;
 }
 
-/* Set the designation of one pin */
+/* Set the designation of one pin. This will reset direction and values. */
 bool mcp2210_set_gpio_pindes(struct cgpu_info *cgpu, int pin, int des)
 {
 	char buf[MCP2210_BUFFER_LENGTH];
@@ -175,8 +175,6 @@ bool mcp2210_set_gpio_pinval(struct cgpu_info *cgpu, int pin, int val)
 /* Set one pin to gpio output and set the value */
 bool mcp2210_set_gpio_output(struct cgpu_info *cgpu, int pin, int val)
 {
-	if (!mcp2210_set_gpio_pindes(cgpu, pin, MCP2210_PIN_GPIO))
-		return false;
 	if (!mcp2210_set_gpio_pindir(cgpu, pin, MCP2210_GPIO_OUTPUT))
 		return false;
 	if (!mcp2210_set_gpio_pinval(cgpu, pin, val))
@@ -187,8 +185,6 @@ bool mcp2210_set_gpio_output(struct cgpu_info *cgpu, int pin, int val)
 /* Set one pin to gpio input */
 bool mcp2210_set_gpio_input(struct cgpu_info *cgpu, int pin)
 {
-	if (!mcp2210_set_gpio_pindes(cgpu, pin, MCP2210_PIN_GPIO))
-		return false;
 	if (!mcp2210_set_gpio_pindir(cgpu, pin, MCP2210_GPIO_INPUT))
 		return false;
 	return true;