diff mbox

[API-NEXT,v4,06/10] linux-generic: sysinfo: add new API to get model string for each CPU

Message ID 1439278439-11386-7-git-send-email-hongbo.zhang@freescale.com
State New
Headers show

Commit Message

hongbo.zhang@freescale.com Aug. 11, 2015, 7:33 a.m. UTC
From: Hongbo Zhang <hongbo.zhang@linaro.org>

Previous patch makes varible model_str to array model_str[] to contain data
for each CPU on AMP platforms, and then this patch adds new API to get the
corresponding model string for each CPU indexed by CPU ID.

Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>
---
 include/odp/api/cpu.h                    | 11 +++++++++++
 platform/linux-generic/odp_system_info.c | 11 ++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/include/odp/api/cpu.h b/include/odp/api/cpu.h
index 9d0aaf5..8f4d11b 100644
--- a/include/odp/api/cpu.h
+++ b/include/odp/api/cpu.h
@@ -58,6 +58,17 @@  uint64_t odp_cpu_hz_max(void);
 const char *odp_cpu_model_str(void);
 
 /**
+ * CPU model name of a CPU
+ *
+ * Return CPU model name of the specified CPU.
+ *
+ * @param id    CPU ID
+ *
+ * @return Pointer to CPU model name string
+ */
+const char *odp_cpu_id_model_str(int id);
+
+/**
  * @}
  */
 
diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c
index d78fd3e..a279061 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -195,6 +195,7 @@  static int cpuinfo_octeon(FILE *file, odp_system_info_t *sysinfo)
 
 	return 0;
 }
+
 #elif defined __powerpc__
 static int cpuinfo_powerpc(FILE *file, odp_system_info_t *sysinfo)
 {
@@ -383,7 +384,15 @@  uint64_t odp_sys_page_size(void)
 
 const char *odp_cpu_model_str(void)
 {
-	return odp_global_data.system_info.model_str[0];
+	return odp_cpu_id_model_str(0);
+}
+
+const char *odp_cpu_id_model_str(int id)
+{
+	if (id >= 0 && id < MAX_CPU_NUMBER)
+		return odp_global_data.system_info.model_str[id];
+	else
+		return NULL;
 }
 
 int odp_sys_cache_line_size(void)