summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConglin Guo <conglin.guo@amlogic.com>2018-07-16 13:17:56 +0800
committerZhi Zhou <zhi.zhou@amlogic.com>2018-07-17 02:32:45 -0700
commitc2a9128868d77339bdb9564e956f4996be455960 (patch)
tree38541400c2198f55ba1b929dd9c556f16d23c2d2
parentddece48fc4adb705e2134a3f6263fec5ca85a1ca (diff)
downloadmedia_modules-c2a9128868d77339bdb9564e956f4996be455960.tar.gz
media_module: interface optimization for get cpu id
PD#168480:media_module: 1: interface optimization for get cpu id Change-Id: Ic5211341becf381347f89bc2a1d41c0482a847e8 Signed-off-by: Conglin Guo <conglin.guo@amlogic.com>
-rw-r--r--drivers/common/chips/decoder_cpu_ver_info.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/drivers/common/chips/decoder_cpu_ver_info.c b/drivers/common/chips/decoder_cpu_ver_info.c
index cae6c7b..6bdba0c 100644
--- a/drivers/common/chips/decoder_cpu_ver_info.c
+++ b/drivers/common/chips/decoder_cpu_ver_info.c
@@ -10,9 +10,10 @@
#define DECODE_CPU_VER_ID_NODE_NAME "cpu_ver_name"
#define AM_SUCESS 0
-
#define MAJOR_ID_START AM_MESON_CPU_MAJOR_ID_M6
+static enum AM_MESON_CPU_MAJOR_ID cpu_ver_id = AM_MESON_CPU_MAJOR_ID_MAX;
+
static enum AM_MESON_CPU_MAJOR_ID cpu_ver_info[AM_MESON_CPU_MAJOR_ID_MAX - MAJOR_ID_START]=
{
AM_MESON_CPU_MAJOR_ID_M6,
@@ -70,16 +71,17 @@ static const struct of_device_id cpu_ver_of_match[] = {
{},
};
-bool get_cpu_id_from_dtb(enum AM_MESON_CPU_MAJOR_ID *pidType)
+static bool get_cpu_id_from_dtb(enum AM_MESON_CPU_MAJOR_ID *pidType)
{
struct device_node *pNode = NULL;
struct platform_device* pDev = NULL;
const struct of_device_id *pMatch = NULL;
pNode = of_find_node_by_name(NULL, DECODE_CPU_VER_ID_NODE_NAME);
+
if (NULL == pNode)
{
- pr_info("No find node.\n");
+ pr_err("No find node.\n");
return -EINVAL;
}
@@ -93,7 +95,7 @@ bool get_cpu_id_from_dtb(enum AM_MESON_CPU_MAJOR_ID *pidType)
if (NULL == pMatch)
{
- pr_info("No find of_match_device\n");
+ pr_err("No find of_match_device\n");
return -EINVAL;
}
@@ -102,16 +104,27 @@ bool get_cpu_id_from_dtb(enum AM_MESON_CPU_MAJOR_ID *pidType)
return AM_SUCESS;
}
-enum AM_MESON_CPU_MAJOR_ID get_cpu_major_id(void)
+static void initial_cpu_id(void)
{
enum AM_MESON_CPU_MAJOR_ID id_type = AM_MESON_CPU_MAJOR_ID_MAX;
if (AM_SUCESS == get_cpu_id_from_dtb(&id_type))
{
- return id_type;
+ cpu_ver_id = id_type;
+ }else
+ {
+ cpu_ver_id = (enum AM_MESON_CPU_MAJOR_ID)get_cpu_type();
+ }
+}
+
+enum AM_MESON_CPU_MAJOR_ID get_cpu_major_id(void)
+{
+ if (AM_MESON_CPU_MAJOR_ID_MAX == cpu_ver_id)
+ {
+ initial_cpu_id();
}
- return (enum AM_MESON_CPU_MAJOR_ID)get_cpu_type();
+ return cpu_ver_id;
}
EXPORT_SYMBOL(get_cpu_major_id);