diff mbox

[v2,API-NEXT,11/11] linux-generic: sysinfo: apply per-CPU implementation to PowerPC

Message ID 1451380373-7759-2-git-send-email-hongbo.zhang@linaro.org
State Superseded
Headers show

Commit Message

Hongbo Zhang Dec. 29, 2015, 9:12 a.m. UTC
From: Hongbo Zhang <hongbo.zhang@linaro.org>

When per-CPU framework was introduced, it was only implemented on x86,
for other platforms, only the model_str[0] and cpu_hz[0] are set to pass
compile, this patch set all values for model_str[] and cpu_hz[] on the
PowerPC platform.

Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>
---
 .../linux-generic/arch/powerpc/odp_sysinfo_parse.c   | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
index 5f4e69d..2baed1e 100644
--- a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
@@ -15,14 +15,17 @@  int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
 	double mhz = 0.0;
 	int model = 0;
 	int count = 2;
+	int id = 0;
 
 	strcpy(sysinfo->cpu_arch_str, "powerpc");
-	while (fgets(str, sizeof(str), file) != NULL && count > 0) {
+	while (fgets(str, sizeof(str), file) != NULL && id < MAX_CPU_NUMBER) {
 		if (!mhz) {
 			pos = strstr(str, "clock");
 
 			if (pos) {
 				sscanf(pos, "clock : %lf", &mhz);
+				sysinfo->cpu_hz[id] = \
+					(uint64_t)(mhz * 1000000.0);
 				count--;
 			}
 		}
@@ -34,16 +37,21 @@  int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
 				int len;
 
 				pos = strchr(str, ':');
-				strncpy(sysinfo->model_str[0], pos + 2,
-					sizeof(sysinfo->model_str[0]));
-				len = strlen(sysinfo->model_str[0]);
-				sysinfo->model_str[0][len - 1] = 0;
+				strncpy(sysinfo->model_str[id], pos + 2,
+					sizeof(sysinfo->model_str[id]));
+				len = strlen(sysinfo->model_str[id]);
+				sysinfo->model_str[id][len - 1] = 0;
 				model = 1;
 				count--;
 			}
 		}
 
-		sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0);
+		if (count == 0) {
+			mhz = 0.0;
+			model = 0;
+			count = 2;
+			id++;
+		}
 	}
 
 	return 0;