From 3c4014d392a00613634a0c89588f318a6d805469 Mon Sep 17 00:00:00 2001
From: Grzegorz Daniluk <grzegorz.daniluk@cern.ch>
Date: Mon, 18 Jul 2016 10:09:24 +0200
Subject: [PATCH] userspace/tools: trivial cleanup in wrs_pstats, make
 checkpatch happy

---
 userspace/tools/wrs_pstats.c | 199 +++++++++++++++++------------------
 1 file changed, 99 insertions(+), 100 deletions(-)

diff --git a/userspace/tools/wrs_pstats.c b/userspace/tools/wrs_pstats.c
index 555d2b2c9..3cff9591a 100644
--- a/userspace/tools/wrs_pstats.c
+++ b/userspace/tools/wrs_pstats.c
@@ -2,7 +2,6 @@
 #include<unistd.h>
 #include<fpga_io.h>
 #include<regs/pstats-regs.h>
-// #include<regs/dummy-regs.h>
 #include<time.h>
 #include<poll.h>
 #include <inttypes.h>
@@ -34,47 +33,47 @@ struct p_cnt {
 struct p_cnt cnt_pp[NPORTS];
 int use_ports;
 
-char info[][20] = {{"Tu-run|"}, // 0
-		   {"Ro-run|"}, // 1
-		   {"Riv-cd|"}, // 2
-		   {"Rsyn-l|"}, // 3
-		   {"Rpause|"}, // 4
-		   {"Rpf-dp|"}, // 5
-		   {"Rpcs-e|"}, // 6
-		   {"Rgiant|"}, // 7
-		   {"Rrunt |"}, // 8
-		   {"Rcrc_e|"}, // 9
-		   {"Rpcl_0|"}, // 10
-		   {"Rpcl_1|"}, // 11
-		   {"Rpcl_2|"}, // 12
-		   {"Rpcl_3|"}, // 13
-		   {"Rpcl_4|"}, // 14
-		   {"Rpcl_5|"}, // 15
-		   {"Rpcl_6|"}, // 16
-		   {"Rpcl_7|"}, // 17
-		   {"Tframe|"}, // 18
-		   {"Rframe|"}, // 19
-		   {"Rrtu_f|"}, // 20
-		   {"Rpri_0|"}, // 21 -> p0
-		   {"Rpri_1|"}, // 22 -> p1
-		   {"Rpri_2|"}, // 23 -> p2
-		   {"Rpri_3|"}, // 24 -> p3
-		   {"Rpri_4|"}, // 25 -> p4
-		   {"Rpri_5|"}, // 26 -> p5
-		   {"Rpri_6|"}, // 27 -> p6
-		   {"Rpri_7|"}, // 28 -> p7
-		   {"RTUreq|"}, // 29
-		   {"RTUrsp|"}, // 30
-		   {"RTUdrp|"}, // 31
-		   {"RTUhp |"}, // 32
-		   {"RTUf-f|"}, // 33
-		   {"RTUn-f|"}, // 34
-		   {"RTUfst|"}, // 35
-		   {"RTUful|"}, // 36
-		   {"RTUfwd|"}, // 37 ---
-		   {"TRUrsp|"}, // 38
-		   {"NIC_Tx|"}  // 39
-                 };
+char info[][20] = {{"Tu-run|"}, /* 0  */
+		   {"Ro-run|"}, /* 1  */
+		   {"Riv-cd|"}, /* 2  */
+		   {"Rsyn-l|"}, /* 3  */
+		   {"Rpause|"}, /* 4  */
+		   {"Rpf-dp|"}, /* 5  */
+		   {"Rpcs-e|"}, /* 6  */
+		   {"Rgiant|"}, /* 7  */
+		   {"Rrunt |"}, /* 8  */
+		   {"Rcrc_e|"}, /* 9  */
+		   {"Rpcl_0|"}, /* 10 */
+		   {"Rpcl_1|"}, /* 11 */
+		   {"Rpcl_2|"}, /* 12 */
+		   {"Rpcl_3|"}, /* 13 */
+		   {"Rpcl_4|"}, /* 14 */
+		   {"Rpcl_5|"}, /* 15 */
+		   {"Rpcl_6|"}, /* 16 */
+		   {"Rpcl_7|"}, /* 17 */
+		   {"Tframe|"}, /* 18 */
+		   {"Rframe|"}, /* 19 */
+		   {"Rrtu_f|"}, /* 20 */
+		   {"Rpri_0|"}, /* 21 -> p0 */
+		   {"Rpri_1|"}, /* 22 -> p1 */
+		   {"Rpri_2|"}, /* 23 -> p2 */
+		   {"Rpri_3|"}, /* 24 -> p3 */
+		   {"Rpri_4|"}, /* 25 -> p4 */
+		   {"Rpri_5|"}, /* 26 -> p5 */
+		   {"Rpri_6|"}, /* 27 -> p6 */
+		   {"Rpri_7|"}, /* 28 -> p7 */
+		   {"RTUreq|"}, /* 29 */
+		   {"RTUrsp|"}, /* 30 */
+		   {"RTUdrp|"}, /* 31 */
+		   {"RTUhp |"}, /* 32 */
+		   {"RTUf-f|"}, /* 33 */
+		   {"RTUn-f|"}, /* 34 */
+		   {"RTUfst|"}, /* 35 */
+		   {"RTUful|"}, /* 36 */
+		   {"RTUfwd|"}, /* 37 */
+		   {"TRUrsp|"}, /* 38 */
+		   {"NIC_Tx|"}  /* 39 */
+		};
 
 int pstats_init(int init)
 {
@@ -88,9 +87,8 @@ int pstats_init(int init)
 
 	printf("module initialized\n");
 
-	for(i=0; i<use_ports; ++i)
-		for(j=0; j<CNT_PP; ++j)
-		{
+	for (i = 0; i < use_ports; ++i)
+		for (j = 0; j < CNT_PP; ++j) {
 			cnt_pp[i].counters[j].init = 0;
 			cnt_pp[i].counters[j].cnt = 0;
 		}
@@ -148,16 +146,15 @@ void print_first_n_cnts(int n_cnts)
 	int cnt = 0;
 	int p_index = 0;
 	printf("P    |");
-	for(cnt=0; cnt<n_cnts; ++cnt)
-		printf("%2d:%s", cnt,info[cnt]);
+	for (cnt = 0; cnt < n_cnts; ++cnt)
+		printf("%2d:%s", cnt, info[cnt]);
 	printf("\n");
 	printf("----");
-	for(cnt=0; cnt<n_cnts; ++cnt)
+	for (cnt = 0; cnt < n_cnts; ++cnt)
 		printf("----------");
 
 	printf("\n");
-	for (p_index = 0; p_index < use_ports; ++p_index)
-	{
+	for (p_index = 0; p_index < use_ports; ++p_index) {
 		printf("%-5s|", cnt_pp[p_index].if_name);
 		for (cnt = 0; cnt < n_cnts; ++cnt)
 			printf("%9llu|", cnt_pp[p_index].counters[cnt].cnt);
@@ -165,21 +162,20 @@ void print_first_n_cnts(int n_cnts)
 	}
 }
 
-void print_chosen_cnts( int cnts_list[], int n_cnts)
+void print_chosen_cnts(int cnts_list[], int n_cnts)
 {
 	int cnt = 0;
 	int p_index = 0;
 
 	printf("P    |");
-	for(cnt=0; cnt<n_cnts; ++cnt)
-		printf("%2d:%s", cnts_list[cnt],info[cnts_list[cnt]]);
+	for (cnt = 0; cnt < n_cnts; ++cnt)
+		printf("%2d:%s", cnts_list[cnt], info[cnts_list[cnt]]);
 	printf("\n");
 	printf("----");
-	for(cnt=0; cnt<n_cnts; ++cnt)
-	printf("----------");
+	for (cnt = 0; cnt < n_cnts; ++cnt)
+		printf("----------");
 	printf("\n");
-	for (p_index = 0; p_index < use_ports; ++p_index)
-	{
+	for (p_index = 0; p_index < use_ports; ++p_index) {
 		printf("%-5s|", cnt_pp[p_index].if_name);
 		for (cnt = 0; cnt < n_cnts; ++cnt)
 			printf("%9llu|",
@@ -206,62 +202,65 @@ void print_info(char *prgname)
 
 int main(int argc, char **argv)
 {
-	int prio_cnts[] = {21,22,23,24,25,26,27,28}; //8
-	int def_cnts[]  = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,29,30,31,32,33,34,35,36,37,39}; //31
-	int rtu_cnts[]  = {29,30,31,32,33,34,35,36,37,38}; //10
-	int ep_cnts[]   = {0,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
-	int traffic[]   = {18,19};//2
+	int prio_cnts[] = {21, 22, 23, 24, 25, 26, 27, 28}; /* 8 */
+	int def_cnts[]  = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+			   15, 16, 17, 18, 19, 20, 29, 30, 31, 32, 33, 34, 35,
+			   36, 37, 39}; /* 31 */
+	int rtu_cnts[]  = {29, 30, 31, 32, 33, 34, 35, 36, 37, 38}; /* 10 */
+	int ep_cnts[]   = {0, 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 */
+	int traffic[]   = {18, 19}; /* 2 */
 	int op = 0, c;
 	int init = 1;
 
 	use_ports = NPORTS;
 	while ((c = getopt(argc, argv, "phsertan:")) != -1) {
-		switch(c) {
-			case 'n':
-				use_ports = atoi(optarg);
-				break;
-			case 'p':
-			case 'e':
-			case 'r':
-			case 'a':
-			case 't':
-				op = c;
-				break;
-			case 's':
-			       init = 2;
-			       break;
-			case 'h':
-			default:
-				print_info(argv[0]);
-				exit(1);
+		switch (c) {
+		case 'n':
+			use_ports = atoi(optarg);
+			break;
+		case 'p':
+		case 'e':
+		case 'r':
+		case 'a':
+		case 't':
+			op = c;
+			break;
+		case 's':
+		       init = 2;
+		       break;
+		case 'h':
+		default:
+			print_info(argv[0]);
+			exit(1);
 		}
 	}
 
 	if (pstats_init(init))
 		return -1;
 
-	while(1)
-	{
+	while (1) {
 		printf("\033[2J\033[1;1H");
 		parse_sysfs();
-		switch(op) {
-			case 'p':
-				print_chosen_cnts(prio_cnts, 8);
-				break;
-			case 'e':
-				print_chosen_cnts(ep_cnts, 29);
-				break;
-			case 'r':
-				print_chosen_cnts(rtu_cnts, 10);
-				break;
-			case 't':
-				print_chosen_cnts(traffic, 2);
-				break;
-			case 'a':
-				print_first_n_cnts(CNT_PP);
-				break;
-			default:
-				print_chosen_cnts(def_cnts, 31);
+		switch (op) {
+		case 'p':
+			print_chosen_cnts(prio_cnts, 8);
+			break;
+		case 'e':
+			print_chosen_cnts(ep_cnts, 29);
+			break;
+		case 'r':
+			print_chosen_cnts(rtu_cnts, 10);
+			break;
+		case 't':
+			print_chosen_cnts(traffic, 2);
+			break;
+		case 'a':
+			print_first_n_cnts(CNT_PP);
+			break;
+		default:
+			print_chosen_cnts(def_cnts, 31);
 		}
 		sleep(1);
 	}
-- 
GitLab