qca-swiss-army-knife: add 'ath9k_get_p_columns' helper

The number of the columns to be printed is computed in
two different function. Add a helper function for that
and remove the duplicated code.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
diff --git a/tools/initvals/initvals.c b/tools/initvals/initvals.c
index 4413e04..94f5aba 100644
--- a/tools/initvals/initvals.c
+++ b/tools/initvals/initvals.c
@@ -443,16 +443,25 @@
 	return val;
 }
 
+static u32 ath9k_get_p_columns(u32 columns, bool wide)
+{
+	u32 p_columns;
+
+	if (wide)
+		p_columns = columns;
+	else
+		p_columns = columns > 5 ? 5 : columns;
+
+	return p_columns;
+}
+
 static void ath9k_hw_print_initval(const char *name, const u32 *array, u32 rows,
 				   u32 columns, bool onedim, bool wide)
 {
 	u32 p_columns;
 	u32 col, row;
 
-	if (wide)
-		p_columns = columns;
-	else
-		p_columns = columns > 5 ? 5 : columns;
+	p_columns = ath9k_get_p_columns(columns, wide);
 
 	if (onedim)
 		printf("static const u32 %s[] = {\n", name);
@@ -508,10 +517,7 @@
 	u32 p_columns;
 	u32 col, row;
 
-	if (wide)
-		p_columns = columns;
-	else
-		p_columns = columns > 5 ? 5 : columns;
+	p_columns = ath9k_get_p_columns(columns, wide);
 
 	SHA1_Init(&ctx);
 	for (row = 0; row < rows; row++) {