Commit ed65653ca6a3199a46621ff4a1728eb3e5985e2c

Con Kolivas 2013-05-02T17:32:04

Simplify the many lines passed as API data in the avalon driver now that the API does not need persistent storage for the name.

diff --git a/driver-avalon.c b/driver-avalon.c
index 51c5e8f..d91d6f6 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -976,6 +976,7 @@ static struct api_data *avalon_api_stats(struct cgpu_info *cgpu)
 {
 	struct api_data *root = NULL;
 	struct avalon_info *info = avalon_infos[cgpu->device_id];
+	int i;
 
 	root = api_add_int(root, "baud", &(info->baud), false);
 	root = api_add_int(root, "miner_count", &(info->miner_count),false);
@@ -993,39 +994,11 @@ static struct api_data *avalon_api_stats(struct cgpu_info *cgpu)
 	root = api_add_int(root, "temp_max", &(info->temp_max), false);
 
 	root = api_add_int(root, "no_matching_work", &(info->no_matching_work), false);
-	root = api_add_int(root, "matching_work_count1", &(info->matching_work[0]), false);
-	root = api_add_int(root, "matching_work_count2", &(info->matching_work[1]), false);
-	root = api_add_int(root, "matching_work_count3", &(info->matching_work[2]), false);
-	root = api_add_int(root, "matching_work_count4", &(info->matching_work[3]), false);
-	root = api_add_int(root, "matching_work_count5", &(info->matching_work[4]), false);
-	root = api_add_int(root, "matching_work_count6", &(info->matching_work[5]), false);
-	root = api_add_int(root, "matching_work_count7", &(info->matching_work[6]), false);
-	root = api_add_int(root, "matching_work_count8", &(info->matching_work[7]), false);
-	root = api_add_int(root, "matching_work_count9", &(info->matching_work[8]), false);
-	root = api_add_int(root, "matching_work_count10", &(info->matching_work[9]), false);
-	root = api_add_int(root, "matching_work_count11", &(info->matching_work[10]), false);
-	root = api_add_int(root, "matching_work_count12", &(info->matching_work[11]), false);
-	root = api_add_int(root, "matching_work_count13", &(info->matching_work[12]), false);
-	root = api_add_int(root, "matching_work_count14", &(info->matching_work[13]), false);
-	root = api_add_int(root, "matching_work_count15", &(info->matching_work[14]), false);
-	root = api_add_int(root, "matching_work_count16", &(info->matching_work[15]), false);
-	root = api_add_int(root, "matching_work_count17", &(info->matching_work[16]), false);
-	root = api_add_int(root, "matching_work_count18", &(info->matching_work[17]), false);
-	root = api_add_int(root, "matching_work_count19", &(info->matching_work[18]), false);
-	root = api_add_int(root, "matching_work_count20", &(info->matching_work[19]), false);
-	root = api_add_int(root, "matching_work_count21", &(info->matching_work[20]), false);
-	root = api_add_int(root, "matching_work_count22", &(info->matching_work[21]), false);
-	root = api_add_int(root, "matching_work_count23", &(info->matching_work[22]), false);
-	root = api_add_int(root, "matching_work_count24", &(info->matching_work[23]), false);
-	if (info->miner_count > 24) {
-		root = api_add_int(root, "matching_work_count25", &(info->matching_work[24]), false);
-		root = api_add_int(root, "matching_work_count26", &(info->matching_work[25]), false);
-		root = api_add_int(root, "matching_work_count27", &(info->matching_work[26]), false);
-		root = api_add_int(root, "matching_work_count28", &(info->matching_work[27]), false);
-		root = api_add_int(root, "matching_work_count29", &(info->matching_work[28]), false);
-		root = api_add_int(root, "matching_work_count30", &(info->matching_work[29]), false);
-		root = api_add_int(root, "matching_work_count31", &(info->matching_work[30]), false);
-		root = api_add_int(root, "matching_work_count32", &(info->matching_work[31]), false);
+	for (i = 0; i < info->miner_count; i++) {
+		char mcw[24];
+
+		sprintf(mcw, "match_work_count%d", i + 1);
+		root = api_add_int(root, mcw, &(info->matching_work[i]), false);
 	}
 
 	return root;