diff mbox

[v5,7/8] linux-generic: use one uniform call systemcpu()

Message ID 1456946992-19251-8-git-send-email-mike.holmes@linaro.org
State New
Headers show

Commit Message

Mike Holmes March 2, 2016, 7:29 p.m. UTC
From: Hongbo Zhang <hongbo.zhang@linaro.org>

Currently there are two systemcpu() functions, one is for some specific
platforms and the other is for default dummy, but most of the contents
are same except for sysinfo->cache_line_size: one is true data from
calling systemcpu_cache_line_size() and another is dummy data.
In such a situation we can create another systemcpu_cache_line_size() to
return dummy data for platforms which are lack of it, then only one
function systemcpu() is enough.

Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>
Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 platform/linux-generic/odp_system_info.c | 40 +++++++-------------------------
 1 file changed, 9 insertions(+), 31 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c
index 2d202a0..6f9fb6e 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -73,6 +73,15 @@  static int systemcpu_cache_line_size(void)
 
 	return size;
 }
+
+#else
+/*
+ * Use dummy data if not available from /sys/devices/system/cpu/
+ */
+static int systemcpu_cache_line_size(void)
+{
+	return 64;
+}
 #endif
 
 
@@ -105,9 +114,6 @@  static int huge_page_size(void)
 }
 
 
-#if defined __x86_64__ || defined __i386__ || defined __OCTEON__ || \
-defined __powerpc__
-
 /*
  * Analysis of /sys/devices/system/cpu/ files
  */
@@ -142,34 +148,6 @@  static int systemcpu(odp_system_info_t *sysinfo)
 	return 0;
 }
 
-#else
-
-/*
- * Use sysconf and dummy values in generic case
- */
-
-
-static int systemcpu(odp_system_info_t *sysinfo)
-{
-	int ret;
-
-	ret = sysconf_cpu_count();
-	if (ret == 0) {
-		ODP_ERR("sysconf_cpu_count failed.\n");
-		return -1;
-	}
-
-	sysinfo->cpu_count = ret;
-
-	sysinfo->huge_page_size = huge_page_size();
-
-	/* Dummy values */
-	sysinfo->cache_line_size = 64;
-
-	return 0;
-}
-
-#endif
 
 /*
  * System info initialisation