ODROID-COMMON: modify pwmSetRange to to call just once.

Signed-off-by: steve.jeong <jkhpro1003@gmail.com>
Change-Id: Ie05850032dea81d03eacfdf21fea96006886585d
diff --git a/wiringPi/odroidc4.c b/wiringPi/odroidc4.c
index 8da29df..badbe78 100644
--- a/wiringPi/odroidc4.c
+++ b/wiringPi/odroidc4.c
@@ -135,7 +135,13 @@
 	"None","None","None","None"
 };
 
-static char setupedPwmPinPath[BLOCK_SIZE];
+static char setupedPwmPinPath[10][BLOCK_SIZE] = {
+	"None","None",
+	"None","None",
+	"None","None",
+	"None","None",
+	"None","None"
+};
 
 /*----------------------------------------------------------------------------*/
 //
@@ -419,7 +425,7 @@
 	pwmClock = C4_PWM_INTERNAL_CLK;
 	sprintf(pwmExport, "%d", (pwmPin % 2));
 	sprintf(pwmPinPath[pwmPin], "%s/pwm%d", sysPwmPath, (pwmPin % 2));
-	strncpy(setupedPwmPinPath, pwmPinPath[pwmPin], (sizeof(setupedPwmPinPath) - 1));
+	strncpy(setupedPwmPinPath[pwmPin], pwmPinPath[pwmPin], (BLOCK_SIZE - 1));
 #ifdef ANDROID
 	sprintf(cmd, "su -s sh -c %s %s", PWM_ACCESS_SCRIPT, pwmPinPath[pwmPin]);
 #else
@@ -872,14 +878,14 @@
 	freq = (pwmClock / pwmRange);
 	period = (1000000000 / freq); // period: s to ns.
 	sprintf(pwmPeriod, "%d", period);
-	if (strstr(setupedPwmPinPath, "pwm") == NULL) {
-		printf("Not setuped pwm target.\n");
-		return;
-	}
 
-	inputToSysNode(setupedPwmPinPath, "period", pwmPeriod);
-	inputToSysNode(setupedPwmPinPath, "polarity", "normal");
-	inputToSysNode(setupedPwmPinPath, "enable", "1");
+	for (int i = 0; i < 10; i++) {
+		if (strstr(setupedPwmPinPath[i], "None") != NULL)
+			continue;
+		inputToSysNode(setupedPwmPinPath[i], "period", pwmPeriod);
+		inputToSysNode(setupedPwmPinPath[i], "polarity", "normal");
+		inputToSysNode(setupedPwmPinPath[i], "enable", "1");
+	}
 }
 
 
diff --git a/wiringPi/odroidm1.c b/wiringPi/odroidm1.c
index bad8086..46c6259 100644
--- a/wiringPi/odroidm1.c
+++ b/wiringPi/odroidm1.c
@@ -160,7 +160,13 @@
 	"None","None","None","None"
 };
 
-static char setupedPwmPinPath[BLOCK_SIZE];
+static char setupedPwmPinPath[10][BLOCK_SIZE] = {
+	"None","None",
+	"None","None",
+	"None","None",
+	"None","None",
+	"None","None"
+};
 /*----------------------------------------------------------------------------*/
 //
 // Global variable define
@@ -332,7 +338,7 @@
 		pwmClock = (M1_PWM_INTERNAL_CLK / 2);
 	sprintf(pwmExport, "%d", 0);
 	sprintf(pwmPinPath[pwmPin], "%s/pwm%d", sysPwmPath, 0);
-	strncpy(setupedPwmPinPath, pwmPinPath[pwmPin], (sizeof(setupedPwmPinPath) - 1));
+	strncpy(setupedPwmPinPath[pwmPin], pwmPinPath[pwmPin], (BLOCK_SIZE - 1));
 #ifdef ANDROID
 	sprintf(cmd, "su -s sh -c %s %s", PWM_ACCESS_SCRIPT, pwmPinPath[pwmPin]);
 #else
@@ -1447,14 +1453,14 @@
 	freq = (pwmClock / pwmRange);
 	period = (1000000000 / freq); // period: s to ns.
 	sprintf(pwmPeriod, "%d", period);
-	if (strstr(setupedPwmPinPath, "pwm") == NULL) {
-		printf("Not setuped pwm target.\n");
-		return;
-	}
 
-	inputToSysNode(setupedPwmPinPath, "period", pwmPeriod);
-	inputToSysNode(setupedPwmPinPath, "polarity", "normal");
-	inputToSysNode(setupedPwmPinPath, "enable", "1");
+	for (int i = 0; i < 10; i++) {
+		if (strstr(setupedPwmPinPath[i], "None") != NULL)
+			continue;
+		inputToSysNode(setupedPwmPinPath[i], "period", pwmPeriod);
+		inputToSysNode(setupedPwmPinPath[i], "polarity", "normal");
+		inputToSysNode(setupedPwmPinPath[i], "enable", "1");
+	}
 }
 
 /*----------------------------------------------------------------------------*/
diff --git a/wiringPi/odroidn2.c b/wiringPi/odroidn2.c
index 6189d62..f83986c 100644
--- a/wiringPi/odroidn2.c
+++ b/wiringPi/odroidn2.c
@@ -135,7 +135,13 @@
 	"None","None","None","None"
 };
 
-static char setupedPwmPinPath[BLOCK_SIZE];
+static char setupedPwmPinPath[10][BLOCK_SIZE] = {
+	"None","None",
+	"None","None",
+	"None","None",
+	"None","None",
+	"None","None"
+};
 
 /*----------------------------------------------------------------------------*/
 //
@@ -404,7 +410,7 @@
 	pwmClock = N2_PWM_INTERNAL_CLK;
 	sprintf(pwmExport, "%d", (pwmPin % 2));
 	sprintf(pwmPinPath[pwmPin], "%s/pwm%d", sysPwmPath, (pwmPin % 2));
-	strncpy(setupedPwmPinPath, pwmPinPath[pwmPin], (sizeof(setupedPwmPinPath) - 1));
+	strncpy(setupedPwmPinPath[pwmPin], pwmPinPath[pwmPin], (BLOCK_SIZE - 1));
 #ifdef ANDROID
 	sprintf(cmd, "su -s sh -c %s %s", PWM_ACCESS_SCRIPT, pwmPinPath[pwmPin]);
 #else
@@ -830,14 +836,14 @@
 	freq = (pwmClock / pwmRange);
 	period = (1000000000 / freq); // period: s to ns.
 	sprintf(pwmPeriod, "%d", period);
-	if (strstr(setupedPwmPinPath, "pwm") == NULL) {
-		printf("Not setuped pwm target.\n");
-		return;
-	}
 
-	inputToSysNode(setupedPwmPinPath, "period", pwmPeriod);
-	inputToSysNode(setupedPwmPinPath, "polarity", "normal");
-	inputToSysNode(setupedPwmPinPath, "enable", "1");
+	for (int i = 0; i < 10; i++) {
+		if (strstr(setupedPwmPinPath[i], "None") != NULL)
+			continue;
+		inputToSysNode(setupedPwmPinPath[i], "period", pwmPeriod);
+		inputToSysNode(setupedPwmPinPath[i], "polarity", "normal");
+		inputToSysNode(setupedPwmPinPath[i], "enable", "1");
+	}
 }
 
 /*----------------------------------------------------------------------------*/