Browse Source

bitfury: Split out SPI port configuration option ("baud") to its own function

Luke Dashjr 12 years ago
parent
commit
1fbd0a0219
1 changed files with 20 additions and 7 deletions
  1. 20 7
      driver-bitfury.c

+ 20 - 7
driver-bitfury.c

@@ -681,9 +681,26 @@ bool _bitfury_set_device_parse_setting(uint32_t * const rv, char * const setting
 	return true;
 	return true;
 }
 }
 
 
+static
+char *bitfury_spi_port_config(struct cgpu_info * const proc, char *option, char *setting, char *replybuf)
+{
+	struct bitfury_device * const bitfury = proc->device_data;
+	
+	if (!strcasecmp(option, "baud"))
+	{
+		if (!_bitfury_set_device_parse_setting(&bitfury->spi->speed, setting, replybuf, INT_MAX))
+			return replybuf;
+		
+		return NULL;
+	}
+	
+	return "";
+}
+
 char *bitfury_set_device(struct cgpu_info * const proc, char * const option, char * const setting, char * const replybuf)
 char *bitfury_set_device(struct cgpu_info * const proc, char * const option, char * const setting, char * const replybuf)
 {
 {
 	struct bitfury_device * const bitfury = proc->device_data;
 	struct bitfury_device * const bitfury = proc->device_data;
+	char *rv;
 	uint32_t newval;
 	uint32_t newval;
 	
 	
 	if (!strcasecmp(option, "help"))
 	if (!strcasecmp(option, "help"))
@@ -692,13 +709,9 @@ char *bitfury_set_device(struct cgpu_info * const proc, char * const option, cha
 		return replybuf;
 		return replybuf;
 	}
 	}
 	
 	
-	if (!strcasecmp(option, "baud"))
-	{
-		if (!_bitfury_set_device_parse_setting(&bitfury->spi->speed, setting, replybuf, INT_MAX))
-			return replybuf;
-		
-		return NULL;
-	}
+	rv = bitfury_spi_port_config(proc, option, setting, replybuf);
+	if ((!rv) || rv[0])
+		return rv;
 	
 	
 	if (!strcasecmp(option, "osc6_bits"))
 	if (!strcasecmp(option, "osc6_bits"))
 	{
 	{