Having the i.MX6 type detection completely inline is less then optimal
in terms of binary size. Make the detection functions non-inline. While
at it ask the registers only once and store the result in a variable as
the i.MX6 type is unlikely to change during runtime.

Signed-off-by: Sascha Hauer <s.ha...@pengutronix.de>
---
 arch/arm/mach-imx/imx6.c              | 26 ++++++++++++++++++++++++++
 arch/arm/mach-imx/include/mach/imx6.h | 16 ++--------------
 2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
index 14a1cba5a4..5a7cb7f8bc 100644
--- a/arch/arm/mach-imx/imx6.c
+++ b/arch/arm/mach-imx/imx6.c
@@ -147,6 +147,32 @@ static void imx6ul_enet_clk_init(void)
        writel(val, gprbase + IOMUXC_GPR1);
 }
 
+int imx6_cpu_type(void)
+{
+       static int cpu_type = -1;
+
+       if (!cpu_is_mx6())
+               return 0;
+
+       if (cpu_type < 0)
+               cpu_type = __imx6_cpu_type();
+
+       return cpu_type;
+}
+
+int imx6_cpu_revision(void)
+{
+       static int soc_revision = -1;
+
+       if (!cpu_is_mx6())
+               return 0;
+
+       if (soc_revision < 0)
+               soc_revision = __imx6_cpu_revision();
+
+       return soc_revision;
+}
+
 int imx6_init(void)
 {
        const char *cputypestr;
diff --git a/arch/arm/mach-imx/include/mach/imx6.h 
b/arch/arm/mach-imx/include/mach/imx6.h
index 6b08e6a521..436f8fc31b 100644
--- a/arch/arm/mach-imx/include/mach/imx6.h
+++ b/arch/arm/mach-imx/include/mach/imx6.h
@@ -55,13 +55,7 @@ static inline int __imx6_cpu_type(void)
        return val;
 }
 
-static inline int imx6_cpu_type(void)
-{
-       if (!cpu_is_mx6())
-               return 0;
-
-       return __imx6_cpu_type();
-}
+int imx6_cpu_type(void);
 
 #define DEFINE_MX6_CPU_TYPE(str, type)                                 \
        static inline int cpu_mx6_is_##str(void)                        \
@@ -102,12 +96,6 @@ static inline int __imx6_cpu_revision(void)
        return ((major_part + 1) << 4) | minor_part;
 }
 
-static inline int imx6_cpu_revision(void)
-{
-       if (!cpu_is_mx6())
-               return 0;
-
-       return __imx6_cpu_revision();
-}
+int imx6_cpu_revision(void);
 
 #endif /* __MACH_IMX6_H */
-- 
2.16.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to